SDL+OpenGL : problem when changing resolution

Hi !

Does anybody know how to change resolution in an
SDL+OpenGL program ?
I’m currently using SetVideoMode with SDL_FULLSCREEN
flag, but this “deletes” all textures under Windows.

Is it possible to avoid this ?
Or at least to know if textures have to be reloaded ?

Thanx a lot in advance.

Rod.

Rodolphe Suescun wrote:

Does anybody know how to change resolution in an
SDL+OpenGL program ?
I’m currently using SetVideoMode with SDL_FULLSCREEN
flag, but this “deletes” all textures under Windows.
Do you mean it deletes the textures or that it clears the screen?
SDL_SetVideoMode() should work just fine.

Does anybody know how to change resolution in an
SDL+OpenGL program ?
I’m currently using SetVideoMode with SDL_FULLSCREEN
flag, but this “deletes” all textures under Windows.

Do you mean it deletes the textures or that it clears the screen?
SDL_SetVideoMode() should work just fine.

It deletes the textures. Somehow it must “reset” the OpenGL
context.

Does anybody know how to change resolution in an
SDL+OpenGL program ?
I’m currently using SetVideoMode with SDL_FULLSCREEN
flag, but this “deletes” all textures under Windows.

Do you mean it deletes the textures or that it clears the screen?
SDL_SetVideoMode() should work just fine.

It deletes the textures. Somehow it must “reset” the OpenGL
context.

Yes, that’s correct. I know it’s not desirable, and patches are welcome. :slight_smile:

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

What API would be acceptable for this? I expect you’ll want to preserve
the current SDL_SetVideoMode behavior for compatibility.

An extra flag to SDL_SetVideoMode (SDL_KEEPOPENGL) can indicate that the
OpenGL context should be preserved whenever possible, and the flag can
be set in the video surface if the context actually was retained.

Any better ideas?

(I have a hack to do this at the moment, but it adds another entry
point, which is overkill.)On Sun, Feb 09, 2003 at 11:24:43AM -0800, Sam Lantinga wrote:

It deletes the textures. Somehow it must “reset” the OpenGL
context.

Yes, that’s correct. I know it’s not desirable, and patches are welcome. :slight_smile:


Glenn Maynard

Hi folks,

Does anybody know how to change resolution in an
SDL+OpenGL program ?
you must change it twice, once for SDL, and once for the Opengl-viewport.
I think, that’s your problem.

look at this example, perhaps it will help you, it’s ripped of my current engine:-------------------------------------------------------------

void set_resolution(SDL_Surface *screen, int width, int height, int bpp, bool fullscreen)
{
screen = SDL_SetVideoMode(width, height, bpp, (fullscreen==true) ? SDL_FULLSCREEN|SDL_OPENGL|SDL_RESIZABLE : SDL_OPENGL|SDL_RESIZABLE );
if(!screen)
{
std::cerr<<"Couldn’t get in display mode!: "<<SDL_GetError()<<std::endl;
exit(-1);
}

glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//gluPerspective(Field_OF_View, Aspect_Ratio, Min_Distance (should never be 0), Max_Distance);
gluPerspective(90, (GLfloat)(width)/(GLfloat)(height), 0.01f, 150.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

}


Otherwise it’s a problem of your windoze, I use Linux and never any
textures were deleted.

best regards and happy coding


funthing

It deletes the textures. Somehow it must “reset” the OpenGL
context.
Yes, that’s correct. I know it’s not desirable, and patches are welcome. :slight_smile:

What API would be acceptable for this? I expect you’ll want to preserve
the current SDL_SetVideoMode behavior for compatibility.

An extra flag to SDL_SetVideoMode (SDL_KEEPOPENGL) can indicate that the
OpenGL context should be preserved whenever possible, and the flag can
be set in the video surface if the context actually was retained.

Shouldn’t this be the default behaviour ? Maybe an option to
create a new context (and know if a new context has been created).

Anyway, I like SDL’s behaviour under Linux. Is it always possible
to keep the opengl context when changing resolution ? Even when
changing color depth ?

Any better ideas?

Ahem… No.

(I have a hack to do this at the moment, but it adds another entry
point, which is overkill.)

I’d be interested in having a look at it ;*)

Thanx a lot !

Rod.