struct texture post_fbtex[2];
int post_fbtex_cur;
-unsigned int post_sdr[MAX_POST_SDR];
+unsigned int sdr_vgn;
+int vgn_uloc_color, vgn_uloc_offs, vgn_uloc_sharp;
int post_init(void)
{
int i;
- static const char *psdr_fname[] = {"sdr/oldfig.p.glsl"};
- for(i=0; i<MAX_POST_SDR; i++) {
- if(!(post_sdr[i] = create_program_load("sdr/post.v.glsl", psdr_fname[i]))) {
- return -1;
- }
+ if(!(sdr_vgn = create_program_load("sdr/post.v.glsl", "sdr/vignette.p.glsl"))) {
+ return -1;
}
+ glUseProgram(sdr_vgn);
+ vgn_uloc_color = get_uniform_loc(sdr_vgn, "color");
+ vgn_uloc_offs = get_uniform_loc(sdr_vgn, "offset");
+ vgn_uloc_sharp = get_uniform_loc(sdr_vgn, "sharpness");
+
glGenTextures(2, post_fbtex_gltexid);
glGenRenderbuffers(2, rbuf_depth);
if(post_fbo[0]) {
glDeleteFramebuffers(2, post_fbo);
}
+
+ if(sdr_vgn) {
+ free_program(sdr_vgn);
+ }
}
void post_reshape(int x, int y)
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, tex);
+ if(tex) {
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ } else {
+ glDisable(GL_TEXTURE_2D);
+ }
glBegin(GL_QUADS);
glColor4f(1, 1, 1, alpha);
- glTexCoord2f(0, 1);
+ glTexCoord2f(0, 0);
glVertex2f(-1, -1);
- glTexCoord2f(1, 1);
- glVertex2f(1, -1);
glTexCoord2f(1, 0);
+ glVertex2f(1, -1);
+ glTexCoord2f(1, 1);
glVertex2f(1, 1);
- glTexCoord2f(0, 0);
+ glTexCoord2f(0, 1);
glVertex2f(-1, 1);
glEnd();
void overlay_tex(struct texture *tex, float alpha)
{
- overlay(tex->id, (float)tex->width / tex->height, alpha);
+ unsigned int tid;
+ float aspect;
+ if(tex) {
+ tid = tex->id;
+ aspect = (float)tex->width / tex->height;
+ } else {
+ tid = 0;
+ aspect = 1.0f;
+ }
+ overlay(tid, aspect, alpha);
+}
+
+void vignette(float r, float g, float b, float offs, float sharp)
+{
+ glUseProgram(sdr_vgn);
+ if(vgn_uloc_color >= 0) {
+ glUniform3f(vgn_uloc_color, r, g, b);
+ }
+ if(vgn_uloc_offs >= 0) {
+ glUniform1f(vgn_uloc_offs, offs);
+ }
+ if(vgn_uloc_sharp >= 0) {
+ glUniform1f(vgn_uloc_sharp, sharp);
+ }
+ overlay(0, 1.0, 1.0);
}