X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=demo_prior;a=blobdiff_plain;f=src%2Fpost.c;fp=src%2Fpost.c;h=c1a2a2304df540cc2aa47e0c99a1f3b01bafac34;hp=0000000000000000000000000000000000000000;hb=3a9f6854df479d81442273c9d0b133c49c5c8f66;hpb=0b24071f728b7c8550daa1b7aa7c4012cb70ef4c diff --git a/src/post.c b/src/post.c new file mode 100644 index 0000000..c1a2a23 --- /dev/null +++ b/src/post.c @@ -0,0 +1,49 @@ +#include "opengl.h" +#include "texture.h" +#include "post.h" +#include "demo.h" + +void overlay(unsigned int tex, float aspect, float alpha) +{ + float xscale = aspect / win_aspect; + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glScalef(xscale, 1.0, 1.0); + + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_2D); + + glBindTexture(GL_TEXTURE_2D, tex); + + glBegin(GL_QUADS); + glColor4f(1, 1, 1, alpha); + glTexCoord2f(0, 1); + glVertex2f(-1, -1); + glTexCoord2f(1, 1); + glVertex2f(1, -1); + glTexCoord2f(1, 0); + glVertex2f(1, 1); + glTexCoord2f(0, 0); + glVertex2f(-1, 1); + glEnd(); + + glPopAttrib(); + + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); +} + +void overlay_tex(struct texture *tex, float alpha) +{ + overlay(tex->id, (float)tex->width / tex->height, alpha); +}