这是关于了解glm的来源。我想知道glm是否实现零初始化它的类并尝试它。是的,glm::vec3和glm::mat4是初始化的,即使没有提供构造函数值。然后,我想了解它是如何完成的,并读取了glm::mat4模板的源代码。
这一节如下:
...
enum ctor{null};
// Constructors
GLM_FUNC_DECL tmat4x4();
GLM_FUNC_DECL tmat4x4(tmat4x4 const & m);
GLM_FUNC_DECL explicit tmat4x4(ctor Null);
...我可以读到有一个(void)构造函数(ctor),但是没有定义,所以没有{...}部分。还有一个explicit ctor,其中0作为参数来自于enum ctor类型的第一个元素,该元素当然得到索引值0。
glm::mat4时,如何将glm::mat4 myMatrix;初始化为标识矩阵编辑:浏览GitHub上的当前源文件时,会从mat4x4.hpp到detail/type_mat4x4.hpp带来一个源文件,该文件在mat4x4.inl中提供了实现细节。在那里,玩家的行为变得明显。
发布于 2016-11-23 10:37:37
"glm/detail/type_mat4x4.inl"下面enum ctor{uninitialize}顺便说一下,我不能下载你的版本,这个答案是基于0.9.6.3
发布于 2020-01-13 19:06:52
在默认情况下,它不再是错误的。在包含之前定义GLM_FORCE_CTOR_INIT以强制初始化。https://github.com/g-truc/glm/issues/809
#define GLM_FORCE_CTOR_INIT
#include <glm/glm.hpp>发布于 2018-07-12 09:31:40
glm::mat4x4 view{ 2 / (right - left), 0, 0, 0,
0, 2 / (top - bottom), 0, 0,
0, 0, -2 / (farplane - nearplane), 0,
-((right + left) / (right - left)), -((top + bottom) / (top - bottom)), -((farplane + nearplane) / (farplane - nearplane)), 1
};
glm::mat4 view{ 2 / (right - left), 0, 0, 0,
0, 2 / (top - bottom), 0, 0,
0, 0, -2 / (farplane - nearplane), 0,
-((right + left) / (right - left)), -((top + bottom) / (top - bottom)), -((farplane + nearplane) / (farplane - nearplane)), 1
};
glm::uvec4 ViewPort(0,0,0,0);
glm::vec3 Origin(0.0f, 0.0f, 0.0f);https://stackoverflow.com/questions/40760841
复制相似问题