配置OpenGL时遇到的一些问题

    今天在配置openGL时遇到了一些问题,在各种"玩弄“后终于配置好了。(汗)

    电脑为windows10(X64),原本是装好vs2015的,所以只需要下载一些头文件。OpenGL 下有一些重用的辅助库,比如glut,glew等等,在windows平台下需要自己安装,因为微软为了推广自己的DX,在windows下只支持openGL 1.1版本。

      现在openGL已经发展到3.0了,因此我们需要自己下载配置这些库,在这里我们来安装glut, glee,  glew这三个库,以及一些OpenGL扩展支持。 

    glut : 提供对窗口的封装,这是跨平台窗口的,我们就不必自己去编写烦琐的窗口代码。

    glee : 方便用来判断当前系统是不是支持某项OpenGL特性,我们就不用自己去写烦琐的先取函数地址然后再判断的代码了。

    glew : 因为windows默认只支持OpenGL 1.1,你要想用更高版本的OpenGL,你就需要安装它,它能自动识别你的平台所支持的全部OpenGL高级扩展函数。

    首先给出官方的一个链接:https://www.opengl.org/wiki/Getting_Started

    奈何官方只给出电脑配置显卡驱动的下载地址。那三个库还得自己丰衣足食。

    1.glut

    GLUT3.7下载地址:http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip

    将glut.dll glut32.dll复制到C:WindowsSysWOW64下。将glut32.lib和glut.lib复制到vs2015VClib下。将glut.h复制到C:Program Files (x86)Windows Kits8.1Includeumgl下。

    写程序时只需要把

    #include <GL/gl.h>
    #include <GL/glu.h>  
    用  
    #include <GL/glut.h> 
    替换就可以了。因为在头文件 glut.h 中已经包含这些头文件,并导入了必要的库:  
    #pragma comment (lib, "winmm.lib")       /* link with Windows MultiMedia lib */
    #pragma comment (lib, "opengl32.lib")   /* link with Microsoft OpenGL lib */
    #pragma comment (lib, "glu32.lib")       /* link with OpenGL Utility lib */
    #pragma comment (lib, "glut32.lib")      /* link with Win32 GLUT lib */ 

    2.glew

    下载地址:https://sourceforge.net/projects/glew/?source=directory

    如上,三种格式的文件还是拷贝到各自目录下。在程序中我们只需要在包含glut.h 之前包含 glew.h就可以了(注意:一定要先包含 glew.h)。

    在代码中加上这么一句: 

    #pragma comment (lib, "glew32.lib")  

    示例:  
    #include <GL/glew.h>
    #include <GL/glut.h>  
    #progrma comment(lib, "glew32.lib")  
    在创建OpenGL渲染context之后,调用 glewInit(); 初始化glew就可以了。

    3.glext.h  glxext.h  glcorearb.h  wglext.h

    glext.h:https://www.opengl.org/registry/api/GL/glext.h

    glxext.h:https://www.opengl.org/registry/api/GL/glxext.h

    glcorearb.h:https://www.opengl.org/registry/api/GL/glcorearb.h

    wglext.h:https://www.opengl.org/registry/api/GL/wglext.h

    还是和上面一样,放到对应得目录下。

    4.glaux

    下载地址:http://download.csdn.net/detail/li235456789/8224459

    当把glaux.h放到指定的文件夹时,运行报错说是,打不开glaux.h。可以在项目——>(projectname)属性——>配置属性——>链接器——>输入——>附加依赖项添加就好

    但是在运行程序时,会出现以下错误:

    “Draw.exe”(Win32):  已加载“C:UsersYCDocumentsVisual Studio 2013ProjectsDrawDebugDraw.exe”。已加载符号。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32 tdll.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32kernel32.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32KernelBase.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32mfc120d.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32advapi32.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32msvcrt.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32sechost.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32 pcrt4.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32msvcr120d.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32user32.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32gdi32.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32lpk.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32usp10.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32ole32.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32oleaut32.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32shlwapi.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32imm32.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32msctf.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32uxtheme.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:Windowswinsxx86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_ec80f00e8593ece5comctl32.dll”。 无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:Windowswinsxs x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.18455_none_72d576ad8665e853 GdiPlus.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32apphelp.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已卸载“C:WindowsSystem32apphelp.dll”
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32cryptbase.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32dwmapi.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:UsersYCAppDataRoamingTaobaoProtectTaobaoProtectSE.dll”。模块已生成,不包含符号。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32psapi.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32shell32.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32version.dll”。无法查找或打开 PDB 文件。
    “Draw.exe”(Win32):  已加载“C:WindowsSystem32profapi.dll”。无法查找或打开 PDB 文件。
    程序“[5036] Draw.exe”已退出,返回值为 0 (0x0)。

    解决办法:调试——>选项——>调式常规——>勾选启动源服务器支持——>符号——>勾选Microsoft符号服务器

    参考了,http://www.cnblogs.com/lzihua/archive/2012/05/11/2495714.htmlhttp://blog.csdn.net/tahelin/article/details/30318341

原文地址:https://www.cnblogs.com/clairvoyant/p/5453551.html