Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Steelrose

SDL Full screen problems

This topic is 5569 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been having a problem with SDL for some time and I hope someone can tell me what I''m doing wrong. When I run my program and try to run in windowed mode at 1024x768x32 I have no problems, But when I try to run the same setup in fullscreen, I get an error stating that my videocard doesn''t support it. Anyone have any ideas on what I''m missing here? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
AMD 1700+
Visiontek GeForce 2 MX
512 MB Ram
Win XP
17" monitor

I just did some testing and come to find out, none of the resolutions work. I tried 640x480x16 all the way up to 1024x768x32. Nothing works at fullscreen I think there is a bit being set wrong but I can't tell where. I'm using the Trent Polack Game Tut as a base if that helps, SDL version.

I'm not sure what you'd need in the way of system specs so I put in what I thought was necassary.

Dreams arn't just dreams,
They're a whole new world to play in.

[edited by - Steelrose on August 17, 2003 4:02:42 PM]

Share this post


Link to post
Share on other sites
Sure. Here ya go.


------------------------------------------------------------------
bool SHINING3D::OpenGLInit(int width, int height, int bpp, int screenflag)
{
/* this holds some info about our display */
const SDL_VideoInfo *videoInfo;

SCREEN_WIDTH =width; //Set the class's constants to the

SCREEN_HEIGHT=height; //parameter's provided by the

SCREEN_BPP =bpp; //user.


S3Dlog.Output("Window initiation:");

/* initialize SDL */
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ) < 0 )
{
S3Dlog.Output(" Video initialization failed: %s", SDL_GetError());
SDL_Quit();
return false;
}
S3Dlog.Output(" Video initialization ... OK");

/* Fetch the video info */
videoInfo = SDL_GetVideoInfo( );

if ( !videoInfo )
{
S3Dlog.Output(" Video query failed: %s", SDL_GetError());
SDL_Quit();
return false;
}
S3Dlog.Output(" Video query ... OK");

/* the flags to pass to SDL_SetVideoMode */
videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */
videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */
videoFlags |= SDL_RESIZABLE; /* Enable window resizing */

/* This checks to see if surfaces can be stored in memory */
if ( videoInfo->hw_available )
videoFlags |= SDL_HWSURFACE;
else
videoFlags |= SDL_SWSURFACE;

/* This checks if hardware blits can be done */
if ( videoInfo->blit_hw )
videoFlags |= SDL_HWACCEL;

SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); // tell SDL that the GL drawing is going to be double buffered

SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, SCREEN_BPP); // size of depth buffer

SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0); // we aren't going to use the stencil buffer

SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 0); // this and the next three lines set the bits allocated per pixel -

SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 0); // - for the accumulation buffer to 0

SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 0);
SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 0);

fullscreen = FULLSCREEN_OFF;
if(screenflag==GIVE_CHOICE)
{
//Ask the user which screen mode they prefer

char cRis;
cout << "Would you like to run in fullscreen mode (Y/N)? ";
cin >> cRis;
if (cRis == 'Y' || cRis == 'y')
{
screenflag=FULLSCREEN; //Fullscreen mode

}
else
screenflag=WINDOW; //Windowed mode

}

/* get a SDL surface */
surface = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, videoFlags );

/* Verify there is a surface */
if ( !surface )
{
S3Dlog.Output(" Video mode set failed: %s", SDL_GetError());
SDL_Quit();
return false;
}
S3Dlog.Output(" Video mode set ... OK");

SDL_WM_SetCaption(TITLE, TITLE); // set the window caption (first argument) and icon caption (2nd arg)


if(screenflag==FULLSCREEN) //Attempt fullscreen mode?

{
//Try to set selected mode and get results

if (!ToggleFullScreen())
{
//If the mode fails, offer 2 options. Quit or use windowed mode.

char cRis;
cout << "The Requested Fullscreen Mode Is Not Supported By Your Video Card." << endl << "Use Windowed Mode Instead (Y/N)? ";
cin >> cRis;
if (cRis == 'Y' || cRis == 'y')
{
S3Dlog.Output(" Fullscreen mode not supported.");
}
else
{
//Display a message letting the user know the program is closing.

cout << "Program Will Now Close." << endl;
SDL_Quit();
return false;
}
}
}

glEnable(GL_TEXTURE_2D); //Enable two dimensional texture mapping

glShadeModel(GL_SMOOTH); //Enable smooth shading (so you can't see the individual polygons of a primitive, best shown when drawing a sphere)

glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //Completely black background


glClearDepth(1.0); //Depth buffer setup

glEnable(GL_DEPTH_TEST); //Enable depth testing

glDepthFunc(GL_LEQUAL); //The type of depth testing to do (LEQUAL==less than or equal to)


glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //The nicest perspective look


glColor4f(1.0f, 1.0f, 1.0f, 1.0f); //Full brightness.

glBlendFunc(GL_SRC_ALPHA,GL_ONE); //Set the blending function for transparency


ResizeGLScene(width, height); //Set up the OpenGL perspective view


return true;
}

------------------------------------------------------------------

Thanks again.

[edited by - Steelrose on August 17, 2003 6:22:33 PM]

Share this post


Link to post
Share on other sites
Your problem *might* be in the ToggleFullScreen function.
Could you post the code for it as well ?

Maybe I''m wrong, but I think you should add SDL_GL_DOUBLEBUFFER and SDL_ANYFORMAT to your videoFlags (in fullscreen and windowed mode).
If you want fullscreen, add the SDL_FULLSCREEN flag (and remove SDL_RESIZABLE) before invoking SDL_SetVideoMode. This should work (it works for me at least).

Share this post


Link to post
Share on other sites
Wow, theres a lot more code in your window creation code than mine. I think its probably that you''re passing the wrong flags in fullscreen mode.

If it helps this is my creation code:



bool CSDLWindow::CreateSDLWindow(void)
{

int flags = 0; //This stores the window attributes we want


if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) //Starts the SDL initialisation

{
fprintf(stderr, "SDL initialisation has failed: %s\n", //If we cant initialise the error is written to a file

SDL_GetError());

return false; //and we return false to quit the application

}

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); //Size of the framebuffer red component, in bits

SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); //Size of the framebuffer green component, in bits

SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); //Size of the framebuffer blue component, in bits

SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); //Sets the size of the depth buffer, 16 bit

SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); //Turns double buffering on or off, we want it on


if (fullscreen) //If we want fullscreen mode

{
flags = SDL_OPENGL | SDL_FULLSCREEN; //Set the flags to fullscreen, and to use OpenGL

}
else
{
flags = SDL_OPENGL; //Otherwise just set to OpenGL

}

screen = SDL_SetVideoMode( width, height, bits, flags ); //Set the video mode with the approriate flags


if(!screen) { //If the mode isn''t supported print a message to stderr.txt to tell us


return false; //Return false and quit

}

SDL_WM_SetCaption(title, NULL); //Set the title caption


Resize(screen->w, screen->h); //Make sure OpenGL knows the windows size


if (!Init()) //If initialisation fails quit

{
return false;
}
SDL_ShowCursor(false);
return true;
}


Lukerd.

Hyperdev

"To err is human, to really mess up requires a computer"

Share this post


Link to post
Share on other sites
rodzilla, I tried adding the variables you specified but it didn''t work. I tried to add it the SDL_FULLSCREEN at the check of the screenflag, um, flag.

Here is a copy of my ToggelFullScreen code:


int SHINING3D::ToggleFullScreen()
{
if (SDL_WM_ToggleFullScreen(surface))
{
fullscreen=!fullscreen;
if(fullscreen==FULLSCREEN_ON) //Did the user want a fullscreen window?

SDL_ShowCursor(SDL_DISABLE); //Hide the mouse pointer

else
SDL_ShowCursor(SDL_ENABLE); //Show the mouse pointer

return 1;
}

return 0;
}


This bit seems pritty straight-foward. Perhaps it''s the fullscreen settings?

Thanks for any help.

Share this post


Link to post
Share on other sites
It could be that your setting the bpp value.. I''m not sure I haven''t done OpenGL SDL apps. I''ve only done 2D ones.. and what happens is that certain monitors want to do different settings.. there is a flag that you can let it pick what it wants to do I believe.

Then what it does is try what you want and then if thats not valid it will just use what it can.. this would also be better if you want to make sure it works totally for everyone cause you never know what settings people might try..



Please visit Turt99 Productions

Share this post


Link to post
Share on other sites
Here''s a funky thing.


int SHINING3D::ToggleFullScreen()
{
if (SDL_WM_ToggleFullScreen(surface))
{
fullscreen=!fullscreen;
if(fullscreen==FULLSCREEN_ON) //Did the user want a fullscreen window?

SDL_ShowCursor(SDL_DISABLE); //Hide the mouse pointer

else
SDL_ShowCursor(SDL_ENABLE); //Show the mouse pointer

return 1;
}

return 0;
}


if I change:

if (SDL_WM_ToggleFullScreen(surface))

to

if (!SDL_WM_ToggleFullScreen(surface))

then it seems to work fine.

But here''s the kicker, I was going over the sdl header file "SDL_Video" and I found the information for SDL_WM_ToggleFullScreen. It states that if it is able to toggle the fullscreen then it returns a ''1'', if it can''t then it returns a ''0''. So what I did shouldn''t work. Freaky.

Any ideas on what is going on here?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!