glTranslate to specific world location?

BlitzMax Forums/OpenGL Module/glTranslate to specific world location?

BLaBZ(Posted 2012) [#1]
How would I translate to a specific world location? and not relative to the camera?


SystemError51(Posted 2012) [#2]
The way I do it (and I think this the normal way) is to call glLoadIdentity before performing a glTranslatef call. glLoadIdentity resets any transformations you have done and effectively puts you at the absolute zero position.


ImaginaryHuman(Posted 2012) [#3]
Hm... but if the camera has moved then isn't that going to give you relative to the camera still? You'd need to translate to a position that `where you want to get to` minus the camera position?


SystemError51(Posted 2012) [#4]
In OpenGL there is no camera. There is no world. There no locations. OpenGL is a state machine, rasterizer, and basically a matrix multiplicator.

If you "move" or "rotate" the "camera" - either by your own means or using gluLookAt (which does all the matrix work for you), you really perform matrix calculations on everything you want to see (mostly information about what makes up your world - triangles, quads).

glLoadIdentity resets the identity matrix, in terms of the projection and modelview matrices - it essentially resets the matrix back to its default state.

It's a lot easier to perform a glLoadIdentity(), then do your glTranslatef calls, followed by the rotations you want your models to have - rather than calculating the steps you have to move away from the point you're on now.