I want to fit my rectangle to the screen size with regards to the camera position.
This is the VBO data for the rectangle.
width = 50.0f;
height = 50.0f;
verticesRect = {
// Positions // Normal Coords // Texture Coords
width, height, 0.0f, 0.0 , 0.0, 1.0 , 1.0f, 0.0f, // Top Right
width, -height, 0.0f, 0.0 , 0.0, 1.0 , 1.0f, 1.0f, // Bottom Right
-width, -height, 0.0f, 0.0 , 0.0, 1.0 , 0.0f, 1.0f, // Bottom Left
-width, height, 0.0f, 0.0 , 0.0, 1.0 , 0.0f, 0.0f // Top Left
};
The Matrix for Projection.
float angle = 45.0f;
glm::mat4 projection = glm::perspective(glm::radians(angle), (float)1920.0 / (float)1080.0, 0.1, 1000.0);
The Matrix for View
glm::vec3 Position( 0.0 , 0.0 , 500.0);
glm::vec3 Front( 0.0 , 0.0 , 0.0);
glm::vec3 Up( 0.0 , 1.0 , 0.0);
glm::mat4 view = glm::lookAt(Position, Front , Up);
The Matrix for rectangle object is
glm::model = PositionMarix * RotationMatrix * ScalingMatrix;
How can i calculate what the scaling of the object should be so that it fits itself to the screen size
The rectangle object can translate in z position so as camera can also move in z Position.
