Mercurial > repos > blastem
comparison render_sdl.c @ 1403:87493f585c7f
Allow selecting linear or nearet neighbor scaling for both the Open GL and SDL 2 renderers
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 15 Jun 2017 22:51:28 -0700 |
parents | 458df351af06 |
children | 8a3d3bb2cd08 |
comparison
equal
deleted
inserted
replaced
1402:458df351af06 | 1403:87493f585c7f |
---|---|
193 | 193 |
194 static uint32_t texture_buf[512 * 513]; | 194 static uint32_t texture_buf[512 * 513]; |
195 #ifndef DISABLE_OPENGL | 195 #ifndef DISABLE_OPENGL |
196 static void gl_setup() | 196 static void gl_setup() |
197 { | 197 { |
198 tern_val def = {.ptrval = "linear"}; | |
199 char *scaling = tern_find_path_default(config, "video\0scaling\0", def, TVAL_PTR).ptrval; | |
200 GLint filter = strcmp(scaling, "linear") ? GL_NEAREST : GL_LINEAR; | |
198 glGenTextures(3, textures); | 201 glGenTextures(3, textures); |
199 for (int i = 0; i < 3; i++) | 202 for (int i = 0; i < 3; i++) |
200 { | 203 { |
201 glBindTexture(GL_TEXTURE_2D, textures[i]); | 204 glBindTexture(GL_TEXTURE_2D, textures[i]); |
202 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 205 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); |
203 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 206 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); |
204 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 207 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
205 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 208 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
206 if (i < 2) { | 209 if (i < 2) { |
207 //TODO: Fixme for PAL + invalid display mode | 210 //TODO: Fixme for PAL + invalid display mode |
208 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture_buf); | 211 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_BGRA, GL_UNSIGNED_BYTE, texture_buf); |
214 glGenBuffers(2, buffers); | 217 glGenBuffers(2, buffers); |
215 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); | 218 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); |
216 glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW); | 219 glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW); |
217 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]); | 220 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]); |
218 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(element_data), element_data, GL_STATIC_DRAW); | 221 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(element_data), element_data, GL_STATIC_DRAW); |
219 tern_val def = {.ptrval = "default.v.glsl"}; | 222 def.ptrval = "default.v.glsl"; |
220 vshader = load_shader(tern_find_path_default(config, "video\0vertex_shader\0", def, TVAL_PTR).ptrval, GL_VERTEX_SHADER); | 223 vshader = load_shader(tern_find_path_default(config, "video\0vertex_shader\0", def, TVAL_PTR).ptrval, GL_VERTEX_SHADER); |
221 def.ptrval = "default.f.glsl"; | 224 def.ptrval = "default.f.glsl"; |
222 fshader = load_shader(tern_find_path_default(config, "video\0fragment_shader\0", def, TVAL_PTR).ptrval, GL_FRAGMENT_SHADER); | 225 fshader = load_shader(tern_find_path_default(config, "video\0fragment_shader\0", def, TVAL_PTR).ptrval, GL_FRAGMENT_SHADER); |
223 program = glCreateProgram(); | 226 program = glCreateProgram(); |
224 glAttachShader(program, vshader); | 227 glAttachShader(program, vshader); |
252 if (render_gl) { | 255 if (render_gl) { |
253 sdl_textures[0] = sdl_textures[1] = NULL; | 256 sdl_textures[0] = sdl_textures[1] = NULL; |
254 gl_setup(); | 257 gl_setup(); |
255 } else { | 258 } else { |
256 #endif | 259 #endif |
257 | 260 tern_val def = {.ptrval = "linear"}; |
261 char *scaling = tern_find_path_default(config, "video\0scaling\0", def, TVAL_PTR).ptrval; | |
262 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, scaling); | |
258 //TODO: Fixme for invalid display mode | 263 //TODO: Fixme for invalid display mode |
259 sdl_textures[0] = sdl_textures[1] = SDL_CreateTexture(main_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, LINEBUF_SIZE, 588); | 264 sdl_textures[0] = sdl_textures[1] = SDL_CreateTexture(main_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, LINEBUF_SIZE, 588); |
260 #ifndef DISABLE_OPENGL | 265 #ifndef DISABLE_OPENGL |
261 } | 266 } |
262 #endif | 267 #endif |