Hi, I’m a begginer with SDL, so I could be making some stupid mistakes…
Anyway, this is not a big problem, but what happens is strange enough
to cause me a need for some explanations.
Here’s the important code of the application:
Resolutions[0].X() = 640; //read X() as x
Resolutions[0].Y() = 480; //read Y() as y
Resolutions[1].X() = 800;
Resolutions[1].Y() = 600;
Resolutions[2].X() = 1024;
Resolutions[2].Y() = 768;
int CurrResolution = 2; //default (1024x768)
int main()
{
//…
if( SDL_PollEvent( &event ) )
somefunction( &event );
//
}
void somefunction(SDL_Event *event)
{
if(event->type == SDL_KEYDOWN)
{
switch(event->key.keysym.sym)
{
//....
case SDLK_PAGEUP:
if(CurrResolution < 2)
++CurrResolution;
SDL_SetVideoMode(Resolutions[CurrResolution].X(),
Resolutions[CurrResolution].Y(), bpp, //bpp extracted with
SDL_GetVideoInfo()
SDL_OPENGL |
SDL_HWSURFACE | SDL_FULLSCREEN);
InitGL(); //restore deleted textures, and set OpenGL states
to initial values
break;
case SDLK_PAGEDOWN:
if(CurrResolution >0)
–CurrResolution;
SDL_SetVideoMode(Resolutions[CurrResolution].X(),
Resolutions[CurrResolution].Y(), bpp, //bpp extracted with
SDL_GetVideoInfo()
SDL_OPENGL |
SDL_HWSURFACE | SDL_FULLSCREEN);
InitGL(); //restore deleted textures, and set OpenGL states
to initial values
break;
}
}
//…
}
This code works perfectly when I switch from the default resolution
(1024x768) to lower resolutions, and works ALMOST well when switching
from lower
resolutions to higher resolutions, I say almost because when, switching
from 800x600 mode, to 1024x768 mode (that is, I press PAGE-UP), the
screen goes
completely black, but, if a press ALT-TAB, the program magically works
again!
Oh… I forgot to tell you that I’m using the binary version (1.2.7) of
SDL for Visual C++.
I really can’t understand this behaviour, so I hope you masters will
give me some explanations for why this strange thing happens.
Thanks, and don’t be surprised if my english sucks! ;-)—
[Quipo ISP - Questa E-mail e’ stata controllata dal programma Declude Virus]
[Quipo ISP - This E-mail was scanned for viruses by Declude Virus]