Im trying to make my own 3D engine using LWJGL.
This is the Line of Code which creates the projection matrix for the uniform to pass.
pMatrix = new Matrix4f().ortho(-2f, 2f, -1.125f, 1.125f, 0.1f, 1000f);
Perfectly working Orthographic Projection
Notice how the rendered mesh is square, correct according to the vertices
Only changing this one line to
pMatrix = new Matrix4f().perspective((float) Math.toRadians(60.0f), 640/360,0.1f, 1000f);
Breaks It
Not Properly working Perspective projection
Notice how in the second image , the mesh is not square
Is there something that im doing wrong. If yes , please help me fix it. If not then why is this happening.
Asked
Active
Viewed 86 times
0

httpdigest
- 5,411
- 2
- 14
- 28

Extorc Productions
- 146
- 2
- 9
-
What about `640.0/360.0`? (instead of `640/360`) – Rabbid76 Oct 10 '21 at 19:47
-
@Rabbid76 Yes that fixes it. Would love to know y – Extorc Productions Oct 10 '21 at 19:48
-
1_640/360_ is an integral division. The result is an int not a float. So the result is 1. – Rabbid76 Oct 10 '21 at 19:50