glut下载地址:http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
glut.h ---> C:\ProgramFiles (x86)\Microsoft SDKs\Windows\v7.0A\Include\gl
glut.dll,glut32.dll---> C:\Windows\SysWOW64 (windows7 64位操作系统)
---> C:\Windows\System32(windows7 32位操作系统)
glut.lib,glut32.lib ---> C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\lib
打开vs2010,随便打开或新建一个项目。选择 project->project property-> ConfigurationProperties->Linker->Input->Additional Dependencies 在其中添加opengl32.lib glu32.lib glut32.lib
在工程中添加如下代码即可。
//glExampl01.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Gl\glut.h>
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f (1.0,0.0,0.0);
glBegin (GL_LINES);
glVertex2i (180,15);
glVertex2i (10,145);
glEnd();
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glFlush();
}
void init (void)
{
glClearColor(1.0 ,1.0, 1.0,0.0);
glMatrixMode (GL_PROJECTION);
gluOrtho2D(0.0,200.0,0.0,150.0);
}
int _tmain(int argc,char * argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB |GLUT_SINGLE);
glutInitWindowPosition(50, 100);
glutInitWindowSize(400,300);
glutCreateWindow("OpenGL");
init ();
glutDisplayFunc(&myDisplay);
glutMainLoop();
return 0;
}