docs/man3/SDL_ListModes.3
author Sam Lantinga <slouken@libsdl.org>
Wed, 08 Mar 2006 18:30:12 +0000
changeset 1486 9d77fc9d0ace
parent 181 e5bc29de3f0a
child 2283 546f7c1eb755
permissions -rw-r--r--
Re-added C runtime support for Visual C++ 5,6
slouken@181
     1
.TH "SDL_ListModes" "3" "Tue 11 Sep 2001, 23:01" "SDL" "SDL API Reference" 
slouken@0
     2
.SH "NAME"
slouken@0
     3
SDL_ListModes\- Returns a pointer to an array of available screen dimensions for the given format and video flags
slouken@0
     4
.SH "SYNOPSIS"
slouken@0
     5
.PP
slouken@0
     6
\fB#include "SDL\&.h"
slouken@0
     7
.sp
slouken@0
     8
\fBSDL_Rect **\fBSDL_ListModes\fP\fR(\fBSDL_PixelFormat *format, Uint32 flags\fR);
slouken@0
     9
.SH "DESCRIPTION"
slouken@0
    10
.PP
slouken@0
    11
Return a pointer to an array of available screen dimensions for the given format and video flags, sorted largest to smallest\&. Returns \fBNULL\fP if there are no dimensions available for a particular format, or \fB-1\fR if any dimension is okay for the given format\&.
slouken@0
    12
.PP
slouken@0
    13
If \fBformat\fR is \fBNULL\fP, the mode list will be for the format returned by \fISDL_GetVideoInfo()\fR->\fBvfmt\fR\&. The \fBflag\fR parameter is an OR\&'d combination of \fIsurface\fR flags\&. The flags are the same as those used \fI\fBSDL_SetVideoMode\fP\fR and they play a strong role in deciding what modes are valid\&. For instance, if you pass \fBSDL_HWSURFACE\fP as a flag only modes that support hardware video surfaces will be returned\&.
slouken@0
    14
.SH "EXAMPLE"
slouken@0
    15
.PP
slouken@0
    16
.nf
slouken@0
    17
\f(CWSDL_Rect **modes;
slouken@0
    18
int i;
slouken@0
    19
\&.
slouken@0
    20
\&.
slouken@0
    21
\&.
slouken@0
    22
slouken@0
    23
/* Get available fullscreen/hardware modes */
slouken@0
    24
modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
slouken@0
    25
slouken@0
    26
/* Check is there are any modes available */
slouken@0
    27
if(modes == (SDL_Rect **)0){
slouken@0
    28
  printf("No modes available!
slouken@0
    29
");
slouken@0
    30
  exit(-1);
slouken@0
    31
}
slouken@0
    32
slouken@0
    33
/* Check if or resolution is restricted */
slouken@0
    34
if(modes == (SDL_Rect **)-1){
slouken@0
    35
  printf("All resolutions available\&.
slouken@0
    36
");
slouken@0
    37
}
slouken@0
    38
else{
slouken@0
    39
  /* Print valid modes */
slouken@0
    40
  printf("Available Modes
slouken@0
    41
");
slouken@0
    42
  for(i=0;modes[i];++i)
slouken@0
    43
    printf("  %d x %d
slouken@0
    44
", modes[i]->w, modes[i]->h);
slouken@0
    45
}
slouken@0
    46
\&.
slouken@0
    47
\&.\fR
slouken@0
    48
.fi
slouken@0
    49
.PP
slouken@0
    50
.SH "SEE ALSO"
slouken@0
    51
.PP
slouken@0
    52
\fI\fBSDL_SetVideoMode\fP\fR, \fI\fBSDL_GetVideoInfo\fP\fR, \fI\fBSDL_Rect\fR\fR, \fI\fBSDL_PixelFormat\fR\fR
slouken@181
    53
...\" created by instant / docbook-to-man, Tue 11 Sep 2001, 23:01