A Newbie SDL Question

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

A Newbie SDL Question

Post 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);"
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: A Newbie SDL Question

Post 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:
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: A Newbie SDL Question

Post 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?
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: A Newbie SDL Question

Post 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. ;)
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
wtetzner
Chaos Rift Regular
Chaos Rift Regular
Posts: 159
Joined: Wed Feb 18, 2009 6:43 pm
Current Project: waterbear, GBA game + editor
Favorite Gaming Platforms: Game Boy Advance
Programming Language of Choice: OCaml
Location: TX
Contact:

Re: A Newbie SDL Question

Post 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().
The novice realizes that the difference between code and data is trivial. The expert realizes that all code is data. And the true master realizes that all data is code.
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: A Newbie SDL Question

Post 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
User avatar
Kros
Chaos Rift Regular
Chaos Rift Regular
Posts: 136
Joined: Tue Feb 24, 2009 4:01 pm
Current Project: N/A
Favorite Gaming Platforms: PC, Playstation/2/3
Programming Language of Choice: C++
Location: Oregon,USA
Contact:

Re: A Newbie SDL Question

Post 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?
Isaac Asimov wrote:Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
YouTube Channel
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: A Newbie SDL Question

Post 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!
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
Post Reply