Many OpenGL contexts

How can I have more than one OpenGL context?
If I want to implement split screen, or things like portals, etc…, must I
draw the various parts in the OpenGL backbuffer, save in a offscreen surface
with a blit, and then blit it again to the screen, all this before flipping
the buffers?

And, when I have a page flipping scheme, everytime I bit from the screen to
a surface, or when I save an image from the screen, do I get the active
image, not the visible, isn’t it?

What is the actual difference between OpenGL double buffer and the screen
double buffer? Why are two different functions? Are they interchangeble?

Thanx.–
Marco Iannaccone @Marco_Iannaccone
ICQ: 18748121 MetalCoder

"What is real? How do you define real? If you’re talking about your
senses, what you feel, taste, smell, or see, then all you’re talking about
are electrical signals interpreted by your brain."
Morpheus - The Matrix

How can I have more than one OpenGL context?

No.

If I want to implement split screen, or things like portals, etc…, must I
draw the various parts in the OpenGL backbuffer, save in a offscreen surface
with a blit, and then blit it again to the screen, all this before flipping
the buffers?

No. The preferred way of handling multiple views is to use 1 OpenGL context
and use glViewport() to manipulate the portion of the context you are
interested in.

And, when I have a page flipping scheme, everytime I bit from the screen to
a surface, or when I save an image from the screen, do I get the active
image, not the visible, isn’t it?

What is the actual difference between OpenGL double buffer and the screen
double buffer?
Why are two different functions? Are they interchangeble?

The major difference is that you can directly access the framebuffer of an
SDL surface, but you cannot for an OpenGL context. What this means is that
every function in SDL that relates to OpenGL must use OpenGL calls behind
the scenes to do its work. The 2D functions, since they have direct
framebuffer access usually do things internally to SDL, occasionally using
special external functions for hardware acceleration.

It may be possible to merge the two calls into one, and let SDL determine
which is the right one to call. But I think the separate way is better,
since it makes you realize that SDL is really in two different modes of
operation (with respect to video).

What is the actual difference between OpenGL double buffer and the
screen

double buffer?
Why are two different functions? Are they interchangeble?

The major difference is that you can directly access the framebuffer of an
SDL surface, but you cannot for an OpenGL context. What this means is that
every function in SDL that relates to OpenGL must use OpenGL calls behind
the scenes to do its work. The 2D functions, since they have direct
framebuffer access usually do things internally to SDL, occasionally using
special external functions for hardware acceleration.
So, with normal surfaces I can write directly to the frame buffer, and use
the blit functions.
And with OpenGL? I can’t use SDL blits, isn’t it? And if I try to access the
buffer directly?
And with SDL_OPENBLIT?

If I want to set OpenGL with Double Buffer, I must first set the GL
attribute on 1, then calla SetVideoMode with the SDL_DOUBLEBUF flags, isn’t
it?

Is OPENBLIT slower than OPENGL?

When I set and OpenGL attribute and the go to GL mode, if I then change
again the video mode, still OpenGL, are the attributes the same I set at the
beginning, or are they again the dfaults values? What are the defaults?–
Marco Iannaccone @Marco_Iannaccone
ICQ: 18748121 MetalCoder

"What is real? How do you define real? If you’re talking about your
senses, what you feel, taste, smell, or see, then all you’re talking about
are electrical signals interpreted by your brain."
Morpheus - The Matrix

So, with normal surfaces I can write directly to the frame buffer, and use
the blit functions.
And with OpenGL? I can’t use SDL blits, isn’t it?

That’s correct.

And if I try to access the buffer directly?

Your program will crash.

And with SDL_OPENBLIT?

SDL will use a set of textures to emulate a framebuffer and upload
them to the video card when you call SDL_UpdateRects(). This tends
to be slow, so only do it if you absolutely need to.

If I want to set OpenGL with Double Buffer, I must first set the GL
attribute on 1, then calla SetVideoMode with the SDL_DOUBLEBUF flags, isn’t
it?

Just set the GL attribute to 1. This is actually the default.

Is OPENBLIT slower than OPENGL?

Yes.

When I set and OpenGL attribute and the go to GL mode, if I then change
again the video mode, still OpenGL, are the attributes the same I set at the
beginning, or are they again the dfaults values? What are the defaults?

The attributes are the same as the ones you set at the beginning.
Don’t rely on a particular set of defaults. They are not defined in the API.
Practically speaking, they will be at least a 16-bit RGBA color buffer with
double buffering. Note that you won’t necessarily get this, but it’s likely.
Always check the actual values if you require something in particular.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software