OpenGL GLM C++ vertex and matrix transformations confusion
I'm pretty confused now that I can no longer do a simply gl_Position = pos * MVP; in my vertex shader, and instead want to transform the vertices before I send them via glBufferSubData.
This is my poor attempt at trying to get the vertex coordinates to be pixel based. Lets say I want a rect to be 100 pixels from 0,0. I was hoping this would work, and I've been fiddling it with for a while.
What am I doing wrong here, or what is it that I actually want to do?
glm::mat4 view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, 0.0f));
glm::mat4 ortho = glm::ortho(0.0f, float(SCREEN_W), float(SCREEN_H), 0.0f, -1.0f, 1.0f);
glm::vec4 rect = glm::vec4(0.0f, 0.0f, 1.0f, 1.0f);
glm::vec4 transformed = rect * view * ortho;
std::cout << "x: " << transformed.x << " y: " << transformed.y << " w: " << transformed.w << " t: " << transformed.t << " z : " << transformed.z << "\n";
float x = transformed.x;
float width = transformed.w;
float y = transformed.y;
float height = transformed.z;
vertices = x; // top left X
vertices = y; //top left Y
vertices = x; // bottom left X
vertices = height; // bottom left Y
vertices = width; // bottom right X
vertices = height; //bottom right Y
vertices = width; // top right X
vertices = y; // top right Y