Having problems resizing window, what is the best way?

Hi there.
I’m using my own GL calls so I create a window like this:

Code:
_window = SDL_CreateWindow(title.c_str(),
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
width, height,
flags);

     // Create an OpenGL context associated with the window.
    _glcontext = SDL_GL_CreateContext(_window);

If I only do this once I can see everything on screen, the game works fine at the start chosen resolution.
However I want resolution options on my game, couldn’t find any resize window function so I’m doing this to resize, I destroy the windows and just recreate it.

Code:

    if (_window!=NULL)
    {
        SDL_GL_DeleteContext(_glcontext);
        SDL_DestroyWindow(_window);
    }
    
    ...
    _window = SDL_CreateWindow(title.c_str(),
                               SDL_WINDOWPOS_CENTERED,
                               SDL_WINDOWPOS_CENTERED,
                               width, height,
                               flags);
    
    // Create an OpenGL context associated with the window.
    _glcontext = SDL_GL_CreateContext(_window);

The problem is that after a resolution change everything gets broken like this picture, it appears it’s calling the wrong context or something. Can someone help me?

[Image: https://pbs.twimg.com/media/BXA-f6PIUAAN_UK.png ]------------------------
@DJ_Link

www.david-amador.com

I forgot to mention, but this is what I do after doing all my GL calls

SDL_GL_SwapWindow(_window);

So I’m always using the last created window, even if it’s recreated------------------------
@DJ_Link

www.david-amador.com

I forgot to mention, but this is what I do after doing all my GL calls

SDL_GL_SwapWindow(_window);

So I’m always using the last created window, even if it’s recreated------------------------
@DJ_Link

www.david-amador.com

This one? http://wiki.libsdl.org/SDL_SetWindowSize

Jonny DOn Sun, Oct 20, 2013 at 7:25 AM, ^DJ_Link^ <david.djlink at gmail.com> wrote:

**
I forgot to mention, but this is what I do after doing all my GL calls

Quote:

SDL_GL_SwapWindow(_window);

So I’m always using the last created window, even if it’s recreated


@DJ_Link

www.david-amador.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

[quote=“Jonny D”]This one??http://wiki.libsdl.org/SDL_SetWindowSize (http://wiki.libsdl.org/SDL_SetWindowSize)

I still have the same problem. Graphics get all broken after using SDL_SetWindowSize. The windows does resize but graphics get broken

Before (just doing the initial windowCreate

[Image: https://dl.dropboxusercontent.com/u/65262/before.png ]

After calling SDL_SetWindowSize

[Image: https://dl.dropboxusercontent.com/u/65262/after.png ]------------------------
@DJ_Link

www.david-amador.com

Did you reset your view/projection matrices after the resize?

Jonny DOn Sun, Oct 20, 2013 at 3:06 PM, ^DJ_Link^ <david.djlink at gmail.com> wrote:

**

[quote=“Jonny D”]This one? http://wiki.libsdl.org/SDL_SetWindowSize

I still have the same problem. Graphics get all broken after using
SDL_SetWindowSize. The windows does resize but graphics get broken

Before (just doing the initial windowCreate

After calling SDL_SetWindowSize


@DJ_Link

www.david-amador.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ah, stupid me. I was reseting them but before doing the actual window resize, so values where getting broken. #facepalm.
It works but now I have another problem.

I can’t change resolution from the moment I choose a window size with fullscreen. On window mode it changes fine.

I’m switching between window and fullscreen using

Code:
if (fullscreen)
{
SDL_SetWindowFullscreen(_window, SDL_WINDOW_FULLSCREEN);
}
else
{
SDL_SetWindowFullscreen(_window, 0);
}

After using the SDL_SetWindowSize. Fullscreen seems to get stuck on the first resolution passed in fullscreen.
I’m checking the window size after the operation via SDL_GetWindowDisplayMode and the resolution always stays the same in fullscreen------------------------
@DJ_Link

www.david-amador.com