简体   繁体   English

glm :: vec2不允许操作

[英]glm::vec2 Not Allowing Operations

In using GLM, I have been able to use operations on vectors and matrices (+, -, *, /). 在使用GLM时,我已经能够对向量和矩阵(+,-,*,/)进行运算。 For some reason in the following line of code, it will not let me do any operations: 由于以下代码行中的某种原因,它不会让我执行任何操作:

glm::vec2 fixedPos = position + dimensions/2;  // <- Error is on the '/'

("position" and "dimensions" are both of type "const glm::vec2") (“位置”和“尺寸”均为“ const glm :: vec2”类型)

Error: no operator "/" matches these operands; 错误:没有运算符“ /”与这些操作数匹配; operand types are: const glm::vec2 / int 操作数类型为:const glm :: vec2 / int

(replacing "/" with any other math operator will result in the same error) (用任何其他数学运算符替换“ /”将导致相同的错误)

I find it annoying and strange why this is not working. 我觉得这很烦人并且很奇怪,为什么这不起作用。 The error is saying my syntax is incorrect, when what it asks for is what I put! 错误是当我要求的是我输入的内容时,我的语法不正确! If you see the issue, please post the answer below. 如果您看到此问题,请在下面发布答案。 Thanks for any help! 谢谢你的帮助!

Try this: 尝试这个:

glm::vec2 fixedPos = position + dimensions / 2.0f;

vec2 is actually a typedef to highp_vec2 which is a typedef to tvec2<float, highp> (cf. glm/detail/type_vec.hpp ) vec2实际上是一个typedefhighp_vec2其是typedeftvec2<float, highp>参见glm/detail/type_vec.hpp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM