SDL_VideoInit

Name

SDL_VideoInit -- Initialize the video subsystem.

Synopsis

#include "SDL_video.h"

int SDL_VideoInit (const char* driver_name, Uint32 flags);

Description

SDL_VideoInit initializes the video subsystem, optionally specifying a video driver.

This function initializes the video subsystem, setting up a connection to the window manager, etc, and determines the available display modes and pixel formats, but does not initialize a window or graphics mode.

Parameters

Return Value

Returns 0 on success, -1 on error.

Note: If you use this function and you haven't used the SDL_INIT_VIDEO flag with either SDL_Init or SDL_InitSubSystem, you should call SDL_VideoQuit before calling SDL_Quit.

Note: It is safe to call this function multiple times. SDL_VideoInit will call SDL_VideoQuit itself if the video subsystem has already been initialized.

Example

#include "SDL.h"

SDL_bool videoinit = SDL_FALSE;

void OnQuit() {
  if (videoinit)
    SDL_VideoQuit();
  SDL_Quit();
}

int main(int argc, char** argv) {
  if (SDL_Init(0) != 0) {
    printf("Error initializing SDL:  %s\n", SDL_GetError());
    return 1;
  }
  atexit(OnQuit);
  
  if (SDL_VideoInit(NULL, 0) != 0) {
    printf("Error initializing SDL video:  %s\n", SDL_GetError());
    return 2;
  }
  videoinit = SDL_TRUE;
  
  /* ... */
  
  return 0;
}

See Also

SDL_VideoQuit, SDL_InitSubSystem, SDL_Init


CategorySDL13API CategorySDL13APIVideo

SDL-1.3/SDL_VideoInit (last edited 2009-07-27 04:27:59 by KenBull)