Reputation: 4372
The arguments to glTranslate() specify the amount of units by which the origin is translated. Hence, there is a possibility of moving beyond the display. Is there a way to normalize the amount we move so that we don't go beyond the drawing area?
Upvotes: 0
Views: 412
Reputation: 474086
The arguments to glTranslate() specify the amount of units by which the origin is translated.
No (yet another reason people should stop learning fixed-function GL).
glTranslate
generates a matrix, which is right-multiplied by the current matrix to become the new current matrix. It does create a translation matrix, but it's not necessarily moving from the center of the screen. For example, this is perfectly valid:
glTranslatef(10.0f, 10.0f, 10.0f);
glTranslatef(0.0f, 50.0f, 0.0f);
It's also valid to do this:
glTranslatef(10.0f, 10.0f, 10.0f);
glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
glTranslatef(0.0f, 50.0f, 0.0f);
This does a translation, then a 90-degree rotation about the Z axis. This affects the final translation performed.
You could also throw a scale in there.
If you want to keep an object on-screen, it's up to you, not OpenGL.
Upvotes: 6