texture isn't working. ( first time ogl )

Started by
12 comments, last by rakoon2 19 years, 7 months ago
glRotate rotates about the origin, so if you want to rotate the quad about it's center, you have to move it's center to the origin.

Since the quad extends from [x, y] to [x+w, y+h], the center is located at [x+w/2, y+h/2]. So first translate the center to the origin, rotate, and translate back. Something like this.
glTranslate(x+w/2, y+h/2, 0);glRotate(whatever);glTranslate(-x-w/2, -y-h/2, 0);
Advertisement
Thank you! Thank you that works fine if I use single quads! :)

But what about if I want to rotate the full scene?

Here a screenshot what I mean:
http://members.chello.at/ennemoser/tile_rotation.jpg

Is it possible to do that without those black "holes"?
What must I rotate the quads about? window_w/2 - window_h/2 ? hmm..

how about:
glTranslatef( window_w/2, window_h/2, 0);
glRotatef( angle, 0.0f, 0.0f, 1.0f);
glTranslatef( - window_w/2, -window_h/2, 0);


Thank you again ^^

[Edited by - rakoon2 on September 4, 2004 5:03:08 AM]
What you see in that jpg is not the scene rotating, but each individual tile rotating around it's own center. That is why there is black space.
Yes I know. :)

glTranslatef( window_w/2, window_h/2, 0);
glRotatef( angle, 0.0f, 0.0f, 1.0f);
glTranslatef( - window_w/2, -window_h/2, 0);

is right. :p

This topic is closed to new replies.

Advertisement