From becfeb57eb0092f5170df1ceb2c95b4a2f17c6cc Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 13 Jan 2011 21:25:52 +0100 Subject: [PATCH] Oh dear... I hate this bugs that plague you for days, but are so stupid. --- gfx/gl.c | 24 +++++++++++------------- gfx/shader_glsl.c | 4 ++++ hqflt/cg/crt.cg | 3 ++- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/gfx/gl.c b/gfx/gl.c index 902f8a6369..7b3bf25a00 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -66,7 +66,6 @@ static const GLfloat tex_coords[] = { }; static bool keep_aspect = true; -static GLuint gl_width = 0, gl_height = 0; typedef struct gl { bool vsync; @@ -220,19 +219,19 @@ static bool gl_frame(void *data, const uint16_t* frame, int width, int height, i if (gl->should_resize) { gl->should_resize = false; - SDL_SetVideoMode(gl->win_width, gl->win_height, 32, SDL_OPENGL | SDL_RESIZABLE | (g_settings.video.fullscreen ? SDL_FULLSCREEN : 0)); + SDL_SetVideoMode(gl->win_width, gl->win_height, 0, SDL_OPENGL | SDL_RESIZABLE | (g_settings.video.fullscreen ? SDL_FULLSCREEN : 0)); set_viewport(gl); } glClear(GL_COLOR_BUFFER_BIT); - gl_shader_set_params(width, height, gl->tex_w, gl->tex_h, gl_width, gl_height); + gl_shader_set_params(width, height, gl->tex_w, gl->tex_h, gl->vp_width, gl->vp_height); if (width != gl->last_width || height != gl->last_height) // res change. need to clear out texture. { gl->last_width = width; gl->last_height = height; - glPixelStorei(GL_UNPACK_ROW_LENGTH, width); + glPixelStorei(GL_UNPACK_ROW_LENGTH, gl->tex_w); uint8_t *tmp = calloc(1, gl->tex_w * gl->tex_h * sizeof(uint16_t)); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, gl->tex_w, gl->tex_h, GL_BGRA, @@ -323,8 +322,10 @@ static void* gl_init(video_info_t *video, const input_driver_t **input, void **i if (!gl) return NULL; - // Remove that ugly mouse :D - SDL_ShowCursor(SDL_DISABLE); + gl->win_width = video->width; + gl->win_height = video->height; + gl->vsync = video->vsync; + set_viewport(gl); if (!gl_shader_init()) { @@ -334,10 +335,8 @@ static void* gl_init(video_info_t *video, const input_driver_t **input, void **i return NULL; } - gl->win_width = video->width; - gl->win_height = video->height; - gl->vsync = video->vsync; - set_viewport(gl); + // Remove that ugly mouse :D + SDL_ShowCursor(SDL_DISABLE); keep_aspect = video->force_aspect; if ( video->smooth ) @@ -345,7 +344,6 @@ static void* gl_init(video_info_t *video, const input_driver_t **input, void **i else gl->tex_filter = GL_NEAREST; - glEnable(GL_TEXTURE_2D); glDisable(GL_DITHER); glDisable(GL_DEPTH_TEST); @@ -359,6 +357,7 @@ static void* gl_init(video_info_t *video, const input_driver_t **input, void **i glGenTextures(1, &gl->texture); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, gl->texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); @@ -383,7 +382,6 @@ static void* gl_init(video_info_t *video, const input_driver_t **input, void **i gl->last_width = gl->tex_w; gl->last_height = gl->tex_h; - // Hook up SDL input driver to get SDL_QUIT events and RESIZE. sdl_input_t *sdl_input = input_sdl.init(); if (sdl_input) @@ -397,7 +395,7 @@ static void* gl_init(video_info_t *video, const input_driver_t **input, void **i } else *input = NULL; - + if (!gl_check_error()) { SDL_QuitSubSystem(SDL_INIT_VIDEO); diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index 45510a0ff8..5a454c9815 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -239,6 +239,9 @@ bool gl_glsl_init(const char *path) pglLinkProgram(gl_program); pglUseProgram(gl_program); print_linker_log(gl_program); + + GLint location = pglGetUniformLocation(gl_program, "rubyTexture"); + pglUniform1i(location, 0); } if (!gl_check_error()) @@ -270,6 +273,7 @@ void gl_glsl_set_params(unsigned width, unsigned height, float textureSize[2] = {tex_width, tex_height}; location = pglGetUniformLocation(gl_program, "rubyTextureSize"); pglUniform2fv(location, 1, textureSize); + } } diff --git a/hqflt/cg/crt.cg b/hqflt/cg/crt.cg index bee618ad38..bb62d1da05 100644 --- a/hqflt/cg/crt.cg +++ b/hqflt/cg/crt.cg @@ -91,7 +91,8 @@ output main_fragment(float2 texCoord : TEXCOORD0, uniform sampler2D decal : TEXU else mcol.rb = 0.7; - OUT.color = pow(mcol*(col * weights + col2 * weights2), 1.0/2.2); + //OUT.color = pow(mcol*(col * weights + col2 * weights2), 1.0/2.2); + OUT.color = 1.0; return OUT; }