OpenGL(Win32控制台应用程序框架)

VS2008为例,下面是“核心步骤”截图:

Step 1:

Step 2:

step 3:

在“stdafx.h”中添加如下代码:

1 #include <Windows.h>
2
3 #include <gl/GL.h>
4 #include <gl/Glu.h>
5 #include <gl/GlAux.h>
6
7  #pragma comment( lib, "opengl32.lib" )
8  #pragma comment( lib, "glu32.lib" )
9  #pragma comment( lib, "glaux.lib" )

step 4:

在“Win32OpenGL.cpp”中添加如下代码:

1 int _tmain(int argc, _TCHAR* argv[])
2 {
3 auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
4 auxInitPosition (0, 0, 500, 500);
5 auxInitWindow (_T("Title"));
6
7 glClearColor(0.0, 0.0, 0.0, 0.0);
8
9 glClear(GL_COLOR_BUFFER_BIT);
10
11 glColor3f(1.0, 0.0, 0.0);
12
13 glRectf(-0.5, -0.5, 0.5, 0.5);
14
15 glFlush();
16
17 system("PAUSE");
18
19 return 0;
20 }

程序运行效果:

原文地址:https://www.cnblogs.com/kekec/p/1789048.html