Hello, i have a little problem. When i rotate object in opengl, rotation speed is not the same. When window is 1200x1000 for example, triangle rotates much slower, then when window is for example 800x600. Can you tell me why is that? Thanks for help.
Rotation code:
std::vector<float> vertices =
{
400.0f, 300.0f,
700.0f, 300.0f,
550.0f, 450.0f,
};
float centerX = (vertices[0] + vertices[2] + vertices[4]) / 3.0f;
float centerY = (vertices[1] + vertices[3] + vertices[5]) / 3.0f;
for (int i = 0; i < vertices.size(); i += 2)
{
vertices[i] -= centerX;
vertices[i + 1] -= centerY;
float rotatedX = vertices[i] * cos(angleRadian) - vertices[i + 1] * sin(angleRadian);
float rotatedY = vertices[i] * sin(angleRadian) + vertices[i + 1] * cos(angleRadian);
vertices[i] = rotatedX + centerX;
vertices[i + 1] = rotatedY + centerY;
}
Shader code:
#shader vertex
#version 330 core
layout(location = 0) in vec2 position;
uniform float u_Scale;
uniform mat4 u_OrthographicMatrix;
uniform float windowWidth;
uniform float windowHeight;
void main()
{
vec2 normalizedCoords = position / vec2(windowWidth, windowHeight) * 2.0 - 1.0;
gl_Position = u_OrthographicMatrix * vec4(normalizedCoords.x, normalizedCoords.y, 0.0, 1.0);
};