1
\$\begingroup\$

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?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Dec 25, 2015 at 7:23
  • \$\begingroup\$ But are you actually drawing it again? Are you calling an OpenGL draw function after the resizing? \$\endgroup\$
    – Athos vk
    Dec 25, 2015 at 13:44
  • \$\begingroup\$ 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. \$\endgroup\$
    – Byron
    Dec 25, 2015 at 18:06
  • 2
    \$\begingroup\$ 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! \$\endgroup\$
    – Byron
    Dec 25, 2015 at 18:57
  • \$\begingroup\$ 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... \$\endgroup\$ Feb 17, 2016 at 22:02

1 Answer 1

0
\$\begingroup\$

As discussed in the comments, the problem was a scissor region. So for anyone reading, make sure scissor testing is disabled if you're resizing the window.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .