2525 #include < glad.h>
2626#endif
2727
28- #include < math.h>
29-
3028#include " imgui.h"
3129#include " imgui_impl_opengl3.h"
3230#include " emu.h"
3331#include " config.h"
34- #include " gui.h"
3532#include " geargrafx.h"
3633
3734#define OGL_RENDERER_IMPORT
@@ -51,7 +48,6 @@ static int quad_uniform_color = -1;
5148static int quad_uniform_tex_scale = -1 ;
5249static int quad_uniform_viewport_size = -1 ;
5350static int quad_uniform_use_fragcoord = -1 ;
54- static int quad_uniform_scanline_scale = -1 ;
5551
5652
5753
@@ -69,40 +65,6 @@ static void update_system_texture(void);
6965static void update_debug_textures (void );
7066static void update_savestates_texture (void );
7167static void render_scanlines (void );
72- static int compute_output_scale (void );
73-
74- static int compute_output_scale (void )
75- {
76- int scale = FRAME_BUFFER_SCALE_DEFAULT;
77-
78- if (!config_video.scanlines || config_debug.debug )
79- return scale;
80-
81- ImGuiIO& io = ImGui::GetIO ();
82- float fb_scale_x = io.DisplayFramebufferScale .x > 0 .0f ? io.DisplayFramebufferScale .x : 1 .0f ;
83- float fb_scale_y = io.DisplayFramebufferScale .y > 0 .0f ? io.DisplayFramebufferScale .y : 1 .0f ;
84- bool fractional_fb_scale = (fabsf (fb_scale_x - roundf (fb_scale_x)) > 0 .001f ) || (fabsf (fb_scale_y - roundf (fb_scale_y)) > 0 .001f );
85-
86- if (!fractional_fb_scale)
87- return scale;
88-
89- if (config_video.scale == 1 )
90- {
91- scale = config_video.scale_manual ;
92- }
93- else if ((config_video.scale == 0 ) && (current_runtime.screen_height > 0 ) && (gui_main_window_height > 0 ))
94- {
95- int physical_height = (int )roundf ((float )gui_main_window_height * fb_scale_y);
96- scale = physical_height / current_runtime.screen_height ;
97- }
98-
99- if (scale < 1 )
100- scale = 1 ;
101- if (scale > FRAME_BUFFER_SCALE)
102- scale = FRAME_BUFFER_SCALE;
103-
104- return scale;
105- }
10668
10769bool ogl_renderer_init (void )
10870{
@@ -172,7 +134,6 @@ void ogl_renderer_begin_render(void)
172134void ogl_renderer_render (void )
173135{
174136 emu_get_runtime (current_runtime);
175- ogl_renderer_output_scale = compute_output_scale ();
176137
177138 if (config_debug.debug )
178139 {
@@ -341,7 +302,7 @@ static void render_emu_mix(void)
341302 update_system_texture ();
342303
343304 int viewportWidth = current_runtime.screen_width ;
344- int viewportHeight = current_runtime.screen_height * ogl_renderer_output_scale ;
305+ int viewportHeight = current_runtime.screen_height * FRAME_BUFFER_SCALE ;
345306
346307 glUseProgram (quad_shader_program);
347308 glUniform2f (quad_uniform_tex_scale, tex_h, tex_v);
@@ -442,7 +403,7 @@ static void update_emu_texture(void)
442403static void render_quad (float tex_h, float tex_v)
443404{
444405 int viewportWidth = current_runtime.screen_width ;
445- int viewportHeight = current_runtime.screen_height * ogl_renderer_output_scale ;
406+ int viewportHeight = current_runtime.screen_height * FRAME_BUFFER_SCALE ;
446407
447408 glUseProgram (quad_shader_program);
448409 glUniform2f (quad_uniform_tex_scale, tex_h, tex_v);
@@ -465,7 +426,7 @@ static void render_scanlines(void)
465426 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
466427
467428 int viewportWidth = current_runtime.screen_width ;
468- int viewportHeight = current_runtime.screen_height * ogl_renderer_output_scale ;
429+ int viewportHeight = current_runtime.screen_height * FRAME_BUFFER_SCALE ;
469430
470431 float tex_h = (float )current_runtime.screen_width ;
471432 float tex_v = (float )current_runtime.screen_height ;
@@ -474,7 +435,6 @@ static void render_scanlines(void)
474435 glUniform2f (quad_uniform_tex_scale, tex_h, tex_v);
475436 glUniform2f (quad_uniform_viewport_size, (float )viewportWidth, (float )viewportHeight);
476437 glUniform1i (quad_uniform_use_fragcoord, 2 );
477- glUniform1i (quad_uniform_scanline_scale, ogl_renderer_output_scale);
478438 glUniform4f (quad_uniform_color, 1 .0f , 1 .0f , 1 .0f , config_video.scanlines_intensity );
479439
480440 glViewport (0 , 0 , viewportWidth, viewportHeight);
@@ -515,11 +475,10 @@ static void init_shaders(void)
515475 " uniform vec2 uTexScale;\n "
516476 " uniform vec2 uViewportSize;\n "
517477 " uniform int uUseFragCoord;\n "
518- " uniform int uScanlineScale;\n "
519478 " void main() {\n "
520479 " if (uUseFragCoord == 2) {\n "
521- " float row = mod(floor(gl_FragCoord.y), float(uScanlineScale) );\n "
522- " float mask = row >= (float(uScanlineScale) * 0.5) ? 1.0 : 0.0;\n "
480+ " float row = mod(floor(gl_FragCoord.y), 4.0 );\n "
481+ " float mask = row >= 2.0 ? 1.0 : 0.0;\n "
523482 " FragColor = vec4(0.0, 0.0, 0.0, uColor.a * mask);\n "
524483 " return;\n "
525484 " }\n "
@@ -579,12 +538,10 @@ static void init_shaders(void)
579538 quad_uniform_color = glGetUniformLocation (quad_shader_program, " uColor" );
580539 quad_uniform_viewport_size = glGetUniformLocation (quad_shader_program, " uViewportSize" );
581540 quad_uniform_use_fragcoord = glGetUniformLocation (quad_shader_program, " uUseFragCoord" );
582- quad_uniform_scanline_scale = glGetUniformLocation (quad_shader_program, " uScanlineScale" );
583541
584542 glUseProgram (quad_shader_program);
585543 glUniform1i (quad_uniform_texture, 0 );
586544 glUniform1i (quad_uniform_use_fragcoord, 0 );
587- glUniform1i (quad_uniform_scanline_scale, FRAME_BUFFER_SCALE_DEFAULT);
588545 glUseProgram (0 );
589546
590547 float quad_vertices[] = {
0 commit comments