rotating an opengl object

glpusghMatrix();

glTranslatef(imagePoint.x, imagePoint.y, 0.0f);

glRotatef(angle, 0.0f, 0.0f, 1.0);

glTranslatef(-imagePoint.x, -imagePoint.y, 0.0f);

///draw image here

glRotatef(angle,0.0f,0.0f,-1.0f);//reset angle

glpopmatrix();

it will rotate around z axis

One Reply to “rotating an opengl object”

  1. if you need to rotate image in center point of image set center position of that image rect in glatranslatef
    like this
    glPush/matrix();
    glTranslatef(imageX+imageWidth/2,imageY-imageHeight/2,0);
    glrotatef(angle,0,0,1);
    glTranslatef(imageX+imageWidth/2,imageY-imageHeight/2,0);
    draw image here
    glpopMatrix();

Leave a Reply

Your email address will not be published. Required fields are marked *