【发布时间】:2021-09-17 12:57:24
【问题描述】:
为什么这段代码会编译
[[nodiscard]] glm::mat4 rotationX(double theta)
{
return glm::rotate(glm::mat4(1.0), static_cast<float>(theta), glm::vec3(1.0, 0.0, 0.0));
}
这个不是
[[nodiscard]] glm::mat4 rotationX(double theta)
{
return glm::rotate(glm::mat4(1.0), theta, glm::vec3(1.0, 0.0, 0.0));
}
它会导致错误C2672 no matching overloaded function found 和
错误C2782: Template parameter T is ambigous。
theta应该是什么类型?
还有这段代码
[[nodiscard]] glm::mat4 shearing(double xy, double xz, double yx, double yz, double zx, double zy)
{
auto sh = glm::mat4(1.0);
sh[1][0] = xy;
sh[2][0] = xz;
sh[2][1] = yz;
sh[0][1] = yx;
sh[0][2] = zx;
sh[1][2] = zy;
return sh;
}
产生以下警告:warning C4244: 'argument' : conversion from 'double' to 'T', possible loss of data
我不明白究竟是什么错误,因为其他一切似乎都正常。
PS,我包括
#include <glm/fwd.hpp>
在 .hpp 和
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
在 .cpp 中。
【问题讨论】: