Win10 VS2015 OpenGL + freeglut + glew + glm 环境配置

来源:互联网 发布:南方s730网络设置 编辑:程序博客网 时间:2024/05/16 17:31

1. 参考网站

搭建环境:win10_x64, VS2015

结论:搭建成功–> 参考第三个参考网站.

  1. OpenGL在Windows下的开发环境配置–>仅给出了一些概念
  2. 使用VS2015编译FreeGLUT –>写的有些简单
  3. Win10 VS2015 OpenGL + freeglut + glew + glm 環境配置整理(32位元 debug + 64位元 debug) –>特别详细!

对于第三个参考网站补充如下:

  1. 选择freeglut2.8.1 版本的原因是可以直接使用VS打开,而不需要使用CMAKE二次加工.
  2. 在做例子时, 需要将电脑重启, 好像这个样子才能使环境变量起作用.
  3. 在使用debug时, 会发生错误提示,告知freeglutd.lib 缺失, 我解决方法为, freeglut 在debug 模式下重新编译, 并将debug 得到 freeglut.lib 更改名称为 freeglutd.lib 加入build\x64\libbuild\x86\lib 中. 暂时运行成功了, 但是对于其运行机制还是有些迷茫.
  4. 我的编译成功的库文件:http://download.csdn.net/download/xuanyuanlei1020/10165233

下面步骤没有走通, 可以参考一下.

2. 安装FreeGLUT

下载地址: http://freeglut.sourceforge.net/index.php#download

但是安装FreeGLUT最新版的时候需要安装CMAKE [ 步骤3 ], 但是我在使用CMAKE编译FreeGLUT时发生了错误.没有进行下去, 参考第三个参考网站成功.


—以下步骤没有走通–主要参考参考网站2.

2.1 使用CMAKE编译FreeGLUT

  1. Download CMake (http://www.cmake.org/cmake/resources/software.html).
    Get one of the releases from the binary distribution section.
  2. Run the CMake installer, install wherever you like.
  3. Launch CMake via Start > Program Files > CMake 2.8 > CMake (GUI)
    (note that the shortcut put by the installer on your desktop does NOT
    point to the CMake GUI program!)
  4. In the “Where is the source code” box, type or browse to the root
    directory of your freeglut source (so that’s /freeglut, not
    /freeglut/src).
  5. In the “Where to build the binaries” box, type or browse to any
    folder you like - this will be where the Visual Studio solution will be
    generated. This folder does not have to exist yet.
  6. Hit the Configure button near the bottom of the window.
  7. Pick your target compiler, make sure that its installed on your
    system of course!
  8. Answer Ok when asked if you want to create the build directory.
  9. Wait for the configure process to finish.
  10. The screen will now have some configuration options on it, for
    instance specifying whether you want to build static and/or shared
    libraries (see below for a complete list). When you’ve selected your
    options, click the Configure button again.
  11. The Generate button at the bottom will now be enabled. Click Generate.
  12. The build files will now be generated in the location you picked.

You can now navigate to the build directory you specified in step 5.
Open the freeglut.sln file that was generated in your build directory,
and compile as usual.

对于步骤7: 我们需要选择Visual Studio 14 2015, 注意:一定不要选其他的, 经过验证, 选择其他都会在VS阶段报错,其余步骤按照英文步骤来就好.

对于步骤12: 打开freeglut.sln, 选择生成–>批处理–>全部–>编译. 我的发生4个错误, 没有进行下去.

2.2 搬运头文件和库文件

不当翻译工,却免不了当搬运工。为了避免每次建立工程的时候都需要配置FreeGLUT相关文件,需要人肉将相关文件放到相关位置上。我的操作系统是64位的Windows 10,具体如下:
(1)将头文件“freeglut.h”,“freeglut_ext.h”,“freeglut_std.h”和“glut.h”搬至MSVC的包含目录,我的是“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\GL”。–> freeglut-3.0.0\include\GL中的
(2)将库文件“freeglut.lib”或“freeglut_static.lib”搬至MSVC的库目录,我的是“C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib”。 –>2.1步骤5中的目录\lib\Release 和 2.1步骤5中的目录\lib\Debug
(3)将DLL文件“freeglut.dll”搬至“C:\Windows\System32”。 –>2.1步骤5中的目录\bin\Release中的
注:步骤(2)和(3)有时候不起作用,这时还是需要在项目属性中设置。

3. 安装CMAKE

CMAKE的下载地址:https://cmake.org/download/

下载编译好的二进制文件就好, 我选择的是zip文件, 而不是安装文件.

4. 安装GLEW

下载地址: http://glew.sourceforge.net/

我下载的是编译好的文件. 版本是: glew-2.1.0

  1. 将glew-2.1.0\include\GL下的文件复制到: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\GL
  2. 将 glew-2.1.0\lib\Release\x64下的文件复制到:C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib 下并复制重命名为: glew.lib 和 glew_static.lib
  3. 将glew-2.1.0\bin\Release\x64下的glew32.dll 复制到: C:\Windows\System32, 并复制和重命名为glew.dll

5. 测试代码

为了测试是否安装成功,可建立一个简单的Win32 console工程测试。代码如下:

#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("First GLUT Sample");    glutDisplayFunc(&myDisplay);    glutMainLoop();    return 0;}
原创粉丝点击