PDA

View Full Version : Where to put glScale?



Aliii
05-28-2012, 02:32 PM
Im working on a program where I can move around with the camera in the "world" and draw objects. All objects have a position ...a pivot point.

I draw this way:

----------------
glLoadIdentity();
glRotate( ...camera orientation);
glTranslate( ...camera position);

drawOtherStuff1();

For( every object){

glPushMatrix();
glTranslate( ...object position);

drawObject();

glPopMatrix();

}

drawOtherStuff2();
----------------

Now this seems to be OK, however I want to scale the objects and I dont know where(and how) to put glScale. I guess I should scale the matrix before I translate and/or rotate it with the camera position and orientation. Should I call a pushMatrix() after the first loadIdentity, then pop it back and scale-rotate-translate before every drawObject() method?

Thanks!

(Plus: In the near future I want to add rotation to the objects, so if you can give any information or link on that, thats appreciated too)

Janika
05-28-2012, 03:31 PM
http://www.glprogramming.com/red/chapter03.html

Usually you apply scale as the first transformation followed by rotation and then translation. But this is very typical and basic.