Hello,
I want to have a bmp that fits exactly my windows, the pb is that the window is 640*480
and, i want my menu to be blended with the background and to be ALWAYS ON TOP, like if it was a 2d menu over a 3d background.
i need help with the kind of projection to use.
i’ve tried to convert a fontloader code but it don’t works.
could you take a look, i’m sure that the error(s) will be as fat as…as… as what ??
in this function i try to draw a quad that even not appears. (a placement error ?)
void test(void)
{
glColor3f(1.0,0.0,0.0);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,640,0,480,-100,100);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTranslated(10,10,0);
glBegin(GL_QUADS);
glVertex3f(0.0,0.0,0.0);
glVertex3f(30.0,0.0,0.0);
glVertex3f(30.0,30.0,0.0);
glVertex3f(0.0,30.0,0.0);
glEnd();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_DEPTH_TEST);
}
Use this, it works fine for this occasion:
(psudo code)
Change to orthograpic projection
disable lighting
enable blending
disable depth-buffer writing
Now its in 2d and u can blend. Its easier then billboarding and I use it.
try this:
glMatrixMode(GL_PROJECTION);
glPushMatrix();
…
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
…
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
…
hope it helps
hello,
i finally make work this little piece of code, the problem was that first i was just draving a quad without texturing it, but the
glEnable(GL_TEXTURE) was written and when i have removed this line, it has worked (or if i don’t remove it but map a texture onto the quad)
Why wasn’t it working when texturing was enabled??
sorry for my bad english and tanks to those people which have ansvered,
Marsu
You must use :
glEnable(GL_TEXTURE_2D);
GL_TEXTURE is a constant used for changing the matrix mode, not for enabling texturing.
With glEnable use GL_TEXTURE_1D, GL_TEXTURE_2D or GL_TEXTURE_3D
also dont forget to bind your texture object with GL_TEXTURE_2D before you use it.
one more thing (hope it helps):
if you enable texturing and do not specify texture coordinates, the actual coordinate is used for all vertices (default is 0,0, so this pixel is used to cover the whole quad)