Chinaunix首页 | 论坛 | 博客
  • 博客访问: 945270
  • 博文数量: 108
  • 博客积分: 3243
  • 博客等级: 中校
  • 技术积分: 964
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-15 22:09
文章分类

全部博文(108)

文章存档

2020年(2)

2019年(1)

2018年(2)

2017年(9)

2016年(20)

2015年(1)

2013年(1)

2012年(12)

2011年(28)

2010年(27)

2009年(4)

2008年(1)

分类: C/C++

2016-10-12 18:04:59

出处:http://www.cnblogs.com/wangguchangqing/p/4425745.html

做三维重建需要用到OpenGL,开始看《OpenGL超级宝典》,新手第一步配置环境就折腾了一天,记录下环境的配置过程。

《超级宝典》中的例子使用了GLEW,freeglut以及GLTools这三个库


1.GLEW

The OpenGL Extension Wrangler Library (GLEW) is a cross-platform open-source C/C++ extension loading library. GLEW provides efficient run-time mechanisms for determining which OpenGL extensions are supported on the target platform. OpenGL core and extension functionality is exposed in a single header file. GLEW has been tested on a variety of operating systems, including Windows, Linux, Mac OS X, FreeBSD, Irix, and Solaris.


GLEW是一个跨平台的OpenGL的扩展库,支持多个操作系统。下载地址:   提供了已编译好的文件

image

解压后将得到的文件分别进行复制:

include文件夹下是头文件,将位于include文件夹下的GL文件夹复制到C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include 下

lib文件夹下Release\Win32的文件复制到:C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib

bin文件夹下Release\Win32的文件复制到:C:\Windows\System32


GLEW就配置完成了


2.freeglut

FreeGLUT is a free-software/open-source alternative to the OpenGL Utility Toolkit (GLUT) library。

最新的稳定版是3.0,其下载地址:   ,没有提供编译好的包,需要使用CMake自行编译。


CMake的配置

image

注意红圈的两个位置,第一个是生成的freeglut库文件所在的位置,其默认是在C(系统盘),由于访问C盘需要管理员权限,这里没有使用默认值。

第二个是生成Static Lib,勾了这个选项在Install的时候会出现一个错误, 如:
CMake Error at cmake_install.cmake:74 (file):
1>    file INSTALL cannot find
1>    "G:/OpenGL/FreeGLUT/freeglut-3.0.0/lib/Debug/freeglut_staticd.pdb".
1>  
1>  
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: 命令“setlocal
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: G:\开发工具\OpenGL\Cmake\cmake-3.6.2-win32-x86\bin\cmake.exe -DBUILD_TYPE=Debug -P cmake_install.cmake
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :cmEnd
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :cmErrorLevel
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: exit /b %1
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :cmDone
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd”已退出,代码为 1。
由于不生成这个Static Lib也没有多大影响,这里就取消了这个选项。配置好CMake选项后,Generate生成的visual studio2013的项目如下:

image

打开freeglut.sln

image

编译,生成的库文件在CMake配置的CMAKE_INSTALL_PREFIX下,有三个文件夹include、bin、lib,和GLEW类似,将其内容复制到相应的位置。

freeglu配置完成。


3.GLTools

GLTools的配置比较麻烦,主要是由于按照书中提供的网址()下载不到源代码。幸好在GitHub上找到一个GLTools的Linux的版本(地址:),使用其源代码编译生成GLTools库。

image

注意glew.c需要到GLEW的网站下其源代码得到,另外就是其include文件需要放到VC\include文件夹下,而且需要GLEW和freeglut都已配置完成。

在编译GLTools前需要更改其项目属性 > C/C++ > 预处理器右边的预处理器定义中添加 _CRT_SECURE_NO_WARNINGS

image

编译生成以后将Debug文件夹下的GLTools.lib复制到C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib下


 

4.最后

设置项目的依赖项

image


忽略特定依赖库

image


《超级宝典》的第一个例子:

image

阅读(1728) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~