I have an odd problem. My glut application positions some objects in the scene. I do this at init.
Later in the DisplayFinc I attempt to rotate an object but the object never moves. The strange part is that I can use the same commands in init and they work but when called from anywhere else in glut they fail. Seem odd? I debugged the matrix class and watched my rotation’s moving around the unit sphere, I watch the translation values changing but when multiplying the matrix against the world the object never moves from it’s original position\orientation set in init.
So, everything seems to work in init but not in the mail display loop.
Many Thanks
Chris
Some code:
#include “GraphicsLibrary.h”
#include <GL/glut.h>CMatrix Camera;
CMatrix Tank;
CMatrix Building;
CMatrix Dish;void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
glEnable(GL_DEPTH_TEST);//Pull camera back
Tank.Forward(10);
Tank.Yaw(15);//Position Building
Building.Translate(2,0,0);//Position Disk above building
Dish.Translate(0,2,0);
}void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);//Camera
glMatrixMode(GL_MODELVIEW);
Camera = Tank;
Camera.Invert();
glLoadMatrixf(Camera);//Update positions
Dish.Yaw(0.2f);//Transform and Render Objects
//Building
glPushMatrix();
glMultMatrixf(Building);
glutWireCube(2);//Dish glPushMatrix(); glMultMatrixf(Dish); glutWireCone(1,1,10,6); glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 1000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}void keyboard (unsigned char key, int x, int y)
{
switch (key)
{
case 27:
exit(0);
break;
case ‘w’:
Tank.Forward(1);
break;
// case ‘s’:
// Tank.Backward(1);
// break;
// case ‘a’:
// Tank.StrafeLeft(1);
// break;
// case ‘d’:
// Tank.StrafeRight(1);
// break;default: break;
}
}
int main(int argc, char** argv)
{
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (640, 480);
glutCreateWindow (argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
[This message has been edited by gimp (edited 03-08-2001).]