2014-02-23, 11:49 AM
Here's the final texture load code:
and the fog code:
For now it is flickering quite fast and I am not responsible for any monitor damage or mental diseases that might result of it...
Here are the images nv1.png and nv2.png:
They are basically the same, but one is moved one pixel up so when they are loaded one by one they flicker nicely (insanely? )
Code:
//somewhere outside the function
static void change_nv = 0;
//...
//In gl_drawhud()
if(nightvision) {
glEnable(GL_TEXTURE_2D);
static Texture *nvtex = textureload("packages/misc/nv1.png", 3);
static Texture *nvtex2 = textureload("packages/misc/nv2.png", 3);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if((lastmillis - change_nv) < 50) {
glBindTexture(GL_TEXTURE_2D, nvtex->id);
} else {
change_nv = lastmillis;
glBindTexture(GL_TEXTURE_2D, nvtex2->id);
}
glColor4f(1, 1, 1,1);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(0, 0);
glTexCoord2f(1, 0); glVertex2f(VIRTW, 0);
glTexCoord2f(1, 1); glVertex2f(VIRTW, VIRTH);
glTexCoord2f(0, 1); glVertex2f(0, VIRTH);
glEnd();
}
Code:
//Best in gl_drawframe() behind the water stuff, but put it whereever you want.
if(nightvision) {
glFogfv(GL_FOG_COLOR, nfogc);
glFogi(GL_FOG_START, 0);
glFogi(GL_FOG_END, 30);
}
For now it is flickering quite fast and I am not responsible for any monitor damage or mental diseases that might result of it...
Here are the images nv1.png and nv2.png:
They are basically the same, but one is moved one pixel up so when they are loaded one by one they flicker nicely (insanely? )