I want to draw a logo(3D awards) at the corner of the window(fixed position when change camera)
Asked
Active
Viewed 1,238 times
0
-
See http://stackoverflow.com/questions/5467218/opengl-2d-hud-over-3d and http://stackoverflow.com/questions/8370537/opengl-2d-hud-in-3d-application – datenwolf May 14 '12 at 07:23
2 Answers
1
Could do it like so:
- Draw your scene
- Disable the depth test (or clear the depth buffer if you need self-depth testing to draw the model correctly)
- Set a new matrix on the stack which ignores camera position.
- Draw the logo.

Tim
- 35,413
- 11
- 95
- 121
-
Can you explain more clearly this :"Set a new matrix on the stack which ignores camera position."? – user1235872 May 14 '12 at 06:31
-
@user1235872 Do you know how to position an object on the screen? Why don't you show what you have already tried. – Tim May 14 '12 at 06:36
-
I just don't understand "'ignore camera position' means". Because if i move camera the logo model till moves too – user1235872 May 14 '12 at 06:41
-
At some point in your code you are doing something which represents the positioning of the camera, and adding it to some kind of matrix stack (some code in your post would really help here). You need to load a new modelview/projection matrix, but one with the view in a fixed position. – Tim May 14 '12 at 06:45
-
This my main draw function: //clearbufferbit; //enable depth test; //draw the scene; //disable depth test; //load identity; //draw the logo; – user1235872 May 14 '12 at 06:51
-
1
here is my code for drawing fullscreen rectangle (in old opengl)
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glBegin(GL_QUADS);
glTexCoord2f( 0,0 );
glVertex3d( -1.0,-1.0, 0 );
glTexCoord2f( 1,0 );
glVertex3d( 1.0,-1.0, 0 );
glTexCoord2f( 1,1 );
glVertex3d( 1.0, 1.0, 0 );
glTexCoord2f( 0,1 );
glVertex3d( -1.0, 1.0, 0 );
glEnd();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
just disable depth buffer abd set the texture to be able to draw your logo in front of eferything Of course you can change the position and the size of it

fen
- 9,835
- 5
- 34
- 57