您的位置:首页 > 运维架构

OpenGL配置 visual studio

2014-05-23 14:52 323 查看
http://homepage.cs.uiowa.edu/~cwyman/classes/common/howto/winGLUT.html

Compiling OpenGL Progams at Home Using Visual Studio

Windows does not include GLUT standard, like the lab machines in MLH 301 do. Thus, getting your OpenGL programs to compile and run at home is slightly more difficult. However by following
the following steps, you should be able to figure out how to make it work:

Download GLUT
Unzip the file.
Put the file "glut32.dll" into the system path.

This can be in the same directory as your executable file.
On Windows XP or earlier, this can be in "C:\WINDOWS\system32"
Or you can create a directory like "C:\DLLs", put the file in this directory and change your system path to include this new directory.

Do this by opening Control Panel -> System, clicking on "Advanced System Settings", followed by "Environment Variables", and editing the "Path" variable.

Put the file "glut.h" into the standard Visual C++ include directoy

(For Visual Studio 2010, this should be: "C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\gl")
(For Visual Studio 2008, this should be: "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl")
(For Visual Studio 2005, this should be: "C:\Program Files\Microsoft Visual Studio.NET\Vc7\PlatformSDK\Include\gl")
You've got the right directory if you see a copy of "gl.h"

Put the file "glut32.lib" into the standard Visual C++ library directory

(For Visual Studio 2010, this should be: "C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib")
(For Visual Studio 2008, this should be: "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib")
(For Visual Studio 2005, this should be: "C:\Program Files\Microsoft Visual Studio.NET\Vc7\PlatformSDK\lib")
There should be lots of .lib files here, including "opengl32.lib" and "glu32.lib".

Make sure your Visual C++ project links in the GLUT/gl/glu libraries (see also this page).
This is located in:

Menu: "Project -> (your-project-name) Properties"
Tab: "Configuration Properties -> Linker -> Input"
Under "Additional Dependancies", add "glut32.lib glu32.lib opengl32.lib"

#include < GL/glut.h > in your program.

Note: This needs to come after you #include < stdio.h > and < stdlib.h >.
Note: This needs to come before you #include < GL/gl.h >.
Also note that glut.h includes gl.h for you (so you need not explicitly #include < GL/gl.h >).

You should not include windows.h or any other Windows-specific header files, no matter what you may read on random forum postings!
If you get compilation errors because of multiple conflicting definitions of "exit()", then "stdio.h" and "glut.h" have been #include'd in the wrong order. You may fix this by:

Reordering your #include files (see step #7). This is the "right" way.
Add "#define GLUT_DISABLE_ATEXIT_HACK" to glut.h on the line immediately after the first "#if defined(_WIN32)".

If you happen to have a 64-bit version of Windows and Visual Studio, make sure you compile a 32-bit executable.

NOTE: Later in the course, you may also need to install GLEW. Follow the same directions: install
the DLLs into the system directory, the header files in the include directory, and the library files into the lib directory.

Last Modified: Friday, August 28, 2009
Chris Wyman (cwyman@cs.uiowa.edu)


win7和VS2010下配置OpenGL的方法

博客分类:

.NET

VC++MicrosoftWindowsCC++

刚装了win7和VS2010。看了下配置OpenGL的方法和以前不太一样这篇文章的内容如下:

glut下载地址:

http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip

glut.h ---> C:\Program Files (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

!!无须!!用宏 #define GLUT_DISABLE_ATEXIT_HACK

好多人glut.h不知道放哪里,自己新建了一个文件夹,其实很多前辈在之前就说过,

要搜索gl这个文件夹,将glut.h放到里面包含gl.h glu.h这两个文件的gl文件夹中.

直接copy下面例程编译即可通过

例程如下

Cpp代码


#include <gl\glut.h>

void myDisplay(void)

{

glClear(GL_COLOR_BUFFER_BIT);

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

glFlush();

}

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

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

glutInitWindowPosition(100, 100);

glutInitWindowSize(400, 400);

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

glutDisplayFunc(&myDisplay);

glutMainLoop();

return 0;

}



================================================

1. 把解压得到的glut.h放到"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\gl"(与具体安装位置有关,应该是 安装目录\microsoft sdks\windows\v7.0A\include\gl)

2. 把解压得到的glut.lib和glut32.lib放到"“Programfiles(x86)\Microsoft Visual studio 10.0\VC\lib" 中(与具体安装位置有关,同上)

3. 把解压得到的glut.dll放到"C:\Windows\System32"

4. 把glut32.dll放到“Programfiles(x86)\Microsoft Visual studio 10.0\VC\bin”下(注意这个,网上有人说放到system32里,但是我试过,会报错)(与具体安装位置有关,同上)

5. 打开vs2010,随便打开或新建一个项目。 选择 project->project property-> Configuration Properties->Linker->Input->Additional Dependencies 在其中添加opengl32.lib glu32.lib glut32.lib





刚装了win7和VS2010。看了下配置OpenGL的方法和以前不太一样这篇文章的内容如下:

如果这样还报错的话应该注意以下几点:

有时候在建console application 的时候添加的cpp文件将后缀句改为 .c

有的程序需要glaux工具包,这个下载了,可以按上述步骤添加(操作基本相同)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: