Original Post
I want this object I created to rotate. Why doesn´t it work?
Can anybody help please???
#include <windows.h> //includes windows.h
#include <GL/glut.h> //includes glut.h which includes all others header-files needed for OpenGL
#include <stdlib.h> //includes standard-c lib stdlib.h
#include <iostream.h> //includes i/o streams-lib iostream.h
GLfloat rot;
void init()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-5.0, 5.0, -5.0, 5.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rot, 1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(1.0, -1.0, 0.0);
glVertex3f(1.0, 1.0, 0.0);
glVertex3f(-1.0, 1.0, 0.0);
glVertex3f(-1.0, -1.0, 0.0);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(1.0, -1.0, -1.0);
glVertex3f(1.0, 1.0, -1.0);
glVertex3f(-1.0, 1.0, -1.0);
glVertex3f(-1.0, -1.0, -1.0);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(1.0, -1.0, 0.0);
glVertex3f(-1.0, -1.0, 0.0);
glVertex3f(-1.0, -1.0, -1.0);
glVertex3f(1.0, -1.0, -1.0);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(-1.0, 1.0, 0.0);
glVertex3f(1.0, 1.0, 0.0);
glVertex3f(1.0, 1.0, -1.0);
glVertex3f(-1.0, 1.0, -1.0);
glColor3f(1.0, 0.0, 1.0);
glVertex3f(-1.0, -1.0, 0.0);
glVertex3f(-1.0, -1.0, -1.0);
glVertex3f(-1.0, 1.0, -1.0);
glVertex3f(-1.0, 1.0, 0.0);
glColor3f(0.0, 1.0, 1.0);
glVertex3f(1.0, -1.0, 0.0);
glVertex3f(1.0, -1.0, -1.0);
glVertex3f(1.0, 1.0, -1.0);
glVertex3f(1.0, 1.0, 0.0);
glEnd();
glutSwapBuffers();
rot += 2.0;
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutInitWindowPosition(100, 100);
glutCreateWindow("Test");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Edited by - nirvanalebt on January 16, 2002 5:24:16 PM
Edited by - nirvanalebt on January 16, 2002 5:42:06 PM
Edited by - nirvanalebt on January 16, 2002 5:42:22 PM