mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-16 15:27:41 +00:00
Add scanline shader. Fix up interface a bit for screen width and height.
This commit is contained in:
parent
0ae1456325
commit
9296f76ef8
2
config.h
2
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;
|
||||
|
7
gl.c
7
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)
|
||||
|
46
hqflt/scanline.cg
Normal file
46
hqflt/scanline.cg
Normal file
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user