OpenGL环境配置

实现OpenGL在VC++6.0和VS2008下的配置

openGL VS2008(Microsoft Visual Studio 2008)环境配置

1.1下载Freeglut:http://freeglut.sourceforge.net/http://prdownloads.sourceforge.net/freeglut/freeglut-2.6.0.tar.gz?download

 

2. 下载到的文件为freeglut-2.6.0.tar.gz,解压到任意目录,使用Visual Studio 2008打开freeglut-2.6.0/VisualStudio2008/freeglut.vcproj,使用Release执行编译。这时会生成Release目录。

3. 将Release目录中的freeglut.dll复制到system32(64位的win7:C:\Windows\SysWOW64)下。

4. 将freeglut-2.6.0/include/GL中的.h文件复制进去:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include

5.将Release目录下的freeglut.lib文件复制进去:C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib

完成配置。

VS2008的测试程序:

1.新建win32控制台程序

#include <stdio.h>

#include <freeglut.h>

void dispaly(void) {  

glColor3f(1.0,1.0,1.0);  

glBegin(GL_POLYGON);  

glVertex3f(0.25,0.25,0.0);  

glVertex3f(0.75,0.25,0.0);

 glVertex3f(0.75,0.75,0.0);  

glVertex3f(0.25,0.75,0.0);

 glEnd();  

glFlush();//绘图命令实际执行

}

void init(void)

{  

glMatrixMode(GL_PROJECTION);

 glLoadIdentity();  g

lOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);

}

int main(int argc, char** argv)

{    

glutInit(&argc,argv);

glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);    

glutInitWindowSize(250,250);    

glutInitWindowPosition(100,100);    

glutCreateWindow("hello");  init();  

glutDisplayFunc(dispaly);    

glutMainLoop();    

return 0;

}

运行结果:

 

openGL VC++6.0环境配置

1.1下载Freeglut:http://freeglut.sourceforge.net/http://prdownloads.sourceforge.net/freeglut/freeglut-2.6.0.tar.gz?download

 

2. 下载到的文件为freeglut-2.6.0.tar.gz,解压到任意目录,使用Visual Studio 2008打开freeglut-2.6.0/VisualStudio2008/freeglut.vcproj,使用Release执行编译。这时会生成Release目录。

3. 将Release目录中的freeglut.dll复制到system32(64位的win7:C:\Windows\SysWOW64)下。

4. 将freeglut-2.6.0/include/GL中的.h文件复制进去:C:\Program Files (x86)\Microsoft Visual Studio\VC98\Include\GL

5.将Release目录下的freeglut.lib文件复制进去:C:\Program Files (x86)\Microsoft Visual Studio\VC98\Lib

测试代码:

 

#include <stdio.h>

 #include <GL/freeglut.h>

 

void dispaly(void) {  glColor3f(1.0,1.0,1.0);  glBegin(GL_POLYGON);  glVertex3f(0.25,0.25,0.0);  glVertex3f(0.75,0.25,0.0);  glVertex3f(0.75,0.75,0.0);  glVertex3f(0.25,0.75,0.0);

 

 glEnd();  glFlush();//绘图命令实际执行 } void init(void) {  glMatrixMode(GL_PROJECTION);  glLoadIdentity();  glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);

 

}

 

int main(int argc, char** argv) {     glutInit(&argc,argv);

    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);     glutInitWindowSize(250,250);     glutInitWindowPosition(100,100);     glutCreateWindow("hello");  init();  glutDisplayFunc(dispaly);     glutMainLoop();     return 0; }

 

 









 

posted on 2013-04-22 20:01  xhuang  阅读(154)  评论(0)    收藏  举报