PDA

View Full Version : Displaying Logo...



OGL_PGR
11-01-2006, 10:46 PM
Hi !

I want to display a small bitmap as the logo on the screen. I tried with the following code, but I'm not getting any output.

Can someone please help me out on this ?

glBindTexture(GL_TEXTURE_2D, Logo.TextureID);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,800,0,600,-1,1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTranslated(10,600 - 10,0);

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3i(x,y);
glTexCoord2f(1.0f, 0.0f); glVertex3i(x+width,y);
glTexCoord2f(1.0f, 1.0f); glVertex3i(x+width,y+height);
glTexCoord2f(0.0f, 1.0f); glVertex3i(x,y+height);
glEnd();

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_DEPTH_TEST);

Thanks !

Relic
11-02-2006, 12:58 AM
That code wouldn't even compile.
- Make sure the texture parameters are set correctly. Use min and mag filter nearest or linear if you didn't dowload mipmaps.
- glOrtho(0,800,0,600,-1,1) requires that your z-coodinates are in the range of -1 to 1 or they are clipped away.
- glTranslated(10,600 - 10,0) moves your origin to the top left (10, 590).
- The glVertex3i calls need to be glVertex2i, z-coordinate is 0.0 then and would be in the frustum.
Make sure that the origin (10, 590) plus your x- and y-coordinates are in the [0,800]x[0,600] view.
- Don't forget to enable GL_TEXTURE_2D.
- For debugging, clear the background in a different color than black to see if you render something at all and add glGetError calls during debug to see if OpenGL indicated any problem.