I need to change the normalize coords from -1 to 1 to the width and height of my application. The reason why I want to change the normalize coords is because i think it would be a easier set position of objects and find the globalbounds of objects

my Rectangle disappear when i put my projection matrix in the vertex shader

Vertex shader code

#version 330

layout(location = 0) in vec4 position;
uniform vec2 offset;
uniform mat4 projection;

void main()
 vec4 translate = vec4(offset.x, offset.y, 0.0, 0.0); //Using translate to move the rectangle via 
 gl_Position = projection * position + translate;

glm::mat4 proj = glm::ortho(-2.f, 2.f, -1.5f, 1.5f, -1.f, 1.f);
shader.setMat4("proj", proj);
  • \$\begingroup\$ There's no matrix named "proj" in your shader. On the cpu side, in the setMat4() function call, change the first argument "proj" to "projection". \$\endgroup\$ Jan 8 at 12:54
  • \$\begingroup\$ @Daniel_1985 thankyou so much \$\endgroup\$
    – user146000
    Jan 8 at 21:17
  • \$\begingroup\$ Did it solve the problem? \$\endgroup\$ Jan 8 at 21:31
  • \$\begingroup\$ @Daniel_1985 yes it did but i notice my rectangle is still has a -1 to 1 position even its drawing it as my height and width of my application \$\endgroup\$
    – user146000
    Jan 8 at 21:39
  • \$\begingroup\$ @Daniel_1985 .What im basically trying to ask does the projection actually changes the normalize coords or just manipulates the ortho to fit the -1 to 1 coords \$\endgroup\$
    – user146000
    Jan 8 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy