This topic is now archived and is closed to further replies.


absolute coordinates(not glTranslatef!)

Recommended Posts

Sven    122
with glTranslatef()i can move the "center of drawing", it''s always relative to the last position of glTranslatef(). this is shit when i want to draw a few objects... is it possible to set the new center of drawing to absolute coordinate?

Share this post

Link to post
Share on other sites
oglman    122
If I''m understnding you right, you can just use glLookAt(). You could also call glPush/PopMatrix() before and after evry item. A slowere yet easier version of this is to call glLoadIdentity() before every glTranslatef().

Open mouth, insert foot

Share this post

Link to post
Share on other sites
thuned    122
call glLoadIdentity(); before translating each time should work


life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it

Share this post

Link to post
Share on other sites
avianRR    100
Well, there are several ways to solve this problem...
One use glLoadIdentity() before drawing each object. the problem with this is that it also resest the rotation.
the second is to push the matrix draw the object the pop the matrix. this works good if you don''t have nested objects as theres no garuentee of the stack depth.
the third method works the best for me and will work great for nested and hirarcial object drawing. use glTranslatef() to translate to the center of drawing before drawing the object then use the negitives of the value to glTranslate to the previous postition afterwords.
A good exapmle of how this can be handy is if you have an object that is made up of 2 or more other objects...

void DrawObjectA(){
< Draw Object A >

void DrawObjectB(){
< Draw Object B >

void DrawObjectC(){

Hope this didn''t confuse you too much!

Share this post

Link to post
Share on other sites