OpenGL 程式設計/引用/基本測試應用程式
外觀
< 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;
}