79
/* RGB color key information */
87
/** RGB color key information */
81
/* Alpha value information (per-surface alpha) */
89
/** Alpha value information (per-surface alpha) */
85
/* This structure should be treated as read-only, except for 'pixels',
86
which, if not NULL, contains the raw pixel data for the surface.
93
/** This structure should be treated as read-only, except for 'pixels',
94
* which, if not NULL, contains the raw pixel data for the surface.
88
96
typedef struct SDL_Surface {
89
Uint32 flags; /* Read-only */
90
SDL_PixelFormat *format; /* Read-only */
91
int w, h; /* Read-only */
92
Uint16 pitch; /* Read-only */
93
void *pixels; /* Read-write */
94
int offset; /* Private */
97
Uint32 flags; /**< Read-only */
98
SDL_PixelFormat *format; /**< Read-only */
99
int w, h; /**< Read-only */
100
Uint16 pitch; /**< Read-only */
101
void *pixels; /**< Read-write */
102
int offset; /**< Private */
96
/* Hardware-specific surface info */
104
/** Hardware-specific surface info */
97
105
struct private_hwdata *hwdata;
99
/* clipping information */
100
SDL_Rect clip_rect; /* Read-only */
101
Uint32 unused1; /* for binary compatibility */
103
/* Allow recursive locks */
104
Uint32 locked; /* Private */
106
/* info for fast blit mapping to other surfaces */
107
struct SDL_BlitMap *map; /* Private */
109
/* format version, bumped at every change to invalidate blit maps */
110
unsigned int format_version; /* Private */
112
/* Reference count -- used when freeing surface */
113
int refcount; /* Read-mostly */
107
/** clipping information */
108
SDL_Rect clip_rect; /**< Read-only */
109
Uint32 unused1; /**< for binary compatibility */
111
/** Allow recursive locks */
112
Uint32 locked; /**< Private */
114
/** info for fast blit mapping to other surfaces */
115
struct SDL_BlitMap *map; /**< Private */
117
/** format version, bumped at every change to invalidate blit maps */
118
unsigned int format_version; /**< Private */
120
/** Reference count -- used when freeing surface */
121
int refcount; /**< Read-mostly */
116
/* These are the currently supported flags for the SDL_surface */
117
/* Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */
118
#define SDL_SWSURFACE 0x00000000 /* Surface is in system memory */
119
#define SDL_HWSURFACE 0x00000001 /* Surface is in video memory */
120
#define SDL_ASYNCBLIT 0x00000004 /* Use asynchronous blits if possible */
121
/* Available for SDL_SetVideoMode() */
122
#define SDL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */
123
#define SDL_HWPALETTE 0x20000000 /* Surface has exclusive palette */
124
#define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */
125
#define SDL_FULLSCREEN 0x80000000 /* Surface is a full screen display */
126
#define SDL_OPENGL 0x00000002 /* Create an OpenGL rendering context */
127
#define SDL_OPENGLBLIT 0x0000000A /* Create an OpenGL rendering context and use it for blitting */
128
#define SDL_RESIZABLE 0x00000010 /* This video mode may be resized */
129
#define SDL_NOFRAME 0x00000020 /* No window caption or edge frame */
130
/* Used internally (read-only) */
131
#define SDL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */
132
#define SDL_SRCCOLORKEY 0x00001000 /* Blit uses a source color key */
133
#define SDL_RLEACCELOK 0x00002000 /* Private flag */
134
#define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */
135
#define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */
136
#define SDL_PREALLOC 0x01000000 /* Surface uses preallocated memory */
138
/* Evaluates to true if the surface needs to be locked before access */
124
/** @name SDL_Surface Flags
125
* These are the currently supported flags for the SDL_surface
129
/** Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */
131
#define SDL_SWSURFACE 0x00000000 /**< Surface is in system memory */
132
#define SDL_HWSURFACE 0x00000001 /**< Surface is in video memory */
133
#define SDL_ASYNCBLIT 0x00000004 /**< Use asynchronous blits if possible */
136
/** Available for SDL_SetVideoMode() */
138
#define SDL_ANYFORMAT 0x10000000 /**< Allow any video depth/pixel-format */
139
#define SDL_HWPALETTE 0x20000000 /**< Surface has exclusive palette */
140
#define SDL_DOUBLEBUF 0x40000000 /**< Set up double-buffered video mode */
141
#define SDL_FULLSCREEN 0x80000000 /**< Surface is a full screen display */
142
#define SDL_OPENGL 0x00000002 /**< Create an OpenGL rendering context */
143
#define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */
144
#define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */
145
#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */
148
/** Used internally (read-only) */
150
#define SDL_HWACCEL 0x00000100 /**< Blit uses hardware acceleration */
151
#define SDL_SRCCOLORKEY 0x00001000 /**< Blit uses a source color key */
152
#define SDL_RLEACCELOK 0x00002000 /**< Private flag */
153
#define SDL_RLEACCEL 0x00004000 /**< Surface is RLE encoded */
154
#define SDL_SRCALPHA 0x00010000 /**< Blit uses source alpha blending */
155
#define SDL_PREALLOC 0x01000000 /**< Surface uses preallocated memory */
160
/** Evaluates to true if the surface needs to be locked before access */
139
161
#define SDL_MUSTLOCK(surface) \
140
162
(surface->offset || \
141
163
((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0))
143
/* typedef for private surface blitting functions */
165
/** typedef for private surface blitting functions */
144
166
typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect,
145
167
struct SDL_Surface *dst, SDL_Rect *dstrect);
148
/* Useful for determining the video hardware capabilities */
170
/** Useful for determining the video hardware capabilities */
149
171
typedef struct SDL_VideoInfo {
150
Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */
151
Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */
172
Uint32 hw_available :1; /**< Flag: Can you create hardware surfaces? */
173
Uint32 wm_available :1; /**< Flag: Can you talk to a window manager? */
152
174
Uint32 UnusedBits1 :6;
153
175
Uint32 UnusedBits2 :1;
154
Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */
155
Uint32 blit_hw_CC :1; /* Flag: Accelerated blits with Colorkey */
156
Uint32 blit_hw_A :1; /* Flag: Accelerated blits with Alpha */
157
Uint32 blit_sw :1; /* Flag: Accelerated blits SW --> HW */
158
Uint32 blit_sw_CC :1; /* Flag: Accelerated blits with Colorkey */
159
Uint32 blit_sw_A :1; /* Flag: Accelerated blits with Alpha */
160
Uint32 blit_fill :1; /* Flag: Accelerated color fill */
176
Uint32 blit_hw :1; /**< Flag: Accelerated blits HW --> HW */
177
Uint32 blit_hw_CC :1; /**< Flag: Accelerated blits with Colorkey */
178
Uint32 blit_hw_A :1; /**< Flag: Accelerated blits with Alpha */
179
Uint32 blit_sw :1; /**< Flag: Accelerated blits SW --> HW */
180
Uint32 blit_sw_CC :1; /**< Flag: Accelerated blits with Colorkey */
181
Uint32 blit_sw_A :1; /**< Flag: Accelerated blits with Alpha */
182
Uint32 blit_fill :1; /**< Flag: Accelerated color fill */
161
183
Uint32 UnusedBits3 :16;
162
Uint32 video_mem; /* The total amount of video memory (in K) */
163
SDL_PixelFormat *vfmt; /* Value: The format of the video surface */
164
int current_w; /* Value: The current video mode width */
165
int current_h; /* Value: The current video mode height */
184
Uint32 video_mem; /**< The total amount of video memory (in K) */
185
SDL_PixelFormat *vfmt; /**< Value: The format of the video surface */
186
int current_w; /**< Value: The current video mode width */
187
int current_h; /**< Value: The current video mode height */
169
/* The most common video overlay formats.
170
For an explanation of these pixel formats, see:
171
http://www.webartz.com/fourcc/indexyuv.htm
173
For information on the relationship between color spaces, see:
174
http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
191
/** @name Overlay Formats
192
* The most common video overlay formats.
193
* For an explanation of these pixel formats, see:
194
* http://www.webartz.com/fourcc/indexyuv.htm
196
* For information on the relationship between color spaces, see:
197
* http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
176
#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */
177
#define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */
178
#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */
179
#define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */
180
#define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */
200
#define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */
201
#define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */
202
#define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
203
#define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
204
#define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
182
/* The YUV hardware video overlay */
207
/** The YUV hardware video overlay */
183
208
typedef struct SDL_Overlay {
184
Uint32 format; /* Read-only */
185
int w, h; /* Read-only */
186
int planes; /* Read-only */
187
Uint16 *pitches; /* Read-only */
188
Uint8 **pixels; /* Read-write */
209
Uint32 format; /**< Read-only */
210
int w, h; /**< Read-only */
211
int planes; /**< Read-only */
212
Uint16 *pitches; /**< Read-only */
213
Uint8 **pixels; /**< Read-write */
190
/* Hardware-specific surface info */
215
/** @name Hardware-specific surface info */
191
217
struct private_yuvhwfuncs *hwfuncs;
192
218
struct private_yuvhwdata *hwdata;
195
Uint32 hw_overlay :1; /* Flag: This overlay hardware accelerated? */
221
/** @name Special flags */
223
Uint32 hw_overlay :1; /**< Flag: This overlay hardware accelerated? */
196
224
Uint32 UnusedBits :31;
200
/* Public enumeration for setting the OpenGL window attributes. */
229
/** Public enumeration for setting the OpenGL window attributes. */
203
232
SDL_GL_GREEN_SIZE,
443
486
SDL_Color *colors, int firstcolor,
447
490
* Maps an RGB triple to an opaque pixel value for a given pixel format
449
492
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB
450
493
(const SDL_PixelFormat * const format,
451
494
const Uint8 r, const Uint8 g, const Uint8 b);
454
497
* Maps an RGBA quadruple to a pixel value for a given pixel format
456
499
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA
457
500
(const SDL_PixelFormat * const format,
458
501
const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a);
461
504
* Maps a pixel value into the RGB components for a given pixel format
463
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt,
506
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
507
const SDL_PixelFormat * const fmt,
464
508
Uint8 *r, Uint8 *g, Uint8 *b);
467
511
* Maps a pixel value into the RGBA components for a given pixel format
469
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt,
470
Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
513
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
514
const SDL_PixelFormat * const fmt,
515
Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
517
/** @sa SDL_CreateRGBSurface */
518
#define SDL_AllocSurface SDL_CreateRGBSurface
473
520
* Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
474
521
* If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
475
522
* If the depth is greater than 8 bits, the pixel format is set using the
677
724
* If either of the surfaces were in video memory, and the blit returns -2,
678
725
* the video memory was lost, so it should be reloaded with artwork and
680
while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
681
while ( SDL_LockSurface(image) < 0 )
683
-- Write image pixels to image->pixels --
684
SDL_UnlockSurface(image);
728
* while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
729
* while ( SDL_LockSurface(image) < 0 )
731
* -- Write image pixels to image->pixels --
732
* SDL_UnlockSurface(image);
686
736
* This happens under DirectX 5.0 when the system switches away from your
687
737
* fullscreen application. The lock will also fail until you have access
688
738
* to the video memory again.
740
* You should call SDL_BlitSurface() unless you know exactly how SDL
741
* blitting works internally and how to use the other blit functions.
690
/* You should call SDL_BlitSurface() unless you know exactly how SDL
691
blitting works internally and how to use the other blit functions.
693
743
#define SDL_BlitSurface SDL_UpperBlit
695
/* This is the public blit function, SDL_BlitSurface(), and it performs
696
rectangle validation and clipping before passing it to SDL_LowerBlit()
745
/** This is the public blit function, SDL_BlitSurface(), and it performs
746
* rectangle validation and clipping before passing it to SDL_LowerBlit()
698
748
extern DECLSPEC int SDLCALL SDL_UpperBlit
699
749
(SDL_Surface *src, SDL_Rect *srcrect,
700
750
SDL_Surface *dst, SDL_Rect *dstrect);
701
/* This is a semi-private blit function and it performs low-level surface
751
/** This is a semi-private blit function and it performs low-level surface
704
754
extern DECLSPEC int SDLCALL SDL_LowerBlit
705
755
(SDL_Surface *src, SDL_Rect *srcrect,
706
756
SDL_Surface *dst, SDL_Rect *dstrect);
709
759
* This function performs a fast fill of the given rectangle with 'color'
710
760
* The given rectangle is clipped to the destination surface clip area
711
761
* and the final fill rectangle is saved in the passed in pointer.
748
798
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
749
/* YUV video surface overlay functions */
799
/** @name YUV video surface overlay functions */ /*@{*/
750
800
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
752
/* This function creates a video output overlay
753
Calling the returned surface an overlay is something of a misnomer because
754
the contents of the display surface underneath the area where the overlay
755
is shown is undefined - it may be overwritten with the converted YUV data.
802
/** This function creates a video output overlay
803
* Calling the returned surface an overlay is something of a misnomer because
804
* the contents of the display surface underneath the area where the overlay
805
* is shown is undefined - it may be overwritten with the converted YUV data.
757
807
extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height,
758
808
Uint32 format, SDL_Surface *display);
760
/* Lock an overlay for direct access, and unlock it when you are done */
810
/** Lock an overlay for direct access, and unlock it when you are done */
761
811
extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay);
762
812
extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay);
764
/* Blit a video overlay to the display surface.
765
The contents of the video surface underneath the blit destination are
767
The width and height of the destination rectangle may be different from
768
that of the overlay, but currently only 2x scaling is supported.
814
/** Blit a video overlay to the display surface.
815
* The contents of the video surface underneath the blit destination are
817
* The width and height of the destination rectangle may be different from
818
* that of the overlay, but currently only 2x scaling is supported.
770
820
extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect);
772
/* Free a video overlay */
822
/** Free a video overlay */
773
823
extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay);
776
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
777
/* OpenGL support functions. */
778
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
827
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
828
/** @name OpenGL support functions. */ /*@{*/
829
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
781
832
* Dynamically load an OpenGL library, or the default one if path is NULL
783
834
* If you do this, you need to retrieve all of the GL functions used in