Hello Guest

LWJGL 3 Window Resize Stretching / Wrong Size [SOLVED]

  • 5 Replies
  • 7915 Views
*

Offline DGK

  • *
  • 12
LWJGL 3 Window Resize Stretching / Wrong Size [SOLVED]
« on: June 17, 2018, 07:21:02 »
I fixed the issue! For anyone else having the problem, make sure you are not using GL_MODELVIEW_MATRIX as the enum for the Model View, use GL_MODELVIEW. I mistakenly used GL_MODELVIEW_MATRIX in my code here:

Code: [Select]
GLFW.glfwSetFramebufferSizeCallback(handle, (window, width, height) -> {
            this.width = width;
            this.height = height;
            getWorldCamera().onWindowResize(width, height);
            glViewport(0, 0, width, height);

            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(0, width, height, 0, 1f, -1f);
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();
        });

Ensure you use the code above ^ and don't use GL_MODELVIEW_MATRIX mistakenly, use GL_MODELVIEW. Also make sure you change the variables for your width and height when resizing your window and using glfwSetFramebufferSizeCallback -- I was told using the WindowSizeCallback is erroneous in other OS' like Mac.
« Last Edit: June 17, 2018, 21:29:55 by DGK »


*

Offline DGK

  • *
  • 12
Re: LWJGL 3 Window Resize Stretching / Wrong Size
« Reply #2 on: June 17, 2018, 08:26:51 »
https://gamedev.stackexchange.com/questions/49674/opengl-resizing-display-and-glortho-glviewport#answer-49698

This doesn't give me an answer why glOrtho makes the screen white LITERALLY every time I call it, no matter what order I do the parameters in either.

*

Offline KaiHH

  • ****
  • 334
Re: LWJGL 3 Window Resize Stretching / Wrong Size
« Reply #3 on: June 17, 2018, 08:31:45 »
Your question was how to fix aspect ratio in an orthographic projection. And that is EXACTLY what this post tells you. There is no point in trying to fix bugs you added to your program before even trying to apply a working solution to your otherwise working program.

*

Offline DGK

  • *
  • 12
Re: LWJGL 3 Window Resize Stretching / Wrong Size
« Reply #4 on: June 17, 2018, 20:19:56 »
Your question was how to fix aspect ratio in an orthographic projection. And that is EXACTLY what this post tells you. There is no point in trying to fix bugs you added to your program before even trying to apply a working solution to your otherwise working program.

You sure are a bit... arrogant. My post is titled "Resize Stretching / Wrong Size", and in my post I even said:

Quote
but this makes my screen completely white and I have tried every single possible suggested 'solution' to fix this and it still won't fix

I don't know why you are attempting to put words in my mouth. I stated that I had two issues, one specifically with using glOrtho because it makes my screen white.

*

Offline KaiHH

  • ****
  • 334
Re: LWJGL 3 Window Resize Stretching / Wrong Size [SOLVED]
« Reply #5 on: June 18, 2018, 08:11:55 »
Here are some more useful resources you should read to understand the cause of your problems and come up with possible solutions:
- https://stackoverflow.com/questions/2571402/how-to-use-glortho-in-opengl#answer-2602693
- https://msdn.microsoft.com/en-us/library/windows/desktop/dd373965(v=vs.85).aspx
- http://www.songho.ca/opengl/gl_projectionmatrix.html

Please make sur you actually understand what you are doing. Just trying to play with some argument values for glOrtho without knowing what it actually does, will not lead to a solution.

Take note that glOrtho (just like all other matrix stack manipulation functions like glTranslate, glFrustum, glRotate, glScale, etc.) post-multiply their result onto the current matrix stack. So chances are that you are probably not doing a glLoadIdentity() before.