So i have a project and when i make a window with 1:1 aspect ratio its 100% fine but when i change the size of the window it messes up and stretches the things on the screen how do i fix this?
Here are some photos
(http://i.stack.imgur.com/tnrEo.png)
(http://i.stack.imgur.com/NwmpF.png)
You have to modify the projection matrix to account for the aspect ratio.
If you haven't yet manipulated the projection matrix (which means you are using an orthographic projection) and are using the fixed-function pipeline, then the easiest solution is to add the following in your render loop before your rendering (or just when the window changes in size):
float aspect = (float)windowWidth/windowHeight;
GL11.glLoadIdentity();
GL11.glOrtho(-aspect, aspect, -1, 1, -1, 1);
or equivalently:
float aspect = (float)windowWidth/windowHeight;
GL11.glLoadIdentity();
GL11.glScale(1.0f/aspect, 1, 1);
i will try that soon thanks so much i will see if it works ;)
it doesn't fix the problem but thanks anyways :>
it usually does. you are probably doing something wrong then :>
If you give a bit more info about how you are rendering we can tell you how to modify the projection matrix.
Its okay im restarting the project anyways
Quote from: Kai on June 20, 2016, 19:44:24
You have to modify the projection matrix to account for the aspect ratio.
If you haven't yet manipulated the projection matrix (which means you are using an orthographic projection) and are using the fixed-function pipeline, then the easiest solution is to add the following in your render loop before your rendering (or just when the window changes in size):
float aspect = (float)windowWidth/windowHeight;
GL11.glLoadIdentity();
GL11.glOrtho(-aspect, aspect, -1, 1, -1, 1);
or equivalently:
float aspect = (float)windowWidth/windowHeight;
GL11.glLoadIdentity();
GL11.glScale(1.0f/aspect, 1, 1);
thanks so much it works now that im using a alternative rendering method :)