Mercurial > repos > blastem
comparison render_sdl.c @ 1326:071e761bcdcf
Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 21 Apr 2017 23:35:32 -0700 |
parents | eca01056a915 |
children | 70faad89d491 |
comparison
equal
deleted
inserted
replaced
1325:58bfbed6cdb5 | 1326:071e761bcdcf |
---|---|
215 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); | 215 glBindBuffer(GL_ARRAY_BUFFER, buffers[0]); |
216 glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW); | 216 glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW); |
217 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]); | 217 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]); |
218 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(element_data), element_data, GL_STATIC_DRAW); | 218 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(element_data), element_data, GL_STATIC_DRAW); |
219 tern_val def = {.ptrval = "default.v.glsl"}; | 219 tern_val def = {.ptrval = "default.v.glsl"}; |
220 vshader = load_shader(tern_find_path_default(config, "video\0vertex_shader\0", def).ptrval, GL_VERTEX_SHADER); | 220 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"; | 221 def.ptrval = "default.f.glsl"; |
222 fshader = load_shader(tern_find_path_default(config, "video\0fragment_shader\0", def).ptrval, GL_FRAGMENT_SHADER); | 222 fshader = load_shader(tern_find_path_default(config, "video\0fragment_shader\0", def, TVAL_PTR).ptrval, GL_FRAGMENT_SHADER); |
223 program = glCreateProgram(); | 223 program = glCreateProgram(); |
224 glAttachShader(program, vshader); | 224 glAttachShader(program, vshader); |
225 glAttachShader(program, fshader); | 225 glAttachShader(program, fshader); |
226 glLinkProgram(program); | 226 glLinkProgram(program); |
227 GLint link_status; | 227 GLint link_status; |
282 memcpy(vertex_data, vertex_data_default, sizeof(vertex_data)); | 282 memcpy(vertex_data, vertex_data_default, sizeof(vertex_data)); |
283 main_clip.w = main_width; | 283 main_clip.w = main_width; |
284 main_clip.h = main_height; | 284 main_clip.h = main_height; |
285 main_clip.x = main_clip.y = 0; | 285 main_clip.x = main_clip.y = 0; |
286 //calculate configured aspect ratio | 286 //calculate configured aspect ratio |
287 char *config_aspect = tern_find_path_default(config, "video\0aspect\0", (tern_val){.ptrval = "4:3"}).ptrval; | 287 char *config_aspect = tern_find_path_default(config, "video\0aspect\0", (tern_val){.ptrval = "4:3"}, TVAL_PTR).ptrval; |
288 if (strcmp("stretch", config_aspect)) { | 288 if (strcmp("stretch", config_aspect)) { |
289 float src_aspect = 4.0f/3.0f; | 289 float src_aspect = 4.0f/3.0f; |
290 char *end; | 290 char *end; |
291 float aspect_numerator = strtof(config_aspect, &end); | 291 float aspect_numerator = strtof(config_aspect, &end); |
292 if (aspect_numerator > 0.0f && *end == ':') { | 292 if (aspect_numerator > 0.0f && *end == ':') { |
354 main_height = height; | 354 main_height = height; |
355 is_fullscreen = fullscreen; | 355 is_fullscreen = fullscreen; |
356 | 356 |
357 render_gl = 0; | 357 render_gl = 0; |
358 tern_val def = {.ptrval = "off"}; | 358 tern_val def = {.ptrval = "off"}; |
359 char *vsync = tern_find_path_default(config, "video\0vsync\0", def).ptrval; | 359 char *vsync = tern_find_path_default(config, "video\0vsync\0", def, TVAL_PTR).ptrval; |
360 | 360 |
361 tern_val video_node = {.ptrval = NULL}; | 361 tern_node *video = tern_find_node(config, "video"); |
362 tern_find(config, "video", &video_node); | |
363 tern_node *video = tern_get_node(video_node); | |
364 if (video) | 362 if (video) |
365 { | 363 { |
366 for (int i = 0; i < NUM_VID_STD; i++) | 364 for (int i = 0; i < NUM_VID_STD; i++) |
367 { | 365 { |
368 video_node.ptrval = NULL; | 366 tern_node *std_settings = tern_find_node(video, vid_std_names[i]); |
369 tern_find(video, vid_std_names[i], &video_node); | |
370 tern_node *std_settings = tern_get_node(video_node); | |
371 if (std_settings) { | 367 if (std_settings) { |
372 char *val = tern_find_path_default(std_settings, "overscan\0top\0", (tern_val){.ptrval = NULL}).ptrval; | 368 char *val = tern_find_path_default(std_settings, "overscan\0top\0", (tern_val){.ptrval = NULL}, TVAL_PTR).ptrval; |
373 if (val) { | 369 if (val) { |
374 overscan_top[i] = atoi(val); | 370 overscan_top[i] = atoi(val); |
375 } | 371 } |
376 val = tern_find_path_default(std_settings, "overscan\0bottom\0", (tern_val){.ptrval = NULL}).ptrval; | 372 val = tern_find_path_default(std_settings, "overscan\0bottom\0", (tern_val){.ptrval = NULL}, TVAL_PTR).ptrval; |
377 if (val) { | 373 if (val) { |
378 overscan_bot[i] = atoi(val); | 374 overscan_bot[i] = atoi(val); |
379 } | 375 } |
380 val = tern_find_path_default(std_settings, "overscan\0left\0", (tern_val){.ptrval = NULL}).ptrval; | 376 val = tern_find_path_default(std_settings, "overscan\0left\0", (tern_val){.ptrval = NULL}, TVAL_PTR).ptrval; |
381 if (val) { | 377 if (val) { |
382 overscan_left[i] = atoi(val); | 378 overscan_left[i] = atoi(val); |
383 } | 379 } |
384 val = tern_find_path_default(std_settings, "overscan\0right\0", (tern_val){.ptrval = NULL}).ptrval; | 380 val = tern_find_path_default(std_settings, "overscan\0right\0", (tern_val){.ptrval = NULL}, TVAL_PTR).ptrval; |
385 if (val) { | 381 if (val) { |
386 overscan_right[i] = atoi(val); | 382 overscan_right[i] = atoi(val); |
387 } | 383 } |
388 } | 384 } |
389 } | 385 } |
445 SDL_GetWindowSize(main_window, &main_width, &main_height); | 441 SDL_GetWindowSize(main_window, &main_width, &main_height); |
446 printf("Window created with size: %d x %d\n", main_width, main_height); | 442 printf("Window created with size: %d x %d\n", main_width, main_height); |
447 update_aspect(); | 443 update_aspect(); |
448 render_alloc_surfaces(); | 444 render_alloc_surfaces(); |
449 def.ptrval = "off"; | 445 def.ptrval = "off"; |
450 scanlines = !strcmp(tern_find_path_default(config, "video\0scanlines\0", def).ptrval, "on"); | 446 scanlines = !strcmp(tern_find_path_default(config, "video\0scanlines\0", def, TVAL_PTR).ptrval, "on"); |
451 | 447 |
452 caption = title; | 448 caption = title; |
453 | 449 |
454 audio_mutex = SDL_CreateMutex(); | 450 audio_mutex = SDL_CreateMutex(); |
455 psg_cond = SDL_CreateCond(); | 451 psg_cond = SDL_CreateCond(); |
456 ym_cond = SDL_CreateCond(); | 452 ym_cond = SDL_CreateCond(); |
457 audio_ready = SDL_CreateCond(); | 453 audio_ready = SDL_CreateCond(); |
458 | 454 |
459 SDL_AudioSpec desired, actual; | 455 SDL_AudioSpec desired, actual; |
460 char * rate_str = tern_find_path(config, "audio\0rate\0").ptrval; | 456 char * rate_str = tern_find_path(config, "audio\0rate\0", TVAL_PTR).ptrval; |
461 int rate = rate_str ? atoi(rate_str) : 0; | 457 int rate = rate_str ? atoi(rate_str) : 0; |
462 if (!rate) { | 458 if (!rate) { |
463 rate = 48000; | 459 rate = 48000; |
464 } | 460 } |
465 desired.freq = rate; | 461 desired.freq = rate; |
466 desired.format = AUDIO_S16SYS; | 462 desired.format = AUDIO_S16SYS; |
467 desired.channels = 2; | 463 desired.channels = 2; |
468 char * samples_str = tern_find_path(config, "audio\0buffer\0").ptrval; | 464 char * samples_str = tern_find_path(config, "audio\0buffer\0", TVAL_PTR).ptrval; |
469 int samples = samples_str ? atoi(samples_str) : 0; | 465 int samples = samples_str ? atoi(samples_str) : 0; |
470 if (!samples) { | 466 if (!samples) { |
471 samples = 512; | 467 samples = 512; |
472 } | 468 } |
473 printf("config says: %d\n", samples); | 469 printf("config says: %d\n", samples); |