Sharing textures in SDL's OpenGL surfaces

Moderator
Posts: 771
Joined: 2003.04
Post: #1
I'd like to be able to switch from windowed mode to fullscreen and back using SDL+OpenGL, but the context switch means I have to reload all my textures. It works, but it's a mess to maintain. I read here that it is posible to share a context in AGL.

The question:
Has anybody been able to implement this using a standard SDL framework?
If not, has anybody been able to hack SDL's source code to make this possible?
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2010.11
Post: #2
For the record I asked the same question for the same reason a few months ago and nobody could help me Sad . I hope things have changed.
Quote this message in a reply
isgoed
Unregistered
 
Post: #3
PowerMacX Wrote:I'd like to be able to switch from windowed mode to fullscreen and back using SDL+OpenGL, but the context switch means I have to reload all my textures. It works, but it's a mess to maintain. I read here that it is posible to share a context in AGL.

I am the one in the thread you pointed out. I don't know what SDL is though. It is possible to share textures between fullscreen and window (as I am able to do). The trick is that you must treat your window and fullscreen state both as grafports. The pseudo code i have does this:

Code:
AGLContext            FullscreenContext;
AGLContext            WindowContext;

FullscreenContext = aglCreateContext (PixelFormat, 0);
WindowContext = aglCreateContext (PixelFormat, FullscreenContext);  // HERE YOU SHARE TEXTURES

aglSetDrawable(FullscreenContext, FullScreenGrafPort);
aglSetDrawable(WindowContext, WindowGrafPort);

if(windowed_mode){
   aglSetCurrentContext(WindowContext);}
else{
   aglSetCurrentContext(FullscreenContext);}

you can also look into the function

Code:
Succes = aglCopyContext (FullscreenContext,WindowContext,GL_ALL_ATTRIB_BITS);

A disadvantage of this method is that your fullscreencontext is not as fast as:

Code:
aglSetFullScreen (FullscreenContext, 0, 0, 0, 0);
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #4
Upon closer inspection of SDL source code, I found out that althrough there is an AGL version of the video code, there is also a "Quartz" version, wich is probably what it is using on OS X...?

For now, I'll just make the player exit the game to apply changes Sad , especially if sharing a context makes it a bit slower (my goal is to make my 3D game playable on a Rage128Pro)

Still, if I have time I'll experiment with SDL source a bit Wacko
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
Yes, it uses Cocoa on Mac OS X, so you'd have to do NSGL things.

Sharing the context shouldn't be a performance penalty.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [SOLVED]OpenGL edges of textures mk12 2 4,352 Sep 2, 2010 08:07 PM
Last Post: mk12
  OpenGL Image Textures mikey 52 24,220 Jun 30, 2009 10:42 AM
Last Post: AnotherJake
  Dealing with inverted textures in OpenGL johncmurphy 7 6,966 Jun 15, 2009 08:11 AM
Last Post: Skorche
  Using textures OpenGL switches to software renderer bruno 2 3,531 Oct 12, 2008 03:06 AM
Last Post: bruno
  Create surfaces with custom data manu1001 0 1,870 Feb 6, 2008 09:48 AM
Last Post: manu1001