[solved]glOrtho and window size

I’m attempting to make my LWJGL window resizeable. When I draw, lets say a quad, I get the middle of the drawing area, then for a 100x100 quad I go 50 left, 50 up, and so on for the other points. (I have set my window up to have (0,0) bottom left, (800,600) top right)

glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0,width,0,height,1,-1);
        glMatrixMode(GL_MODELVIEW);
        glEnable(GL_TEXTURE_2D);

width = 800 height = 600

Then if(Display.wasResized())

I work out how much it has been resized, calculating a float called scale, and In my render loop I ‘draw(scale);’ so everything can be resized. So x co-ords are calculated:

middlex - (scale*50)
middlex + (scale*50)

(I take into account it may of been increased in width and not height etc).

This works perfectly, except it cannot draw beyond 800 width, I’m believe because of the clipping plane set by

glOrtho(0,width,0,height,1,-1);

with width = 800. Its at this point I would like to re-run glOrtho() with the new width and height, but when I do this, its stops working perfectly, and starts drawing in crazy places (I have printed the floats it is trying to draw at, they are correct at least for how I would like it drawn with 0,0 as the origin)

Is changing the window size a problem, and how can I re-run glOrtho()? I feel like doing it twice is causing some effect I’ve overlooked…

Are you remembering to switch back go GL_PROJECTION, clear it with glLoadIdentity(), then call glOrtho() and finally switching back to GL_MODELVIEW?

Aye, this is the block of code used after I get the new height and width

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

Don’t forget to reset the viewport too:

GL11.glViewport(0,0,width,height);

Yes you will want to update the viewport if LWJGL doesn’t take care of that for you. If this wasn’t happening, it would explain why things were being clipped when you’d scale the window up.

Thanks, viewport solved the problem