---
name: "SDL_ListModes"
section: "3"
platform: "linux"
package: "libsdl1.2-dev"
version: "1.2.15+dfsg2-8"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_ListModes"
---

# SDL\_ListModes(3)

Returns a pointer to an array of available screen dimensions for the given format and video flags

## NAME

SDL\_ListModes - Returns a pointer to an array of available screen dimensions for the given format and video flags

## SYNOPSIS

**#include "SDL.h"**

**SDL\_Rect \*\*SDL\_ListModes**(**SDL\_PixelFormat \*format, Uint32 flags**);

## DESCRIPTION

Return a pointer to an array of available screen dimensions for the given format and video flags, sorted largest to smallest. Returns **NULL** if there are no dimensions available for a particular format, or **-1** if any dimension is okay for the given format.

If **format** is **NULL**, the mode list will be for the format returned by *SDL\_GetVideoInfo()*-\>**vfmt**. The **flag** parameter is an OR'd combination of *surface* flags. The flags are the same as those used **SDL\_SetVideoMode** and they play a strong role in deciding what modes are valid. For instance, if you pass **SDL\_HWSURFACE** as a flag only modes that support hardware video surfaces will be returned.

## EXAMPLE

```
SDL_Rect **modes;
int i;
.
.
.
/* Get available fullscreen/hardware modes */
modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
/* Check is there are any modes available */
if(modes == (SDL_Rect **)0){
  printf("No modes available!
");
  exit(-1);
}
/* Check if or resolution is restricted */
if(modes == (SDL_Rect **)-1){
  printf("All resolutions available.
");
}
else{
  /* Print valid modes */
  printf("Available Modes
");
  for(i=0;modes[i];++i)
    printf("  %d x %d
", modes[i]->w, modes[i]->h);
}
.
.
```

## SEE ALSO

**SDL\_SetVideoMode**, **SDL\_GetVideoInfo**, **SDL\_Rect**, **SDL\_PixelFormat**
