peng
06-20-2002, 02:29 AM
When I program opengl,I find that the objects which I went them be scaled or rotated can not scale and rotate in it's center.
When scale and rotate object,object will scale in other pos.
any one can tell me how to solve this problem.
source as those:
//-------------------
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0,0,400,300);
glOrtho(-200,200,-150,150,-150,150);
glTranslatef(X,Y,Z);
gluLookAt(0,100,0,0,0,0,0,0,-1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glTranslatef(PosX,PosY,PosZ);
glRotatef(RotX,-1,0,0);
DrawObject();
glPopMatrix();
When scale and rotate object,object will scale in other pos.
any one can tell me how to solve this problem.
source as those:
//-------------------
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0,0,400,300);
glOrtho(-200,200,-150,150,-150,150);
glTranslatef(X,Y,Z);
gluLookAt(0,100,0,0,0,0,0,0,-1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glTranslatef(PosX,PosY,PosZ);
glRotatef(RotX,-1,0,0);
DrawObject();
glPopMatrix();