I would need some help. In the following piece of code, I am drawing a meadow with a house (both drawn in OpenGL) with a mill, trees, bushes and a car (3DS models, some animated). The whole scene should have an “old-movie”-effect drawn over it. It has to be done with a GL_QUAD which gets the texture that is randomly translated so it appears that the “streaks” of the texture are moving.
Now I need the GL_ALPHA_TEST for the OpenGL house (I need to see through the windows) and I used the GL_BLEND function for the overlay (so the color of the overlay-texture can be added to the color of the obejcts lying underneath).
However, now I can see the background through the overlay (when glClearColor is set to black, the overlay is dark with the streaks, when it’s grey (0.5, 0.5, 0.5) the overlay is also grey). But I simply don’t see all my modelled object through the overlay.
What I don’t understand is why I don’t see them, when in another project I could see a simple cube through the overlay and in this project I can see the background but nothing of the modelled stuff (I can’t see the OpenGL house or meadow as well as none of the 3DS modells).
Now here are the important parts of the code - if anybody has any idea what could be the problem but needs the whole code, feel free to e-mail me (firstname.lastname@example.org) and I will send them the whole project (it has 600+ lines of code).
static void init(int argc, char **argv)
glClearColor(0.0, 0.0, 0.0, 1.0);
glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); glEnable(GL_BLEND); glEnable(GL_NORMALIZE); glAlphaFunc(GL_GEQUAL, 0.95); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL);
static void drawQuad(GLuint texture, GLdouble brightness, GLdouble alpha, GLdouble depth, GLdouble tiling)
glColor4d(brightness, brightness, brightness, alpha);
glTexCoord2d(0.0, 0.0); glVertex3d(-1.0, -1.0, depth);
glTexCoord2d(0.0, tiling); glVertex3d(-1.0, 1.0, depth);
glTexCoord2d(tiling, tiling); glVertex3d(1.0, 1.0, depth);
glTexCoord2d(tiling, 0.0); glVertex3d(1.0, -1.0, depth);
And last but not least the drawOverlay()-function:
static void drawOverlay(GLint texture, GLdouble depth)
glMatrixMode(GL_TEXTURE); glPushMatrix(); glTranslated(GLdouble(rand()) / GLdouble(RAND_MAX), GLdouble(rand()) / GLdouble(RAND_MAX), 0.0); drawQuad(texture, 1.0, 1.0, depth, 1.0); glPopMatrix(); glMatrixMode(GL_MODELVIEW);
Now here’s how it’s drawn (part of the display()-function:
glScalef(2.5, 2.5, 1.0);
Ok, if anyone has any idea what the problem could be, please reply or if you need the whole code, feel free to e-mail me. Thx!
[This message has been edited by marco1475 (edited 11-11-2003).]