Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with ortho projection on Vulkan #283

Open
gamecoder-nz opened this issue Dec 25, 2022 · 2 comments
Open

Issue with ortho projection on Vulkan #283

gamecoder-nz opened this issue Dec 25, 2022 · 2 comments

Comments

@gamecoder-nz
Copy link

gamecoder-nz commented Dec 25, 2022

I'm sure I'm doing something wrong but I can't figure out what. I have an orthographic projection like this

m_AspectRatio = (float)width / (float)height;
float orthoLeft = 0.0f;
float orthoRight = (float)m_OrthographicHeight * m_AspectRatio * m_Zoom;
float orthoTop = (float)m_OrthographicHeight * m_Zoom;
float orthoBottom = 0.0f;

m_Projection = glm::ortho(orthoLeft, orthoRight, orthoBottom, orthoTop, (float)m_OrthographicNear, (float)m_OrthographicFar);

glm::mat4 transformationMatrix = glm::translate(glm::mat4(1.0f), m_Position);

m_View = glm::inverse(transformationMatrix);

The camera doesn't rotate and stays at z = 10 but the y axis for the guizmo is inverted. It is pointing the wrong direction and drags in the wrong direction.

view

@gamecoder-nz
Copy link
Author

If I create another matrix where the top and bottom are swapped like this
glm::ortho(orthoLeft, orthoRight, orthoTop, orthoBottom, (float)m_OrthographicNear, (float)m_OrthographicFar);

Then it works

@gamecoder-nz
Copy link
Author

It also works if I swap the projection matrices around. So the top and bottom for ImGuizmo has to be the opposite of what's used for the engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant