Mercurial > repos > blastem
comparison render_sdl.c @ 505:b7b7a1cab44a
The local clone on my laptop got messed up and some changes had not been pushed. This commit represents the status of the working copy from that clone. It unfortunately contains some changes that I did not intend to commit yet, but this seems like the best option at the moment.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 06 Jan 2014 22:54:05 -0800 |
parents | 7fdfcced65b6 |
children | b76d2a628ab9 2e1b3b258523 |
comparison
equal
deleted
inserted
replaced
504:7b0df1aaf384 | 505:b7b7a1cab44a |
---|---|
16 #endif | 16 #endif |
17 | 17 |
18 SDL_Surface *screen; | 18 SDL_Surface *screen; |
19 uint8_t render_dbg = 0; | 19 uint8_t render_dbg = 0; |
20 uint8_t debug_pal = 0; | 20 uint8_t debug_pal = 0; |
21 uint8_t render_gl; | 21 uint8_t render_gl = 1; |
22 | 22 |
23 uint32_t last_frame = 0; | 23 uint32_t last_frame = 0; |
24 | 24 |
25 uint32_t min_delay; | 25 uint32_t min_delay; |
26 uint32_t frame_delay = 1000/60; | 26 uint32_t frame_delay = 1000/60; |
98 return SDL_MapRGB(screen->format, r, g, b); | 98 return SDL_MapRGB(screen->format, r, g, b); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 #ifndef DISABLE_OPENGL | 102 #ifndef DISABLE_OPENGL |
103 GLuint textures[3], buffers[2], vshader, fshader, program, un_textures[2], at_pos; | 103 GLuint textures[3], buffers[2], vshader, fshader, program, un_textures[2], un_width, at_pos; |
104 | 104 |
105 GLfloat vertex_data[] = { | 105 GLfloat vertex_data[] = { |
106 -1.0f, -1.0f, | 106 -1.0f, -1.0f, |
107 1.0f, -1.0f, | 107 1.0f, -1.0f, |
108 -1.0f, 1.0f, | 108 -1.0f, 1.0f, |
194 fputs("Failed to link shader program\n", stderr); | 194 fputs("Failed to link shader program\n", stderr); |
195 exit(1); | 195 exit(1); |
196 } | 196 } |
197 un_textures[0] = glGetUniformLocation(program, "textures[0]"); | 197 un_textures[0] = glGetUniformLocation(program, "textures[0]"); |
198 un_textures[1] = glGetUniformLocation(program, "textures[1]"); | 198 un_textures[1] = glGetUniformLocation(program, "textures[1]"); |
199 un_width = glGetUniformLocation(program, "width"); | |
199 at_pos = glGetAttribLocation(program, "pos"); | 200 at_pos = glGetAttribLocation(program, "pos"); |
200 } else { | 201 } else { |
201 #endif | 202 #endif |
202 context->oddbuf = context->framebuf = malloc(320 * 240 * screen->format->BytesPerPixel * 2); | 203 context->oddbuf = context->framebuf = malloc(320 * 240 * screen->format->BytesPerPixel * 2); |
203 context->evenbuf = ((char *)context->oddbuf) + 320 * 240 * screen->format->BytesPerPixel; | 204 context->evenbuf = ((char *)context->oddbuf) + 320 * 240 * screen->format->BytesPerPixel; |
360 glUniform1i(un_textures[0], 0); | 361 glUniform1i(un_textures[0], 0); |
361 | 362 |
362 glActiveTexture(GL_TEXTURE1); | 363 glActiveTexture(GL_TEXTURE1); |
363 glBindTexture(GL_TEXTURE_2D, (context->regs[REG_MODE_4] & BIT_INTERLACE) ? textures[1] : textures[2]); | 364 glBindTexture(GL_TEXTURE_2D, (context->regs[REG_MODE_4] & BIT_INTERLACE) ? textures[1] : textures[2]); |
364 glUniform1i(un_textures[1], 1); | 365 glUniform1i(un_textures[1], 1); |
366 | |
367 glUniform1f(un_width, context->latched_mode & BIT_H40 ? 320.0f : 256.0f); | |
365 | 368 |
366 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); | 369 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); |
367 glVertexAttribPointer(at_pos, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat[2]), (void *)0); | 370 glVertexAttribPointer(at_pos, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat[2]), (void *)0); |
368 glEnableVertexAttribArray(at_pos); | 371 glEnableVertexAttribArray(at_pos); |
369 | 372 |