Advertisement Jump to content
Sign in to follow this  

OpenGL glRotate and glTranslate and general beginner confusion

This topic is 4478 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been working with Astle and Hawkins' Beginning OpenGL Game Programming and I'm running into some conceptual problems about how one goes about certain things when making a game (only in the loosest sense of the word of course) with OpenGL. Let's say in my program I want to keep track of an object moving around in my world. The approach that seems natural to me is to have some coordinates for the object and then make changes to them with user input or the game physics or whatever and then redraw the object at its new coordinates each frame, etc. I've written some programs that move primatives around like this where each object has some coordinates that get modified in various ways and redrawn and we have animation. Great. So then I wanted to rotate an object around, and the book had some examples of a rotating triangle or whatever and so I thought I should use their techniques for doing this as a model for my own program. Their codes however seem to draw the object at fixed coordinates and then use functions like glTranslate and glRotate to give the impression that the object is moving. To my understanding these functions are actually moving the camera (and I know that all this stuff is relative and moving the camera is the same as moving the object, etc) and not the object itself. So I was able to use glTranslate and glRotate (along with glPush/PopMatrix) to create the program I had in mind but it felt very unnatural the whole time to think that all my models (again only in the loosest sense...) were just sitting in their initial positions and I was moving the camera to make it look like they were moving around and frankley I don't really like this idea. Now I could just translate objects like I had done originally, and write my own routines to rotate vertices, but it seems like a waste (and a sign I'm doing something wrong) if I have to do that when there are these library functions already setup that my book apparently has no qualms about using this way. So what gives? How does one conceptually approach making a program like this? Am I grossley misunderstanding how this all works? I realize I don't have a very good grip on how OpenGL works and I've rushed ahead beyond my understanding, so if the only response I get is "read the damn manual" I suppose I'll understand :) . So anyway, thanks for any guidance anyone can offer to help me straighten all this out in my head. Evan

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!