diff --git a/config.h b/config.h index 7e0e4972f1..edeb0f3ab8 100644 --- a/config.h +++ b/config.h @@ -65,7 +65,7 @@ static const bool vsync = true; static const bool video_smooth = false; // Path to custom Cg shader. If using custom shaders, it is recommended to disable video_smooth and VIDEO_FILTER. -static const char *cg_shader_path = "hqflt/HDR-TV.cg"; +static const char *cg_shader_path = "hqflt/crt.cg"; // On resize and fullscreen, rendering area will stay 4:3 static const bool force_aspect = true; diff --git a/gl.c b/gl.c index 1a430a85df..4dbb51b6ed 100644 --- a/gl.c +++ b/gl.c @@ -31,11 +31,12 @@ static CGcontext cgCtx; static CGprogram cgPrg; static CGprofile cgVProf; + +static CGparameter cg_video_size, cg_texture_size; #endif // Lots of globals, yes I know. :( static GLuint texture; -static uint8_t *gl_buffer; static bool keep_aspect = true; static GLuint tex_filter; @@ -232,6 +233,11 @@ static bool gl_frame(void *data, const uint16_t* frame, int width, int height, i glClear(GL_COLOR_BUFFER_BIT); +#if HAVE_CG + cgGLSetParameter2f(cg_video_size, width, height); + cgGLSetParameter2f(cg_texture_size, width, height); +#endif + glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch >> 1); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA, @@ -253,7 +259,6 @@ static void gl_free(void *data) glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDeleteTextures(1, &texture); glfwTerminate(); - free(gl_buffer); } static void gl_set_nonblock_state(void *data, bool state) @@ -348,6 +353,10 @@ static void* gl_init(video_info_t *video, const input_driver_t **input) cgGLLoadProgram(cgPrg); cgGLEnableProfile(cgVProf); cgGLBindProgram(cgPrg); + + cg_video_size = cgGetNamedParameter(cgPrg, "IN.video_size"); + cg_texture_size = cgGetNamedParameter(cgPrg, "IN.texture_size"); + #endif *input = &input_glfw; diff --git a/hqflt/crt.cg b/hqflt/crt.cg index 77e703c752..55c3e54727 100644 --- a/hqflt/crt.cg +++ b/hqflt/crt.cg @@ -11,10 +11,12 @@ struct output float4 color : COLOR; }; +struct input +{ + float2 video_size; + float2 texture_size; +}; -//uniform float2 rubyInputSize; -//uniform float2 rubyOutputSize; -//uniform float2 rubyTextureSize; float2 fract(float2 v) { @@ -32,13 +34,13 @@ float2 barrelDistortion(float2 coord) { return coord + cc * (dist + distortion * dist * dist) * distortion; } -output main(float2 texCoord : TEXCOORD0, uniform sampler2D decal : TEXUNIT0) +output main(float2 texCoord : TEXCOORD0, uniform sampler2D decal : TEXUNIT0, uniform input IN) { output OUT; - float2 rubyInputSize = float2(256, 224); - float2 rubyOutputSize = float2(256, 224); - float2 rubyTextureSize = float2(256, 224); + float2 rubyInputSize = IN.video_size; + float2 rubyOutputSize = IN.video_size; + float2 rubyTextureSize = IN.texture_size; float2 xy = barrelDistortion(texCoord.xy); float2 one = 1.0/rubyTextureSize;