Advertisement

Questions about openGL

Started by January 20, 2002 03:25 PM
1 comment, last by ironhell3 23 years, 1 month ago
Hi, i am a beginner openGL programer,and i have the following problems: 1)i am rotating a triangle with the following code: glRotatef(.... triangle1(); when i place a second triangle after the first, it rotates too.How can we prevent this happening???? 2)Is there a way to align an object to the screen?For example put a font to the upper left corner? 3)Is there a camera we can use ?Or there is only the default??? thanks for your time! Ironhell3
store the current modelview matrix with...

"glPushMatrix();".

call your rotate and draw functions for the first triangle.

then restore the current modelview matrix with...

"glPopMatrix();".

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
Advertisement
1) Jenova got #1.
2) Yes. Setup an orthographic project matrix and set the dimensions to those of your window or the screen. Like this:
  glViewport(0, 0, (GLsizei) Width, (GLsizei) Height);glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(0.0f,(GLfloat)Width,(GLfloat)Height,0.0f,-1.0f,1.0f);glMatrixMode(GL_MODELVIEW);glLoadIdentity();  

3) Think of the projection matrix as the "screen" matrix and the modelview matrix as the "camera" matrix. The modelview matrix (using glTranslate?, glRotate?, and glScale) is your camera.

This topic is closed to new replies.

Advertisement