Mercurial > repos > blastem
comparison render_sdl.c @ 489:e97b80e3bd76 opengl
Support interlace mode with OpenGL backend
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 27 Oct 2013 21:41:21 -0700 |
parents | 32f053ad9b02 |
children | c8e65962bfed |
comparison
equal
deleted
inserted
replaced
488:32f053ad9b02 | 489:e97b80e3bd76 |
---|---|
158 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 158 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
159 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 159 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
160 if (i < 2) { | 160 if (i < 2) { |
161 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 256, 0, GL_BGRA, GL_UNSIGNED_BYTE, i ? context->evenbuf : context->oddbuf); | 161 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 256, 0, GL_BGRA, GL_UNSIGNED_BYTE, i ? context->evenbuf : context->oddbuf); |
162 } else { | 162 } else { |
163 uint32_t blank = 255; | 163 uint32_t blank = 255 << 24; |
164 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_BGRA, GL_UNSIGNED_BYTE, &blank); | 164 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_BGRA, GL_UNSIGNED_BYTE, &blank); |
165 } | 165 } |
166 } | 166 } |
167 glGenBuffers(2, buffers); | 167 glGenBuffers(2, buffers); |
168 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); | 168 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); |
330 glActiveTexture(GL_TEXTURE0); | 330 glActiveTexture(GL_TEXTURE0); |
331 glBindTexture(GL_TEXTURE_2D, textures[0]); | 331 glBindTexture(GL_TEXTURE_2D, textures[0]); |
332 glUniform1i(un_textures[0], 0); | 332 glUniform1i(un_textures[0], 0); |
333 | 333 |
334 glActiveTexture(GL_TEXTURE1); | 334 glActiveTexture(GL_TEXTURE1); |
335 //TODO: Select appropriate texture based on status of interlace | 335 glBindTexture(GL_TEXTURE_2D, (context->regs[REG_MODE_4] & BIT_INTERLACE) ? textures[1] : textures[2]); |
336 glBindTexture(GL_TEXTURE_2D, textures[1]); | |
337 glUniform1i(un_textures[1], 1); | 336 glUniform1i(un_textures[1], 1); |
338 | 337 |
339 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); | 338 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); |
340 glVertexAttribPointer(at_pos, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat[2]), (void *)0); | 339 glVertexAttribPointer(at_pos, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat[2]), (void *)0); |
341 glEnableVertexAttribArray(at_pos); | 340 glEnableVertexAttribArray(at_pos); |
344 glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, (void *)0); | 343 glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, (void *)0); |
345 | 344 |
346 glDisableVertexAttribArray(at_pos); | 345 glDisableVertexAttribArray(at_pos); |
347 | 346 |
348 SDL_GL_SwapBuffers(); | 347 SDL_GL_SwapBuffers(); |
349 | 348 if (context->regs[REG_MODE_4] & BIT_INTERLACE) |
349 { | |
350 context->framebuf = context->framebuf == context->oddbuf ? context->evenbuf : context->oddbuf; | |
351 } | |
350 } | 352 } |
351 | 353 |
352 uint32_t blankbuf[320*240]; | 354 uint32_t blankbuf[320*240]; |
353 | 355 |
354 void render_context(vdp_context * context) | 356 void render_context(vdp_context * context) |