Code:
#ifdef _WIN32
#include <windows.h>
#include <gl\gl.h>
#include <gl\glut.h>
#endif
#ifndef _WIN32
#include <glut/glut.h>
#endif
#include <stdlib.h>
#include <iostream.h>
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
}
GLfloat spin=0.0;
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity (); /* clear the matrix */
/* viewing transformation */
gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef (1.0, 2.0, 1.0); /* modeling transformation */
spin+=0.2;
if(spin>=360) spin=0;
glRotatef(spin,1.0,1.0,1.0);
glutSolidCube (1.0);
glFlush();
glutSwapBuffers();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW);
}
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
}
}
void animation(void)
{
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(animation);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
dieser code ist aus einem tutorial aus meinem opengl buchh (ein bisschen modifiziert) die animatin läuft auf mac gewaltig gut...jedoch auch windows total langsam... obwohl der pc um einiges schneller ist...kapier das einfach nicht.....falls jemand einen fehler sieht bitte melden...
PS.: auf mac opengl entwickleln -> unmöglich weil da funktioniert immer alles sofort ;-)