Wiki Page Content

Differences between revisions 7 and 8
Revision 7 as of 2011-01-03 20:00:38
Size: 2183
Editor: SheenaSmith
Comment: update content - w/ Sam
Revision 8 as of 2011-02-03 17:40:32
Size: 1938
Editor: SheenaSmith
Comment: update content - 2/1 changeset 5136
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
int SDL_VideoInit(const char* driver_name,
                  Uint32 flags
)
int SDL_VideoInit(const char* driver_name)
Line 17: Line 16:
||'''flags'''||SDL_INIT_EVENTTHREAD or 0; see [[#Remarks|Remarks]] for details||
Line 56: Line 54:
If '''flags''' is set to SDL_INIT_EVENTTHREAD it will run the event loop in a separate thread (not supported by all OSs).

SDL_VideoInit

Use this function to initialize the video subsystem, optionally specifying a video driver.

Syntax

int SDL_VideoInit(const char* driver_name)

Function Parameters

driver_name

the name of a video driver to initialize, or NULL for the default driver

Return Value

Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.

Code Examples

#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;
}

Remarks

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.

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().

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

You can use SDL_GetNumVideoDrivers() and SDL_GetVideoDriver() to find a specific driver_name.


CategoryAPI, CategoryVideo

None: SDL_VideoInit (last edited 2013-10-13 12:37:21 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit