View Full Version : Rotate specific area

12-01-2008, 07:24 AM
How can i rotate a single area in opengl? tks

12-01-2008, 08:19 AM
Define "area" : image, portion of screen, object(s), ... ?

12-01-2008, 08:21 AM
i have a polygon consisting of several polygons, and I want to rotate one of these polygons. I think i have to use glLoadMatrix but im not sure/dont know how

thanks in advance

12-01-2008, 08:24 AM
matrix it is. glLoadMatrix specifies current matrix in current matrix stack f.e glMatrixMode(GL_MODELVIEW). whatever value you put in there your vertices will be "transformed" by this matrix. if you need to rotate objects you need to upload a rotation matrix then. also check glRotate().

12-01-2008, 08:28 AM
but how do I define this matrix to put in the glLoadMatrix ? I have a 6 vertice polygon that I want rotated, I know the world coordinates of its vertices and I was successful on rotating the entire polygon, but rotating this single polygon I cant do

12-01-2008, 08:30 AM
this is advanced because you either need your own matrix class which performs matrix operations and stores the output in say GLfloat[16] array so you can just pass it to glLoadMatrix, but for writing a matrix class you need excellent math knowledge or you can reuse some matrix classes. there are plenty of them in open source 3d engines.

12-01-2008, 11:26 AM
Why do you want to use glLoadMatrix?
It would go something like this without glLoadMatrix

glTranslatef(x, y, z);
glRotatef(45.0, 0.0, 1.0, 0.0);
glPopMatrix(); //Restore matrix
glPopMatrix(); //Restore matrix

I recommend the Red book. It explains the fundamentals of GL.