Scope in OpenGL?

Started by
1 comment, last by NaliXL 22 years, 4 months ago
Hi there, Never tried, but just wondering : can I use scope in OpenGL? Like :
  
glRotatef(rotation-rate,x,y,z);
glBegin(GL_TRIANGLES);
	glrotatef(rotation-rate,x,y,z);
	glBegin(GL_TRIANGLES);
		//object no. 1

	glEnd();

	glrotatef(rotation-rate,x,y,z);
	glBegin(GL_TRIANGLES);
		//object no. 2

	glEnd();
glEnd();
  
Okay, I know this code probably won''t work (cause of GL_TRIANGLES), but it''s just for the idea. Making 2 objects, rotate each of them separately, and then rotate both of the objects as if they where one object. Are such things possible? Thanks!
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
Advertisement
You can kind of do what you want (if I understand) like this:
  glRotatef(FirstVal,x,y,z);glPushMatrix();  glRotatef(SecondVal,x,y,z);  glBegin(GL_TRIANGLES);    // ...  glEnd();glPopMatrix();glPushMatrix();  glRotatef(ThirdVal,x,y,z);  glBegin(GL_TRIANGLES);    // ...  glEnd();glPopMatrix();  


[Resist Windows XP''s Invasive Production Activation Technology!]
No, because you can only use a subset of OpenGL commands between glBegin and glEnd. You can have OpenGL "remember" previous states (though not for the drawing mode as in your example), using the glPush* and glPop* commands. This is particularly useful for matrices.

This topic is closed to new replies.

Advertisement