comparison render_sdl.c @ 884:252dfd29831d

Selecting a second game from the menu now works
author Michael Pavone <pavone@retrodev.com>
date Fri, 13 Nov 2015 22:56:59 -0800
parents b6842dfb8edf
children b9564fb88a5a
comparison
equal deleted inserted replaced
883:9f149f0e98b7 884:252dfd29831d
113 113
114 const GLushort element_data[] = {0, 1, 2, 3}; 114 const GLushort element_data[] = {0, 1, 2, 3};
115 115
116 GLuint load_shader(char * fname, GLenum shader_type) 116 GLuint load_shader(char * fname, GLenum shader_type)
117 { 117 {
118 char * parts[] = {get_home_dir(), "/.config/blastem/shaders/", fname}; 118 char const * parts[] = {get_home_dir(), "/.config/blastem/shaders/", fname};
119 char * shader_path = alloc_concat_m(3, parts); 119 char * shader_path = alloc_concat_m(3, parts);
120 FILE * f = fopen(shader_path, "rb"); 120 FILE * f = fopen(shader_path, "rb");
121 free(shader_path); 121 free(shader_path);
122 if (!f) { 122 if (!f) {
123 parts[0] = get_exe_dir(); 123 parts[0] = get_exe_dir();
156 } 156 }
157 #endif 157 #endif
158 158
159 void render_alloc_surfaces(vdp_context * context) 159 void render_alloc_surfaces(vdp_context * context)
160 { 160 {
161 static uint8_t texture_init;
161 context->oddbuf = context->framebuf = malloc(512 * 256 * 4 * 2); 162 context->oddbuf = context->framebuf = malloc(512 * 256 * 4 * 2);
162 memset(context->oddbuf, 0, 512 * 256 * 4 * 2); 163 memset(context->oddbuf, 0, 512 * 256 * 4 * 2);
163 context->evenbuf = ((char *)context->oddbuf) + 512 * 256 * 4; 164 context->evenbuf = ((char *)context->oddbuf) + 512 * 256 * 4;
164 165
166 if (texture_init) {
167 return;
168 }
169 texture_init = 1;
165 #ifndef DISABLE_OPENGL 170 #ifndef DISABLE_OPENGL
166 if (render_gl) { 171 if (render_gl) {
167 glGenTextures(3, textures); 172 glGenTextures(3, textures);
168 for (int i = 0; i < 3; i++) 173 for (int i = 0; i < 3; i++)
169 { 174 {
207 /* height=480 to fit interlaced output */ 212 /* height=480 to fit interlaced output */
208 main_texture = SDL_CreateTexture(main_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 320, 480); 213 main_texture = SDL_CreateTexture(main_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 320, 480);
209 #ifndef DISABLE_OPENGL 214 #ifndef DISABLE_OPENGL
210 } 215 }
211 #endif 216 #endif
217 }
218
219 void render_free_surfaces(vdp_context *context)
220 {
221 free(context->framebuf);
212 } 222 }
213 223
214 char * caption = NULL; 224 char * caption = NULL;
215 225
216 static void render_quit() 226 static void render_quit()