Hello ,
I drew a cube and I tried to rotate it but it doesn’t work ? I don’t know why ?
This is the code :
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
//// Cube
float angle = 0.0f;
GLvoid DrawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
// Calculate the rotating angle for the first cube.
angle = angle + 0.1f;
if(angle >= 360.0f) angle = 0.0f;
glPushMatrix(); //save matrix
glTranslatef(0.0,0.0,-6.0);
glRotatef(angle, 1.0f, 0.0f, 1.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glutSolidCube(1.5f);
glPopMatrix(); //restore matrix
glFlush();
// glutSwapBuffers();
}
int main(int argc, char **argv)
{
/* Initialisation and window creation */
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE| GLUT_DEPTH);
glutInitWindowSize(400,400); glutInitWindowPosition(0,0);
glutCreateWindow(“Cube”);
/* A general OpenGL initialization function. Sets all of the initial parameters. */
glClearColor(0.0, 0.0, 0.0, 0.0);
glViewport(0, 0, 400, 400); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0,1,0.1,100.0); glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glutDisplayFunc(DrawGLScene);
glutMainLoop();
}
Thanks in advance for any help …
[This message has been edited by glcrazy (edited 01-26-2004).]