# HG changeset patch # User Mike Pavone # Date 1382935281 25200 # Node ID e97b80e3bd76c992623fbf346ee426aaf4bdbb20 # Parent 32f053ad9b02a3e3289fb70c1b20e772c4ffa2eb Support interlace mode with OpenGL backend diff -r 32f053ad9b02 -r e97b80e3bd76 default.f.glsl --- a/default.f.glsl Sun Oct 27 01:29:50 2013 -0700 +++ b/default.f.glsl Sun Oct 27 21:41:21 2013 -0700 @@ -6,5 +6,9 @@ void main() { - gl_FragColor = texture2D(textures[0], texcoord); + gl_FragColor = mix( + texture2D(textures[0], texcoord), + texture2D(textures[1], vec2(texcoord.x, texcoord.y - 1.0/512.0)), + sin((texcoord.y * 512.0 - 0.75) * 3.14159265359) / 2.0 + 0.5 + ); } diff -r 32f053ad9b02 -r e97b80e3bd76 render_sdl.c --- a/render_sdl.c Sun Oct 27 01:29:50 2013 -0700 +++ b/render_sdl.c Sun Oct 27 21:41:21 2013 -0700 @@ -160,7 +160,7 @@ if (i < 2) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 256, 0, GL_BGRA, GL_UNSIGNED_BYTE, i ? context->evenbuf : context->oddbuf); } else { - uint32_t blank = 255; + uint32_t blank = 255 << 24; glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_BGRA, GL_UNSIGNED_BYTE, &blank); } } @@ -332,8 +332,7 @@ glUniform1i(un_textures[0], 0); glActiveTexture(GL_TEXTURE1); - //TODO: Select appropriate texture based on status of interlace - glBindTexture(GL_TEXTURE_2D, textures[1]); + glBindTexture(GL_TEXTURE_2D, (context->regs[REG_MODE_4] & BIT_INTERLACE) ? textures[1] : textures[2]); glUniform1i(un_textures[1], 1); glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); @@ -346,7 +345,10 @@ glDisableVertexAttribArray(at_pos); SDL_GL_SwapBuffers(); - + if (context->regs[REG_MODE_4] & BIT_INTERLACE) + { + context->framebuf = context->framebuf == context->oddbuf ? context->evenbuf : context->oddbuf; + } } uint32_t blankbuf[320*240];