OpenGL 编程/引用/基本测试应用程序
外观
这是基本的 opengl 测试应用程序,可在函数引用部分与示例配合使用。
要运行多个示例,你只需替换设置或显示功能即可。
#ifndef WIN32 //if using windows then do windows specific stuff.
#define WIN32_LEAN_AND_MEAN //remove MFC overhead from windows.h witch can cause slowness
#define WIN32_EXTRA_LEAN
#include <windows.h>
#endif
#include <GL/gl.h>
#include <glut.h>
#include <GL/glu.h>
#include <conio.h>//needed for getch
void setup(void)
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* drawing commands would go below here, if we had any yet... */
/* drawing commands would go above here, if we had any yet... */
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(800,600);
glutCreateWindow("Hello World");
setup();
glutDisplayFunc(display);
glutMainLoop();
getch();//pause here to see results or lack there of
return 0;
}