Search code examples
c++openglglm-math

Convertation to Glint from float


I want to get *Glint from glm::mat4x4.

I try to use GlProject (...,viewMatrix,..)

It is glm::mediump_float there and i don't know how to translate it to Glint. Is there any function or anything that way?

I tried just

GLint viewport[4];
viewport[0]=float(viewMatrix[0]);

, but it is not okay.


Solution

  • If you want an array of GLints from a glm::mat4x4 then you need to declare a new array and fill it with the values of the matrix.

    GLint newArray[16];
    newArray[0] = (GLint) viewMatrix[0][0];
    newArray[1] = (GLint) viewMatrix[0][1];
    ...
    

    I'm explicitly casting the float to an int here, but it will usually "autobox"/autoconvert this to an int for you.