# SDL Fullscreen Problems

**URL:** <https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893>\
**Category:** SDL Development\
**Created:** [June 6, 2004, 1:23pm UTC](https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893 "2004-06-06T13:23:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![join\_at\_krakendev.co](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/839c29/32.png) [@join\_at\_krakendev.co](https://discourse.libsdl.org/u/join_at_krakendev.co)\
**Post date:** [June 6, 2004, 1:23pm UTC](https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893/1 "2004-06-06T13:23:31Z")

</div>

Hi,  
I’m running the an SDL tutorial from a  
href="[http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut2](http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut2)  
and have run into a bit of a snag. When I attempt to pass  
SDL\_HWSURFACE|SDL\_DOUBLEBUF|SDL\_FULLSCREEN  
to SDL\_InitVideo I get a blank screen, However, double buffering with  
hardware works, and software with fullscreen works, but I can’t seem to  
get the three I’d like running up. Should there be other code  
modifications to the tutorial aside from the flag changes or am I missing  
something else entirely? Could this be a video card issue (mine is pretty  
new)?Cheers.

Also, I’ve attempted passing the bit depth as 0 to the SetVideoMode as was  
recommended to me, to no avail.

---

<div class="post-metadata">

**Author:** ![Florian\_Hufsky](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/f/e9a140/32.png) [@Florian\_Hufsky](https://discourse.libsdl.org/u/Florian_Hufsky)\
**Post date:** [June 6, 2004, 5:07pm UTC](https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893/2 "2004-06-06T17:07:47Z")

</div>

if sdl\_swsurface | sdl\_doublebuf | sdl\_fullscreen works you should use that.  
usually your code should work.

you could check the return value of sdl\_setvideomode.  
or query for the mode information after it’s set to find out what you  
really got.

if you have a directx compatible graphics card there should be no  
problem with it afaik.

join at [krakendev.com](http://krakendev.com) wrote:\>Hi,

> I’m running the an SDL tutorial from a  
> href="[http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut2](http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut2)  
> and have run into a bit of a snag. When I attempt to pass  
> SDL\_HWSURFACE|SDL\_DOUBLEBUF|SDL\_FULLSCREEN  
> to SDL\_InitVideo I get a blank screen, However, double buffering with  
> hardware works, and software with fullscreen works, but I can’t seem to  
> get the three I’d like running up. Should there be other code  
> modifications to the tutorial aside from the flag changes or am I missing  
> something else entirely? Could this be a video card issue (mine is pretty  
> new)?Cheers.
> 
> Also, I’ve attempted passing the bit depth as 0 to the SetVideoMode as was  
> recommended to me, to no avail.
> 
> * * *
> 
> SDL mailing list  
> SDL at [libsdl.org](http://libsdl.org)  
> [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)

---

<div class="post-metadata">

**Author:** ![join\_at\_krakendev.co](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/839c29/32.png) [@join\_at\_krakendev.co](https://discourse.libsdl.org/u/join_at_krakendev.co)\
**Post date:** [June 6, 2004, 8:51pm UTC](https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893/3 "2004-06-06T20:51:23Z")

</div>

Well, I can get SWSURFACE and FULLSCREEN working, but when I add  
FULLSCREEN I just get black. I’m not really sure what’s up. Cheers.\> ----- Original Message -----

> From: fhufsky@phorus.at (Florian Hufsky)  
> To: “A list for developers using the SDL library. (includes SDL-announce)”  
>   
> Sent: Sunday, June 06, 2004 1:07 PM  
> Subject: Re: [SDL] SDL Fullscreen Problems
> 
> > if sdl\_swsurface | sdl\_doublebuf | sdl\_fullscreen works you should use  
> > that.  
> > usually your code should work.
> > 
> > you could check the return value of sdl\_setvideomode.  
> > or query for the mode information after it’s set to find out what you  
> > really got.
> > 
> > if you have a directx compatible graphics card there should be no  
> > problem with it afaik.
> > 
> > @join_at_krakendev.co wrote:
> > 
> > > Hi,  
> > > I’m running the an SDL tutorial from a  
> > > href="[http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut2](http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut2)  
> > > and have run into a bit of a snag. When I attempt to pass  
> > > SDL\_HWSURFACE|SDL\_DOUBLEBUF|SDL\_FULLSCREEN  
> > > to SDL\_InitVideo I get a blank screen, However, double buffering with  
> > > hardware works, and software with fullscreen works, but I can’t seem to  
> > > get the three I’d like running up. Should there be other code  
> > > modifications to the tutorial aside from the flag changes or am I missing  
> > > something else entirely? Could this be a video card issue (mine is pretty  
> > > new)?Cheers.
> > > 
> > > Also, I’ve attempted passing the bit depth as 0 to the SetVideoMode as was  
> > > recommended to me, to no avail.
> > > 
> > > * * *
> > > 
> > > SDL mailing list  
> > > SDL at [libsdl.org](http://libsdl.org)  
> > > [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)
> > 
> > * * *
> > 
> > SDL mailing list  
> > SDL at [libsdl.org](http://libsdl.org)  
> > [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)

---

<div class="post-metadata">

**Author:** ![join\_at\_krakendev.co](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/839c29/32.png) [@join\_at\_krakendev.co](https://discourse.libsdl.org/u/join_at_krakendev.co)\
**Post date:** [June 6, 2004, 8:56pm UTC](https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893/4 "2004-06-06T20:56:07Z")

</div>

Erg, sorry. Correction:

Well, I can get SWSURFACE and FULLSCREEN working, but when I add DOUBLEBUF  
I just get black. I’m not really sure what’s up. Cheers.

---

<div class="post-metadata">

**Author:** ![jake\_b](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/8edcca/32.png) [@jake\_b](https://discourse.libsdl.org/u/jake_b)\
**Post date:** [June 6, 2004, 9:02pm UTC](https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893/5 "2004-06-06T21:02:54Z")

</div>

— join at [krakendev.com](http://krakendev.com) wrote:

> Erg, sorry. Correction:
> 
> Well, I can get SWSURFACE and FULLSCREEN working, but when I  
> add DOUBLEBUF  
> I just get black. I’m not really sure what’s up. Cheers.

If doublebuffering is enabled, you need to flip surfaces,  
instead of updating.\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
Do you Yahoo!?  
Friends. Fun. Try the all-new Yahoo! Messenger.  
[http://messenger.yahoo.com/](http://messenger.yahoo.com/)

---

<div class="post-metadata">

**Author:** ![join\_at\_krakendev.co](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/839c29/32.png) [@join\_at\_krakendev.co](https://discourse.libsdl.org/u/join_at_krakendev.co)\
**Post date:** [June 6, 2004, 9:46pm UTC](https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893/6 "2004-06-06T21:46:29Z")

</div>

Yeah. My current Draw function is as follows:

void BSDL::DrawScene()  
{  
Slock(screen);  
ClearScreen();  
DrawRotated((int)angle,1);  
SDL\_Flip(screen);  
Sulock(screen);  
}

DrawRotated just uses BlitSurface.

The other pertinent functions are:

void BSDL::Slock(SDL\_Surface \*screen)  
{  
if ( SDL\_MUSTLOCK(screen) )  
{  
if ( SDL\_LockSurface(screen) \< 0 )  
{  
return;  
}  
}  
}

void BSDL::Sulock(SDL\_Surface \*screen)  
{  
if ( SDL\_MUSTLOCK(screen) )  
{  
SDL\_UnlockSurface(screen);  
}  
}

I’m just going by the tutorial’s example, but that seems correct (though  
obviously I’m making a mistake somewhere). Cheers.\> ----- Original Message -----

> From: [ninmonkeys@yahoo.com](mailto:ninmonkeys@yahoo.com) (jake b)  
> To: “A list for developers using the SDL library. (includes SDL-announce)”  
>   
> Sent: Sunday, June 06, 2004 5:02 PM  
> Subject: Re: [SDL] SDL Fullscreen Problems
> 
> > — @join_at_krakendev.co wrote:
> > 
> > > Erg, sorry. Correction:
> > > 
> > > Well, I can get SWSURFACE and FULLSCREEN working, but when I  
> > > add DOUBLEBUF  
> > > I just get black. I’m not really sure what’s up. Cheers.
> > 
> > If doublebuffering is enabled, you need to flip surfaces,  
> > instead of updating.

---

<div class="post-metadata">

**Author:** ![jake\_b](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/8edcca/32.png) [@jake\_b](https://discourse.libsdl.org/u/jake_b)\
**Post date:** [June 6, 2004, 11:44pm UTC](https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893/7 "2004-06-06T23:44:22Z")

</div>

I just noticed you unlock your surface after flipping. The doc  
project says to _not_ call SDL\_UpdateRect() if the surface is  
locked, and i’m guessing the same applies to flipping. Does  
unlocking before flipping fix the problem?

\*\*If ClearScreen() calls SDL\_FillRect, the surface doesn’t have  
to be locked at that point.

If unlocking didn’t work;

a)Are you getting a valid video surface?

b)does DrawRotated() work when doublebuffering is not enabled?

//code to initialize SDL, set a video mode, and check if it  
worked

if(SDL\_Init(SDL\_INIT\_VIDEO) \< 0) {  
cerr \<\< "Couldn’t initialize sdl: " \<\< SDL\_GetError() \<\<  
endl;  
SDL\_Quit();  
return -1;  
}  
screen = SDL\_SetVideoMode(SCREEN\_W, SCREEN\_H, screen\_bpp,  
SDL\_HWSURFACE | SDL\_FULLSCREEN | SDL\_DOUBLEBUF);  
if(screen == NULL)  
{  
cerr \<\< "Couldn’t set " \<\< SCREEN\_W \<\< “x” \<\< SCREEN\_H \<\<  
“x” \<\< screen\_bpp  
\<\< " video mode " \<\< endl \<\< SDL\_GetError() \<\< endl;  
//could try at a lower setting, or quit  
SDL\_Quit();  
return -1;  
}

//enter game/render loop

SDL\_Quit();

— join at [krakendev.com](http://krakendev.com) wrote:\> Yeah. My current Draw function is as follows:

> void BSDL::DrawScene()  
> {  
> Slock(screen);  
> ClearScreen();  
> DrawRotated((int)angle,1);  
> SDL\_Flip(screen);  
> Sulock(screen);  
> }
> 
> DrawRotated just uses BlitSurface.
> 
> The other pertinent functions are:
> 
> void BSDL::Slock(SDL\_Surface \*screen)  
> {  
> if ( SDL\_MUSTLOCK(screen) )  
> {  
> if ( SDL\_LockSurface(screen) \< 0 )  
> {  
> return;  
> }  
> }  
> }
> 
> void BSDL::Sulock(SDL\_Surface \*screen)  
> {  
> if ( SDL\_MUSTLOCK(screen) )  
> {  
> SDL\_UnlockSurface(screen);  
> }  
> }
> 
> I’m just going by the tutorial’s example, but that seems  
> correct (though  
> obviously I’m making a mistake somewhere). Cheers.
> 
> ----- Original Message -----  
> From: “jake b” \<@jake\_b\>  
> To: “A list for developers using the SDL library. (includes  
> SDL-announce)”  
>   
> Sent: Sunday, June 06, 2004 5:02 PM  
> Subject: Re: [SDL] SDL Fullscreen Problems
> 
> > — join at [krakendev.com](http://krakendev.com) wrote:
> > 
> > > Erg, sorry. Correction:
> > > 
> > > Well, I can get SWSURFACE and FULLSCREEN working, but when  
> > > I  
> > > add DOUBLEBUF  
> > > I just get black. I’m not really sure what’s up. Cheers.
> > 
> > If doublebuffering is enabled, you need to flip surfaces,  
> > instead of updating.
> 
> * * *
> 
> SDL mailing list  
> SDL at [libsdl.org](http://libsdl.org)  
> [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)

* * *

Do you Yahoo!?  
Friends. Fun. Try the all-new Yahoo! Messenger.  
[http://messenger.yahoo.com/](http://messenger.yahoo.com/)

---

<div class="post-metadata">

**Author:** ![Florian\_Hufsky](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/f/e9a140/32.png) [@Florian\_Hufsky](https://discourse.libsdl.org/u/Florian_Hufsky)\
**Post date:** [June 7, 2004, 2:47pm UTC](https://discourse.libsdl.org/t/sdl-fullscreen-problems/10893/8 "2004-06-07T14:47:19Z")

</div>

having your surface locked while flipping seems somewhat evil to me.

join at [krakendev.com](http://krakendev.com) wrote:\>Yeah. My current Draw function is as follows:

> void BSDL::DrawScene()  
> {  
> Slock(screen);  
> ClearScreen();  
> DrawRotated((int)angle,1);  
> SDL\_Flip(screen);  
> Sulock(screen);  
> }
> 
> DrawRotated just uses BlitSurface.
> 
> The other pertinent functions are:
> 
> void BSDL::Slock(SDL\_Surface \*screen)  
> {  
> if ( SDL\_MUSTLOCK(screen) )  
> {  
> if ( SDL\_LockSurface(screen) \< 0 )  
> {  
> return;  
> }  
> }  
> }
> 
> void BSDL::Sulock(SDL\_Surface \*screen)  
> {  
> if ( SDL\_MUSTLOCK(screen) )  
> {  
> SDL\_UnlockSurface(screen);  
> }  
> }
> 
> I’m just going by the tutorial’s example, but that seems correct (though  
> obviously I’m making a mistake somewhere). Cheers.
> 
> ----- Original Message -----  
> From: “jake b”   
> To: “A list for developers using the SDL library. (includes SDL-announce)”  
>   
> Sent: Sunday, June 06, 2004 5:02 PM  
> Subject: Re: [SDL] SDL Fullscreen Problems
> 
> > — join at [krakendev.com](http://krakendev.com) wrote:
> > 
> > > Erg, sorry. Correction:
> > > 
> > > Well, I can get SWSURFACE and FULLSCREEN working, but when I  
> > > add DOUBLEBUF  
> > > I just get black. I’m not really sure what’s up. Cheers.
> > 
> > If doublebuffering is enabled, you need to flip surfaces,  
> > instead of updating.
> 
> * * *
> 
> SDL mailing list  
> SDL at [libsdl.org](http://libsdl.org)  
> [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)
