需要的东西:
1. VS2013(实际上应该13/15/17都是一样的,更古老的版本没有使用过)
2. GLUT库 (下载链接:链接: https://pan.baidu.com/s/1eSGFcFg 密码: dxuf ,解压后得到:glut.h,glut.dll,glut32.dll,glut.lib,glut32.lib。
安装GLUT库:
glut.h: 复制到安装路径Microsoft Visual Studio 12.0/VC/include/ , 然后新建一个文件夹GL,将glut.h复制到文件夹里。
例如:C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\GL\glut.h
glut.lib和glut32.lib: 复制到Visual Studio 12.0/VC/lib/下,
glut.dll和glut32.dll: 复制到以下目录
32位系统:C:\Windows\System32
64位系统:C:\Windows\SysWOW64
新建win32项目:
选择 File/New/Project/Visual C++/Win32/Win32 Console Application, OK之后下一步,钩上Empty project。
运行代码测试:
<pre>
#include
void myInit(void) {
glClearColor(0.0, 0.0,0.0, 0.0);
glColor3f(1.0, 1.0,1.0);
glPointSize(5.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640.0,0.0, 480.0);
}
void mydisplay(){
GLint vertices[7][2] ={{20, 10}, {74, 74}, {129, 83}, {194, 101},
{239, 67}, {320, 128}, {289,190}};
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
glVertex2iv(vertices[0]);
glVertex2iv(vertices[1]);
glVertex2iv(vertices[2]);
glVertex2iv(vertices[3]);
glVertex2iv(vertices[4]);
glVertex2iv(vertices[5]);
glVertex2iv(vertices[6]);
glEnd();
glFlush();
}
int main(int argc, char** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE| GLUT_RGB);
glutInitWindowSize(640,480);
glutCreateWindow("TheBig Dipper");
glutDisplayFunc(mydisplay);
myInit();
glutMainLoop();
}
</pre>
完成。