|
|
1.1 ! root 1: /* ! 2: SDL - Simple DirectMedia Layer ! 3: Copyright (C) 1997-2004 Sam Lantinga ! 4: ! 5: This library is free software; you can redistribute it and/or ! 6: modify it under the terms of the GNU Library General Public ! 7: License as published by the Free Software Foundation; either ! 8: version 2 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: Library General Public License for more details. ! 14: ! 15: You should have received a copy of the GNU Library General Public ! 16: License along with this library; if not, write to the Free ! 17: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! 18: ! 19: Sam Lantinga ! 20: [email protected] ! 21: */ ! 22: ! 23: #ifdef SAVE_RCSID ! 24: static char rcsid = ! 25: "@(#) $Id: SDL_video.h,v 1.1.1.1 2005/11/18 23:23:31 rswindell Exp $"; ! 26: #endif ! 27: ! 28: /* Header file for access to the SDL raw framebuffer window */ ! 29: ! 30: #ifndef _SDL_video_h ! 31: #define _SDL_video_h ! 32: ! 33: #include <stdio.h> ! 34: ! 35: #include "SDL_types.h" ! 36: #include "SDL_mutex.h" ! 37: #include "SDL_rwops.h" ! 38: ! 39: #include "begin_code.h" ! 40: /* Set up for C function definitions, even when using C++ */ ! 41: #ifdef __cplusplus ! 42: extern "C" { ! 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: /* Useful data types */ ! 50: typedef struct SDL_Rect { ! 51: Sint16 x, y; ! 52: Uint16 w, h; ! 53: } SDL_Rect; ! 54: ! 55: typedef struct SDL_Color { ! 56: Uint8 r; ! 57: Uint8 g; ! 58: Uint8 b; ! 59: Uint8 unused; ! 60: } SDL_Color; ! 61: #define SDL_Colour SDL_Color ! 62: ! 63: typedef struct SDL_Palette { ! 64: int ncolors; ! 65: SDL_Color *colors; ! 66: } SDL_Palette; ! 67: ! 68: /* Everything in the pixel format structure is read-only */ ! 69: typedef struct SDL_PixelFormat { ! 70: SDL_Palette *palette; ! 71: Uint8 BitsPerPixel; ! 72: Uint8 BytesPerPixel; ! 73: Uint8 Rloss; ! 74: Uint8 Gloss; ! 75: Uint8 Bloss; ! 76: Uint8 Aloss; ! 77: Uint8 Rshift; ! 78: Uint8 Gshift; ! 79: Uint8 Bshift; ! 80: Uint8 Ashift; ! 81: Uint32 Rmask; ! 82: Uint32 Gmask; ! 83: Uint32 Bmask; ! 84: Uint32 Amask; ! 85: ! 86: /* RGB color key information */ ! 87: Uint32 colorkey; ! 88: /* Alpha value information (per-surface alpha) */ ! 89: Uint8 alpha; ! 90: } SDL_PixelFormat; ! 91: ! 92: /* This structure should be treated as read-only, except for 'pixels', ! 93: which, if not NULL, contains the raw pixel data for the surface. ! 94: */ ! 95: typedef struct SDL_Surface { ! 96: Uint32 flags; /* Read-only */ ! 97: SDL_PixelFormat *format; /* Read-only */ ! 98: int w, h; /* Read-only */ ! 99: Uint16 pitch; /* Read-only */ ! 100: void *pixels; /* Read-write */ ! 101: int offset; /* Private */ ! 102: ! 103: /* Hardware-specific surface info */ ! 104: struct private_hwdata *hwdata; ! 105: ! 106: /* clipping information */ ! 107: SDL_Rect clip_rect; /* Read-only */ ! 108: Uint32 unused1; /* for binary compatibility */ ! 109: ! 110: /* Allow recursive locks */ ! 111: Uint32 locked; /* Private */ ! 112: ! 113: /* info for fast blit mapping to other surfaces */ ! 114: struct SDL_BlitMap *map; /* Private */ ! 115: ! 116: /* format version, bumped at every change to invalidate blit maps */ ! 117: unsigned int format_version; /* Private */ ! 118: ! 119: /* Reference count -- used when freeing surface */ ! 120: int refcount; /* Read-mostly */ ! 121: } SDL_Surface; ! 122: ! 123: /* These are the currently supported flags for the SDL_surface */ ! 124: /* Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */ ! 125: #define SDL_SWSURFACE 0x00000000 /* Surface is in system memory */ ! 126: #define SDL_HWSURFACE 0x00000001 /* Surface is in video memory */ ! 127: #define SDL_ASYNCBLIT 0x00000004 /* Use asynchronous blits if possible */ ! 128: /* Available for SDL_SetVideoMode() */ ! 129: #define SDL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */ ! 130: #define SDL_HWPALETTE 0x20000000 /* Surface has exclusive palette */ ! 131: #define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */ ! 132: #define SDL_FULLSCREEN 0x80000000 /* Surface is a full screen display */ ! 133: #define SDL_OPENGL 0x00000002 /* Create an OpenGL rendering context */ ! 134: #define SDL_OPENGLBLIT 0x0000000A /* Create an OpenGL rendering context and use it for blitting */ ! 135: #define SDL_RESIZABLE 0x00000010 /* This video mode may be resized */ ! 136: #define SDL_NOFRAME 0x00000020 /* No window caption or edge frame */ ! 137: /* Used internally (read-only) */ ! 138: #define SDL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */ ! 139: #define SDL_SRCCOLORKEY 0x00001000 /* Blit uses a source color key */ ! 140: #define SDL_RLEACCELOK 0x00002000 /* Private flag */ ! 141: #define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */ ! 142: #define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */ ! 143: #define SDL_PREALLOC 0x01000000 /* Surface uses preallocated memory */ ! 144: ! 145: /* Evaluates to true if the surface needs to be locked before access */ ! 146: #define SDL_MUSTLOCK(surface) \ ! 147: (surface->offset || \ ! 148: ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) ! 149: ! 150: /* typedef for private surface blitting functions */ ! 151: typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, ! 152: struct SDL_Surface *dst, SDL_Rect *dstrect); ! 153: ! 154: ! 155: /* Useful for determining the video hardware capabilities */ ! 156: typedef struct SDL_VideoInfo { ! 157: Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */ ! 158: Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */ ! 159: Uint32 UnusedBits1 :6; ! 160: Uint32 UnusedBits2 :1; ! 161: Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */ ! 162: Uint32 blit_hw_CC :1; /* Flag: Accelerated blits with Colorkey */ ! 163: Uint32 blit_hw_A :1; /* Flag: Accelerated blits with Alpha */ ! 164: Uint32 blit_sw :1; /* Flag: Accelerated blits SW --> HW */ ! 165: Uint32 blit_sw_CC :1; /* Flag: Accelerated blits with Colorkey */ ! 166: Uint32 blit_sw_A :1; /* Flag: Accelerated blits with Alpha */ ! 167: Uint32 blit_fill :1; /* Flag: Accelerated color fill */ ! 168: Uint32 UnusedBits3 :16; ! 169: Uint32 video_mem; /* The total amount of video memory (in K) */ ! 170: SDL_PixelFormat *vfmt; /* Value: The format of the video surface */ ! 171: } SDL_VideoInfo; ! 172: ! 173: ! 174: /* The most common video overlay formats. ! 175: For an explanation of these pixel formats, see: ! 176: http://www.webartz.com/fourcc/indexyuv.htm ! 177: ! 178: For information on the relationship between color spaces, see: ! 179: http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html ! 180: */ ! 181: #define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */ ! 182: #define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */ ! 183: #define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */ ! 184: #define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */ ! 185: #define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */ ! 186: ! 187: /* The YUV hardware video overlay */ ! 188: typedef struct SDL_Overlay { ! 189: Uint32 format; /* Read-only */ ! 190: int w, h; /* Read-only */ ! 191: int planes; /* Read-only */ ! 192: Uint16 *pitches; /* Read-only */ ! 193: Uint8 **pixels; /* Read-write */ ! 194: ! 195: /* Hardware-specific surface info */ ! 196: struct private_yuvhwfuncs *hwfuncs; ! 197: struct private_yuvhwdata *hwdata; ! 198: ! 199: /* Special flags */ ! 200: Uint32 hw_overlay :1; /* Flag: This overlay hardware accelerated? */ ! 201: Uint32 UnusedBits :31; ! 202: } SDL_Overlay; ! 203: ! 204: ! 205: /* Public enumeration for setting the OpenGL window attributes. */ ! 206: typedef enum { ! 207: SDL_GL_RED_SIZE, ! 208: SDL_GL_GREEN_SIZE, ! 209: SDL_GL_BLUE_SIZE, ! 210: SDL_GL_ALPHA_SIZE, ! 211: SDL_GL_BUFFER_SIZE, ! 212: SDL_GL_DOUBLEBUFFER, ! 213: SDL_GL_DEPTH_SIZE, ! 214: SDL_GL_STENCIL_SIZE, ! 215: SDL_GL_ACCUM_RED_SIZE, ! 216: SDL_GL_ACCUM_GREEN_SIZE, ! 217: SDL_GL_ACCUM_BLUE_SIZE, ! 218: SDL_GL_ACCUM_ALPHA_SIZE, ! 219: SDL_GL_STEREO, ! 220: SDL_GL_MULTISAMPLEBUFFERS, ! 221: SDL_GL_MULTISAMPLESAMPLES ! 222: } SDL_GLattr; ! 223: ! 224: /* flags for SDL_SetPalette() */ ! 225: #define SDL_LOGPAL 0x01 ! 226: #define SDL_PHYSPAL 0x02 ! 227: ! 228: /* Function prototypes */ ! 229: ! 230: /* These functions are used internally, and should not be used unless you ! 231: * have a specific need to specify the video driver you want to use. ! 232: * You should normally use SDL_Init() or SDL_InitSubSystem(). ! 233: * ! 234: * SDL_VideoInit() initializes the video subsystem -- sets up a connection ! 235: * to the window manager, etc, and determines the current video mode and ! 236: * pixel format, but does not initialize a window or graphics mode. ! 237: * Note that event handling is activated by this routine. ! 238: * ! 239: * If you use both sound and video in your application, you need to call ! 240: * SDL_Init() before opening the sound device, otherwise under Win32 DirectX, ! 241: * you won't be able to set full-screen display modes. ! 242: */ ! 243: extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags); ! 244: extern DECLSPEC void SDLCALL SDL_VideoQuit(void); ! 245: ! 246: /* This function fills the given character buffer with the name of the ! 247: * video driver, and returns a pointer to it if the video driver has ! 248: * been initialized. It returns NULL if no driver has been initialized. ! 249: */ ! 250: extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); ! 251: ! 252: /* ! 253: * This function returns a pointer to the current display surface. ! 254: * If SDL is doing format conversion on the display surface, this ! 255: * function returns the publicly visible surface, not the real video ! 256: * surface. ! 257: */ ! 258: extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void); ! 259: ! 260: /* ! 261: * This function returns a read-only pointer to information about the ! 262: * video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt' ! 263: * member of the returned structure will contain the pixel format of the ! 264: * "best" video mode. ! 265: */ ! 266: extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void); ! 267: ! 268: /* ! 269: * Check to see if a particular video mode is supported. ! 270: * It returns 0 if the requested mode is not supported under any bit depth, ! 271: * or returns the bits-per-pixel of the closest available mode with the ! 272: * given width and height. If this bits-per-pixel is different from the ! 273: * one used when setting the video mode, SDL_SetVideoMode() will succeed, ! 274: * but will emulate the requested bits-per-pixel with a shadow surface. ! 275: * ! 276: * The arguments to SDL_VideoModeOK() are the same ones you would pass to ! 277: * SDL_SetVideoMode() ! 278: */ ! 279: extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags); ! 280: ! 281: /* ! 282: * Return a pointer to an array of available screen dimensions for the ! 283: * given format and video flags, sorted largest to smallest. Returns ! 284: * NULL if there are no dimensions available for a particular format, ! 285: * or (SDL_Rect **)-1 if any dimension is okay for the given format. ! 286: * ! 287: * If 'format' is NULL, the mode list will be for the format given ! 288: * by SDL_GetVideoInfo()->vfmt ! 289: */ ! 290: extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); ! 291: ! 292: /* ! 293: * Set up a video mode with the specified width, height and bits-per-pixel. ! 294: * ! 295: * If 'bpp' is 0, it is treated as the current display bits per pixel. ! 296: * ! 297: * If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the ! 298: * requested bits-per-pixel, but will return whatever video pixel format is ! 299: * available. The default is to emulate the requested pixel format if it ! 300: * is not natively available. ! 301: * ! 302: * If SDL_HWSURFACE is set in 'flags', the video surface will be placed in ! 303: * video memory, if possible, and you may have to call SDL_LockSurface() ! 304: * in order to access the raw framebuffer. Otherwise, the video surface ! 305: * will be created in system memory. ! 306: * ! 307: * If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle ! 308: * updates asynchronously, but you must always lock before accessing pixels. ! 309: * SDL will wait for updates to complete before returning from the lock. ! 310: * ! 311: * If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee ! 312: * that the colors set by SDL_SetColors() will be the colors you get. ! 313: * Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all ! 314: * of the colors exactly the way they are requested, and you should look ! 315: * at the video surface structure to determine the actual palette. ! 316: * If SDL cannot guarantee that the colors you request can be set, ! 317: * i.e. if the colormap is shared, then the video surface may be created ! 318: * under emulation in system memory, overriding the SDL_HWSURFACE flag. ! 319: * ! 320: * If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set ! 321: * a fullscreen video mode. The default is to create a windowed mode ! 322: * if the current graphics system has a window manager. ! 323: * If the SDL library is able to set a fullscreen video mode, this flag ! 324: * will be set in the surface that is returned. ! 325: * ! 326: * If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up ! 327: * two surfaces in video memory and swap between them when you call ! 328: * SDL_Flip(). This is usually slower than the normal single-buffering ! 329: * scheme, but prevents "tearing" artifacts caused by modifying video ! 330: * memory while the monitor is refreshing. It should only be used by ! 331: * applications that redraw the entire screen on every update. ! 332: * ! 333: * If SDL_RESIZABLE is set in 'flags', the SDL library will allow the ! 334: * window manager, if any, to resize the window at runtime. When this ! 335: * occurs, SDL will send a SDL_VIDEORESIZE event to you application, ! 336: * and you must respond to the event by re-calling SDL_SetVideoMode() ! 337: * with the requested size (or another size that suits the application). ! 338: * ! 339: * If SDL_NOFRAME is set in 'flags', the SDL library will create a window ! 340: * without any title bar or frame decoration. Fullscreen video modes have ! 341: * this flag set automatically. ! 342: * ! 343: * This function returns the video framebuffer surface, or NULL if it fails. ! 344: * ! 345: * If you rely on functionality provided by certain video flags, check the ! 346: * flags of the returned surface to make sure that functionality is available. ! 347: * SDL will fall back to reduced functionality if the exact flags you wanted ! 348: * are not available. ! 349: */ ! 350: extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode ! 351: (int width, int height, int bpp, Uint32 flags); ! 352: ! 353: /* ! 354: * Makes sure the given list of rectangles is updated on the given screen. ! 355: * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire ! 356: * screen. ! 357: * These functions should not be called while 'screen' is locked. ! 358: */ ! 359: extern DECLSPEC void SDLCALL SDL_UpdateRects ! 360: (SDL_Surface *screen, int numrects, SDL_Rect *rects); ! 361: extern DECLSPEC void SDLCALL SDL_UpdateRect ! 362: (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); ! 363: ! 364: /* ! 365: * On hardware that supports double-buffering, this function sets up a flip ! 366: * and returns. The hardware will wait for vertical retrace, and then swap ! 367: * video buffers before the next video surface blit or lock will return. ! 368: * On hardware that doesn not support double-buffering, this is equivalent ! 369: * to calling SDL_UpdateRect(screen, 0, 0, 0, 0); ! 370: * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when ! 371: * setting the video mode for this function to perform hardware flipping. ! 372: * This function returns 0 if successful, or -1 if there was an error. ! 373: */ ! 374: extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen); ! 375: ! 376: /* ! 377: * Set the gamma correction for each of the color channels. ! 378: * The gamma values range (approximately) between 0.1 and 10.0 ! 379: * ! 380: * If this function isn't supported directly by the hardware, it will ! 381: * be emulated using gamma ramps, if available. If successful, this ! 382: * function returns 0, otherwise it returns -1. ! 383: */ ! 384: extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); ! 385: ! 386: /* ! 387: * Set the gamma translation table for the red, green, and blue channels ! 388: * of the video hardware. Each table is an array of 256 16-bit quantities, ! 389: * representing a mapping between the input and output for that channel. ! 390: * The input is the index into the array, and the output is the 16-bit ! 391: * gamma value at that index, scaled to the output color precision. ! 392: * ! 393: * You may pass NULL for any of the channels to leave it unchanged. ! 394: * If the call succeeds, it will return 0. If the display driver or ! 395: * hardware does not support gamma translation, or otherwise fails, ! 396: * this function will return -1. ! 397: */ ! 398: extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue); ! 399: ! 400: /* ! 401: * Retrieve the current values of the gamma translation tables. ! 402: * ! 403: * You must pass in valid pointers to arrays of 256 16-bit quantities. ! 404: * Any of the pointers may be NULL to ignore that channel. ! 405: * If the call succeeds, it will return 0. If the display driver or ! 406: * hardware does not support gamma translation, or otherwise fails, ! 407: * this function will return -1. ! 408: */ ! 409: extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue); ! 410: ! 411: /* ! 412: * Sets a portion of the colormap for the given 8-bit surface. If 'surface' ! 413: * is not a palettized surface, this function does nothing, returning 0. ! 414: * If all of the colors were set as passed to SDL_SetColors(), it will ! 415: * return 1. If not all the color entries were set exactly as given, ! 416: * it will return 0, and you should look at the surface palette to ! 417: * determine the actual color palette. ! 418: * ! 419: * When 'surface' is the surface associated with the current display, the ! 420: * display colormap will be updated with the requested colors. If ! 421: * SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors() ! 422: * will always return 1, and the palette is guaranteed to be set the way ! 423: * you desire, even if the window colormap has to be warped or run under ! 424: * emulation. ! 425: */ ! 426: extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface, ! 427: SDL_Color *colors, int firstcolor, int ncolors); ! 428: ! 429: /* ! 430: * Sets a portion of the colormap for a given 8-bit surface. ! 431: * 'flags' is one or both of: ! 432: * SDL_LOGPAL -- set logical palette, which controls how blits are mapped ! 433: * to/from the surface, ! 434: * SDL_PHYSPAL -- set physical palette, which controls how pixels look on ! 435: * the screen ! 436: * Only screens have physical palettes. Separate change of physical/logical ! 437: * palettes is only possible if the screen has SDL_HWPALETTE set. ! 438: * ! 439: * The return value is 1 if all colours could be set as requested, and 0 ! 440: * otherwise. ! 441: * ! 442: * SDL_SetColors() is equivalent to calling this function with ! 443: * flags = (SDL_LOGPAL|SDL_PHYSPAL). ! 444: */ ! 445: extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags, ! 446: SDL_Color *colors, int firstcolor, ! 447: int ncolors); ! 448: ! 449: /* ! 450: * Maps an RGB triple to an opaque pixel value for a given pixel format ! 451: */ ! 452: extern DECLSPEC Uint32 SDLCALL SDL_MapRGB ! 453: (SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b); ! 454: ! 455: /* ! 456: * Maps an RGBA quadruple to a pixel value for a given pixel format ! 457: */ ! 458: extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(SDL_PixelFormat *format, ! 459: Uint8 r, Uint8 g, Uint8 b, Uint8 a); ! 460: ! 461: /* ! 462: * Maps a pixel value into the RGB components for a given pixel format ! 463: */ ! 464: extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt, ! 465: Uint8 *r, Uint8 *g, Uint8 *b); ! 466: ! 467: /* ! 468: * Maps a pixel value into the RGBA components for a given pixel format ! 469: */ ! 470: extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt, ! 471: Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); ! 472: ! 473: /* ! 474: * Allocate and free an RGB surface (must be called after SDL_SetVideoMode) ! 475: * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. ! 476: * If the depth is greater than 8 bits, the pixel format is set using the ! 477: * flags '[RGB]mask'. ! 478: * If the function runs out of memory, it will return NULL. ! 479: * ! 480: * The 'flags' tell what kind of surface to create. ! 481: * SDL_SWSURFACE means that the surface should be created in system memory. ! 482: * SDL_HWSURFACE means that the surface should be created in video memory, ! 483: * with the same format as the display surface. This is useful for surfaces ! 484: * that will not change much, to take advantage of hardware acceleration ! 485: * when being blitted to the display surface. ! 486: * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with ! 487: * this surface, but you must always lock it before accessing the pixels. ! 488: * SDL will wait for current blits to finish before returning from the lock. ! 489: * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. ! 490: * If the hardware supports acceleration of colorkey blits between ! 491: * two surfaces in video memory, SDL will try to place the surface in ! 492: * video memory. If this isn't possible or if there is no hardware ! 493: * acceleration available, the surface will be placed in system memory. ! 494: * SDL_SRCALPHA means that the surface will be used for alpha blits and ! 495: * if the hardware supports hardware acceleration of alpha blits between ! 496: * two surfaces in video memory, to place the surface in video memory ! 497: * if possible, otherwise it will be placed in system memory. ! 498: * If the surface is created in video memory, blits will be _much_ faster, ! 499: * but the surface format must be identical to the video surface format, ! 500: * and the only way to access the pixels member of the surface is to use ! 501: * the SDL_LockSurface() and SDL_UnlockSurface() calls. ! 502: * If the requested surface actually resides in video memory, SDL_HWSURFACE ! 503: * will be set in the flags member of the returned surface. If for some ! 504: * reason the surface could not be placed in video memory, it will not have ! 505: * the SDL_HWSURFACE flag set, and will be created in system memory instead. ! 506: */ ! 507: #define SDL_AllocSurface SDL_CreateRGBSurface ! 508: extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface ! 509: (Uint32 flags, int width, int height, int depth, ! 510: Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); ! 511: extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, ! 512: int width, int height, int depth, int pitch, ! 513: Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); ! 514: extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface); ! 515: ! 516: /* ! 517: * SDL_LockSurface() sets up a surface for directly accessing the pixels. ! 518: * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write ! 519: * to and read from 'surface->pixels', using the pixel format stored in ! 520: * 'surface->format'. Once you are done accessing the surface, you should ! 521: * use SDL_UnlockSurface() to release it. ! 522: * ! 523: * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates ! 524: * to 0, then you can read and write to the surface at any time, and the ! 525: * pixel format of the surface will not change. In particular, if the ! 526: * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you ! 527: * will not need to lock the display surface before accessing it. ! 528: * ! 529: * No operating system or library calls should be made between lock/unlock ! 530: * pairs, as critical system locks may be held during this time. ! 531: * ! 532: * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. ! 533: */ ! 534: extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface); ! 535: extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); ! 536: ! 537: /* ! 538: * Load a surface from a seekable SDL data source (memory or file.) ! 539: * If 'freesrc' is non-zero, the source will be closed after being read. ! 540: * Returns the new surface, or NULL if there was an error. ! 541: * The new surface should be freed with SDL_FreeSurface(). ! 542: */ ! 543: extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc); ! 544: ! 545: /* Convenience macro -- load a surface from a file */ ! 546: #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) ! 547: ! 548: /* ! 549: * Save a surface to a seekable SDL data source (memory or file.) ! 550: * If 'freedst' is non-zero, the source will be closed after being written. ! 551: * Returns 0 if successful or -1 if there was an error. ! 552: */ ! 553: extern DECLSPEC int SDLCALL SDL_SaveBMP_RW ! 554: (SDL_Surface *surface, SDL_RWops *dst, int freedst); ! 555: ! 556: /* Convenience macro -- save a surface to a file */ ! 557: #define SDL_SaveBMP(surface, file) \ ! 558: SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) ! 559: ! 560: /* ! 561: * Sets the color key (transparent pixel) in a blittable surface. ! 562: * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), ! 563: * 'key' will be the transparent pixel in the source image of a blit. ! 564: * SDL_RLEACCEL requests RLE acceleration for the surface if present, ! 565: * and removes RLE acceleration if absent. ! 566: * If 'flag' is 0, this function clears any current color key. ! 567: * This function returns 0, or -1 if there was an error. ! 568: */ ! 569: extern DECLSPEC int SDLCALL SDL_SetColorKey ! 570: (SDL_Surface *surface, Uint32 flag, Uint32 key); ! 571: ! 572: /* ! 573: * This function sets the alpha value for the entire surface, as opposed to ! 574: * using the alpha component of each pixel. This value measures the range ! 575: * of transparency of the surface, 0 being completely transparent to 255 ! 576: * being completely opaque. An 'alpha' value of 255 causes blits to be ! 577: * opaque, the source pixels copied to the destination (the default). Note ! 578: * that per-surface alpha can be combined with colorkey transparency. ! 579: * ! 580: * If 'flag' is 0, alpha blending is disabled for the surface. ! 581: * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface. ! 582: * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the ! 583: * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. ! 584: * ! 585: * The 'alpha' parameter is ignored for surfaces that have an alpha channel. ! 586: */ ! 587: extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); ! 588: ! 589: /* ! 590: * Sets the clipping rectangle for the destination surface in a blit. ! 591: * ! 592: * If the clip rectangle is NULL, clipping will be disabled. ! 593: * If the clip rectangle doesn't intersect the surface, the function will ! 594: * return SDL_FALSE and blits will be completely clipped. Otherwise the ! 595: * function returns SDL_TRUE and blits to the surface will be clipped to ! 596: * the intersection of the surface area and the clipping rectangle. ! 597: * ! 598: * Note that blits are automatically clipped to the edges of the source ! 599: * and destination surfaces. ! 600: */ ! 601: extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect); ! 602: ! 603: /* ! 604: * Gets the clipping rectangle for the destination surface in a blit. ! 605: * 'rect' must be a pointer to a valid rectangle which will be filled ! 606: * with the correct values. ! 607: */ ! 608: extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect); ! 609: ! 610: /* ! 611: * Creates a new surface of the specified format, and then copies and maps ! 612: * the given surface to it so the blit of the converted surface will be as ! 613: * fast as possible. If this function fails, it returns NULL. ! 614: * ! 615: * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those ! 616: * semantics. You can also pass SDL_RLEACCEL in the flags parameter and ! 617: * SDL will try to RLE accelerate colorkey and alpha blits in the resulting ! 618: * surface. ! 619: * ! 620: * This function is used internally by SDL_DisplayFormat(). ! 621: */ ! 622: extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface ! 623: (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); ! 624: ! 625: /* ! 626: * This performs a fast blit from the source surface to the destination ! 627: * surface. It assumes that the source and destination rectangles are ! 628: * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire ! 629: * surface (src or dst) is copied. The final blit rectangles are saved ! 630: * in 'srcrect' and 'dstrect' after all clipping is performed. ! 631: * If the blit is successful, it returns 0, otherwise it returns -1. ! 632: * ! 633: * The blit function should not be called on a locked surface. ! 634: * ! 635: * The blit semantics for surfaces with and without alpha and colorkey ! 636: * are defined as follows: ! 637: * ! 638: * RGBA->RGB: ! 639: * SDL_SRCALPHA set: ! 640: * alpha-blend (using alpha-channel). ! 641: * SDL_SRCCOLORKEY ignored. ! 642: * SDL_SRCALPHA not set: ! 643: * copy RGB. ! 644: * if SDL_SRCCOLORKEY set, only copy the pixels matching the ! 645: * RGB values of the source colour key, ignoring alpha in the ! 646: * comparison. ! 647: * ! 648: * RGB->RGBA: ! 649: * SDL_SRCALPHA set: ! 650: * alpha-blend (using the source per-surface alpha value); ! 651: * set destination alpha to opaque. ! 652: * SDL_SRCALPHA not set: ! 653: * copy RGB, set destination alpha to source per-surface alpha value. ! 654: * both: ! 655: * if SDL_SRCCOLORKEY set, only copy the pixels matching the ! 656: * source colour key. ! 657: * ! 658: * RGBA->RGBA: ! 659: * SDL_SRCALPHA set: ! 660: * alpha-blend (using the source alpha channel) the RGB values; ! 661: * leave destination alpha untouched. [Note: is this correct?] ! 662: * SDL_SRCCOLORKEY ignored. ! 663: * SDL_SRCALPHA not set: ! 664: * copy all of RGBA to the destination. ! 665: * if SDL_SRCCOLORKEY set, only copy the pixels matching the ! 666: * RGB values of the source colour key, ignoring alpha in the ! 667: * comparison. ! 668: * ! 669: * RGB->RGB: ! 670: * SDL_SRCALPHA set: ! 671: * alpha-blend (using the source per-surface alpha value). ! 672: * SDL_SRCALPHA not set: ! 673: * copy RGB. ! 674: * both: ! 675: * if SDL_SRCCOLORKEY set, only copy the pixels matching the ! 676: * source colour key. ! 677: * ! 678: * If either of the surfaces were in video memory, and the blit returns -2, ! 679: * the video memory was lost, so it should be reloaded with artwork and ! 680: * re-blitted: ! 681: while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { ! 682: while ( SDL_LockSurface(image) < 0 ) ! 683: Sleep(10); ! 684: -- Write image pixels to image->pixels -- ! 685: SDL_UnlockSurface(image); ! 686: } ! 687: * This happens under DirectX 5.0 when the system switches away from your ! 688: * fullscreen application. The lock will also fail until you have access ! 689: * to the video memory again. ! 690: */ ! 691: /* You should call SDL_BlitSurface() unless you know exactly how SDL ! 692: blitting works internally and how to use the other blit functions. ! 693: */ ! 694: #define SDL_BlitSurface SDL_UpperBlit ! 695: ! 696: /* This is the public blit function, SDL_BlitSurface(), and it performs ! 697: rectangle validation and clipping before passing it to SDL_LowerBlit() ! 698: */ ! 699: extern DECLSPEC int SDLCALL SDL_UpperBlit ! 700: (SDL_Surface *src, SDL_Rect *srcrect, ! 701: SDL_Surface *dst, SDL_Rect *dstrect); ! 702: /* This is a semi-private blit function and it performs low-level surface ! 703: blitting only. ! 704: */ ! 705: extern DECLSPEC int SDLCALL SDL_LowerBlit ! 706: (SDL_Surface *src, SDL_Rect *srcrect, ! 707: SDL_Surface *dst, SDL_Rect *dstrect); ! 708: ! 709: /* ! 710: * This function performs a fast fill of the given rectangle with 'color' ! 711: * The given rectangle is clipped to the destination surface clip area ! 712: * and the final fill rectangle is saved in the passed in pointer. ! 713: * If 'dstrect' is NULL, the whole surface will be filled with 'color' ! 714: * The color should be a pixel of the format used by the surface, and ! 715: * can be generated by the SDL_MapRGB() function. ! 716: * This function returns 0 on success, or -1 on error. ! 717: */ ! 718: extern DECLSPEC int SDLCALL SDL_FillRect ! 719: (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); ! 720: ! 721: /* ! 722: * This function takes a surface and copies it to a new surface of the ! 723: * pixel format and colors of the video framebuffer, suitable for fast ! 724: * blitting onto the display surface. It calls SDL_ConvertSurface() ! 725: * ! 726: * If you want to take advantage of hardware colorkey or alpha blit ! 727: * acceleration, you should set the colorkey and alpha value before ! 728: * calling this function. ! 729: * ! 730: * If the conversion fails or runs out of memory, it returns NULL ! 731: */ ! 732: extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormat(SDL_Surface *surface); ! 733: ! 734: /* ! 735: * This function takes a surface and copies it to a new surface of the ! 736: * pixel format and colors of the video framebuffer (if possible), ! 737: * suitable for fast alpha blitting onto the display surface. ! 738: * The new surface will always have an alpha channel. ! 739: * ! 740: * If you want to take advantage of hardware colorkey or alpha blit ! 741: * acceleration, you should set the colorkey and alpha value before ! 742: * calling this function. ! 743: * ! 744: * If the conversion fails or runs out of memory, it returns NULL ! 745: */ ! 746: extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *surface); ! 747: ! 748: ! 749: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ ! 750: /* YUV video surface overlay functions */ ! 751: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ ! 752: ! 753: /* This function creates a video output overlay ! 754: Calling the returned surface an overlay is something of a misnomer because ! 755: the contents of the display surface underneath the area where the overlay ! 756: is shown is undefined - it may be overwritten with the converted YUV data. ! 757: */ ! 758: extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height, ! 759: Uint32 format, SDL_Surface *display); ! 760: ! 761: /* Lock an overlay for direct access, and unlock it when you are done */ ! 762: extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay); ! 763: extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay); ! 764: ! 765: /* Blit a video overlay to the display surface. ! 766: The contents of the video surface underneath the blit destination are ! 767: not defined. ! 768: The width and height of the destination rectangle may be different from ! 769: that of the overlay, but currently only 2x scaling is supported. ! 770: */ ! 771: extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect); ! 772: ! 773: /* Free a video overlay */ ! 774: extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay); ! 775: ! 776: ! 777: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ ! 778: /* OpenGL support functions. */ ! 779: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ ! 780: ! 781: /* ! 782: * Dynamically load a GL driver, if SDL is built with dynamic GL. ! 783: * ! 784: * SDL links normally with the OpenGL library on your system by default, ! 785: * but you can compile it to dynamically load the GL driver at runtime. ! 786: * If you do this, you need to retrieve all of the GL functions used in ! 787: * your program from the dynamic library using SDL_GL_GetProcAddress(). ! 788: * ! 789: * This is disabled in default builds of SDL. ! 790: */ ! 791: extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); ! 792: ! 793: /* ! 794: * Get the address of a GL function (for extension functions) ! 795: */ ! 796: extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc); ! 797: ! 798: /* ! 799: * Set an attribute of the OpenGL subsystem before intialization. ! 800: */ ! 801: extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); ! 802: ! 803: /* ! 804: * Get an attribute of the OpenGL subsystem from the windowing ! 805: * interface, such as glX. This is of course different from getting ! 806: * the values from SDL's internal OpenGL subsystem, which only ! 807: * stores the values you request before initialization. ! 808: * ! 809: * Developers should track the values they pass into SDL_GL_SetAttribute ! 810: * themselves if they want to retrieve these values. ! 811: */ ! 812: extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value); ! 813: ! 814: /* ! 815: * Swap the OpenGL buffers, if double-buffering is supported. ! 816: */ ! 817: extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); ! 818: ! 819: /* ! 820: * Internal functions that should not be called unless you have read ! 821: * and understood the source code for these functions. ! 822: */ ! 823: extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects); ! 824: extern DECLSPEC void SDLCALL SDL_GL_Lock(void); ! 825: extern DECLSPEC void SDLCALL SDL_GL_Unlock(void); ! 826: ! 827: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ ! 828: /* These functions allow interaction with the window manager, if any. */ ! 829: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ ! 830: ! 831: /* ! 832: * Sets/Gets the title and icon text of the display window ! 833: */ ! 834: extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon); ! 835: extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon); ! 836: ! 837: /* ! 838: * Sets the icon for the display window. ! 839: * This function must be called before the first call to SDL_SetVideoMode(). ! 840: * It takes an icon surface, and a mask in MSB format. ! 841: * If 'mask' is NULL, the entire icon surface will be used as the icon. ! 842: */ ! 843: extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); ! 844: ! 845: /* ! 846: * This function iconifies the window, and returns 1 if it succeeded. ! 847: * If the function succeeds, it generates an SDL_APPACTIVE loss event. ! 848: * This function is a noop and returns 0 in non-windowed environments. ! 849: */ ! 850: extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void); ! 851: ! 852: /* ! 853: * Toggle fullscreen mode without changing the contents of the screen. ! 854: * If the display surface does not require locking before accessing ! 855: * the pixel information, then the memory pointers will not change. ! 856: * ! 857: * If this function was able to toggle fullscreen mode (change from ! 858: * running in a window to fullscreen, or vice-versa), it will return 1. ! 859: * If it is not implemented, or fails, it returns 0. ! 860: * ! 861: * The next call to SDL_SetVideoMode() will set the mode fullscreen ! 862: * attribute based on the flags parameter - if SDL_FULLSCREEN is not ! 863: * set, then the display will be windowed by default where supported. ! 864: * ! 865: * This is currently only implemented in the X11 video driver. ! 866: */ ! 867: extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface); ! 868: ! 869: /* ! 870: * This function allows you to set and query the input grab state of ! 871: * the application. It returns the new input grab state. ! 872: */ ! 873: typedef enum { ! 874: SDL_GRAB_QUERY = -1, ! 875: SDL_GRAB_OFF = 0, ! 876: SDL_GRAB_ON = 1, ! 877: SDL_GRAB_FULLSCREEN /* Used internally */ ! 878: } SDL_GrabMode; ! 879: /* ! 880: * Grabbing means that the mouse is confined to the application window, ! 881: * and nearly all keyboard input is passed directly to the application, ! 882: * and not interpreted by a window manager, if any. ! 883: */ ! 884: extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode); ! 885: ! 886: /* Not in public API at the moment - do not use! */ ! 887: extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, ! 888: SDL_Surface *dst, SDL_Rect *dstrect); ! 889: ! 890: /* Ends C function definitions when using C++ */ ! 891: #ifdef __cplusplus ! 892: } ! 893: #endif ! 894: #include "close_code.h" ! 895: ! 896: #endif /* _SDL_video_h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.