Elementwise entries into glm::mat4

I’m trying to move to the new glm syntax and trying to set up a 4x4 matrix and add entries to each column - can’t seem to find a proper way to do it. This is what I finally ended up with,

    glm::mat4 B;
    
    glm::vec4 x = glm::vec4(1, 0, 0, 0);
    glm::vec4 y =  glm::vec4(-3, 3, 0, 0);
    glm::vec4 z = glm::vec4(3, -6, 3, 0);
    glm::vec4 w = glm::vec4(-1, 3, -3, 1);
    
    
    B.tmat4x4(x.x, y.x, z.x, w.x, x.y, y.y, z.y, w.y, x.z, y.z, z.z, w.z, x.w, y.w, z.w, w.w);

Basically each vec4 is supposed to be one column in the matrix. This gives me the error,
Cannot refer to type member 'tmat4x4' in 'glm::mat4' (aka 'tmat4x4<float, highp>') with '.'

New to glm so I’m pretty sure I’m messing up with the syntax somewhere. What’s the right way of doing this?

Posted to soon, looks like B[0]...B[3] is accessing t he columns. Right?

any of:

		glm::vec4 x = glm::vec4(1, 0, 0, 0);
		glm::vec4 y =  glm::vec4(-3, 3, 0, 0);
		glm::vec4 z = glm::vec4(3, -6, 3, 0);
		glm::vec4 w = glm::vec4(-1, 3, -3, 1);

		glm::mat4 B(x.x, y.x, z.x, w.x, x.y, y.y, z.y, w.y, x.z, y.z, z.z, w.z, x.w, y.w, z.w, w.w);
		glm::mat4 C(x,y,z,w);

should work. tmat4x4 is just the constructor so you can’t call it on an instance like you are doing

1 Like