<commit_before>// Hacks to fix compile errors due to polluted namespace
#ifdef _WIN32
#define _WINUSER_H
#define _WINGDI_H
#endif

#include "SDL_gpu_OpenGL_internal.h"
#include "SOIL.h"
#include <math.h>

static Uint8 checkExtension(const char* str)
{
	if(!glewIsExtensionSupported(str))
	{
		fprintf(stderr, "Error: %s is not supported.\n", str);
		return 0;
	}
	return 1;
}

static GPU_Target* Init(GPU_Renderer* renderer, Uint16 w, Uint16 h, Uint32 flags)
{
	if(flags & SDL_DOUBLEBUF)
		SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	flags &= ~SDL_DOUBLEBUF;
	
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
	
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
	
	flags |= SDL_OPENGL;
	
	SDL_Surface* screen = SDL_SetVideoMode(w, h, 0, flags);
	
	if(screen == NULL)
		return NULL;
    
	GLenum err = glewInit();
	if (GLEW_OK != err)
	{
		/* Problem: glewInit failed, something is seriously wrong. */
		fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
	}
	
	checkExtension("GL_EXT_framebuffer_object");
	checkExtension("GL_ARB_framebuffer_object"); // glGenerateMipmap
	checkExtension("GL_EXT_framebuffer_blit");
    
	glEnable( GL_TEXTURE_2D );
	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
	
	glViewport( 0, 0, w, h);
	
	glClear( GL_COLOR_BUFFER_BIT );
	
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	
	glOrtho(0.0f, w, h, 0.0f, -1.0f, 1.0f);
	
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
	
	glEnable( GL_TEXTURE_2D );
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	glEnable(GL_BLEND);
    glTranslatef(0.375f, 0.375f, 0.0f);

	
	if(renderer->display == NULL)
		renderer->display = (GPU_Target*)malloc(sizeof(GPU_Target));
	
	renderer->display->data = (TargetData_OpenGL*)malloc(sizeof(TargetData_OpenGL));

	((TargetData_OpenGL*)renderer->display->data)->handle = 0;
	renderer->display->renderer = renderer;
	renderer->display->w = screen->w;
	renderer->display->h = screen->h;
	
	renderer->display->useClip = 0;
	renderer->display->clipRect.x = 0;
	renderer->display->clipRect.y = 0;
	renderer->display->clipRect.w = screen->w;
	renderer->display->clipRect.h = screen->h;<commit_msg>Removed OpenGL translate hack (meant for pixel-perfect primitives, but it is bad when using the camera zoom).<commit_after>// Hacks to fix compile errors due to polluted namespace
#ifdef _WIN32
#define _WINUSER_H
#define _WINGDI_H
#endif

#include "SDL_gpu_OpenGL_internal.h"
#include "SOIL.h"
#include <math.h>

static Uint8 checkExtension(const char* str)
{
	if(!glewIsExtensionSupported(str))
	{
		fprintf(stderr, "Error: %s is not supported.\n", str);
		return 0;
	}
	return 1;
}

static GPU_Target* Init(GPU_Renderer* renderer, Uint16 w, Uint16 h, Uint32 flags)
{
	if(flags & SDL_DOUBLEBUF)
		SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	flags &= ~SDL_DOUBLEBUF;
	
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
	
	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
	
	flags |= SDL_OPENGL;
	
	SDL_Surface* screen = SDL_SetVideoMode(w, h, 0, flags);
	
	if(screen == NULL)
		return NULL;
    
	GLenum err = glewInit();
	if (GLEW_OK != err)
	{
		/* Problem: glewInit failed, something is seriously wrong. */
		fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
	}
	
	checkExtension("GL_EXT_framebuffer_object");
	checkExtension("GL_ARB_framebuffer_object"); // glGenerateMipmap
	checkExtension("GL_EXT_framebuffer_blit");
    
	glEnable( GL_TEXTURE_2D );
	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
	
	glViewport( 0, 0, w, h);
	
	glClear( GL_COLOR_BUFFER_BIT );
	
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	
	glOrtho(0.0f, w, h, 0.0f, -1.0f, 1.0f);
	
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
	
	glEnable( GL_TEXTURE_2D );
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	glEnable(GL_BLEND);

	
	if(renderer->display == NULL)
		renderer->display = (GPU_Target*)malloc(sizeof(GPU_Target));
	
	renderer->display->data = (TargetData_OpenGL*)malloc(sizeof(TargetData_OpenGL));

	((TargetData_OpenGL*)renderer->display->data)->handle = 0;
	renderer->display->renderer = renderer;
	renderer->display->w = screen->w;
	renderer->display->h = screen->h;
	
	renderer->display->useClip = 0;
	renderer->display->clipRect.x = 0;
	renderer->display->clipRect.y = 0;
	renderer->display->clipRect.w = screen->w;
	renderer->display->clipRect.h = screen->h;
{'fraction_non_alphanumeric': 0.1387782204515272, 'fraction_numerical': 0.021248339973439574, 'mean_word_length': 5.267683772538142, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3927642', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1752, 'n_words': 326}