VS2005/2008下如何配置OpenGL函数库

下载OpenGL库文件。
对相应库文件进行放置。把.h文件放到\Program Files\Microsoft Visual Studio 8\VC\Include\GL文件夹中,如果没有GL文件夹就自己建一个,我的就是自己建的。把.lib文件放到\Program Files\Microsoft Visual Studio 8\VC\lib文件夹中;把.dll文件放到system32文件夹中。
建立工程后,选择项目->属性-> C\C++-->preprocessor(预处理器)-->preprocessor definition(预处理器定义),添加GLUT_BUILDING_LIB,中间用分号隔开。
然后点击linker(链接器)->Input(输入)->additional dependencies(附加依赖项)添加glut32.lib Opengl32.lib Glu32.lib
结束,这样就可以使用了。
可以添加如下代码测试:
显示代码打印01 #include "stdafx.h" 

02 #include <GL/glut.h> 

03 void myDisplay(void) 

04 { 

05     glClear(GL_COLOR_BUFFER_BIT); 

06     glRectf(-0.5f, -0.5f, 0.5f, 0.5f); 

07     glFlush(); 

08 } 

09 int main(int argc, char *argv[]) 

10 { 

11     glutInit(&argc, argv); 

12     glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); 

13     glutInitWindowPosition(100, 100); 

14     glutInitWindowSize(400, 400); 

15     glutCreateWindow("第一个OpenGL程序"); 

16     glutDisplayFunc(&myDisplay); 

17     glutMainLoop(); 

18     return 0; 

19 }


文章出处:飞诺网(www.firnow.com):http://dev.firnow.com/course/3_program/c++/cppjs/20090403/163782.html

posted @ 2010-11-02 15:24  白了少年头  阅读(1214)  评论(2编辑  收藏  举报