c++ - GLM 是否与 GLload 和 GCC 兼容

标签 c++ glm-math glload

我目前正在设置我的 OpenGL“框架”,并决定使用 GLload,主要用于扩展加载,但它具有证明适当的“gl” namespace 的额外好处。因此,所有 gl* 函数都被用作 gl::* 例如:

glUniformMatrix4fv(...) // instead of this
gl::UniformMatrix4fv(...) // use this

我还想使用 glm,根据我的理解,它应该像 include glm/glm.hpp 一样简单,并确保我告诉我的编译器在哪里可以找到它。但似乎它可能无法直接与 glload 兼容,因为我尝试使用它进行编译时出现以下错误。

In file included from glm/glm/fwd.hpp:32:0,
                 from glm/glm/glm.hpp:91,
                 from src/main.cpp:3:
glm/glm/core/type_int.hpp:220:2: error: redefinition of ‘struct glm::detail::is_int<long int>’
glm/glm/core/type_int.hpp:219:2: error: previous definition of ‘struct glm::detail::is_int<long int>’
glm/glm/core/type_int.hpp:250:2: error: redefinition of ‘struct glm::detail::is_uint<long unsigned int>’
glm/glm/core/type_int.hpp:249:2: error: previous definition of ‘struct glm::detail::is_uint<long unsigned int>’

通过查看 type_int.hpp,您可以看到它使用宏,首先分别使用“signed long”和“unsigned long”,然后使用“highp_int_t”和“highp_uint_t”(导致这个错误)。这两个重新定义的类型是“int64”和“uint64”,具体类型取决于编译器。当我使用 GCC 时,我相信这意味着我应该将这些类型视为“signed long long”和“usigned long long”。

如果我确实注释掉这两行,所有内容似乎 都可以正常编译。当然,我确定迟早会发现我这样做破坏了一些东西。

查找类似问题将我带到了 this回答,这基本上是说 glm 不支持使用 -std=C++11 构建,这对我来说是 Not Acceptable ;但是这个答案已经有将近两年的历史了,glm 的网站确实声称完全兼容 C++11。

作为引用,我使用的是 gcc 版本 4.7.3,glm 版本 0.9.5(从 github repo 中提取),glload 来自 glsdk 版本 0.4.4(我已经删除了所有其他“模块” glsdk,留给我 justglload)。

最佳答案

好的,看来是使用GLM 0.9.5版本的问题。

谢天谢地,我使用了一个 git 子模块,所以我能够方便地使用版本 0.9.4 进行测试。看来 0.9.4 版本对我来说工作得很好。

关于c++ - GLM 是否与 GLload 和 GCC 兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17259711/

相关文章:

opengl - GLSDK 打破了 easylogging++

c++ - 在 glm::rotate 中使用 "custom"sin 和 cos

c++ - ARB_DEBUG_OUTPUT 的访问冲突

c++ - 尝试创建在类中找到方法 "size"的元函数

c++ - SDL2 中 GLFW 样式的无限鼠标移动?

c++ - 在 OpenGL 中更改相机位置和方向?

c++ - 在 OpenGL 中缩放投影矩阵时出现意外行为

c++ - 在 openGL 4 中呈现文本 - 不起作用

c++ - OpenGL中VAO的目的是什么