# Maximum width and height

**URL:** <https://discourse.libsdl.org/t/maximum-width-and-height/14923>\
**Category:** SDL Development\
**Created:** [October 27, 2007, 9:51pm UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923 "2007-10-27T21:51:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mogumbo](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/mogumbo/32/704_2.png) [@mogumbo](https://discourse.libsdl.org/u/mogumbo)\
**Post date:** [October 27, 2007, 9:51pm UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923/1 "2007-10-27T21:51:04Z")

</div>

Is there any way to get SDL to tell you the maximum width and height  
that you can make a window? I want to know the width and height to  
pass to SDL\_SetVideoMode() when I start an app or go to fullscreen  
mode with SDL\_WM\_ToggleFullScreen().

- Terry

---

<div class="post-metadata">

**Author:** ![Torsten\_Giebl](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/torsten_giebl/32/2804_2.png) [@Torsten\_Giebl](https://discourse.libsdl.org/u/Torsten_Giebl)\
**Post date:** [October 27, 2007, 10:00pm UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923/2 "2007-10-27T22:00:22Z")

</div>

Hello !

> Is there any way to get SDL to tell you the maximum width and height  
> that you can make a window? I want to know the width and height to  
> pass to SDL\_SetVideoMode() when I start an app or go to fullscreen  
> mode with SDL\_WM\_ToggleFullScreen().

Use SDL\_SetVideoMode with Width=0 and Height=0.

Look at this :

[http://www.libsdl.org/cgi/docwiki.cgi/SDL\_5fSetVideoMode](http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSetVideoMode)

CU

---

<div class="post-metadata">

**Author:** ![mogumbo](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/mogumbo/32/704_2.png) [@mogumbo](https://discourse.libsdl.org/u/mogumbo)\
**Post date:** [October 29, 2007, 5:53am UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923/3 "2007-10-29T05:53:46Z")

</div>

Hi again,  
Thanks for the reply Torsten. Unfortunately I’m still having trouble.  
I’m using SDL 1.2.11. If I pass 0 for both width and height to  
SDL\_SetVideoMode() I use my full display resolution the first time.  
But if I resize the display to something smaller and then try to go to  
fullscreen again, I end up with the smaller display size. In other  
words:

surface = SDL\_SetVideoMode(0, 0, 32, SDL\_OPENGL | SDL\_RESIZABLE |  
SDL\_FULLSCREEN);

surface-\>w is 1280  
surface-\>h is 1024

surface = SDL\_SetVideoMode(800, 600, 32, SDL\_OPENGL | SDL\_RESIZABLE);

surface-\>w is 800  
surface-\>h is 600

surface = SDL\_SetVideoMode(0, 0, 32, SDL\_OPENGL | SDL\_RESIZABLE |  
SDL\_FULLSCREEN);

surface-\>w is 800  
surface-\>h is 600

SDL\_GetVideoInfo() reports the same numbers as my SDL\_Surface. Any  
other suggestions? I suppose I could start my app in fullscreen mode  
and save the original dimensions for later use, but I would prefer to  
start it in a smaller window.

- Terry\> Message: 5

> Date: Sun, 28 Oct 2007 00:00:22 +0200  
> From: “Torsten Giebl”   
> Subject: Re: [SDL] maximum width and height  
> To: “A list for developers using the SDL library. (includes  
> SDL-announce)”   
> Message-ID:  
>   
> Content-Type: text/plain; charset=ISO-8859-1
> 
> Hello !
> 
> > Is there any way to get SDL to tell you the maximum width and height  
> > that you can make a window? I want to know the width and height to  
> > pass to SDL\_SetVideoMode() when I start an app or go to fullscreen  
> > mode with SDL\_WM\_ToggleFullScreen().
> 
> Use SDL\_SetVideoMode with Width=0 and Height=0.
> 
> Look at this :
> 
> [http://www.libsdl.org/cgi/docwiki.cgi/SDL\_5fSetVideoMode](http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSetVideoMode)
> 
> CU

---

<div class="post-metadata">

**Author:** ![Andreas\_K\_Foerster](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Andreas\_K\_Foerster](https://discourse.libsdl.org/u/Andreas_K_Foerster)\
**Post date:** [October 29, 2007, 6:40am UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923/4 "2007-10-29T06:40:38Z")

</div>

> SDL\_GetVideoInfo() reports the same numbers as my SDL\_Surface. Any  
> other suggestions? I suppose I could start my app in fullscreen mode  
> and save the original dimensions for later use, but I would prefer to  
> start it in a smaller window.

How about using SDL\_ListModes with SDL\_FULLSCREEN in the flags?Am Sunday, dem 28. Oct 2007 schrieb Terry Welsh:

–  
AKFoerster

---

<div class="post-metadata">

**Author:** ![Torsten\_Giebl](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/torsten_giebl/32/2804_2.png) [@Torsten\_Giebl](https://discourse.libsdl.org/u/Torsten_Giebl)\
**Post date:** [October 29, 2007, 7:50am UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923/5 "2007-10-29T07:50:39Z")

</div>

Hello !

> Thanks for the reply Torsten. Unfortunately I’m still having trouble.  
> I’m using SDL 1.2.11.

Please use SDL 1.2.12 if possible.

CU

---

<div class="post-metadata">

**Author:** ![mogumbo](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/mogumbo/32/704_2.png) [@mogumbo](https://discourse.libsdl.org/u/mogumbo)\
**Post date:** [October 30, 2007, 3:06am UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923/6 "2007-10-30T03:06:09Z")

</div>

Hi,  
1.2.12 behaves the same as 1.2.11. SDL\_ListModes seems to do the  
trick. I’ll use that for now:

int fullX = 0;  
int fullY = 0;  
SDL\_Rect \*\*modes;  
modes = SDL\_ListModes(NULL, SDL\_FULLSCREEN /_| SDL\_HWSURFACE_/);  
if(modes != (SDL\_Rect \*\*)0 && modes != (SDL\_Rect \*\*)-1){  
// zeros should work, but don’t  
fullX = modes[0]-\>w;  
fullY = modes[0]-\>h;  
}–  
Terry Welsh - mogumbo ‘at’ [gmail.com](http://gmail.com)  
[www.reallyslick.com](http://www.reallyslick.com) | [www.mogumbo.com](http://www.mogumbo.com)

> Message: 4  
> Date: Mon, 29 Oct 2007 07:40:38 +0100  
> From: list at [akfoerster.de](http://akfoerster.de)  
> Subject: Re: [SDL] maximum width and height  
> To: “A list for developers using the SDL library. (includes  
> SDL-announce)”   
> Message-ID: \<20071029064038.GA3383 at [castrophe.akfoerster.de](http://castrophe.akfoerster.de)\>  
> Content-Type: text/plain; charset=us-ascii
> 
> Am Sunday, dem 28. Oct 2007 schrieb Terry Welsh:
> 
> > SDL\_GetVideoInfo() reports the same numbers as my SDL\_Surface. Any  
> > other suggestions? I suppose I could start my app in fullscreen mode  
> > and save the original dimensions for later use, but I would prefer to  
> > start it in a smaller window.
> 
> How about using SDL\_ListModes with SDL\_FULLSCREEN in the flags?
> 
> –  
> AKFoerster

---

<div class="post-metadata">

**Author:** ![Solra\_Bizna](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Solra\_Bizna](https://discourse.libsdl.org/u/Solra_Bizna)\
**Post date:** [October 31, 2007, 4:37am UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923/7 "2007-10-31T04:37:05Z")

</div>

If you’re going to do that, do it with the caveat in mind that the  
largest fullscreen resolution is not always the best. (For example,  
while my CRT supports up to 2048x1280, at 60Hz I don’t necessarily  
_want_ anything going that high.)  
-:sigma.SBOn 10/30/07, Terry Welsh wrote:

> fullX = modes[0]-\>w;  
> fullY = modes[0]-\>h;

---

<div class="post-metadata">

**Author:** ![mogumbo](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/mogumbo/32/704_2.png) [@mogumbo](https://discourse.libsdl.org/u/mogumbo)\
**Post date:** [October 31, 2007, 3:37pm UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923/8 "2007-10-31T15:37:42Z")

</div>

Hi SB,  
Well, the fullscreen resolution I get this way is 1280x1024 because  
that’s what my display is running at when I start my app. My CRT can  
also run at a much higher resolution, but it isn’t detected by this  
method. Is that what you were worried about?

Eventually I’ll want the user to be able to change between different  
fullscreen resolutions, but just switching between windowed and  
fullscreen right now is very nice for development.–  
Terry Welsh - mogumbo ‘at’ [gmail.com](http://gmail.com)  
[www.reallyslick.com](http://www.reallyslick.com) | [www.mogumbo.com](http://www.mogumbo.com)

> Message: 1  
> Date: Wed, 31 Oct 2007 04:37:05 +0000  
> From: “Solra Bizna”   
> Subject: Re: [SDL] maximum width and height  
> To: “A list for developers using the SDL library. (includes  
> SDL-announce)”   
> Message-ID:  
>   
> Content-Type: text/plain; charset=UTF-8
> 
> On 10/30/07, Terry Welsh \<@Terry\_Welsh\> wrote:
> 
> > fullX = modes[0]-\>w;  
> > fullY = modes[0]-\>h;  
> > If you’re going to do that, do it with the caveat in mind that the  
> > largest fullscreen resolution is not always the best. (For example,  
> > while my CRT supports up to 2048x1280, at 60Hz I don’t necessarily  
> > _want_ anything going that high.)  
> > -:sigma.SB

---

<div class="post-metadata">

**Author:** ![Solra\_Bizna](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Solra\_Bizna](https://discourse.libsdl.org/u/Solra_Bizna)\
**Post date:** [October 31, 2007, 5:54pm UTC](https://discourse.libsdl.org/t/maximum-width-and-height/14923/9 "2007-10-31T17:54:50Z")

</div>

> Well, the fullscreen resolution I get this way is 1280x1024 because  
> that’s what my display is running at when I start my app. My CRT can  
> also run at a much higher resolution, but it isn’t detected by this  
> method. Is that what you were worried about?  
> Yeah, but that behavior seems a little weird to me. ListModes is  
> supposed to return the list of possible modes, sorted largest to  
> smallest. Maybe 1280x1024 is the largest your card can support at your  
> bit depth?  
> Eventually I’ll want the user to be able to change between different  
> fullscreen resolutions, but just switching between windowed and  
> fullscreen right now is very nice for development.  
> Anything goes if it’s for “development” purposes, just remember to fix  
> it later. 😉

It’s worth noting that GetVideoInfo will return the current “real”  
video mode if you call it before a SetVideoMode.  
-:sigma.SBOn 10/31/07, Terry Welsh wrote:
