1
\$\begingroup\$

Its easy enough doing it on the gpu via GLSL, but how would I do this in c++? When I try it gives me an error telling me I cant cast a glm::mat4 to float, Which makes sense, but how should I do it?

EDIT

A little code example of my failed attempt:

glm::vec4 Off = glm::vec4(0, 0, 0, 1);
Off *= Util::createTransform(offset); // Util::createTransform(...) Creates a glm::mat4

for (int i = 0; i < Tvertex.size(); i++) {
    Tvertex[i] += glm::vec3(Off.x, Off.y, Off.z);
}
\$\endgroup\$
1
  • 1
    \$\begingroup\$ I think this is what you need. \$\endgroup\$
    – Vaillancourt
    Jan 17, 2016 at 15:22

1 Answer 1

2
\$\begingroup\$

You get the error because there is no operator*= for vec4 that takes a matrix as a parameter. It then tries to convert the matrix to a float, but just can't.

To work around this, you should try to not use the operator*= and write it all in the long form:

Off = Off * Util::createTransform(offset);

Also, as pointed out in the comments to the OP, what you need is probably this:

Off = Util::createTransform(offset) * Off;
\$\endgroup\$

You must log in to answer this question.