我有一些非常基本的代码,我认为不会导致问题:
#include <glm/ext.hpp>
...
mat4x4 m = mat4x4(1.0f);
m = rotate(m, (float) glfwGetTime(), vec3(0.0f, 0.0f, 1.0f));
mat4x4 p = glm::ortho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);
mat4x4 mvp = mat4x4(0.0f);
mvp = m * p;
但我在线上遇到错误
mvp = m * p
在执行
operator*
时,该错误看起来像是模板构造函数的问题,当我删除乘法时,程序编译得很好。
In file included from lib\glm-1.0.0/glm/./ext/../detail/.././ext/matrix_double4x4.hpp:5,
from lib\glm-1.0.0/glm/./ext/../detail/../mat4x4.hpp:5,
from lib\glm-1.0.0/glm/./ext/../detail/../matrix.hpp:29,
from lib\glm-1.0.0/glm/./ext/../detail/type_mat2x2.inl:1,
from lib\glm-1.0.0/glm/./ext/../detail/type_mat2x2.hpp:176,
from lib\glm-1.0.0/glm/./ext/matrix_double2x2.hpp:5,
from lib\glm-1.0.0/glm/mat2x2.hpp:5,
from lib\glm-1.0.0/glm/glm.hpp:120,
from lib\glm-1.0.0/glm/ext.hpp:9,
from src\main.cpp:4:
lib\glm-1.0.0/glm/./ext/../detail/.././ext/../detail/type_mat4x4.inl: In instantiation of 'constexpr glm::mat<4, 4, T, Q> glm::operator*(const glm::mat<4, 4, T, Q>&, const glm::mat<4, 4, T, Q>&) [with T = float; glm::qualifier Q = (glm::qualifier)0]':
src\main.cpp:139:19: required from here
lib\glm-1.0.0/glm/./ext/../detail/.././ext/../detail/type_mat4x4.hpp:13:9: note: 'struct glm::mat<4, 4, float, (glm::qualifier)0>' has no user-provided default constructor
struct mat<4, 4, T, Q>
^~~~~~~~~~~~~~~
我正在 Windows 上使用 g++ 编译 glm 版本 1.0.1。有人以前见过这个错误吗?
我尝试过包含一堆不同的标题。我还尝试了glm 1.0.0版本。未经乘法测试,编译正确。
使用 glm-1.0.1 和 gcc 11.4.0(在 Cygwin 上)没有错误。也许是编译器?