openGl画一个简单的立方体

#include "stdafx.h"

#include

voiddisplay()

{

 glClear(GL_COLOR_BUFFER_BIT);

 glMatrixMode(GL_MODELVIEW);

 glLoadIdentity();

 gluLookAt(1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0);

 glutWireCube(3.0);

 glutSwapBuffers();

}

voidreshape(int w,int h)

{

 glViewport(0,0,w,h);

 glMatrixMode(GL_PROJECTION);

 glLoadIdentity();

 glOrtho(-4.0,4.0,-4.0,4.0,-4.0,4.0);

}

voidinit()

{

 glClearColor(1.0,1.0,1.0,1.0);

 glColor3f(0.0,0.0,0.0);

}

intmain(int argc,char** argv)

{

 glutInit(&argc,argv);

 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);

 glutInitWindowSize(500,500);

 glutInitWindowPosition(100,100);

 glutCreateWindow("¢¡é¤?¬?");

 glutReshapeFunc(reshape);

 glutDisplayFunc(display);

 init();

 glutMainLoop();

 return 0;

}

你可能感兴趣的:(openGl画一个简单的立方体)