Page 1 of 1

A Newbie SDL Question

Posted: Sun Mar 08, 2009 4:34 pm
by ibly31
How do you maximize a window? I know how to set the size to 1024*768(My dimensions), and I'm sure there is a way to set the windows position, but thats not true maximize. Anyone know? Is it as simple as "SDL_WindowMaximize(blah);"

Re: A Newbie SDL Question

Posted: Sun Mar 08, 2009 4:44 pm
by Ginto8
you can pass a combination of the flags SDL_FULLSCREEN and SDL_NOFRAME (using bitwise XOR, ^) so that you have a fullscreen window with a frame. Example in pseudocode:

Code: Select all

if(player maximizes window)
{
    screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, (SDL_SWSURFACE|SDL_RESIZABLE|SDL_FULLSCREEN)^SDL_NOFRAME);
}
you have to XOR out SDL_NOFRAME because, by default, it is included in SDL_FULLSCREEN. ;)

Hope I helped. :mrgreen:

Re: A Newbie SDL Question

Posted: Mon Mar 09, 2009 7:56 pm
by ibly31
Umm... How do I XOR noframe? And I tried that code you had there, and it errored, went non-responding, then crashed. :D

EDIT: Also, I'm displaying PNG's with Alpha pre-made... and they are displaying with a black background... how do I make it interpret the alpha values?

Re: A Newbie SDL Question

Posted: Mon Mar 09, 2009 9:16 pm
by Ginto8
#1. Use the debugger, check what error you get. Also, check if there's an stderr.txt or stdout.txt in the executable's folder. It may have information on the crash.

#2. If you're colorkeying, premade transparancy won't work.

Hopefully that helps. ;)

Re: A Newbie SDL Question

Posted: Mon Mar 09, 2009 11:30 pm
by wtetzner
ibly31 wrote:EDIT: Also, I'm displaying PNG's with Alpha pre-made... and they are displaying with a black background... how do I make it interpret the alpha values?
in this tutorial: http://www.lazyfoo.net/SDL_tutorials/le ... /index.php
Where he has

Code: Select all

//If nothing went wrong in loading the image
if( loadedImage != NULL )
{
    //Create an optimized image
    optimizedImage = SDL_DisplayFormat( loadedImage );

    //Free the old image SDL_FreeSurface( loadedImage ); 
} 
use SDL_DisplayFormatAlpha() instead of SDL_DisplayFormat().

Re: A Newbie SDL Question

Posted: Tue Mar 10, 2009 1:46 am
by PixelP
this should get the job done.

Code: Select all

#include "SDL.h"

int SDL_WM_ToggleFullScreen(SDL_Surface *surface);
http://www.libsdl.org/cgi/docwiki.cgi/S ... FullScreen

Re: A Newbie SDL Question

Posted: Tue Mar 10, 2009 1:48 am
by Kros
PixelP wrote:this should get the job done.

Code: Select all

#include "SDL.h"

int SDL_WM_ToggleFullScreen(SDL_Surface *surface);
http://www.libsdl.org/cgi/docwiki.cgi/S ... FullScreen
There is a slight difference between fullscreen and a maximized window. Mayhaps he should clarify which hes looking to accomplish?

Re: A Newbie SDL Question

Posted: Tue Mar 10, 2009 6:37 am
by ibly31
I want, when you click that little button on the top right hand corner; maximized. NOT fullscreen. How is it done? Because the other code made the screen go black except for the start bar and them freeZe and crash...
EDIT:
I took away the XOR of noframe and it works fine, except I had to add a little event SDLK_ESCAPE checker to exit instead of the X button event. Thanks!