#include <windows.h> // Header File For Windows #include <gl/gl.h> // Header File For The OpenGL32 Library #include <gl/glu.h> // Header File For The GLu32 Library #include <gl/glaux.h> // Header File For The Glaux Library
WinMain() 是程序的的入口函数.
BOOL CreateGLWindow(char* title, int width, int height, int bits, BOOL fullscreenflag)
创建一个openGL窗口.
GLvoid KillGLWindow(GLvoid)
消除一个openGL窗口.
int DrawGLScene(GLvoid)
在窗口中画图,在里面我们可以加入自己的代码.
其他略.
以下是WinMain中的主循环:
while(!done) // Loop That Runs While done=FALSE ...{ if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting? ...{ if (msg.message==WM_QUIT) // Have We Received A Quit Message? ...{ done=TRUE; // If So done=TRUE } else// If Not, Deal With Window Messages ...{ TranslateMessage(&msg); // Translate The Message DispatchMessage(&msg); // Dispatch The Message } if (keys[VK_F1]) // Is F1 Being Pressed? ...{ keys[VK_F1]=FALSE; // If So Make Key FALSE KillGLWindow(); // Kill Our Current Window fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode // Recreate Our OpenGL Window if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen)) ...{ return0; // Quit If Window Was Not Created } } } else// If There Are No Messages ...{ // Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene() if (active) // Program Active? ...{ if (keys[VK_ESCAPE]) // Was ESC Pressed? ...{ done=TRUE; // ESC Signalled A Quit } else// Not Time To Quit, Update Screen ...{ DrawGLScene(); // Draw The Scene SwapBuffers(hDC); // Swap Buffers (Double Buffering) } } }