Skip to main content
GameDev.net gamedev.net
🔒 Locked

[Newbie] Fixed position

Started by Mr E Mar 30, 2007 at 4:12 PM 3 replies 900+ views
Original Post
Mr E
Mr E
Hi. I played a bit with OpenGL today - and I have the following problem : - First I draw a rotating triangle with the following code :

	glRotatef( 0.5f, 1.0f, 1.0f , 1.0f );		
	glBegin( GL_TRIANGLES );
		glColor3f( 1.0f, 0.0f, 0.0f );
		glVertex3f( 0.0f, -1.0f, 0.0f );

		glColor3f( 0.0f, 1.0f, 0.0f );
		glVertex3f( 1.0f, 1.0f, 0.0f );
		
		glColor3f( 0.0f, 0.0f, 1.0f );
		glVertex3f( -1.0f, 1.0f, 0.0f );
	glEnd();
- Then I wanted a text to be appeared over it at a fixed position.

	glRasterPos3f( 0.2,0.0,0.0 );
	glPushAttrib(GL_LIST_BIT);		
		glListBase(m_iFontBase);
		glCallLists(strlen(pText), GL_UNSIGNED_BYTE, pText);
	glPopAttrib();
The problem is, due to the glRotatef( 0.5f, 1.0f, 1.0f , 1.0f ) the text now also rotates/moves. Does anybody has a idea how to solve this ? Any help appreciated!
So long,Mr.E
Stani R
Stani R
You can either push the transformation matrix before rotating and then popping it afterwards, or you can load an identity matrix before rendering the text. Either way will work, though the former is probably a bit more elegant.
Feralrath
Feralrath
as lighbringer said, simply pushing then poping the stack would be the best way to accomplish this.

glPushMatrix();    glRotatef();    glBegin();    glEnd();glPopMatrix();



basicly like that.
Mr E
Mr E
Thanks a lot - I will try this !!!
So long,Mr.E
Mr E
Mr E
Yeah. Got it working ... thanks again. Problem solved!
So long,Mr.E

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.