3535#include " ogl_renderer.h"
3636
3737static uint32_t system_texture;
38- static uint32_t scanlines_texture;
3938static uint32_t frame_buffer_object;
4039static GG_Runtime_Info current_runtime;
4140static bool first_frame;
4241static bool mix_round_error = false ;
43- static u8 scanlines[64 ] = {
44- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
45- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
46- 0 , 0 , 0 , 255 , 0 , 0 , 0 , 255 , 0 , 0 , 0 , 255 , 0 , 0 , 0 , 255 ,
47- 0 , 0 , 0 , 255 , 0 , 0 , 0 , 255 , 0 , 0 , 0 , 255 , 0 , 0 , 0 , 255 };
4842
4943static uint32_t quad_shader_program = 0 ;
5044static uint32_t quad_vao = 0 ;
@@ -61,7 +55,6 @@ static void init_ogl_gui(void);
6155static void init_ogl_emu (void );
6256static void init_ogl_debug (void );
6357static void init_ogl_savestates (void );
64- static void init_scanlines_texture (void );
6558static void init_shaders (void );
6659static void render_gui (void );
6760static void render_emu_normal (void );
@@ -107,7 +100,6 @@ void ogl_renderer_destroy(void)
107100 glDeleteFramebuffers (1 , &frame_buffer_object);
108101 glDeleteTextures (1 , &ogl_renderer_emu_texture);
109102 glDeleteTextures (1 , &system_texture);
110- glDeleteTextures (1 , &scanlines_texture);
111103
112104 glDeleteTextures (1 , &ogl_renderer_emu_debug_huc6270_background[0 ]);
113105 glDeleteTextures (1 , &ogl_renderer_emu_debug_huc6270_background[1 ]);
@@ -218,8 +210,6 @@ static void init_ogl_emu(void)
218210 glTexImage2D (GL_TEXTURE_2D, 0 , GL_RGBA8, SYSTEM_TEXTURE_WIDTH, SYSTEM_TEXTURE_HEIGHT, 0 , GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) emu_frame_buffer);
219211 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
220212 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
221-
222- init_scanlines_texture ();
223213}
224214
225215static void init_ogl_debug (void )
@@ -265,17 +255,6 @@ static void init_ogl_savestates(void)
265255 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
266256}
267257
268- static void init_scanlines_texture (void )
269- {
270- glGenTextures (1 , &scanlines_texture);
271- glBindTexture (GL_TEXTURE_2D, scanlines_texture);
272- glTexImage2D (GL_TEXTURE_2D, 0 , GL_RGBA8, 4 , 4 , 0 , GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) scanlines);
273- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
274- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
275- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
276- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
277- }
278-
279258static void render_gui (void )
280259{
281260 ImGui_ImplOpenGL3_RenderDrawData (ImGui::GetDrawData ());
@@ -446,8 +425,6 @@ static void render_scanlines(void)
446425 glEnable (GL_BLEND);
447426 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
448427
449- glBindTexture (GL_TEXTURE_2D, scanlines_texture);
450-
451428 int viewportWidth = current_runtime.screen_width ;
452429 int viewportHeight = current_runtime.screen_height * FRAME_BUFFER_SCALE;
453430
@@ -457,7 +434,7 @@ static void render_scanlines(void)
457434 glUseProgram (quad_shader_program);
458435 glUniform2f (quad_uniform_tex_scale, tex_h, tex_v);
459436 glUniform2f (quad_uniform_viewport_size, (float )viewportWidth, (float )viewportHeight);
460- glUniform1i (quad_uniform_use_fragcoord, 1 );
437+ glUniform1i (quad_uniform_use_fragcoord, 2 );
461438 glUniform4f (quad_uniform_color, 1 .0f , 1 .0f , 1 .0f , config_video.scanlines_intensity );
462439
463440 glViewport (0 , 0 , viewportWidth, viewportHeight);
@@ -499,6 +476,12 @@ static void init_shaders(void)
499476 " uniform vec2 uViewportSize;\n "
500477 " uniform int uUseFragCoord;\n "
501478 " void main() {\n "
479+ " if (uUseFragCoord == 2) {\n "
480+ " float row = mod(floor(gl_FragCoord.y), 4.0);\n "
481+ " float mask = row >= 2.0 ? 1.0 : 0.0;\n "
482+ " FragColor = vec4(0.0, 0.0, 0.0, uColor.a * mask);\n "
483+ " return;\n "
484+ " }\n "
502485 " vec2 texCoord = vTexCoord;\n "
503486 " if (uUseFragCoord != 0)\n "
504487 " texCoord = (gl_FragCoord.xy / uViewportSize) * uTexScale;\n "
0 commit comments