comparison include/SDL_video.h @ 1670:eef792d31de8 SDL-1.3

Work in progress. :)
author Sam Lantinga <slouken@libsdl.org>
date Wed, 07 Jun 2006 16:10:28 +0000
parents 9857d21967bb
children d33dcfc3fde7
comparison
equal deleted inserted replaced
1669:9857d21967bb 1670:eef792d31de8
44 44
45 /* Transparency definitions: These define alpha as the opacity of a surface */ 45 /* Transparency definitions: These define alpha as the opacity of a surface */
46 #define SDL_ALPHA_OPAQUE 255 46 #define SDL_ALPHA_OPAQUE 255
47 #define SDL_ALPHA_TRANSPARENT 0 47 #define SDL_ALPHA_TRANSPARENT 0
48 48
49 /* Useful data types */ 49 /**
50 * \struct SDL_Rect
51 *
52 * \brief A rectangle, with the origin at the upper left.
53 */
50 typedef struct SDL_Rect 54 typedef struct SDL_Rect
51 { 55 {
52 Sint16 x, y; 56 Sint16 x, y;
53 Uint16 w, h; 57 Uint16 w, h;
54 } SDL_Rect; 58 } SDL_Rect;
55
56 /* This structure should be treated as read-only, except for 'pixels',
57 which, if not NULL, contains the raw pixel data for the surface.
58 */
59 typedef struct SDL_Surface
60 {
61 Uint32 flags; /* Read-only */
62 SDL_PixelFormat *format; /* Read-only */
63 int w, h; /* Read-only */
64 Uint16 pitch; /* Read-only */
65 void *pixels; /* Read-write */
66 int offset; /* Private */
67
68 /* Hardware-specific surface info */
69 struct private_hwdata *hwdata;
70
71 /* clipping information */
72 SDL_Rect clip_rect; /* Read-only */
73 Uint32 unused1; /* for binary compatibility */
74
75 /* Allow recursive locks */
76 Uint32 locked; /* Private */
77
78 /* info for fast blit mapping to other surfaces */
79 struct SDL_BlitMap *map; /* Private */
80
81 /* format version, bumped at every change to invalidate blit maps */
82 unsigned int format_version; /* Private */
83
84 /* Reference count -- used when freeing surface */
85 int refcount; /* Read-mostly */
86 } SDL_Surface;
87
88 /* The most common video overlay formats.
89 For an explanation of these pixel formats, see:
90 http://www.webartz.com/fourcc/indexyuv.htm
91
92 For information on the relationship between color spaces, see:
93 http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
94 */
95 #define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */
96 #define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */
97 #define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
98 #define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
99 #define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
100
101 /* The YUV hardware video overlay */
102 typedef struct SDL_Overlay
103 {
104 Uint32 format; /* Read-only */
105 int w, h; /* Read-only */
106 int planes; /* Read-only */
107 Uint16 *pitches; /* Read-only */
108 Uint8 **pixels; /* Read-write */
109
110 /* Hardware-specific surface info */
111 struct private_yuvhwfuncs *hwfuncs;
112 struct private_yuvhwdata *hwdata;
113
114 /* Special flags */
115 Uint32 hw_overlay:1; /* Flag: This overlay hardware accelerated? */
116 Uint32 UnusedBits:31;
117 } SDL_Overlay;
118
119 /* Evaluates to true if the surface needs to be locked before access */
120 #define SDL_MUSTLOCK(surface) \
121 (surface->offset || \
122 ((surface->flags & (SDL_HWSURFACE|SDL_RLEACCEL)) != 0))
123
124 /* typedef for private surface blitting functions */
125 typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
126 struct SDL_Surface * dst, SDL_Rect * dstrect);
127
128
129 /**
130 * \struct SDL_VideoInfo
131 *
132 * \brief Useful for determining the video hardware capabilities
133 */
134 typedef struct SDL_VideoInfo
135 {
136 Uint32 hw_available:1; /**< Flag: Can you create hardware surfaces? */
137 Uint32 wm_available:1; /**< Flag: Can you talk to a window manager? */
138 Uint32 UnusedBits1:6;
139 Uint32 UnusedBits2:1;
140 Uint32 blit_hw:1; /**< Flag: Accelerated blits HW --> HW */
141 Uint32 blit_hw_CC:1; /**< Flag: Accelerated blits with Colorkey */
142 Uint32 blit_hw_A:1; /**< Flag: Accelerated blits with Alpha */
143 Uint32 blit_sw:1; /**< Flag: Accelerated blits SW --> HW */
144 Uint32 blit_sw_CC:1; /**< Flag: Accelerated blits with Colorkey */
145 Uint32 blit_sw_A:1; /**< Flag: Accelerated blits with Alpha */
146 Uint32 blit_fill:1; /**< Flag: Accelerated color fill */
147 Uint32 UnusedBits3:16;
148 Uint32 video_mem; /* The total amount of video memory (in K) */
149
150 /* Here for backwards compatibility */
151 SDL_PixelFormat *vfmt;
152 } SDL_VideoInfo;
153 59
154 /** 60 /**
155 * \struct SDL_DisplayMode 61 * \struct SDL_DisplayMode
156 * 62 *
157 * \brief The structure that defines a display mode 63 * \brief The structure that defines a display mode
202 108
203 /** 109 /**
204 * \enum SDL_WindowFlags 110 * \enum SDL_WindowFlags
205 * 111 *
206 * \brief The flags on a window 112 * \brief The flags on a window
113 *
114 * \sa SDL_GetWindowFlags()
207 */ 115 */
208 typedef enum 116 typedef enum
209 { 117 {
210 SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window, implies borderless */ 118 SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window, implies borderless */
211 SDL_WINDOW_BORDERLESS = 0x00000002, /**< no window decoration */ 119 SDL_WINDOW_BORDERLESS = 0x00000002, /**< no window decoration */
237 SDL_WINDOWEVENT_ENTER, /**< The window has gained mouse focus */ 145 SDL_WINDOWEVENT_ENTER, /**< The window has gained mouse focus */
238 SDL_WINDOWEVENT_LEAVE, /**< The window has lost mouse focus */ 146 SDL_WINDOWEVENT_LEAVE, /**< The window has lost mouse focus */
239 SDL_WINDOWEVENT_FOCUS_GAINED, /**< The window has gained keyboard focus */ 147 SDL_WINDOWEVENT_FOCUS_GAINED, /**< The window has gained keyboard focus */
240 SDL_WINDOWEVENT_FOCUS_LOST, /**< The window has lost keyboard focus */ 148 SDL_WINDOWEVENT_FOCUS_LOST, /**< The window has lost keyboard focus */
241 } SDL_WindowEventID; 149 } SDL_WindowEventID;
150
151 /**
152 * \enum SDL_RendererFlags
153 *
154 * \brief Flags used when initializing a render manager.
155 */
156 typedef enum
157 {
158 SDL_Renderer_PresentDiscard = 0x00000001, /**< Present leaves the contents of the backbuffer undefined */
159 SDL_Renderer_PresentCopy = 0x00000002, /**< Present uses a copy from back buffer to the front buffer */
160 SDL_Renderer_PresentFlip2 = 0x00000004, /**< Present uses a flip, swapping back buffer and front buffer */
161 SDL_Renderer_PresentFlip3 = 0x00000008, /**< Present uses a flip, rotating between two back buffers and a front buffer */
162 SDL_Renderer_PresentVSync = 0x00000010, /**< Present is synchronized with the refresh rate */
163 SDL_Renderer_RenderTarget = 0x00000020, /**< The renderer can create texture render targets */
164 SDL_Renderer_Accelerated = 0x00000040, /**< The renderer uses hardware acceleration */
165 SDL_Renderer_Minimal = 0x00000080, /**< The renderer only supports the read/write pixel and present functions */
166 } SDL_RendererFlags;
167
168 /**
169 * \struct SDL_RendererInfo
170 *
171 * \brief Information on the capabilities of a render manager.
172 */
173 typedef struct SDL_RendererInfo
174 {
175 const char *name; /**< The name of the renderer */
176 Uint32 flags; /**< Supported SDL_RendererFlags */
177 Uint32 blend_modes; /**< A mask of supported blend modes */
178 Uint32 scale_modes; /**< A mask of supported scale modes */
179 Uint32 num_texture_formats; /**< The number of available texture formats */
180 Uint32 texture_formats[32]; /**< The available texture formats */
181 int max_texture_width; /**< The maximimum texture width */
182 int max_texture_height; /**< The maximimum texture height */
183 } SDL_RendererInfo;
184
185 /**
186 * \enum SDL_TextureAccess
187 *
188 * \brief The access pattern allowed for a texture
189 */
190 typedef enum
191 {
192 SDL_TextureAccess_Render, /**< Unlockable video memory, rendering allowed */
193 SDL_TextureAccess_Remote, /**< Unlockable video memory */
194 SDL_TextureAccess_Local, /**< Lockable system memory */
195 } SDL_TextureAccess;
196
197 /**
198 * \enum SDL_TextureBlendMode
199 *
200 * \brief The blend mode used in SDL_RenderCopy()
201 */
202 typedef enum
203 {
204 SDL_TextureBlendMode_None, /**< No blending */
205 SDL_TextureBlendMode_Mask, /**< dst = A ? src : dst (alpha is mask) */
206 SDL_TextureBlendMode_Blend, /**< dst = (src * A) + (dst * (1-A)) */
207 SDL_TextureBlendMode_Add, /**< dst = (src * A) + dst */
208 SDL_TextureBlendMode_Mod, /**< dst = src * dst */
209 } SDL_TextureBlendMode;
210
211 /**
212 * \enum SDL_TextureScaleMode
213 *
214 * \brief The scale mode used in SDL_RenderCopy()
215 */
216 typedef enum
217 {
218 SDL_TextureScaleMode_None, /**< No scaling, rectangles must match dimensions */
219 SDL_TextureScaleMode_Fast, /**< Point sampling or equivalent algorithm */
220 SDL_TextureScaleMode_Slow, /**< Linear filtering or equivalent algorithm */
221 SDL_TextureScaleMode_Best, /**< Bicubic filtering or equivalent algorithm */
222 } SDL_TextureScaleMode;
223
224 /**
225 * \typedef SDL_TextureID
226 *
227 * \brief An efficient driver-specific representation of pixel data
228 */
229 typedef Uint32 SDL_TextureID;
230
231
232 /* These are the currently supported flags for the SDL_surface */
233 /* Used internally (read-only) */
234 #define SDL_HWSURFACE 0x00000001 /* Surface represents a texture */
235 #define SDL_PREALLOC 0x00000002 /* Surface uses preallocated memory */
236 #define SDL_SRCALPHA 0x00000004 /* Blit uses source alpha blending */
237 #define SDL_SRCCOLORKEY 0x00000008 /* Blit uses a source color key */
238 #define SDL_RLEACCELOK 0x00000010 /* Private flag */
239 #define SDL_RLEACCEL 0x00000020 /* Surface is RLE encoded */
240
241 /* Evaluates to true if the surface needs to be locked before access */
242 #define SDL_MUSTLOCK(S) (((S)->flags & (SDL_HWSURFACE|SDL_RLEACCEL)) != 0)
243
244 /* This structure should be treated as read-only, except for 'pixels',
245 which, if not NULL, contains the raw pixel data for the surface.
246 */
247 typedef struct SDL_Surface
248 {
249 Uint32 flags; /* Read-only */
250 SDL_PixelFormat *format; /* Read-only */
251 int w, h; /* Read-only */
252 int pitch; /* Read-only */
253 void *pixels; /* Read-write */
254
255 /* information needed for surfaces requiring locks */
256 int locked;
257 void *lock_data;
258
259 /* clipping information */
260 SDL_Rect clip_rect; /* Read-only */
261
262 /* info for fast blit mapping to other surfaces */
263 struct SDL_BlitMap *map; /* Private */
264
265 /* format version, bumped at every change to invalidate blit maps */
266 unsigned int format_version; /* Private */
267
268 /* Reference count -- used when freeing surface */
269 int refcount; /* Read-mostly */
270 } SDL_Surface;
271
272 /* typedef for private surface blitting functions */
273 typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
274 struct SDL_Surface * dst, SDL_Rect * dstrect);
275
276
277 /* The most common video overlay formats.
278 For an explanation of these pixel formats, see:
279 http://www.webartz.com/fourcc/indexyuv.htm
280
281 For information on the relationship between color spaces, see:
282 http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
283 */
284 #define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */
285 #define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */
286 #define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
287 #define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
288 #define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
289
290 /* The YUV hardware video overlay */
291 typedef struct SDL_Overlay
292 {
293 Uint32 format; /* Read-only */
294 int w, h; /* Read-only */
295 int planes; /* Read-only */
296 Uint16 *pitches; /* Read-only */
297 Uint8 **pixels; /* Read-write */
298
299 /* Hardware-specific surface info */
300 struct private_yuvhwfuncs *hwfuncs;
301 struct private_yuvhwdata *hwdata;
302
303 /* Special flags */
304 Uint32 hw_overlay:1; /* Flag: This overlay hardware accelerated? */
305 Uint32 UnusedBits:31;
306 } SDL_Overlay;
242 307
243 /** 308 /**
244 * \enum SDL_GLattr 309 * \enum SDL_GLattr
245 * 310 *
246 * \brief OpenGL configuration attributes 311 * \brief OpenGL configuration attributes
264 SDL_GL_MULTISAMPLESAMPLES, 329 SDL_GL_MULTISAMPLESAMPLES,
265 SDL_GL_ACCELERATED_VISUAL, 330 SDL_GL_ACCELERATED_VISUAL,
266 SDL_GL_SWAP_CONTROL 331 SDL_GL_SWAP_CONTROL
267 } SDL_GLattr; 332 } SDL_GLattr;
268 333
269 /* These are the currently supported flags for the SDL_surface */
270 #define SDL_SWSURFACE 0x00000000 /* Surface is in system memory */
271 #define SDL_HWSURFACE 0x00000001 /* Surface is in video memory */
272 /* Available for SDL_CreateWindowSurface() */
273 #define SDL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */
274 #define SDL_HWPALETTE 0x20000000 /* Surface has exclusive palette */
275 #define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered surface */
276 /* Used internally (read-only) */
277 #define SDL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */
278 #define SDL_SRCCOLORKEY 0x00001000 /* Blit uses a source color key */
279 #define SDL_RLEACCELOK 0x00002000 /* Private flag */
280 #define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */
281 #define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */
282 #define SDL_PREALLOC 0x00100000 /* Surface uses preallocated memory */
283 #define SDL_SCREEN_SURFACE 0x01000000 /* Surface is a window screen surface */
284 #define SDL_SHADOW_SURFACE 0x02000000 /* Surface is a window shadow surface */
285 334
286 /* Function prototypes */ 335 /* Function prototypes */
287 336
288 /** 337 /**
289 * \fn int SDL_GetNumVideoDrivers(void) 338 * \fn int SDL_GetNumVideoDrivers(void)
348 * \sa SDL_GetVideoDriver() 397 * \sa SDL_GetVideoDriver()
349 */ 398 */
350 extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); 399 extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
351 400
352 /** 401 /**
353 * \fn const SDL_VideoInfo *SDL_GetVideoInfo(void)
354 *
355 * \brief Returns information about the currently initialized video driver.
356 *
357 * \return A read-only pointer to information about the video hardware,
358 * or NULL if no video driver has been initialized.
359 */
360 extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
361
362 /**
363 * \fn int SDL_GetNumVideoDisplays(void) 402 * \fn int SDL_GetNumVideoDisplays(void)
364 * 403 *
365 * \brief Returns the number of available video displays. 404 * \brief Returns the number of available video displays.
366 * 405 *
367 * \sa SDL_SelectVideoDisplay() 406 * \sa SDL_SelectVideoDisplay()
370 409
371 /** 410 /**
372 * \fn int SDL_SelectVideoDisplay(int index) 411 * \fn int SDL_SelectVideoDisplay(int index)
373 * 412 *
374 * \brief Set the index of the currently selected display. 413 * \brief Set the index of the currently selected display.
414 *
415 * \return The index of the currently selected display.
375 * 416 *
376 * \note You can query the currently selected display by passing an index of -1. 417 * \note You can query the currently selected display by passing an index of -1.
377 * 418 *
378 * \sa SDL_GetNumVideoDisplays() 419 * \sa SDL_GetNumVideoDisplays()
379 */ 420 */
448 * \param mode The desired display mode 489 * \param mode The desired display mode
449 * 490 *
450 * \return 0 on success, or -1 if setting the display mode failed. 491 * \return 0 on success, or -1 if setting the display mode failed.
451 */ 492 */
452 extern DECLSPEC int SDLCALL SDL_SetDisplayMode(const SDL_DisplayMode * mode); 493 extern DECLSPEC int SDLCALL SDL_SetDisplayMode(const SDL_DisplayMode * mode);
494
495 /**
496 * \fn int SDL_SetDisplayColormap(SDL_Color *colors, int firstcolor, int ncolors)
497 *
498 * \brief Set the colormap for indexed display modes.
499 *
500 * \return 0 on success, or -1 if not all the colors could be set.
501 */
502 extern DECLSPEC int SDLCALL SDL_SetDisplayColors(SDL_Color * colors,
503 int firstcolor, int ncolors);
453 504
454 /** 505 /**
455 * \fn SDL_WindowID SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) 506 * \fn SDL_WindowID SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
456 * 507 *
457 * \brief Create a window with the specified position, dimensions, and flags. 508 * \brief Create a window with the specified position, dimensions, and flags.
671 * \brief Destroy a window. 722 * \brief Destroy a window.
672 */ 723 */
673 extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_WindowID windowID); 724 extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_WindowID windowID);
674 725
675 /** 726 /**
676 * \fn SDL_Surface *SDL_CreateWindowSurface (SDL_WindowID windowID, Uint32 format, Uint32 flags) 727 * \fn int SDL_GetNumRenderers(void)
677 * 728 *
678 * \brief Create an SDL_Surface representing the drawing area of the window. 729 * \brief Get the number of render managers on the current display.
679 */ 730 *
680 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateWindowSurface(SDL_WindowID 731 * A render manager is a set of code that handles rendering and texture
681 windowID, 732 * management on a particular display. Normally there is only one, but
682 Uint32 format, 733 * some drivers may have several available with different capabilities.
683 Uint32 flags); 734 *
684 735 * \sa SDL_GetRendererInfo()
685 /* 736 * \sa SDL_CreateRenderer()
686 * Makes sure the given list of rectangles is updated on the given screen. 737 */
687 * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire 738 extern DECLSPEC int SDLCALL SDL_GetNumRenderers(void);
688 * screen. 739
689 * These functions should not be called while 'screen' is locked. 740 /**
690 */ 741 * \fn SDL_RendererInfo *SDL_GetRendererInfo(int index)
691 extern DECLSPEC void SDLCALL SDL_UpdateRects 742 *
692 (SDL_Surface * screen, int numrects, SDL_Rect * rects); 743 * \brief Get information about a specific render manager on the current
693 extern DECLSPEC void SDLCALL SDL_UpdateRect 744 * display.
694 (SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); 745 *
695 746 * \sa SDL_CreateRenderer()
696 /* 747 */
697 * On hardware that supports double-buffering, this function sets up a flip 748 extern DECLSPEC int SDLCALL SDL_GetRendererInfo(int index,
698 * and returns. The hardware will wait for vertical retrace, and then swap 749 SDL_RendererInfo * info);
699 * video buffers before the next video surface blit or lock will return. 750
700 * On hardware that doesn not support double-buffering, this is equivalent 751 /**
701 * to calling SDL_UpdateRect(screen, 0, 0, 0, 0); 752 * \fn int SDL_CreateRenderer(SDL_WindowID window, int index, Uint32 flags)
702 * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when 753 *
703 * setting the video mode for this function to perform hardware flipping. 754 * \brief Create and make active a 2D rendering context for a window.
704 * This function returns 0 if successful, or -1 if there was an error. 755 *
705 */ 756 * \param windowID The window used for rendering.
706 extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen); 757 * \param index The index of the render manager to initialize, or -1 to initialize the first one supporting the requested flags.
758 * \param flags SDL_RendererFlags
759 *
760 * \return 0 on success, -1 if the flags were not supported, or -2 if
761 * there isn't enough memory to support the requested flags
762 *
763 * \sa SDL_SelectRenderer()
764 * \sa SDL_DestroyRenderer()
765 */
766 extern DECLSPEC int SDLCALL SDL_CreateRenderer(SDL_WindowID windowID,
767 int index, Uint32 flags);
768
769 /**
770 * \fn int SDL_SelectRenderer(SDL_WindowID windowID)
771 *
772 * \brief Select the rendering context for a particular window.
773 *
774 * \return 0 on success, -1 if the selected window doesn't have a
775 * rendering context.
776 */
777 extern DECLSPEC int SDLCALL SDL_SelectRenderer(SDL_WindowID windowID);
778
779 /**
780 * \fn SDL_TextureID SDL_CreateTexture(Uint32 format, int access, int w, int h)
781 *
782 * \brief Create a texture
783 *
784 * \param format The format of the texture
785 * \param access One of the enumerated values in SDL_TextureAccess
786 * \param w The width of the texture in pixels
787 * \param h The height of the texture in pixels
788 *
789 * \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.
790 *
791 * \sa SDL_QueryTexture()
792 * \sa SDL_DestroyTexture()
793 */
794 extern DECLSPEC SDL_TextureID SDLCALL SDL_CreateTexture(Uint32 format,
795 int access, int w,
796 int h);
797
798 /**
799 * \fn SDL_TextureID SDL_CreateTextureFromSurface(Uint32 format, int access, SDL_Surface *surface)
800 *
801 * \brief Create a texture from an existing surface
802 *
803 * \param format The format of the texture, or 0 to pick an appropriate format
804 * \param access One of the enumerated values in SDL_TextureAccess
805 * \param surface The surface containing pixel data used to fill the texture
806 *
807 * \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.
808 *
809 * \note The surface is not modified or freed by this function.
810 *
811 * \sa SDL_QueryTexture()
812 * \sa SDL_DestroyTexture()
813 */
814 extern DECLSPEC SDL_TextureID SDLCALL SDL_CreateTextureFromSurface(Uint32
815 format,
816 int access,
817 SDL_Surface
818 * surface);
819
820 /**
821 * \fn int SDL_QueryTexture(SDL_TextureID textureID, Uint32 *format, int *access, int *w, int *h)
822 *
823 * \brief Query the attributes of a texture
824 *
825 * \param texture A texture to be queried
826 * \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.
827 * \param access A pointer filled in with the actual access to the texture.
828 * \param w A pointer filled in with the width of the texture in pixels
829 * \param h A pointer filled in with the height of the texture in pixels
830 *
831 * \return 0 on success, or -1 if the texture is not valid
832 */
833 extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_TextureID textureID,
834 Uint32 * format, int *access,
835 int *w, int *h);
836
837 /**
838 * \fn int SDL_SetTexturePalette(SDL_TextureID textureID, SDL_Color * colors, int firstcolor, int ncolors)
839 *
840 * \brief Update an indexed texture with a color palette
841 *
842 * \param texture The texture to update
843 * \param colors The array of RGB color data
844 * \param firstcolor The first index to update
845 * \param ncolors The number of palette entries to fill with the color data
846 *
847 * \return 0 on success, or -1 if the texture is not valid or not an indexed texture
848 */
849 extern DECLSPEC int SDLCALL SDL_SetTexturePalette(SDL_TextureID textureID,
850 SDL_Color * colors,
851 int firstcolor,
852 int ncolors);
853
854 /**
855 * \fn int SDL_UpdateTexture(SDL_TextureID textureID, SDL_Rect *rect, const void *pixels, int pitch)
856 *
857 * \brief Update the given texture rectangle with new pixel data.
858 *
859 * \param texture The texture to update
860 * \param rect A pointer to the rectangle of pixels to update, or NULL to update the entire texture.
861 * \param pixels The raw pixel data
862 * \param pitch The number of bytes between rows of pixel data
863 *
864 * \return 0 on success, or -1 if the texture is not valid
865 *
866 * \note This is a very slow function for textures not created with SDL_TextureAccess_Local.
867 */
868 extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_TextureID textureID,
869 SDL_Rect * rect,
870 const void *pixels, int pitch);
871
872 /**
873 * \fn void SDL_LockTexture(SDL_TextureID textureID, SDL_Rect *rect, int markDirty, void **pixels, int *pitch)
874 *
875 * \brief Lock a portion of the texture for pixel access.
876 *
877 * \param texture The texture to lock for access, which must have been created with SDL_TextureAccess_Local.
878 * \param rect A pointer to the rectangle to lock for access. If the rect is NULL, the entire texture will be locked.
879 * \param markDirty If this is nonzero, the locked area will be marked dirty when the texture is unlocked.
880 * \param pixels This is filled in with a pointer to the locked pixels, appropriately offset by the locked area.
881 * \param pitch This is filled in with the pitch of the locked pixels.
882 *
883 * \return 0 on success, or -1 if the texture is not valid or was created with SDL_TextureAccess_Remote
884 *
885 * \sa SDL_DirtyTexture()
886 * \sa SDL_UnlockTexture()
887 */
888 extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_TextureID textureID,
889 SDL_Rect * rect, int markDirty,
890 void **pixels, int *pitch);
891
892 /**
893 * \fn void SDL_UnlockTexture(SDL_TextureID textureID)
894 *
895 * \brief Unlock a texture, uploading the changes to video memory, if needed.
896 *
897 * \sa SDL_LockTexture()
898 * \sa SDL_DirtyTexture()
899 */
900 extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_TextureID textureID);
901
902 /**
903 * \fn void SDL_DirtyTexture(SDL_TextureID textureID, int numrects, SDL_Rect * rects)
904 *
905 * \brief Mark the specified rectangles of the texture as dirty.
906 *
907 * \note The texture must have been created with SDL_TextureAccess_Local.
908 *
909 * \sa SDL_LockTexture()
910 * \sa SDL_UnlockTexture()
911 */
912 extern DECLSPEC void SDLCALL SDL_DirtyTexture(SDL_TextureID textureID,
913 int numrects, SDL_Rect * rects);
914
915 /**
916 * \fn void SDL_SelectRenderTexture(SDL_TextureID textureID)
917 *
918 * \brief Select a texture as the rendering target, or 0 to reselect the current window.
919 *
920 * \note The texture must have been created with SDL_TextureAccess_Render.
921 */
922 extern DECLSPEC void SDLCALL SDL_SelectRenderTexture(SDL_TextureID textureID);
923
924 /**
925 * \fn void SDL_RenderFill(SDL_Rect *rect, Uint32 color)
926 *
927 * \brief Fill the current rendering target with the specified color.
928 *
929 * \param rect A pointer to the destination rectangle, or NULL for the entire rendering target.
930 * \param color An ARGB color value.
931 *
932 * \return 0 on success, or -1 if there is no renderer current
933 */
934 extern DECLSPEC int SDLCALL SDL_RenderFill(SDL_Rect * rect, Uint32 color);
935
936 /**
937 * \fn int SDL_RenderCopy(SDL_TextureID textureID, SDL_Rect *srcrect, SDL_Rect *dstrect, Uint32 blendMode, Uint32 scaleMode)
938 *
939 * \brief Copy a portion of the texture to the current rendering target.
940 *
941 * \param texture The source texture.
942 * \param srcrect A pointer to the source rectangle, or NULL for the entire texture.
943 * \param dstrect A pointer to the destination rectangle, or NULL for the entire rendering target.
944 * \param blendMode SDL_TextureBlendMode to be used if the source texture has an alpha channel.
945 * \param scaleMode SDL_TextureScaleMode to be used if the source and destination rectangles don't have the same width and height.
946 *
947 * \return 0 on success, or -1 if there is no renderer current, or the driver doesn't support the requested operation.
948 *
949 * \note You can check the video driver info to see what operations are supported.
950 */
951 extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_TextureID textureID,
952 SDL_Rect * srcrect,
953 SDL_Rect * dstrect, int blendMode,
954 int scaleMode);
955
956 /**
957 * \fn int SDL_RenderReadPixels(SDL_Rect *rect, void *pixels, int pitch)
958 *
959 * \brief Read pixels from the current rendering target.
960 *
961 * \param rect A pointer to the rectangle to read, or NULL for the entire render target
962 * \param pixels A pointer to be filled in with the pixel data
963 * \param pitch The pitch of the pixels parameter
964 *
965 * \return 0 on success, or -1 if pixel reading is not supported.
966 *
967 * \warning This is a very slow operation, and should not be used frequently.
968 */
969 extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Rect * rect,
970 void *pixels, int pitch);
971
972 /**
973 * \fn int SDL_RenderWritePixels(SDL_Rect *rect, const void *pixels, int pitch)
974 *
975 * \brief Write pixels to the current rendering target.
976 *
977 * \param rect A pointer to the rectangle to write, or NULL for the entire render target
978 * \param pixels A pointer to the pixel data to write
979 * \param pitch The pitch of the pixels parameter
980 *
981 * \return 0 on success, or -1 if pixel writing is not supported.
982 *
983 * \warning This is a very slow operation, and should not be used frequently.
984 */
985 extern DECLSPEC int SDLCALL SDL_RenderWritePixels(SDL_Rect * rect,
986 const void *pixels,
987 int pitch);
988
989 /**
990 * \fn void SDL_RenderPresent(void)
991 *
992 * \brief Update the screen with rendering performed.
993 */
994 extern DECLSPEC void SDLCALL SDL_RenderPresent(void);
995
996 /**
997 * \fn void SDL_DestroyTexture(SDL_TextureID textureID);
998 *
999 * \brief Destroy the specified texture.
1000 *
1001 * \sa SDL_CreateTexture()
1002 * \sa SDL_CreateTextureFromSurface()
1003 */
1004 extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_TextureID textureID);
1005
1006 /**
1007 * \fn void SDL_DestroyRenderer(SDL_WindowID windowID);
1008 *
1009 * \brief Destroy the rendering context for a window and free associated
1010 * textures.
1011 *
1012 * \sa SDL_CreateRenderer()
1013 */
1014 extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_WindowID windowID);
707 1015
708 /* 1016 /*
709 * Set the gamma correction for each of the color channels. 1017 * Set the gamma correction for each of the color channels.
710 * The gamma values range (approximately) between 0.1 and 10.0 1018 * The gamma values range (approximately) between 0.1 and 10.0
711 * 1019 *
794 * If the depth is greater than 8 bits, the pixel format is set using the 1102 * If the depth is greater than 8 bits, the pixel format is set using the
795 * flags '[RGB]mask'. 1103 * flags '[RGB]mask'.
796 * If the function runs out of memory, it will return NULL. 1104 * If the function runs out of memory, it will return NULL.
797 * 1105 *
798 * The 'flags' tell what kind of surface to create. 1106 * The 'flags' tell what kind of surface to create.
799 * SDL_SWSURFACE means that the surface should be created in system memory.
800 * SDL_HWSURFACE means that the surface should be created in video memory,
801 * with the same format as the display surface. This is useful for surfaces
802 * that will not change much, to take advantage of hardware acceleration
803 * when being blitted to the display surface.
804 * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
805 * this surface, but you must always lock it before accessing the pixels.
806 * SDL will wait for current blits to finish before returning from the lock.
807 * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. 1107 * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
808 * If the hardware supports acceleration of colorkey blits between 1108 * SDL_SRCALPHA means that the surface will be used for alpha blits.
809 * two surfaces in video memory, SDL will try to place the surface in 1109 */
810 * video memory. If this isn't possible or if there is no hardware
811 * acceleration available, the surface will be placed in system memory.
812 * SDL_SRCALPHA means that the surface will be used for alpha blits and
813 * if the hardware supports hardware acceleration of alpha blits between
814 * two surfaces in video memory, to place the surface in video memory
815 * if possible, otherwise it will be placed in system memory.
816 * If the surface is created in video memory, blits will be _much_ faster,
817 * but the surface format must be identical to the video surface format,
818 * and the only way to access the pixels member of the surface is to use
819 * the SDL_LockSurface() and SDL_UnlockSurface() calls.
820 * If the requested surface actually resides in video memory, SDL_HWSURFACE
821 * will be set in the flags member of the returned surface. If for some
822 * reason the surface could not be placed in video memory, it will not have
823 * the SDL_HWSURFACE flag set, and will be created in system memory instead.
824 */
825 #define SDL_AllocSurface SDL_CreateRGBSurface
826 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface 1110 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
827 (Uint32 flags, int width, int height, int depth, 1111 (Uint32 flags, int width, int height, int depth,
828 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); 1112 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
829 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, 1113 extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
830 int width, 1114 int width,
833 int pitch, 1117 int pitch,
834 Uint32 Rmask, 1118 Uint32 Rmask,
835 Uint32 Gmask, 1119 Uint32 Gmask,
836 Uint32 Bmask, 1120 Uint32 Bmask,
837 Uint32 Amask); 1121 Uint32 Amask);
1122 extern DECLSPEC SDL_Surface *SDLCALL
1123 SDL_CreateRGBSurfaceFromTexture(SDL_TextureID textureID);
838 extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); 1124 extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
839 1125
840 /* 1126 /*
841 * SDL_LockSurface() sets up a surface for directly accessing the pixels. 1127 * SDL_LockSurface() sets up a surface for directly accessing the pixels.
842 * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write 1128 * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
844 * 'surface->format'. Once you are done accessing the surface, you should 1130 * 'surface->format'. Once you are done accessing the surface, you should
845 * use SDL_UnlockSurface() to release it. 1131 * use SDL_UnlockSurface() to release it.
846 * 1132 *
847 * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates 1133 * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
848 * to 0, then you can read and write to the surface at any time, and the 1134 * to 0, then you can read and write to the surface at any time, and the
849 * pixel format of the surface will not change. In particular, if the 1135 * pixel format of the surface will not change.
850 * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
851 * will not need to lock the display surface before accessing it.
852 * 1136 *
853 * No operating system or library calls should be made between lock/unlock 1137 * No operating system or library calls should be made between lock/unlock
854 * pairs, as critical system locks may be held during this time. 1138 * pairs, as critical system locks may be held during this time.
855 * 1139 *
856 * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. 1140 * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
947 * 1231 *
948 * This function is used internally by SDL_DisplayFormat(). 1232 * This function is used internally by SDL_DisplayFormat().
949 */ 1233 */
950 extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface 1234 extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
951 (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags); 1235 (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags);
1236
1237 /*
1238 * This function performs a fast fill of the given rectangle with 'color'
1239 * The given rectangle is clipped to the destination surface clip area
1240 * and the final fill rectangle is saved in the passed in pointer.
1241 * If 'dstrect' is NULL, the whole surface will be filled with 'color'
1242 * The color should be a pixel of the format used by the surface, and
1243 * can be generated by the SDL_MapRGB() function.
1244 * This function returns 0 on success, or -1 on error.
1245 */
1246 extern DECLSPEC int SDLCALL SDL_FillRect
1247 (SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color);
952 1248
953 /* 1249 /*
954 * This performs a fast blit from the source surface to the destination 1250 * This performs a fast blit from the source surface to the destination
955 * surface. It assumes that the source and destination rectangles are 1251 * surface. It assumes that the source and destination rectangles are
956 * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire 1252 * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire
1032 */ 1328 */
1033 extern DECLSPEC int SDLCALL SDL_LowerBlit 1329 extern DECLSPEC int SDLCALL SDL_LowerBlit
1034 (SDL_Surface * src, SDL_Rect * srcrect, 1330 (SDL_Surface * src, SDL_Rect * srcrect,
1035 SDL_Surface * dst, SDL_Rect * dstrect); 1331 SDL_Surface * dst, SDL_Rect * dstrect);
1036 1332
1037 /* 1333 /**
1038 * This function performs a fast fill of the given rectangle with 'color' 1334 * \fn int SDL_SoftStretch(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect)
1039 * The given rectangle is clipped to the destination surface clip area 1335 *
1040 * and the final fill rectangle is saved in the passed in pointer. 1336 * \brief Perform a fast, low quality, stretch blit between two surfaces of the same pixel format.
1041 * If 'dstrect' is NULL, the whole surface will be filled with 'color' 1337 * \note This function uses a static buffer, and is not thread-safe.
1042 * The color should be a pixel of the format used by the surface, and 1338 */
1043 * can be generated by the SDL_MapRGB() function. 1339 extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
1044 * This function returns 0 on success, or -1 on error. 1340 SDL_Rect * srcrect,
1045 */ 1341 SDL_Surface * dst,
1046 extern DECLSPEC int SDLCALL SDL_FillRect 1342 SDL_Rect * dstrect);
1047 (SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color);
1048
1049 /*
1050 * This function takes a surface and copies it to a new surface of the
1051 * pixel format and colors of the video framebuffer, suitable for fast
1052 * blitting onto the display surface. It calls SDL_ConvertSurface()
1053 *
1054 * If you want to take advantage of hardware colorkey or alpha blit
1055 * acceleration, you should set the colorkey and alpha value before
1056 * calling this function.
1057 *
1058 * If the conversion fails or runs out of memory, it returns NULL
1059 */
1060 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
1061
1062 /*
1063 * This function takes a surface and copies it to a new surface of the
1064 * pixel format and colors of the video framebuffer (if possible),
1065 * suitable for fast alpha blitting onto the display surface.
1066 * The new surface will always have an alpha channel.
1067 *
1068 * If you want to take advantage of hardware colorkey or alpha blit
1069 * acceleration, you should set the colorkey and alpha value before
1070 * calling this function.
1071 *
1072 * If the conversion fails or runs out of memory, it returns NULL
1073 */
1074 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
1075 surface);
1076 1343
1077 1344
1078 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 1345 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1079 /* YUV video surface overlay functions */ 1346 /* YUV video surface overlay functions */
1080 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 1347 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1143 /* 1410 /*
1144 * Swap the OpenGL buffers, if double-buffering is supported. 1411 * Swap the OpenGL buffers, if double-buffering is supported.
1145 */ 1412 */
1146 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); 1413 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
1147 1414
1148 /* Not in public API at the moment - do not use! */
1149 extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
1150 SDL_Rect * srcrect,
1151 SDL_Surface * dst,
1152 SDL_Rect * dstrect);
1153
1154 /* Ends C function definitions when using C++ */ 1415 /* Ends C function definitions when using C++ */
1155 #ifdef __cplusplus 1416 #ifdef __cplusplus
1156 /* *INDENT-OFF* */ 1417 /* *INDENT-OFF* */
1157 } 1418 }
1158 /* *INDENT-ON* */ 1419 /* *INDENT-ON* */