将 GLUT 与 Visual C++ Express Edition 结合使用
-
08-06-2019 - |
题
使用以下命令编译 OpenGL 应用程序的基本步骤是什么 GLUT(OpenGL实用工具包) 在 Visual C++ Express 版本下?
解决方案
- 如果您没有 Visual C++ Express Edition (VCEE),请下载并安装 VCEE.
- Visual C++ Express Edition 的默认安装是针对 .Net 平台构建的。我们需要针对 Windows 平台进行构建,因为 .Net 尚未完全支持 OpenGL 和 GLUT。为此,我们需要 Microsoft Platform SDK。(如果您使用的是旧版本的 VCEE,请下载并安装 微软平台SDK. 。Visual C++ Express Edition 需要配置为 Windows 平台构建。所有这些说明都可用 这里.)
- 如果您没有 GLUT,请下载并解压 Nate Robin 的 GLUT 的 Windows 端口.
- 添加 谷胱甘肽 给你的 平台SDK/include/GL/ 目录
- 将项目链接到 过剩库. 。(去VCEE 项目属性 -> 其他链接器目录 并添加目录 过剩库.
- 添加 glue.dll 到 Windows/系统32 目录,以便所有使用Glut的程序都可以在运行时找到它。
您使用 GLUT 或 OpenGL 的程序现在应该在 Visual C++ Express Edition 下编译。
其他提示
Nate Robin 网站上的 GLUT 端口来自 2001 年,与更新的 Visual Studio 版本(.NET 2003 及更高版本)存在一些不兼容性。不兼容表现为重新定义的错误 exit()
. 。如果您看到此错误,有两种可能的解决方案:
- 更换
exit()
原型在glut.h
与你的那个stdlib.h
以便它们匹配。这可能是最好的解决方案。 - 一个更简单的解决方案是
#define GLUT_DISABLE_ATEXIT_HACK
在你之前#include <gl/glut.h>
在你的程序中。
(应得信用:我最初是在 TAMU 服务台网站.)
自从.NET 2003问世以来,我自己一直在使用方法#1,并且使用了相同的修改后的方法 glut.h
与 VC++ 2003、VC++ 2005 和 VC++ 2008。
这是我使用的 glut.h 的差异,它执行#1(但在适当的情况下) #ifdef blocks
这样它仍然可以与旧版本的 Visual Studio 一起使用):
--- c:\naterobbins\glut.h 2000-12-13 00:22:52.000000000 +0900
+++ c:\updated\glut.h 2006-05-23 11:06:10.000000000 +0900
@@ -143,7 +143,12 @@
#if defined(_WIN32)
# ifndef GLUT_BUILDING_LIB
-extern _CRTIMP void __cdecl exit(int);
+/* extern _CRTIMP void __cdecl exit(int); /* Changed for .NET */
+# if _MSC_VER >= 1200
+extern _CRTIMP __declspec(noreturn) void __cdecl exit(int);
+# else
+extern _CRTIMP void __cdecl exit(int);
+# endif
# endif
#else
/* non-Win32 case. */
不隶属于 StackOverflow