[SDL] OpenGL textures and SDL_SetVideoMode()
mandin.patrice at wanadoo.fr
Fri Jun 10 06:16:11 PDT 2005
Le Fri, 10 Jun 2005 10:34:37 +0100
Ben Campbell <ben at scumways.com> a écrit:
> > The problem is the OpenGL context destruction is platform-dependent.
> > And you may have a platform, where a simple resize don't destroy the
> > context, but changing bpp do. So SDL should inform us that it has
> > been destroyed, thus avoiding some IFDEF in the code. I proposed to
> > add a specific event a while ago, but nobody answered to this.
> Ahh - yep. Platform-specific differences. Thanks for the explaination!
> I think you're right that some sort of notification is in order.
> However I'd feel a little uneasy about the idea of a context-lost
> event, because it's not immediately obvious when it'll get handled.
> For example, the chances are that the event won't be caught and
> handled until the app next does some event processing. So, when the
> SDL_SetVideoMode() returns, your recovery code (to recreate your
> textures, display lists, vertex programs etc) hasn't yet run, so you
> can't immediately start drawing. In fact there could be other events
> ahead of the context-lost notification in the event queue, and you
> could get odd behaviour if they try drawing with textures that no
> longer exist...
> Another solution would be to enforce the context destruct/recreate on
> every SDL_SetVideoMode() call, even if it wasn't strictly required by
> specific platforms. So you'd _know_ that your textures etc had been
> zapped every time you called SDL_SetVideoMode(). I don't really know
> what the implications of this are, and it does feel a little bit
> silly, but maybe it's worth it to achieve consistant behaviour across
> platforms... (not sure I like this idea much either :-)
> The route I plan to go down for now is to assume the context will be
> recreated when SDL_SetVideoMode() is called. So before I make the call
> I'll destroy all my textures, and recreate them after the call
> returns. This should work fine no matter what SDL_SetVideoMode() does
> to the context...
Maybe we could add a SDL_NEWOPENGLCONTEXT to the SDL_Surface->flags
If it is set, an OpenGL context has been created (on first run) or the
context has been destroy/recreated (changed mode on win32), and leave it
to 0 if the OpenGL context was not touched (x11 or some other platform).
Programmeur Linux, Atari
Spécialité: Développement, jeux
More information about the SDL