Ok, here is the code:
you see, there is no more simple code…
i don’t use mesa, so i think it is the other way.
#include <GL/glut.h>
#include <stdio.h>
#include <iostream>
using namespace std;
float angle = 0.f;
void initGL(){
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}
void keyboard(unsigned char key, int x, int y)
{
switch(key){
case 27:
glClear(GL_ACCUM_BUFFER_BIT |GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
exit(0);
break;
default:
break;
}
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glTranslatef(0.f,0.f,-10.f);
glRotatef(angle, 0.f, 0.f,1.0f);
angle = 0.2f;
glBegin(GL_QUADS);
glVertex3f(0.f, 0.f, 0.f);
glVertex3f(1.f, 0.f, 0.f);
glVertex3f(1.f, 1.f, 0.f);
glVertex3f(0.f, 1.f, 0.f);
glVertex3f(0.f, 0.f,0.f);
glVertex3f(0.f, 1.f, 0.f);
glVertex3f(0.f, 1.f, 1.f);
glVertex3f(0.f, 0.f, 1.f);
glEnd();
glFlush(); //glutSwapBuffers();
}
void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(h<=0)
h=1;
gluPerspective(45.0, (GLfloat) w/ (GLfloat) h, 1.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitWindowSize(800,800);
glutInitDisplayMode(GLUT_SINGLE | GLUT_DEPTH | GLUT_RGB );
glutCreateWindow(“Double Buffer test”);
initGL();
glutIdleFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
greetings
Peter