diff --git a/config.h b/config.h index 7054520099..5f9ac0e897 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. -static const char *cg_shader_path = "hqflt/hq2x.cg"; +static const char *cg_shader_path = "hqflt/scanline.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 e73c23bcb6..7b3b778a8c 100644 --- a/gl.c +++ b/gl.c @@ -164,6 +164,7 @@ static void GLFWCALL resize(int width, int height) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); + GLuint out_width = width, out_height = height; if ( keep_aspect ) { @@ -176,12 +177,14 @@ static void GLFWCALL resize(int width, int height) { float delta = (desired_aspect / device_aspect - 1.0) / 2.0 + 0.5; glViewport(width * (0.5 - delta), 0, 2.0 * width * delta, height); + out_width = (int)(2.0 * width * delta); } else if ( (int)(device_aspect*1000) < (int)(desired_aspect*1000) ) { float delta = (device_aspect / desired_aspect - 1.0) / 2.0 + 0.5; glViewport(0, height * (0.5 - delta), width, 2.0 * height * delta); + out_height = (int)(2.0 * height * delta); } else glViewport(0, 0, width, height); @@ -195,8 +198,8 @@ static void GLFWCALL resize(int width, int height) #ifdef HAVE_CG cgGLSetStateMatrixParameter(cg_mvp_matrix, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY); #endif - gl_width = width; - gl_height = height; + gl_width = out_width; + gl_height = out_height; } static float tv_to_fps(const struct timeval *tv, const struct timeval *new_tv, int frames) diff --git a/hqflt/scanline.cg b/hqflt/scanline.cg new file mode 100644 index 0000000000..611382ea61 --- /dev/null +++ b/hqflt/scanline.cg @@ -0,0 +1,46 @@ + +/* Default Vertex shader */ +void main_vertex +( + float4 position : POSITION, + float4 color : COLOR, + float2 texCoord : TEXCOORD0, + + uniform float4x4 modelViewProj, + + out float4 oPosition : POSITION, + out float4 oColor : COLOR, + out float2 otexCoord : TEXCOORD +) +{ + oPosition = mul(modelViewProj, position); + oColor = color; + otexCoord = texCoord; +} + + +struct output +{ + float4 color : COLOR; +}; + +struct input +{ + float2 video_size; + float2 texture_size; + float2 output_size; +}; + +output main_fragment(float2 texCoord : TEXCOORD0, uniform sampler2D decal : TEXUNIT0, uniform input IN) +{ + output OUT; + + float winHeight = IN.output_size.y; + float4 tex_color = tex2D(decal, texCoord); + + OUT.color = (1.0 - 0.60 * floor(fmod(texCoord.y * winHeight, 2.0))) * tex_color; + + return OUT; +} + +