include/SDL_video.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 06 Jul 2006 07:17:11 +0000
branchSDL-1.3
changeset 1724 6c63fc2bd986
parent 1722 5daa04d862f1
child 1725 98a3207ddde8
permissions -rw-r--r--
Proof of concept done - Win32 GDI implementation mostly complete.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 /**
    24  * \file SDL_video.h
    25  *
    26  * Header file for access to the SDL raw framebuffer window
    27  */
    28 
    29 #ifndef _SDL_video_h
    30 #define _SDL_video_h
    31 
    32 #include "SDL_stdinc.h"
    33 #include "SDL_error.h"
    34 #include "SDL_pixels.h"
    35 #include "SDL_rwops.h"
    36 
    37 #include "begin_code.h"
    38 /* Set up for C function definitions, even when using C++ */
    39 #ifdef __cplusplus
    40 /* *INDENT-OFF* */
    41 extern "C" {
    42 /* *INDENT-ON* */
    43 #endif
    44 
    45 /* Transparency definitions: These define alpha as the opacity of a surface */
    46 #define SDL_ALPHA_OPAQUE 255
    47 #define SDL_ALPHA_TRANSPARENT 0
    48 
    49 /**
    50  * \struct SDL_Rect
    51  *
    52  * \brief A rectangle, with the origin at the upper left.
    53  */
    54 typedef struct SDL_Rect
    55 {
    56     Sint16 x, y;
    57     Uint16 w, h;
    58 } SDL_Rect;
    59 
    60 /**
    61  * \struct SDL_DisplayMode
    62  *
    63  * \brief  The structure that defines a display mode
    64  *
    65  * \sa SDL_GetNumDisplayModes()
    66  * \sa SDL_GetDisplayMode()
    67  * \sa SDL_GetDesktopDisplayMode()
    68  * \sa SDL_GetCurrentDisplayMode()
    69  * \sa SDL_GetClosestDisplayMode()
    70  * \sa SDL_SetDisplayMode()
    71  */
    72 typedef struct
    73 {
    74     Uint32 format;              /**< pixel format */
    75     int w;                      /**< width */
    76     int h;                      /**< height */
    77     int refresh_rate;           /**< refresh rate (or zero for unspecified) */
    78 } SDL_DisplayMode;
    79 
    80 /**
    81  * \typedef SDL_WindowID
    82  *
    83  * \brief The type used to identify a window
    84  *
    85  * \sa SDL_CreateWindow()
    86  * \sa SDL_CreateWindowFrom()
    87  * \sa SDL_DestroyWindow()
    88  * \sa SDL_GetWindowData()
    89  * \sa SDL_GetWindowFlags()
    90  * \sa SDL_GetWindowGrab()
    91  * \sa SDL_GetWindowPosition()
    92  * \sa SDL_GetWindowSize()
    93  * \sa SDL_GetWindowTitle()
    94  * \sa SDL_HideWindow()
    95  * \sa SDL_MaximizeWindow()
    96  * \sa SDL_MinimizeWindow()
    97  * \sa SDL_RaiseWindow()
    98  * \sa SDL_RestoreWindow()
    99  * \sa SDL_SetWindowData()
   100  * \sa SDL_SetWindowGrab()
   101  * \sa SDL_SetWindowIcon()
   102  * \sa SDL_SetWindowPosition()
   103  * \sa SDL_SetWindowSize()
   104  * \sa SDL_SetWindowTitle()
   105  * \sa SDL_ShowWindow()
   106  */
   107 typedef Uint32 SDL_WindowID;
   108 
   109 /**
   110  * \enum SDL_WindowFlags
   111  *
   112  * \brief The flags on a window
   113  *
   114  * \sa SDL_GetWindowFlags()
   115  */
   116 typedef enum
   117 {
   118     SDL_WINDOW_FULLSCREEN = 0x00000001,         /**< fullscreen window, implies borderless */
   119     SDL_WINDOW_OPENGL = 0x00000002,             /**< window usable with OpenGL context */
   120     SDL_WINDOW_SHOWN = 0x00000004,              /**< window is visible */
   121     SDL_WINDOW_BORDERLESS = 0x00000008,         /**< no window decoration */
   122     SDL_WINDOW_RESIZABLE = 0x00000010,          /**< window can be resized */
   123     SDL_WINDOW_MINIMIZED = 0x00000020,          /**< minimized */
   124     SDL_WINDOW_MAXIMIZED = 0x00000040,          /**< maximized */
   125     SDL_WINDOW_INPUT_GRABBED = 0x00000100,      /**< window has grabbed input focus */
   126     SDL_WINDOW_KEYBOARD_FOCUS = 0x00000200,     /**< window has keyboard focus */
   127     SDL_WINDOW_MOUSE_FOCUS = 0x00000400,        /**< window has mouse focus */
   128 } SDL_WindowFlags;
   129 
   130 /**
   131  * \def SDL_WINDOWPOS_UNDEFINED
   132  * \brief Used to indicate that you don't care what the window position is.
   133  */
   134 #define SDL_WINDOWPOS_UNDEFINED 0x7FFFFFF
   135 /**
   136  * \def SDL_WINDOWPOS_CENTERED
   137  * \brief Used to indicate that the window position should be centered.
   138  */
   139 #define SDL_WINDOWPOS_CENTERED  0x7FFFFFE
   140 
   141 /**
   142  * \enum SDL_WindowEventID
   143  *
   144  * \brief Event subtype for window events
   145  */
   146 typedef enum
   147 {
   148     SDL_WINDOWEVENT_NONE,               /**< Never used */
   149     SDL_WINDOWEVENT_SHOWN,              /**< Window has been shown */
   150     SDL_WINDOWEVENT_HIDDEN,             /**< Window has been hidden */
   151     SDL_WINDOWEVENT_EXPOSED,            /**< Window has been exposed and should be redrawn */
   152     SDL_WINDOWEVENT_MOVED,              /**< Window has been moved to data1,data2 */
   153     SDL_WINDOWEVENT_RESIZED,            /**< Window size changed to data1xdata2 */
   154     SDL_WINDOWEVENT_MINIMIZED,          /**< Window has been minimized */
   155     SDL_WINDOWEVENT_MAXIMIZED,          /**< Window has been maximized */
   156     SDL_WINDOWEVENT_RESTORED,           /**< Window has been restored to normal size and position */
   157     SDL_WINDOWEVENT_ENTER,              /**< The window has gained mouse focus */
   158     SDL_WINDOWEVENT_LEAVE,              /**< The window has lost mouse focus */
   159     SDL_WINDOWEVENT_FOCUS_GAINED,       /**< The window has gained keyboard focus */
   160     SDL_WINDOWEVENT_FOCUS_LOST,         /**< The window has lost keyboard focus */
   161     SDL_WINDOWEVENT_CLOSE,                              /**< The window manager requests that the window be closed */
   162 } SDL_WindowEventID;
   163 
   164 /**
   165  * \enum SDL_RendererFlags
   166  *
   167  * \brief Flags used when initializing a render manager.
   168  */
   169 typedef enum
   170 {
   171     SDL_Renderer_PresentDiscard = 0x00000001,   /**< Present leaves the contents of the backbuffer undefined */
   172     SDL_Renderer_PresentCopy = 0x00000002,      /**< Present uses a copy from back buffer to the front buffer */
   173     SDL_Renderer_PresentFlip2 = 0x00000004,     /**< Present uses a flip, swapping back buffer and front buffer */
   174     SDL_Renderer_PresentFlip3 = 0x00000008,     /**< Present uses a flip, rotating between two back buffers and a front buffer */
   175     SDL_Renderer_PresentVSync = 0x00000010,     /**< Present is synchronized with the refresh rate */
   176     SDL_Renderer_RenderTarget = 0x00000020,     /**< The renderer can create texture render targets */
   177     SDL_Renderer_Accelerated = 0x00000040,      /**< The renderer uses hardware acceleration */
   178     SDL_Renderer_Minimal = 0x00000080,          /**< The renderer only supports the read/write pixel and present functions */
   179 } SDL_RendererFlags;
   180 
   181 /**
   182  * \struct SDL_RendererInfo
   183  *
   184  * \brief Information on the capabilities of a render manager.
   185  */
   186 typedef struct SDL_RendererInfo
   187 {
   188     const char *name;           /**< The name of the renderer */
   189     Uint32 flags;               /**< Supported SDL_RendererFlags */
   190     Uint32 blend_modes;         /**< A mask of supported blend modes */
   191     Uint32 scale_modes;         /**< A mask of supported scale modes */
   192     Uint32 num_texture_formats; /**< The number of available texture formats */
   193     Uint32 texture_formats[32]; /**< The available texture formats */
   194     int max_texture_width;      /**< The maximimum texture width */
   195     int max_texture_height;     /**< The maximimum texture height */
   196 } SDL_RendererInfo;
   197 
   198 /**
   199  * \enum SDL_TextureAccess
   200  *
   201  * \brief The access pattern allowed for a texture
   202  */
   203 typedef enum
   204 {
   205     SDL_TextureAccess_Render,   /**< Unlockable video memory, rendering allowed */
   206     SDL_TextureAccess_Remote,   /**< Unlockable video memory */
   207     SDL_TextureAccess_Local,    /**< Lockable system memory */
   208 } SDL_TextureAccess;
   209 
   210 /**
   211  * \enum SDL_TextureBlendMode
   212  *
   213  * \brief The blend mode used in SDL_RenderCopy()
   214  */
   215 typedef enum
   216 {
   217     SDL_TextureBlendMode_None = 0x00000000,     /**< No blending */
   218     SDL_TextureBlendMode_Mask = 0x00000001,     /**< dst = A ? src : dst (alpha is mask) */
   219     SDL_TextureBlendMode_Blend = 0x00000002,    /**< dst = (src * A) + (dst * (1-A)) */
   220     SDL_TextureBlendMode_Add = 0x00000004,      /**< dst = (src * A) + dst */
   221     SDL_TextureBlendMode_Mod = 0x00000008,      /**< dst = src * dst */
   222 } SDL_TextureBlendMode;
   223 
   224 /**
   225  * \enum SDL_TextureScaleMode
   226  *
   227  * \brief The scale mode used in SDL_RenderCopy()
   228  */
   229 typedef enum
   230 {
   231     SDL_TextureScaleMode_None = 0x00000000,     /**< No scaling, rectangles must match dimensions */
   232     SDL_TextureScaleMode_Fast = 0x00000001,     /**< Point sampling or equivalent algorithm */
   233     SDL_TextureScaleMode_Slow = 0x00000002,     /**< Linear filtering or equivalent algorithm */
   234     SDL_TextureScaleMode_Best = 0x00000004,     /**< Bicubic filtering or equivalent algorithm */
   235 } SDL_TextureScaleMode;
   236 
   237 /**
   238  * \typedef SDL_TextureID
   239  *
   240  * \brief An efficient driver-specific representation of pixel data
   241  */
   242 typedef Uint32 SDL_TextureID;
   243 
   244 
   245 /* These are the currently supported flags for the SDL_surface */
   246 /* Used internally (read-only) */
   247 #define SDL_HWSURFACE       0x00000001  /* Surface represents a texture */
   248 #define SDL_PREALLOC        0x00000002  /* Surface uses preallocated memory */
   249 #define SDL_SRCALPHA        0x00000004  /* Blit uses source alpha blending */
   250 #define SDL_SRCCOLORKEY     0x00000008  /* Blit uses a source color key */
   251 #define SDL_RLEACCELOK      0x00000010  /* Private flag */
   252 #define SDL_RLEACCEL        0x00000020  /* Surface is RLE encoded */
   253 
   254 /* Evaluates to true if the surface needs to be locked before access */
   255 #define SDL_MUSTLOCK(S)	(((S)->flags & (SDL_HWSURFACE|SDL_RLEACCEL)) != 0)
   256 
   257 /* This structure should be treated as read-only, except for 'pixels',
   258    which, if not NULL, contains the raw pixel data for the surface.
   259 */
   260 typedef struct SDL_Surface
   261 {
   262     Uint32 flags;               /* Read-only */
   263     SDL_PixelFormat *format;    /* Read-only */
   264     int w, h;                   /* Read-only */
   265     int pitch;                  /* Read-only */
   266     void *pixels;               /* Read-write */
   267 
   268     /* texture associated with the surface, if any */
   269     SDL_TextureID textureID;
   270 
   271     /* information needed for surfaces requiring locks */
   272     int locked;
   273     void *lock_data;
   274 
   275     /* clipping information */
   276     SDL_Rect clip_rect;         /* Read-only */
   277 
   278     /* info for fast blit mapping to other surfaces */
   279     struct SDL_BlitMap *map;    /* Private */
   280 
   281     /* format version, bumped at every change to invalidate blit maps */
   282     unsigned int format_version;        /* Private */
   283 
   284     /* Reference count -- used when freeing surface */
   285     int refcount;               /* Read-mostly */
   286 } SDL_Surface;
   287 
   288 /* typedef for private surface blitting functions */
   289 typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
   290                          struct SDL_Surface * dst, SDL_Rect * dstrect);
   291 
   292 
   293 /**
   294  * \enum SDL_GLattr
   295  *
   296  * \brief OpenGL configuration attributes
   297  */
   298 typedef enum
   299 {
   300     SDL_GL_RED_SIZE,
   301     SDL_GL_GREEN_SIZE,
   302     SDL_GL_BLUE_SIZE,
   303     SDL_GL_ALPHA_SIZE,
   304     SDL_GL_BUFFER_SIZE,
   305     SDL_GL_DOUBLEBUFFER,
   306     SDL_GL_DEPTH_SIZE,
   307     SDL_GL_STENCIL_SIZE,
   308     SDL_GL_ACCUM_RED_SIZE,
   309     SDL_GL_ACCUM_GREEN_SIZE,
   310     SDL_GL_ACCUM_BLUE_SIZE,
   311     SDL_GL_ACCUM_ALPHA_SIZE,
   312     SDL_GL_STEREO,
   313     SDL_GL_MULTISAMPLEBUFFERS,
   314     SDL_GL_MULTISAMPLESAMPLES,
   315     SDL_GL_ACCELERATED_VISUAL,
   316     SDL_GL_SWAP_CONTROL
   317 } SDL_GLattr;
   318 
   319 
   320 /* Function prototypes */
   321 
   322 /**
   323  * \fn int SDL_GetNumVideoDrivers(void)
   324  *
   325  * \brief Get the number of video drivers compiled into SDL
   326  *
   327  * \sa SDL_GetVideoDriver()
   328  */
   329 extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
   330 
   331 /**
   332  * \fn const char *SDL_GetVideoDriver(int index)
   333  *
   334  * \brief Get the name of a built in video driver.
   335  *
   336  * \note The video drivers are presented in the order in which they are
   337  * normally checked during initialization.
   338  *
   339  * \sa SDL_GetNumVideoDrivers()
   340  */
   341 extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
   342 
   343 /**
   344  * \fn int SDL_VideoInit(const char *driver_name, Uint32 flags)
   345  *
   346  * \brief Initialize the video subsystem, optionally specifying a video driver.
   347  *
   348  * \param driver_name Initialize a specific driver by name, or NULL for the default video driver.
   349  * \param flags FIXME: Still needed?
   350  *
   351  * \return 0 on success, -1 on error
   352  *
   353  * This function initializes the video subsystem; setting up a connection
   354  * to the window manager, etc, and determines the available display modes
   355  * and pixel formats, but does not initialize a window or graphics mode.
   356  *
   357  * \sa SDL_VideoQuit()
   358  */
   359 extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name,
   360                                           Uint32 flags);
   361 
   362 /**
   363  * \fn void SDL_VideoQuit(void)
   364  *
   365  * \brief Shuts down the video subsystem.
   366  *
   367  * This function closes all windows, and restores the original video mode.
   368  *
   369  * \sa SDL_VideoInit()
   370  */
   371 extern DECLSPEC void SDLCALL SDL_VideoQuit(void);
   372 
   373 /**
   374  * \fn const char *SDL_GetCurrentVideoDriver(void)
   375  *
   376  * \brief Returns the name of the currently initialized video driver.
   377  *
   378  * \return The name of the current video driver or NULL if no driver
   379  *         has been initialized
   380  *
   381  * \sa SDL_GetNumVideoDrivers()
   382  * \sa SDL_GetVideoDriver()
   383  */
   384 extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
   385 
   386 /**
   387  * \fn int SDL_GetNumVideoDisplays(void)
   388  *
   389  * \brief Returns the number of available video displays.
   390  *
   391  * \sa SDL_SelectVideoDisplay()
   392  */
   393 extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
   394 
   395 /**
   396  * \fn int SDL_SelectVideoDisplay(int index)
   397  *
   398  * \brief Set the index of the currently selected display.
   399  *
   400  * \return The index of the currently selected display.
   401  *
   402  * \note You can query the currently selected display by passing an index of -1.
   403  *
   404  * \sa SDL_GetNumVideoDisplays()
   405  */
   406 extern DECLSPEC int SDLCALL SDL_SelectVideoDisplay(int index);
   407 
   408 /**
   409  * \fn int SDL_GetNumDisplayModes(void)
   410  *
   411  * \brief Returns the number of available display modes for the current display.
   412  *
   413  * \sa SDL_GetDisplayMode()
   414  */
   415 extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void);
   416 
   417 /**
   418  * \fn const SDL_DisplayMode *SDL_GetDisplayMode(int index)
   419  *
   420  * \brief Retrieve information about a specific display mode.
   421  *
   422  * \note The display modes are sorted in this priority:
   423  *       \li bits per pixel -> more colors to fewer colors
   424  *       \li width -> largest to smallest
   425  *       \li height -> largest to smallest
   426  *       \li refresh rate -> highest to lowest
   427  *
   428  * \sa SDL_GetNumDisplayModes()
   429  */
   430 extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetDisplayMode(int index);
   431 
   432 /**
   433  * \fn const SDL_DisplayMode *SDL_GetDesktopDisplayMode(void)
   434  *
   435  * \brief Retrieve information about the desktop display mode for the current display.
   436  */
   437 extern DECLSPEC const SDL_DisplayMode *SDLCALL
   438 SDL_GetDesktopDisplayMode(void);
   439 
   440 /**
   441  * \fn const SDL_DisplayMode *SDL_GetCurrentDisplayMode(void)
   442  *
   443  * \brief Retrieve information about the current display mode.
   444  */
   445 extern DECLSPEC const SDL_DisplayMode *SDLCALL
   446 SDL_GetCurrentDisplayMode(void);
   447 
   448 /**
   449  * \fn SDL_DisplayMode *SDL_GetClosestDisplayMode(const SDL_DisplayMode *mode, SDL_DisplayMode *closest)
   450  *
   451  * \brief Get the closest match to the requested display mode.
   452  *
   453  * \param mode The desired display mode
   454  * \param closest A pointer to a display mode to be filled in with the closest match of the available display modes.
   455  *
   456  * \return The passed in value 'closest', or NULL if no matching video mode was available.
   457  *
   458  * The available display modes are scanned, and 'closest' is filled in with the closest mode matching the requested mode and returned.  The mode format and refresh_rate default to the desktop mode if they are 0.  The modes are scanned with size being first priority, format being second priority, and finally checking the refresh_rate.  If all the available modes are too small, then NULL is returned.
   459  *
   460  * \sa SDL_GetNumDisplayModes()
   461  * \sa SDL_GetDisplayMode()
   462  */
   463 extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(const
   464                                                                    SDL_DisplayMode
   465                                                                    * mode,
   466                                                                    SDL_DisplayMode
   467                                                                    * closest);
   468 
   469 /**
   470  * \fn int SDL_SetDisplayMode(const SDL_DisplayMode *mode)
   471  *
   472  * \brief Set up the closest available mode on the current display.
   473  *
   474  * \param mode The desired display mode, or NULL to set the desktop mode.
   475  *
   476  * \return 0 on success, or -1 if setting the display mode failed.
   477  */
   478 extern DECLSPEC int SDLCALL SDL_SetDisplayMode(const SDL_DisplayMode * mode);
   479 
   480 /**
   481  * \fn int SDL_SetDisplayPalette(const SDL_Color *colors, int firstcolor, int ncolors)
   482  *
   483  * \brief Set the palette entries for indexed display modes.
   484  *
   485  * \return 0 on success, or -1 if the display mode isn't palettized or the colors couldn't be set.
   486  */
   487 extern DECLSPEC int SDLCALL SDL_SetDisplayPalette(const SDL_Color * colors,
   488                                                   int firstcolor,
   489                                                   int ncolors);
   490 
   491 /**
   492  * \fn int SDL_GetDisplayPalette(SDL_Color *colors, int firstcolor, int ncolors)
   493  *
   494  * \brief Gets the palette entries for indexed display modes.
   495  *
   496  * \return 0 on success, or -1 if the display mode isn't palettized
   497  */
   498 extern DECLSPEC int SDLCALL SDL_GetDisplayPalette(SDL_Color * colors,
   499                                                   int firstcolor,
   500                                                   int ncolors);
   501 
   502 /**
   503  * \fn SDL_WindowID SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
   504  *
   505  * \brief Create a window with the specified position, dimensions, and flags.
   506  *
   507  * \param title The title of the window
   508  * \param x The x position of the window
   509  * \param y The y position of the window
   510  * \param w The width of the window
   511  * \param h The height of the window
   512  * \param flags The flags for the window
   513  *
   514  * \return The id of the window created, or zero if window creation failed.
   515  *
   516  * \note Setting the position to -1, -1, indicates any position is fine.
   517  *
   518  * \sa SDL_DestroyWindow()
   519  */
   520 extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindow(const char *title,
   521                                                       int x, int y, int w,
   522                                                       int h, Uint32 flags);
   523 
   524 /**
   525  * \fn SDL_WindowID SDL_CreateWindowFrom(void *data)
   526  *
   527  * \brief Create an SDL window struct from an existing native window.
   528  *
   529  * \param data A pointer to driver-dependent window creation data
   530  *
   531  * \return The id of the window created, or zero if window creation failed.
   532  *
   533  * \warning This function is NOT SUPPORTED, use at your own risk!
   534  *
   535  * \sa SDL_DestroyWindow()
   536  */
   537 extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindowFrom(const void *data);
   538 
   539 /**
   540  * \fn Uint32 SDL_GetWindowFlags(SDL_WindowID windowID)
   541  *
   542  * \brief Get the window flags.
   543  */
   544 extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_WindowID windowID);
   545 
   546 /**
   547  * \fn void SDL_SetWindowTitle(SDL_WindowID windowID, const char *title)
   548  *
   549  * \brief Set the title of the window, in UTF-8 format.
   550  *
   551  * \sa SDL_GetWindowTitle()
   552  */
   553 extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_WindowID windowID,
   554                                                 const char *title);
   555 
   556 /**
   557  * \fn const char *SDL_GetWindowTitle(SDL_WindowID windowID)
   558  *
   559  * \brief Get the title of the window, in UTF-8 format.
   560  *
   561  * \sa SDL_SetWindowTitle()
   562  */
   563 extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_WindowID windowID);
   564 
   565 /**
   566  * \fn void SDL_SetWindowIcon(SDL_Surface *icon)
   567  *
   568  * \brief Set the icon of the window.
   569  *
   570  * \param icon The icon for the window
   571  *
   572  * FIXME: The icon needs to be set before the window is first shown.  Should some icon representation be part of the window creation data?
   573  */
   574 extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Surface * icon);
   575 
   576 /**
   577  * \fn void SDL_SetWindowData(SDL_WindowID windowID, void *userdata)
   578  *
   579  * \brief Associate an arbitrary pointer with the window.
   580  *
   581  * \sa SDL_GetWindowData()
   582  */
   583 extern DECLSPEC void SDLCALL SDL_SetWindowData(SDL_WindowID windowID,
   584                                                void *userdata);
   585 
   586 /**
   587  * \fn void *SDL_GetWindowData(SDL_WindowID windowID)
   588  *
   589  * \brief Retrieve the data pointer associated with the window.
   590  *
   591  * \sa SDL_SetWindowData()
   592  */
   593 extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_WindowID windowID);
   594 
   595 /**
   596  * \fn void SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y)
   597  *
   598  * \brief Set the position of the window.
   599  *
   600  * \param windowID The window to reposition
   601  * \param x The x coordinate of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
   602  * \param y The y coordinate of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
   603  *
   604  * \note The window coordinate origin is the upper left of the display.
   605  *
   606  * \sa SDL_GetWindowPosition()
   607  */
   608 extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_WindowID windowID,
   609                                                    int x, int y);
   610 
   611 /**
   612  * \fn void SDL_GetWindowPosition(SDL_WindowID windowID, int *x, int *y)
   613  *
   614  * \brief Get the position of the window.
   615  *
   616  * \sa SDL_SetWindowPosition()
   617  */
   618 extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_WindowID windowID,
   619                                                    int *x, int *y);
   620 
   621 /**
   622  * \fn void SDL_SetWindowSize(SDL_WindowID windowID, int w, int w)
   623  *
   624  * \brief Set the size of the window's client area.
   625  *
   626  * \note You can't change the size of a fullscreen window, it automatically
   627  * matches the size of the display mode.
   628  *
   629  * \sa SDL_GetWindowSize()
   630  */
   631 extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_WindowID windowID, int w,
   632                                                int h);
   633 
   634 /**
   635  * \fn void SDL_GetWindowSize(SDL_WindowID windowID, int *w, int *w)
   636  *
   637  * \brief Get the size of the window's client area.
   638  *
   639  * \sa SDL_SetWindowSize()
   640  */
   641 extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_WindowID windowID, int *w,
   642                                                int *h);
   643 
   644 /**
   645  * \fn void SDL_ShowWindow(SDL_WindowID windowID)
   646  *
   647  * \brief Show the window
   648  *
   649  * \sa SDL_HideWindow()
   650  */
   651 extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_WindowID windowID);
   652 
   653 /**
   654  * \fn void SDL_HideWindow(SDL_WindowID windowID)
   655  *
   656  * \brief Hide the window
   657  *
   658  * \sa SDL_ShowWindow()
   659  */
   660 extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_WindowID windowID);
   661 
   662 /**
   663  * \fn void SDL_RaiseWindow(SDL_WindowID windowID)
   664  *
   665  * \brief Raise the window so it's above other windows.
   666  */
   667 extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_WindowID windowID);
   668 
   669 /**
   670  * \fn void SDL_MaximizeWindow(SDL_WindowID windowID)
   671  *
   672  * \brief Make the window as large as possible.
   673  *
   674  * \sa SDL_RestoreWindow()
   675  */
   676 extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_WindowID windowID);
   677 
   678 /**
   679  * \fn void SDL_MinimizeWindow(SDL_WindowID windowID)
   680  *
   681  * \brief Minimize the window to an iconic representation.
   682  *
   683  * \sa SDL_RestoreWindow()
   684  */
   685 extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_WindowID windowID);
   686 
   687 /**
   688  * \fn void SDL_RestoreWindow(SDL_WindowID windowID)
   689  *
   690  * \brief Restore the size and position of a minimized or maximized window.
   691  *
   692  * \sa SDL_MaximizeWindow()
   693  * \sa SDL_MinimizeWindow()
   694  */
   695 extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_WindowID windowID);
   696 
   697 /**
   698  * \fn void SDL_SetWindowGrab(SDL_WindowID windowID, int mode)
   699  *
   700  * \brief Set the window's input grab mode.
   701  *
   702  * \param mode This is 1 to grab input, and 0 to release input.
   703  *
   704  * \sa SDL_GrabMode
   705  * \sa SDL_GetWindowGrab()
   706  */
   707 extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_WindowID windowID,
   708                                                int mode);
   709 
   710 /**
   711  * \fn int SDL_GetWindowGrab(SDL_WindowID windowID)
   712  *
   713  * \brief Get the window's input grab mode.
   714  *
   715  * \return This returns 1 if input is grabbed, and 0 otherwise.
   716  *
   717  * \sa SDL_GrabMode
   718  * \sa SDL_SetWindowGrab()
   719  */
   720 extern DECLSPEC int SDLCALL SDL_GetWindowGrab(SDL_WindowID windowID);
   721 
   722 /**
   723  * \fn SDL_bool SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo * info)
   724  *
   725  * \brief Get driver specific information about a window.
   726  *
   727  * \note Include SDL_syswm.h for the declaration of SDL_SysWMinfo.
   728  */
   729 struct SDL_SysWMinfo;
   730 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_WindowID windowID,
   731                                                      struct SDL_SysWMinfo
   732                                                      *info);
   733 
   734 /**
   735  * \fn void SDL_DestroyWindow(SDL_WindowID windowID)
   736  *
   737  * \brief Destroy a window.
   738  */
   739 extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_WindowID windowID);
   740 
   741 /**
   742  * \fn int SDL_GetNumRenderers(void)
   743  *
   744  * \brief Get the number of render managers on the current display.
   745  *
   746  * A render manager is a set of code that handles rendering and texture
   747  * management on a particular display.  Normally there is only one, but
   748  * some drivers may have several available with different capabilities.
   749  *
   750  * \sa SDL_GetRendererInfo()
   751  * \sa SDL_CreateRenderer()
   752  */
   753 extern DECLSPEC int SDLCALL SDL_GetNumRenderers(void);
   754 
   755 /**
   756  * \fn SDL_RendererInfo *SDL_GetRendererInfo(int index)
   757  *
   758  * \brief Get information about a specific render manager on the current
   759  *        display.
   760  *
   761  * \sa SDL_CreateRenderer()
   762  */
   763 extern DECLSPEC int SDLCALL SDL_GetRendererInfo(int index,
   764                                                 SDL_RendererInfo * info);
   765 
   766 /**
   767  * \fn int SDL_CreateRenderer(SDL_WindowID window, int index, Uint32 flags)
   768  *
   769  * \brief Create and make active a 2D rendering context for a window.
   770  *
   771  * \param windowID The window used for rendering
   772  * \param index The index of the render manager to initialize, or -1 to initialize the first one supporting the requested flags.
   773  * \param flags SDL_RendererFlags
   774  *
   775  * \return 0 on success, -1 if the flags were not supported, or -2 if
   776  *         there isn't enough memory to support the requested flags
   777  *
   778  * \sa SDL_SelectRenderer()
   779  * \sa SDL_DestroyRenderer()
   780  */
   781 extern DECLSPEC int SDLCALL SDL_CreateRenderer(SDL_WindowID windowID,
   782                                                int index, Uint32 flags);
   783 
   784 /**
   785  * \fn int SDL_SelectRenderer(SDL_WindowID windowID)
   786  *
   787  * \brief Select the rendering context for a particular window.
   788  *
   789  * \return 0 on success, -1 if the selected window doesn't have a
   790  *         rendering context.
   791  */
   792 extern DECLSPEC int SDLCALL SDL_SelectRenderer(SDL_WindowID windowID);
   793 
   794 /**
   795  * \fn SDL_TextureID SDL_CreateTexture(Uint32 format, int access, int w, int h)
   796  *
   797  * \brief Create a texture for the current rendering context.
   798  *
   799  * \param format The format of the texture
   800  * \param access One of the enumerated values in SDL_TextureAccess
   801  * \param w The width of the texture in pixels
   802  * \param h The height of the texture in pixels
   803  *
   804  * \return The created texture is returned, or 0 if no render manager was active,  the format was unsupported, or the width or height were out of range.
   805  *
   806  * \sa SDL_QueryTexture()
   807  * \sa SDL_DestroyTexture()
   808  */
   809 extern DECLSPEC SDL_TextureID SDLCALL SDL_CreateTexture(Uint32 format,
   810                                                         int access, int w,
   811                                                         int h);
   812 
   813 /**
   814  * \fn SDL_TextureID SDL_CreateTextureFromSurface(Uint32 format, int access, SDL_Surface *surface)
   815  *
   816  * \brief Create a texture from an existing surface.
   817  *
   818  * \param format The format of the texture, or 0 to pick an appropriate format
   819  * \param access One of the enumerated values in SDL_TextureAccess
   820  * \param surface The surface containing pixel data used to fill the texture
   821  *
   822  * \return The created texture is returned, or 0 if no render manager was active,  the format was unsupported, or the surface width or height were out of range.
   823  *
   824  * \note The surface is not modified or freed by this function.
   825  *
   826  * \sa SDL_QueryTexture()
   827  * \sa SDL_DestroyTexture()
   828  */
   829 extern DECLSPEC SDL_TextureID SDLCALL SDL_CreateTextureFromSurface(Uint32
   830                                                                    format,
   831                                                                    int access,
   832                                                                    SDL_Surface
   833                                                                    * surface);
   834 
   835 /**
   836  * \fn int SDL_QueryTexture(SDL_TextureID textureID, Uint32 *format, int *access, int *w, int *h)
   837  *
   838  * \brief Query the attributes of a texture
   839  *
   840  * \param texture A texture to be queried
   841  * \param format A pointer filled in with the raw format of the texture.  The actual format may differ, but pixel transfers will use this format.
   842  * \param access A pointer filled in with the actual access to the texture.
   843  * \param w A pointer filled in with the width of the texture in pixels
   844  * \param h A pointer filled in with the height of the texture in pixels
   845  *
   846  * \return 0 on success, or -1 if the texture is not valid
   847  */
   848 extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_TextureID textureID,
   849                                              Uint32 * format, int *access,
   850                                              int *w, int *h);
   851 
   852 /**
   853  * \fn int SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int pitch)
   854  *
   855  * \brief Query the pixels of a texture, if the texture does not need to be locked for pixel access.
   856  *
   857  * \param texture A texture to be queried, which was created with SDL_TextureAccess_Local
   858  * \param pixels A pointer filled with a pointer to the pixels for the texture 
   859  * \param pitch A pointer filled in with the pitch of the pixel data
   860  *
   861  * \return 0 on success, or -1 if the texture is not valid, or must be locked for pixel access.
   862  */
   863 extern DECLSPEC int SDLCALL SDL_QueryTexturePixels(SDL_TextureID textureID,
   864                                                    void **pixels, int *pitch);
   865 
   866 /**
   867  * \fn int SDL_SetTexturePalette(SDL_TextureID textureID, const SDL_Color * colors, int firstcolor, int ncolors)
   868  *
   869  * \brief Update an indexed texture with a color palette
   870  *
   871  * \param texture The texture to update
   872  * \param colors The array of RGB color data
   873  * \param firstcolor The first index to update
   874  * \param ncolors The number of palette entries to fill with the color data
   875  *
   876  * \return 0 on success, or -1 if the texture is not valid or not an indexed texture
   877  */
   878 extern DECLSPEC int SDLCALL SDL_SetTexturePalette(SDL_TextureID textureID,
   879                                                   const SDL_Color * colors,
   880                                                   int firstcolor,
   881                                                   int ncolors);
   882 
   883 /**
   884  * \fn int SDL_GetTexturePalette(SDL_TextureID textureID, SDL_Color * colors, int firstcolor, int ncolors)
   885  *
   886  * \brief Update an indexed texture with a color palette
   887  *
   888  * \param texture The texture to update
   889  * \param colors The array to fill with RGB color data
   890  * \param firstcolor The first index to retrieve
   891  * \param ncolors The number of palette entries to retrieve
   892  *
   893  * \return 0 on success, or -1 if the texture is not valid or not an indexed texture
   894  */
   895 extern DECLSPEC int SDLCALL SDL_GetTexturePalette(SDL_TextureID textureID,
   896                                                   SDL_Color * colors,
   897                                                   int firstcolor,
   898                                                   int ncolors);
   899 
   900 /**
   901  * \fn int SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect *rect, const void *pixels, int pitch)
   902  *
   903  * \brief Update the given texture rectangle with new pixel data.
   904  *
   905  * \param texture The texture to update
   906  * \param rect A pointer to the rectangle of pixels to update, or NULL to update the entire texture.
   907  * \param pixels The raw pixel data
   908  * \param pitch The number of bytes between rows of pixel data
   909  *
   910  * \return 0 on success, or -1 if the texture is not valid
   911  *
   912  * \note This is a very slow function for textures not created with SDL_TextureAccess_Local.
   913  */
   914 extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_TextureID textureID,
   915                                               const SDL_Rect * rect,
   916                                               const void *pixels, int pitch);
   917 
   918 /**
   919  * \fn void SDL_LockTexture(SDL_TextureID textureID, const SDL_Rect *rect, int markDirty, void **pixels, int *pitch)
   920  *
   921  * \brief Lock a portion of the texture for pixel access.
   922  *
   923  * \param texture The texture to lock for access, which must have been created with SDL_TextureAccess_Local.
   924  * \param rect A pointer to the rectangle to lock for access. If the rect is NULL, the entire texture will be locked.
   925  * \param markDirty If this is nonzero, the locked area will be marked dirty when the texture is unlocked.
   926  * \param pixels This is filled in with a pointer to the locked pixels, appropriately offset by the locked area.
   927  * \param pitch This is filled in with the pitch of the locked pixels.
   928  *
   929  * \return 0 on success, or -1 if the texture is not valid or was created with SDL_TextureAccess_Remote
   930  *
   931  * \sa SDL_DirtyTexture()
   932  * \sa SDL_UnlockTexture()
   933  */
   934 extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_TextureID textureID,
   935                                             const SDL_Rect * rect,
   936                                             int markDirty, void **pixels,
   937                                             int *pitch);
   938 
   939 /**
   940  * \fn void SDL_UnlockTexture(SDL_TextureID textureID)
   941  *
   942  * \brief Unlock a texture, uploading the changes to video memory, if needed.
   943  *
   944  * \sa SDL_LockTexture()
   945  * \sa SDL_DirtyTexture()
   946  */
   947 extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_TextureID textureID);
   948 
   949 /**
   950  * \fn void SDL_DirtyTexture(SDL_TextureID textureID, int numrects, const SDL_Rect * rects)
   951  *
   952  * \brief Mark the specified rectangles of the texture as dirty.
   953  *
   954  * \note The texture must have been created with SDL_TextureAccess_Local.
   955  *
   956  * \sa SDL_LockTexture()
   957  * \sa SDL_UnlockTexture()
   958  */
   959 extern DECLSPEC void SDLCALL SDL_DirtyTexture(SDL_TextureID textureID,
   960                                               int numrects,
   961                                               const SDL_Rect * rects);
   962 
   963 /**
   964  * \fn void SDL_SelectRenderTexture(SDL_TextureID textureID)
   965  *
   966  * \brief Select a texture as the rendering target, or 0 to reselect the current window.
   967  *
   968  * \note The texture must have been created with SDL_TextureAccess_Render.
   969  */
   970 extern DECLSPEC void SDLCALL SDL_SelectRenderTexture(SDL_TextureID textureID);
   971 
   972 /**
   973  * \fn void SDL_RenderFill(const SDL_Rect *rect, Uint32 color)
   974  *
   975  * \brief Fill the current rendering target with the specified color.
   976  *
   977  * \param rect A pointer to the destination rectangle, or NULL for the entire rendering target.
   978  * \param color An ARGB color value.
   979  *
   980  * \return 0 on success, or -1 if there is no renderer current
   981  */
   982 extern DECLSPEC int SDLCALL SDL_RenderFill(const SDL_Rect * rect,
   983                                            Uint32 color);
   984 
   985 /**
   986  * \fn int SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect *srcrect, const SDL_Rect *dstrect, Uint32 blendMode, Uint32 scaleMode)
   987  *
   988  * \brief Copy a portion of the texture to the current rendering target.
   989  *
   990  * \param texture The source texture.
   991  * \param srcrect A pointer to the source rectangle, or NULL for the entire texture.
   992  * \param dstrect A pointer to the destination rectangle, or NULL for the entire rendering target.
   993  * \param blendMode SDL_TextureBlendMode to be used if the source texture has an alpha channel.
   994  * \param scaleMode SDL_TextureScaleMode to be used if the source and destination rectangles don't have the same width and height.
   995  *
   996  * \return 0 on success, or -1 if there is no renderer current, or the driver doesn't support the requested operation.
   997  *
   998  * \note You can check the video driver info to see what operations are supported.
   999  */
  1000 extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_TextureID textureID,
  1001                                            const SDL_Rect * srcrect,
  1002                                            const SDL_Rect * dstrect,
  1003                                            int blendMode, int scaleMode);
  1004 
  1005 /**
  1006  * \fn int SDL_RenderReadPixels(const SDL_Rect *rect, void *pixels, int pitch)
  1007  *
  1008  * \brief Read pixels from the current rendering target.
  1009  *
  1010  * \param rect A pointer to the rectangle to read, or NULL for the entire render target
  1011  * \param pixels A pointer to be filled in with the pixel data
  1012  * \param pitch The pitch of the pixels parameter
  1013  *
  1014  * \return 0 on success, or -1 if pixel reading is not supported.
  1015  *
  1016  * \warning This is a very slow operation, and should not be used frequently.
  1017  */
  1018 extern DECLSPEC int SDLCALL SDL_RenderReadPixels(const SDL_Rect * rect,
  1019                                                  void *pixels, int pitch);
  1020 
  1021 /**
  1022  * \fn int SDL_RenderWritePixels(const SDL_Rect *rect, const void *pixels, int pitch)
  1023  *
  1024  * \brief Write pixels to the current rendering target.
  1025  *
  1026  * \param rect A pointer to the rectangle to write, or NULL for the entire render target
  1027  * \param pixels A pointer to the pixel data to write
  1028  * \param pitch The pitch of the pixels parameter
  1029  *
  1030  * \return 0 on success, or -1 if pixel writing is not supported.
  1031  *
  1032  * \warning This is a very slow operation, and should not be used frequently.
  1033  */
  1034 extern DECLSPEC int SDLCALL SDL_RenderWritePixels(const SDL_Rect * rect,
  1035                                                   const void *pixels,
  1036                                                   int pitch);
  1037 
  1038 /**
  1039  * \fn void SDL_RenderPresent(void)
  1040  *
  1041  * \brief Update the screen with rendering performed.
  1042  */
  1043 extern DECLSPEC void SDLCALL SDL_RenderPresent(void);
  1044 
  1045 /**
  1046  * \fn void SDL_DestroyTexture(SDL_TextureID textureID);
  1047  *
  1048  * \brief Destroy the specified texture.
  1049  *
  1050  * \sa SDL_CreateTexture()
  1051  * \sa SDL_CreateTextureFromSurface()
  1052  */
  1053 extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_TextureID textureID);
  1054 
  1055 /**
  1056  * \fn void SDL_DestroyRenderer(SDL_WindowID windowID);
  1057  *
  1058  * \brief Destroy the rendering context for a window and free associated
  1059  *        textures.
  1060  *
  1061  * \sa SDL_CreateRenderer()
  1062  */
  1063 extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_WindowID windowID);
  1064 
  1065 /*
  1066  * Set the gamma correction for each of the color channels.
  1067  * The gamma values range (approximately) between 0.1 and 10.0
  1068  * 
  1069  * If this function isn't supported directly by the hardware, it will
  1070  * be emulated using gamma ramps, if available.  If successful, this
  1071  * function returns 0, otherwise it returns -1.
  1072  */
  1073 extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
  1074 
  1075 /*
  1076  * Set the gamma translation table for the red, green, and blue channels
  1077  * of the video hardware.  Each table is an array of 256 16-bit quantities,
  1078  * representing a mapping between the input and output for that channel.
  1079  * The input is the index into the array, and the output is the 16-bit
  1080  * gamma value at that index, scaled to the output color precision.
  1081  * 
  1082  * You may pass NULL for any of the channels to leave it unchanged.
  1083  * If the call succeeds, it will return 0.  If the display driver or
  1084  * hardware does not support gamma translation, or otherwise fails,
  1085  * this function will return -1.
  1086  */
  1087 extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 * red,
  1088                                              const Uint16 * green,
  1089                                              const Uint16 * blue);
  1090 
  1091 /*
  1092  * Retrieve the current values of the gamma translation tables.
  1093  * 
  1094  * You must pass in valid pointers to arrays of 256 16-bit quantities.
  1095  * Any of the pointers may be NULL to ignore that channel.
  1096  * If the call succeeds, it will return 0.  If the display driver or
  1097  * hardware does not support gamma translation, or otherwise fails,
  1098  * this function will return -1.
  1099  */
  1100 extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green,
  1101                                              Uint16 * blue);
  1102 
  1103 /*
  1104  * Maps an RGB triple to an opaque pixel value for a given pixel format
  1105  */
  1106 extern DECLSPEC Uint32 SDLCALL SDL_MapRGB
  1107     (SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b);
  1108 
  1109 /*
  1110  * Maps an RGBA quadruple to a pixel value for a given pixel format
  1111  */
  1112 extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(SDL_PixelFormat * format,
  1113                                            Uint8 r, Uint8 g, Uint8 b,
  1114                                            Uint8 a);
  1115 
  1116 /*
  1117  * Maps a pixel value into the RGB components for a given pixel format
  1118  */
  1119 extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, SDL_PixelFormat * fmt,
  1120                                         Uint8 * r, Uint8 * g, Uint8 * b);
  1121 
  1122 /*
  1123  * Maps a pixel value into the RGBA components for a given pixel format
  1124  */
  1125 extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat * fmt,
  1126                                          Uint8 * r, Uint8 * g, Uint8 * b,
  1127                                          Uint8 * a);
  1128 
  1129 /*
  1130  * Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
  1131  * If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
  1132  * If the depth is greater than 8 bits, the pixel format is set using the
  1133  * flags '[RGB]mask'.
  1134  * If the function runs out of memory, it will return NULL.
  1135  *
  1136  * The 'flags' tell what kind of surface to create.
  1137  * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
  1138  * SDL_SRCALPHA means that the surface will be used for alpha blits.
  1139  */
  1140 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
  1141     (Uint32 flags, int width, int height, int depth,
  1142      Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
  1143 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
  1144                                                               int width,
  1145                                                               int height,
  1146                                                               int depth,
  1147                                                               int pitch,
  1148                                                               Uint32 Rmask,
  1149                                                               Uint32 Gmask,
  1150                                                               Uint32 Bmask,
  1151                                                               Uint32 Amask);
  1152 extern DECLSPEC SDL_Surface *SDLCALL
  1153 SDL_CreateRGBSurfaceFromTexture(SDL_TextureID textureID);
  1154 extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
  1155 
  1156 /**
  1157  * \fn int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
  1158  *
  1159  * \brief Set the palette used by a surface.
  1160  *
  1161  * \return 0, or -1 if the surface format doesn't use a palette.
  1162  *
  1163  * \note A single palette can be shared with many surfaces.
  1164  */
  1165 extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
  1166                                                   SDL_Palette * palette);
  1167 
  1168 /*
  1169  * SDL_LockSurface() sets up a surface for directly accessing the pixels.
  1170  * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
  1171  * to and read from 'surface->pixels', using the pixel format stored in 
  1172  * 'surface->format'.  Once you are done accessing the surface, you should 
  1173  * use SDL_UnlockSurface() to release it.
  1174  *
  1175  * Not all surfaces require locking.  If SDL_MUSTLOCK(surface) evaluates
  1176  * to 0, then you can read and write to the surface at any time, and the
  1177  * pixel format of the surface will not change.
  1178  * 
  1179  * No operating system or library calls should be made between lock/unlock
  1180  * pairs, as critical system locks may be held during this time.
  1181  *
  1182  * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
  1183  */
  1184 extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
  1185 extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
  1186 
  1187 /*
  1188  * Load a surface from a seekable SDL data source (memory or file.)
  1189  * If 'freesrc' is non-zero, the source will be closed after being read.
  1190  * Returns the new surface, or NULL if there was an error.
  1191  * The new surface should be freed with SDL_FreeSurface().
  1192  */
  1193 extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
  1194                                                     int freesrc);
  1195 
  1196 /* Convenience macro -- load a surface from a file */
  1197 #define SDL_LoadBMP(file)	SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
  1198 
  1199 /*
  1200  * Save a surface to a seekable SDL data source (memory or file.)
  1201  * If 'freedst' is non-zero, the source will be closed after being written.
  1202  * Returns 0 if successful or -1 if there was an error.
  1203  */
  1204 extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
  1205     (SDL_Surface * surface, SDL_RWops * dst, int freedst);
  1206 
  1207 /* Convenience macro -- save a surface to a file */
  1208 #define SDL_SaveBMP(surface, file) \
  1209 		SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
  1210 
  1211 /*
  1212  * Sets the color key (transparent pixel) in a blittable surface.
  1213  * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), 
  1214  * 'key' will be the transparent pixel in the source image of a blit.
  1215  * SDL_RLEACCEL requests RLE acceleration for the surface if present,
  1216  * and removes RLE acceleration if absent.
  1217  * If 'flag' is 0, this function clears any current color key.
  1218  * This function returns 0, or -1 if there was an error.
  1219  */
  1220 extern DECLSPEC int SDLCALL SDL_SetColorKey
  1221     (SDL_Surface * surface, Uint32 flag, Uint32 key);
  1222 
  1223 /*
  1224  * This function sets the alpha value for the entire surface, as opposed to
  1225  * using the alpha component of each pixel. This value measures the range
  1226  * of transparency of the surface, 0 being completely transparent to 255
  1227  * being completely opaque. An 'alpha' value of 255 causes blits to be
  1228  * opaque, the source pixels copied to the destination (the default). Note
  1229  * that per-surface alpha can be combined with colorkey transparency.
  1230  *
  1231  * If 'flag' is 0, alpha blending is disabled for the surface.
  1232  * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
  1233  * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
  1234  * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed.
  1235  *
  1236  * The 'alpha' parameter is ignored for surfaces that have an alpha channel.
  1237  */
  1238 extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface, Uint32 flag,
  1239                                          Uint8 alpha);
  1240 
  1241 /*
  1242  * Sets the clipping rectangle for the destination surface in a blit.
  1243  *
  1244  * If the clip rectangle is NULL, clipping will be disabled.
  1245  * If the clip rectangle doesn't intersect the surface, the function will
  1246  * return SDL_FALSE and blits will be completely clipped.  Otherwise the
  1247  * function returns SDL_TRUE and blits to the surface will be clipped to
  1248  * the intersection of the surface area and the clipping rectangle.
  1249  *
  1250  * Note that blits are automatically clipped to the edges of the source
  1251  * and destination surfaces.
  1252  */
  1253 extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
  1254                                                  const SDL_Rect * rect);
  1255 
  1256 /*
  1257  * Gets the clipping rectangle for the destination surface in a blit.
  1258  * 'rect' must be a pointer to a valid rectangle which will be filled
  1259  * with the correct values.
  1260  */
  1261 extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
  1262                                              SDL_Rect * rect);
  1263 
  1264 /*
  1265  * Creates a new surface of the specified format, and then copies and maps 
  1266  * the given surface to it so the blit of the converted surface will be as 
  1267  * fast as possible.  If this function fails, it returns NULL.
  1268  *
  1269  * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those 
  1270  * semantics.  You can also pass SDL_RLEACCEL in the flags parameter and
  1271  * SDL will try to RLE accelerate colorkey and alpha blits in the resulting
  1272  * surface.
  1273  *
  1274  * This function is used internally by SDL_DisplayFormat().
  1275  */
  1276 extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
  1277     (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags);
  1278 
  1279 /*
  1280  * This function performs a fast fill of the given rectangle with 'color'
  1281  * The given rectangle is clipped to the destination surface clip area
  1282  * and the final fill rectangle is saved in the passed in pointer.
  1283  * If 'dstrect' is NULL, the whole surface will be filled with 'color'
  1284  * The color should be a pixel of the format used by the surface, and 
  1285  * can be generated by the SDL_MapRGB() function.
  1286  * This function returns 0 on success, or -1 on error.
  1287  */
  1288 extern DECLSPEC int SDLCALL SDL_FillRect
  1289     (SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color);
  1290 
  1291 /*
  1292  * This performs a fast blit from the source surface to the destination
  1293  * surface.  It assumes that the source and destination rectangles are
  1294  * the same size.  If either 'srcrect' or 'dstrect' are NULL, the entire
  1295  * surface (src or dst) is copied.  The final blit rectangles are saved
  1296  * in 'srcrect' and 'dstrect' after all clipping is performed.
  1297  * If the blit is successful, it returns 0, otherwise it returns -1.
  1298  *
  1299  * The blit function should not be called on a locked surface.
  1300  *
  1301  * The blit semantics for surfaces with and without alpha and colorkey
  1302  * are defined as follows:
  1303  *
  1304  * RGBA->RGB:
  1305  *     SDL_SRCALPHA set:
  1306  * 	alpha-blend (using alpha-channel).
  1307  * 	SDL_SRCCOLORKEY ignored.
  1308  *     SDL_SRCALPHA not set:
  1309  * 	copy RGB.
  1310  * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
  1311  * 	RGB values of the source colour key, ignoring alpha in the
  1312  * 	comparison.
  1313  * 
  1314  * RGB->RGBA:
  1315  *     SDL_SRCALPHA set:
  1316  * 	alpha-blend (using the source per-surface alpha value);
  1317  * 	set destination alpha to opaque.
  1318  *     SDL_SRCALPHA not set:
  1319  * 	copy RGB, set destination alpha to source per-surface alpha value.
  1320  *     both:
  1321  * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
  1322  * 	source colour key.
  1323  * 
  1324  * RGBA->RGBA:
  1325  *     SDL_SRCALPHA set:
  1326  * 	alpha-blend (using the source alpha channel) the RGB values;
  1327  * 	leave destination alpha untouched. [Note: is this correct?]
  1328  * 	SDL_SRCCOLORKEY ignored.
  1329  *     SDL_SRCALPHA not set:
  1330  * 	copy all of RGBA to the destination.
  1331  * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
  1332  * 	RGB values of the source colour key, ignoring alpha in the
  1333  * 	comparison.
  1334  * 
  1335  * RGB->RGB: 
  1336  *     SDL_SRCALPHA set:
  1337  * 	alpha-blend (using the source per-surface alpha value).
  1338  *     SDL_SRCALPHA not set:
  1339  * 	copy RGB.
  1340  *     both:
  1341  * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
  1342  * 	source colour key.
  1343  *
  1344  * If either of the surfaces were in video memory, and the blit returns -2,
  1345  * the video memory was lost, so it should be reloaded with artwork and 
  1346  * re-blitted:
  1347 	while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
  1348 		while ( SDL_LockSurface(image) < 0 )
  1349 			Sleep(10);
  1350 		-- Write image pixels to image->pixels --
  1351 		SDL_UnlockSurface(image);
  1352 	}
  1353  * This happens under DirectX 5.0 when the system switches away from your
  1354  * fullscreen application.  The lock will also fail until you have access
  1355  * to the video memory again.
  1356  */
  1357 /* You should call SDL_BlitSurface() unless you know exactly how SDL
  1358    blitting works internally and how to use the other blit functions.
  1359 */
  1360 #define SDL_BlitSurface SDL_UpperBlit
  1361 
  1362 /* This is the public blit function, SDL_BlitSurface(), and it performs
  1363    rectangle validation and clipping before passing it to SDL_LowerBlit()
  1364 */
  1365 extern DECLSPEC int SDLCALL SDL_UpperBlit
  1366     (SDL_Surface * src, SDL_Rect * srcrect,
  1367      SDL_Surface * dst, SDL_Rect * dstrect);
  1368 /* This is a semi-private blit function and it performs low-level surface
  1369    blitting only.
  1370 */
  1371 extern DECLSPEC int SDLCALL SDL_LowerBlit
  1372     (SDL_Surface * src, SDL_Rect * srcrect,
  1373      SDL_Surface * dst, SDL_Rect * dstrect);
  1374 
  1375 /**
  1376  * \fn int SDL_SoftStretch(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect)
  1377  *
  1378  * \brief Perform a fast, low quality, stretch blit between two surfaces of the same pixel format.
  1379  * \note This function uses a static buffer, and is not thread-safe.
  1380  */
  1381 extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
  1382                                             SDL_Rect * srcrect,
  1383                                             SDL_Surface * dst,
  1384                                             SDL_Rect * dstrect);
  1385 
  1386 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1387 /* OpenGL support functions.                                                 */
  1388 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1389 
  1390 /*
  1391  * Dynamically load an OpenGL library, or the default one if path is NULL
  1392  *
  1393  * If you do this, you need to retrieve all of the GL functions used in
  1394  * your program from the dynamic library using SDL_GL_GetProcAddress().
  1395  */
  1396 extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
  1397 
  1398 /*
  1399  * Get the address of a GL function
  1400  */
  1401 extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc);
  1402 
  1403 /*
  1404  * Set an attribute of the OpenGL subsystem before window creation.
  1405  */
  1406 extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
  1407 
  1408 /*
  1409  * Get an attribute of the OpenGL subsystem from the windowing
  1410  * interface, such as glX. This is of course different from getting
  1411  * the values from SDL's internal OpenGL subsystem, which only
  1412  * stores the values you request before initialization.
  1413  *
  1414  * Developers should track the values they pass into SDL_GL_SetAttribute
  1415  * themselves if they want to retrieve these values.
  1416  */
  1417 extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
  1418 
  1419 /*
  1420  * Swap the OpenGL buffers, if double-buffering is supported.
  1421  */
  1422 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
  1423 
  1424 /*
  1425  * Calculate the intersection of two rectangles
  1426  */
  1427 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
  1428                                                    const SDL_Rect * B,
  1429                                                    SDL_Rect * intersection);
  1430 
  1431 /* Ends C function definitions when using C++ */
  1432 #ifdef __cplusplus
  1433 /* *INDENT-OFF* */
  1434 }
  1435 /* *INDENT-ON* */
  1436 #endif
  1437 #include "close_code.h"
  1438 
  1439 #endif /* _SDL_video_h */
  1440 
  1441 /* vi: set ts=4 sw=4 expandtab: */