# OpenGL/SDL2 How to resize the render area with the window?

After calling SDL_SetWindowSize, the area being rendered to doesn't change with the window, so if the window gets bigger, it leaves a black area on the top and right sides. I am adjusting the OpenGL viewport to the new window dimentions. Everything I'm drawing scales correctly but is cut off when the window is bigger.

I've been searching for the solution all day and all I've found is creating a new OpenGL context, but that causes crashes unless I reload all my graphics data which seems ridiculous just to resize the window.

Is it the default framebuffer that needs to be resized? According to the OpenGL wiki,

All default framebuffer images are automatically resized to the size of the output window, as it is resized.

So if the default framebuffer is being resized, why is it only rendering to the same small area?

I could initialize it to the largest possible resolution and then shrink it, but wouldn't that cause OpenGL to process a bunch of fragments outside the window?

• Sounds like maybe you have a leftover scissor region still active? Also worth checking that you're resizing any non-default framebuffers. In my game, for example, I rendering into a couple of offscreen framebuffers, before blitting the results to the screen. So when my window gets resized, I need to resize those other framebuffers as well. – Trevor Powell Dec 25 '15 at 7:23
• But are you actually drawing it again? Are you calling an OpenGL draw function after the resizing? – Athos vk Dec 25 '15 at 13:44
• Thanks for your suggestions. I'm now calling glBindFramebuffer(GL_FRAMEBUFFER, 0); before the resize, in case that matters, but no change. I'm drawing the scene to the default framebuffer only, and I'm continually redrawing after the resize. I'd like to know if anyone who's played with SDL2/OpenGL has seen this before? And I'm on Linux, in case platform makes a difference. – Byron Dec 25 '15 at 18:06
• Re: Trevor Powell - Your idea about the scissor region was spot on - I had scissor testing enabled in my initialization left from forever ago, which I don't even use any more. Removed that line and now it works, thanks! – Byron Dec 25 '15 at 18:57
• Should close the question. You could add your own answer and a list of the things you checked, as a guide for future questioners with similar problem... – david van brink Feb 17 '16 at 22:02