How to rotate an object relative to a given point in OpenGL 1.0? The object is drawn with a center at the point 0,0,0 (the beginning of world coordinates). I can rotate it with glRotate () relative to the center of the object, but in some cases it is necessary to rotate about another point.

How to implement it?

  • Move the center of the object to a given point. Then the rotation will be around her. - Evgeny Karavashkin
  • @EvgenyKaravashkin I figured it out. Describe in more detail - Aleh Lipka
  • how are you doing on the 1st version of openGL? or ES 2.0 through shaders? - Evgeny Karavashkin
  • one
    I never worked with the first. But try to change the vertices so that the center of the object you have is the point around which you want to rotate. Well, for example, you have a square in the coordinates {-1, -1} {1,1} its center is 0.0, and if you specify the square {0,0} {1,1} it already has a center of rotation in the corner, not in the center of the figure. + transtale where necessary and rotate as you like. - Evgeny Karavashkin
  • one
    Why leave someone suddenly the same question. PS and hammer on openGL 1.0 is the last century, don't waste your time, take a week to figure out the shaders. - Evgeny Karavashkin pm

1 answer 1

x , y , z - point relative to which you want to rotate

a - angle of rotation

 glTranslate(-x, -y, -z); glRotate(a, 0, 0, 1); glTranslate(x, y, z); glDraw...