[SDL] strange context switch when changing Window-Size

Brian Barrett brian.ripoff at gmail.com
Thu Nov 17 11:25:24 PST 2005


AFAIK you shouldnt call SDL_FreeSurface on a surface created by
SDL_SetVieoMode either...

On 12/9/05, Benjamin Grauer <bensch at orxonox.ethz.ch> wrote:
>  Hi there
>
>  we are coding a 3d action shooter for Linux/Windows/osX, and since we
> ported to Windows via SDL we have a strange effect, when changing the Screen
> size in windows:
>
>  On loading everything works well, most models are stored in glLists (at the
> moment) and all Textures are stored in glTexture2D's...
>
>  But, when the resolution gets changed, SDL sends a WindowResizeEvent, that
> we catch, and handle with this code:
>
>  int GraphicsEngine::setResolution(int width, int height,
> int bpp)
>  {
>    this->resolutionX = width;
>    this->resolutionY = height;
>    this->bitsPerPixel = bpp;
>
>    if (this->screen != NULL)
>      SDL_FreeSurface(screen);
>    if((this->screen = SDL_SetVideoMode(this->resolutionX,
> this->resolutionY, this->bitsPerPixel, this->videoFlags |
> this->fullscreenFlag)) == NULL)
>      {
>        PRINTF(1)("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n",
> this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags,
> SDL_GetError());
>        //    SDL_Quit();
>        //    return -1;
>      }
>      glMatrixMode(GL_PROJECTION_MATRIX);
>      glLoadIdentity();
>      glViewport(0, 0, width, height);                     // Reset The
> Current Viewport
>  }
>
>
>  Then all Textures get removed from rendered Objects, and glLists wont
> render anymore, but the objects rendered through glVertex, are still
> visible.
>
>  I suspect, that somehow an openGL context switch occurs, or gl gets
> reinitialized...
>
>  here is a precompiled binary, and source.
> http://www.orxonox.net/files/snapshots/orxonox-src-latest.tar.bz2
> http://www.orxonox.net/files/snapshots/orxonox-win32-latest.zip
>
>
>  any help is appreciated
>      Benjamin
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>
>
>




More information about the SDL mailing list