Hi,

How can i rotate a single area in opengl? tks

# Rotate specific area

Define “area” : image, portion of screen, object(s), … ?

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

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().

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

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.

Why do you want to use glLoadMatrix?

It would go something like this without glLoadMatrix

[source]

glPushMatrix();

glTranslatef(x, y, z);

RenderSomeThings();

glPushMatrix();

glRotatef(45.0, 0.0, 1.0, 0.0);

RenderMyArea();

glPopMatrix(); //Restore matrix

glPopMatrix(); //Restore matrix

[/source]

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