X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdemo.c;h=a4bb0c70fd8f7462638b11c90f6343ddcaeb2942;hb=5eefe7b94c8d6c6caa2c10e3835ab0831a3c42a1;hp=97da53671ab39de8ed363d4cb04671f9a0ce6592;hpb=8d209f332b7ac731aae8b7b46fc3b5622b713100;p=demo_prior diff --git a/src/demo.c b/src/demo.c index 97da536..a4bb0c7 100644 --- a/src/demo.c +++ b/src/demo.c @@ -13,7 +13,6 @@ float win_aspect; long time_msec; static int reshape_pending; -static unsigned int fbtex; static unsigned int sdr_gamma; int demo_init(void) @@ -26,18 +25,16 @@ int demo_init(void) glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); - glEnable(GL_FRAMEBUFFER_SRGB); - glEnable(GL_MULTISAMPLE); - - glGenTextures(1, &fbtex); - glBindTexture(GL_TEXTURE_2D, fbtex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - if(win_width) { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, win_width, win_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + if(opt.srgb) { + glEnable(GL_FRAMEBUFFER_SRGB); } + if(opt.msaa) { + glEnable(GL_MULTISAMPLE); + } + + post_init(); - if(!(sdr_gamma = create_program_load("sdr/gamma.v.glsl", "sdr/gamma.p.glsl"))) { + if(!(sdr_gamma = create_program_load("sdr/post.v.glsl", "sdr/gamma.p.glsl"))) { fprintf(stderr, "Warning: failed to load the gamma correction shader\n"); } @@ -61,9 +58,7 @@ void demo_cleanup(void) if(sdr_gamma) { glDeleteProgram(sdr_gamma); } - if(fbtex) { - glDeleteTextures(1, &fbtex); - } + post_cleanup(); for(i=0; idestroy(); @@ -75,10 +70,8 @@ void demo_display(void) long part_time; if(reshape_pending) { - /* reshape fbtex */ - glBindTexture(GL_TEXTURE_2D, fbtex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, win_width, win_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - reshape_pending = 1; + post_reshape(win_width, win_height); + reshape_pending = 0; } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -110,11 +103,11 @@ void demo_display(void) /* no-srgb gamma correction fallback */ if(!opt.srgb) { - glBindTexture(GL_TEXTURE_2D, fbtex); + glBindTexture(GL_TEXTURE_2D, post_fbtex[0].id); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, win_width, win_height); glUseProgram(sdr_gamma); - overlay(fbtex, win_aspect, 1.0); + overlay_tex(post_fbtex, 1.0); } }