comparison src/video/SDL_sysvideo.h @ 2753:0969758c8809

indent
author Sam Lantinga <slouken@libsdl.org>
date Mon, 15 Sep 2008 04:32:36 +0000
parents b86247d21929
children 99210400e8b9
comparison
equal deleted inserted replaced
2752:edd2839b36f7 2753:0969758c8809
35 typedef struct SDL_RenderDriver SDL_RenderDriver; 35 typedef struct SDL_RenderDriver SDL_RenderDriver;
36 typedef struct SDL_VideoDisplay SDL_VideoDisplay; 36 typedef struct SDL_VideoDisplay SDL_VideoDisplay;
37 typedef struct SDL_VideoDevice SDL_VideoDevice; 37 typedef struct SDL_VideoDevice SDL_VideoDevice;
38 38
39 /* Define the SDL texture structure */ 39 /* Define the SDL texture structure */
40 struct SDL_Texture { 40 struct SDL_Texture
41 Uint32 id; 41 {
42 42 Uint32 id;
43 Uint32 format; /**< The pixel format of the texture */ 43
44 int access; /**< SDL_TextureAccess */ 44 Uint32 format; /**< The pixel format of the texture */
45 int w; /**< The width of the texture */ 45 int access; /**< SDL_TextureAccess */
46 int h; /**< The height of the texture */ 46 int w; /**< The width of the texture */
47 int modMode;/**< The texture modulation mode */ 47 int h; /**< The height of the texture */
48 int blendMode; /**< The texture blend mode */ 48 int modMode; /**< The texture modulation mode */
49 int scaleMode; /**< The texture scale mode */ 49 int blendMode; /**< The texture blend mode */
50 Uint8 r, g, b, a; /**< Texture modulation values */ 50 int scaleMode; /**< The texture scale mode */
51 51 Uint8 r, g, b, a; /**< Texture modulation values */
52 SDL_Renderer *renderer; 52
53 53 SDL_Renderer *renderer;
54 void *driverdata; /**< Driver specific texture representation */ 54
55 55 void *driverdata; /**< Driver specific texture representation */
56 SDL_Texture *next; 56
57 SDL_Texture *next;
57 }; 58 };
58 59
59 /* Define the SDL renderer structure */ 60 /* Define the SDL renderer structure */
60 struct SDL_Renderer { 61 struct SDL_Renderer
61 int (*ActivateRenderer) (SDL_Renderer * renderer); 62 {
62 int (*DisplayModeChanged) (SDL_Renderer * renderer); 63 int (*ActivateRenderer) (SDL_Renderer * renderer);
63 int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture); 64 int (*DisplayModeChanged) (SDL_Renderer * renderer);
64 int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture, 65 int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
65 void **pixels, int *pitch); 66 int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
66 int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture, 67 void **pixels, int *pitch);
67 const SDL_Color * colors, int firstcolor, 68 int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
68 int ncolors); 69 const SDL_Color * colors, int firstcolor,
69 int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture, 70 int ncolors);
70 SDL_Color * colors, int firstcolor, 71 int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
71 int ncolors); 72 SDL_Color * colors, int firstcolor,
72 int (*SetTextureColorMod) (SDL_Renderer * renderer, 73 int ncolors);
73 SDL_Texture * texture); 74 int (*SetTextureColorMod) (SDL_Renderer * renderer,
74 int (*SetTextureAlphaMod) (SDL_Renderer * renderer, 75 SDL_Texture * texture);
75 SDL_Texture * texture); 76 int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
76 int (*SetTextureBlendMode) (SDL_Renderer * renderer, 77 SDL_Texture * texture);
77 SDL_Texture * texture); 78 int (*SetTextureBlendMode) (SDL_Renderer * renderer,
78 int (*SetTextureScaleMode) (SDL_Renderer * renderer, 79 SDL_Texture * texture);
79 SDL_Texture * texture); 80 int (*SetTextureScaleMode) (SDL_Renderer * renderer,
80 int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, 81 SDL_Texture * texture);
81 const SDL_Rect * rect, const void *pixels, 82 int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
82 int pitch); 83 const SDL_Rect * rect, const void *pixels,
83 int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, 84 int pitch);
84 const SDL_Rect * rect, int markDirty, void **pixels, 85 int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
85 int *pitch); 86 const SDL_Rect * rect, int markDirty, void **pixels,
86 void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); 87 int *pitch);
87 void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture, 88 void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
88 int numrects, const SDL_Rect * rects); 89 void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
89 int (*RenderFill) (SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, 90 int numrects, const SDL_Rect * rects);
90 Uint8 a, const SDL_Rect * rect); 91 int (*RenderFill) (SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
91 int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture, 92 Uint8 a, const SDL_Rect * rect);
92 const SDL_Rect * srcrect, const SDL_Rect * dstrect); 93 int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
93 void (*RenderPresent) (SDL_Renderer * renderer); 94 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
94 void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture); 95 void (*RenderPresent) (SDL_Renderer * renderer);
95 96 void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
96 void (*DestroyRenderer) (SDL_Renderer * renderer); 97
97 98 void (*DestroyRenderer) (SDL_Renderer * renderer);
98 /* The current renderer info */ 99
99 SDL_RendererInfo info; 100 /* The current renderer info */
100 101 SDL_RendererInfo info;
101 /* The window associated with the renderer */ 102
102 SDL_WindowID window; 103 /* The window associated with the renderer */
103 104 SDL_WindowID window;
104 void *driverdata; 105
106 void *driverdata;
105 }; 107 };
106 108
107 /* Define the SDL render driver structure */ 109 /* Define the SDL render driver structure */
108 struct SDL_RenderDriver { 110 struct SDL_RenderDriver
109 SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags); 111 {
110 112 SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
111 /* Info about the renderer capabilities */ 113
112 SDL_RendererInfo info; 114 /* Info about the renderer capabilities */
115 SDL_RendererInfo info;
113 }; 116 };
114 117
115 /* Define the SDL window structure, corresponding to toplevel windows */ 118 /* Define the SDL window structure, corresponding to toplevel windows */
116 struct SDL_Window { 119 struct SDL_Window
117 Uint32 id; 120 {
118 121 Uint32 id;
119 char *title; 122
120 int x, y; 123 char *title;
121 int w, h; 124 int x, y;
122 Uint32 flags; 125 int w, h;
123 126 Uint32 flags;
124 int display; 127
125 SDL_Renderer *renderer; 128 int display;
126 129 SDL_Renderer *renderer;
127 void *userdata; 130
128 void *driverdata; 131 void *userdata;
132 void *driverdata;
129 }; 133 };
130 #define FULLSCREEN_VISIBLE(W) \ 134 #define FULLSCREEN_VISIBLE(W) \
131 (((W)->flags & SDL_WINDOW_FULLSCREEN) && \ 135 (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
132 ((W)->flags & SDL_WINDOW_SHOWN) && \ 136 ((W)->flags & SDL_WINDOW_SHOWN) && \
133 !((W)->flags & SDL_WINDOW_MINIMIZED)) 137 !((W)->flags & SDL_WINDOW_MINIMIZED))
134 138
135 /* 139 /*
136 * Define the SDL display structure This corresponds to physical monitors 140 * Define the SDL display structure This corresponds to physical monitors
137 * attached to the system. 141 * attached to the system.
138 */ 142 */
139 struct SDL_VideoDisplay { 143 struct SDL_VideoDisplay
140 int max_display_modes; 144 {
141 int num_display_modes; 145 int max_display_modes;
142 SDL_DisplayMode *display_modes; 146 int num_display_modes;
143 SDL_DisplayMode desktop_mode; 147 SDL_DisplayMode *display_modes;
144 SDL_DisplayMode current_mode; 148 SDL_DisplayMode desktop_mode;
145 SDL_DisplayMode fullscreen_mode; 149 SDL_DisplayMode current_mode;
146 SDL_Palette *palette; 150 SDL_DisplayMode fullscreen_mode;
147 151 SDL_Palette *palette;
148 Uint16 *gamma; 152
149 Uint16 *saved_gamma; /* (just offset into gamma) */ 153 Uint16 *gamma;
150 154 Uint16 *saved_gamma; /* (just offset into gamma) */
151 int num_render_drivers; 155
152 SDL_RenderDriver *render_drivers; 156 int num_render_drivers;
153 157 SDL_RenderDriver *render_drivers;
154 int num_windows; 158
155 SDL_Window *windows; 159 int num_windows;
156 160 SDL_Window *windows;
157 SDL_Renderer *current_renderer; 161
158 162 SDL_Renderer *current_renderer;
159 /* The hash list of textures */ 163
160 SDL_Texture *textures[64]; 164 /* The hash list of textures */
161 165 SDL_Texture *textures[64];
162 SDL_VideoDevice *device; 166
163 167 SDL_VideoDevice *device;
164 void *driverdata; 168
169 void *driverdata;
165 }; 170 };
166 171
167 /* Define the SDL video driver structure */ 172 /* Define the SDL video driver structure */
168 #define _THIS SDL_VideoDevice *_this 173 #define _THIS SDL_VideoDevice *_this
169 174
170 struct SDL_VideoDevice { 175 struct SDL_VideoDevice
171 /* * * */ 176 {
172 /* The name of this video driver */ 177 /* * * */
173 const char *name; 178 /* The name of this video driver */
174 179 const char *name;
175 /* * * */ 180
176 /* Initialization/Query functions */ 181 /* * * */
177 182 /* Initialization/Query functions */
178 /* 183
179 * Initialize the native video subsystem, filling in the list of 184 /*
180 * displays for this driver, returning 0 or -1 if there's an error. 185 * Initialize the native video subsystem, filling in the list of
181 */ 186 * displays for this driver, returning 0 or -1 if there's an error.
182 int (*VideoInit) (_THIS); 187 */
183 188 int (*VideoInit) (_THIS);
184 /* 189
185 * Reverse the effects VideoInit() -- called if VideoInit() fails or 190 /*
186 * if the application is shutting down the video subsystem. 191 * Reverse the effects VideoInit() -- called if VideoInit() fails or
187 */ 192 * if the application is shutting down the video subsystem.
188 void (*VideoQuit) (_THIS); 193 */
189 194 void (*VideoQuit) (_THIS);
190 /* * * */ 195
191 /* 196 /* * * */
192 * Display functions 197 /*
193 */ 198 * Display functions
194 199 */
195 /* 200
196 * Get a list of the available display modes. e.g. 201 /*
197 * SDL_AddDisplayMode(_this->current_display, mode) 202 * Get a list of the available display modes. e.g.
198 */ 203 * SDL_AddDisplayMode(_this->current_display, mode)
199 void (*GetDisplayModes) (_THIS); 204 */
200 205 void (*GetDisplayModes) (_THIS);
201 /* 206
202 * Setting the display mode is independent of creating windows, so 207 /*
203 * when the display mode is changed, all existing windows should have 208 * Setting the display mode is independent of creating windows, so
204 * their data updated accordingly, including the display surfaces 209 * when the display mode is changed, all existing windows should have
205 * associated with them. 210 * their data updated accordingly, including the display surfaces
206 */ 211 * associated with them.
207 int (*SetDisplayMode) (_THIS, SDL_DisplayMode * mode); 212 */
208 213 int (*SetDisplayMode) (_THIS, SDL_DisplayMode * mode);
209 /* Set the color entries of the display palette */ 214
210 int (*SetDisplayPalette) (_THIS, SDL_Palette * palette); 215 /* Set the color entries of the display palette */
211 216 int (*SetDisplayPalette) (_THIS, SDL_Palette * palette);
212 /* Get the color entries of the display palette */ 217
213 int (*GetDisplayPalette) (_THIS, SDL_Palette * palette); 218 /* Get the color entries of the display palette */
214 219 int (*GetDisplayPalette) (_THIS, SDL_Palette * palette);
215 /* Set the gamma ramp */ 220
216 int (*SetDisplayGammaRamp) (_THIS, Uint16 * ramp); 221 /* Set the gamma ramp */
217 222 int (*SetDisplayGammaRamp) (_THIS, Uint16 * ramp);
218 /* Get the gamma ramp */ 223
219 int (*GetDisplayGammaRamp) (_THIS, Uint16 * ramp); 224 /* Get the gamma ramp */
220 225 int (*GetDisplayGammaRamp) (_THIS, Uint16 * ramp);
221 /* * * */ 226
222 /* 227 /* * * */
223 * Window functions 228 /*
224 */ 229 * Window functions
225 int (*CreateWindow) (_THIS, SDL_Window * window); 230 */
226 int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data); 231 int (*CreateWindow) (_THIS, SDL_Window * window);
227 void (*SetWindowTitle) (_THIS, SDL_Window * window); 232 int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
228 void (*SetWindowPosition) (_THIS, SDL_Window * window); 233 void (*SetWindowTitle) (_THIS, SDL_Window * window);
229 void (*SetWindowSize) (_THIS, SDL_Window * window); 234 void (*SetWindowPosition) (_THIS, SDL_Window * window);
230 void (*ShowWindow) (_THIS, SDL_Window * window); 235 void (*SetWindowSize) (_THIS, SDL_Window * window);
231 void (*HideWindow) (_THIS, SDL_Window * window); 236 void (*ShowWindow) (_THIS, SDL_Window * window);
232 void (*RaiseWindow) (_THIS, SDL_Window * window); 237 void (*HideWindow) (_THIS, SDL_Window * window);
233 void (*MaximizeWindow) (_THIS, SDL_Window * window); 238 void (*RaiseWindow) (_THIS, SDL_Window * window);
234 void (*MinimizeWindow) (_THIS, SDL_Window * window); 239 void (*MaximizeWindow) (_THIS, SDL_Window * window);
235 void (*RestoreWindow) (_THIS, SDL_Window * window); 240 void (*MinimizeWindow) (_THIS, SDL_Window * window);
236 void (*SetWindowGrab) (_THIS, SDL_Window * window); 241 void (*RestoreWindow) (_THIS, SDL_Window * window);
237 void (*DestroyWindow) (_THIS, SDL_Window * window); 242 void (*SetWindowGrab) (_THIS, SDL_Window * window);
238 243 void (*DestroyWindow) (_THIS, SDL_Window * window);
239 /* Get some platform dependent window information */ 244
240 SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window, 245 /* Get some platform dependent window information */
241 struct SDL_SysWMinfo * info); 246 SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
242 247 struct SDL_SysWMinfo * info);
243 /* * * */ 248
244 /* 249 /* * * */
245 * OpenGL support 250 /*
246 */ 251 * OpenGL support
247 int (*GL_LoadLibrary) (_THIS, const char *path); 252 */
248 void *(*GL_GetProcAddress) (_THIS, const char *proc); 253 int (*GL_LoadLibrary) (_THIS, const char *path);
249 SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window); 254 void *(*GL_GetProcAddress) (_THIS, const char *proc);
250 int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context); 255 SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
251 int (*GL_SetSwapInterval) (_THIS, int interval); 256 int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
252 int (*GL_GetSwapInterval) (_THIS); 257 int (*GL_SetSwapInterval) (_THIS, int interval);
253 void (*GL_SwapWindow) (_THIS, SDL_Window * window); 258 int (*GL_GetSwapInterval) (_THIS);
254 void (*GL_DeleteContext) (_THIS, SDL_GLContext context); 259 void (*GL_SwapWindow) (_THIS, SDL_Window * window);
255 260 void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
256 /* * * */ 261
257 /* 262 /* * * */
258 * Event manager functions 263 /*
259 */ 264 * Event manager functions
260 void (*PumpEvents) (_THIS); 265 */
261 266 void (*PumpEvents) (_THIS);
262 /* * * */ 267
263 /* Data common to all drivers */ 268 /* * * */
264 int num_displays; 269 /* Data common to all drivers */
265 SDL_VideoDisplay *displays; 270 int num_displays;
266 int current_display; 271 SDL_VideoDisplay *displays;
267 Uint32 next_object_id; 272 int current_display;
268 273 Uint32 next_object_id;
269 /* * * */ 274
270 /* Data used by the GL drivers */ 275 /* * * */
271 struct { 276 /* Data used by the GL drivers */
272 int red_size; 277 struct
273 int green_size; 278 {
274 int blue_size; 279 int red_size;
275 int alpha_size; 280 int green_size;
276 int depth_size; 281 int blue_size;
277 int buffer_size; 282 int alpha_size;
278 int stencil_size; 283 int depth_size;
279 int double_buffer; 284 int buffer_size;
280 int accum_red_size; 285 int stencil_size;
281 int accum_green_size; 286 int double_buffer;
282 int accum_blue_size; 287 int accum_red_size;
283 int accum_alpha_size; 288 int accum_green_size;
284 int stereo; 289 int accum_blue_size;
285 int multisamplebuffers; 290 int accum_alpha_size;
286 int multisamplesamples; 291 int stereo;
287 int accelerated; 292 int multisamplebuffers;
288 int retained_backing; 293 int multisamplesamples;
289 int driver_loaded; 294 int accelerated;
290 char driver_path[256]; 295 int retained_backing;
291 void *dll_handle; 296 int driver_loaded;
292 } gl_config; 297 char driver_path[256];
293 298 void *dll_handle;
294 /* * * */ 299 } gl_config;
295 /* Data private to this driver */ 300
296 void *driverdata; 301 /* * * */
297 struct SDL_GLDriverData *gl_data; 302 /* Data private to this driver */
298 303 void *driverdata;
299 /* * * */ 304 struct SDL_GLDriverData *gl_data;
300 /* The function used to dispose of this structure */ 305
301 void (*free) (_THIS); 306 /* * * */
302 }; 307 /* The function used to dispose of this structure */
303 308 void (*free) (_THIS);
304 typedef struct VideoBootStrap { 309 };
305 const char *name; 310
306 const char *desc; 311 typedef struct VideoBootStrap
307 int (*available) (void); 312 {
308 SDL_VideoDevice *(*create) (int devindex); 313 const char *name;
309 } VideoBootStrap; 314 const char *desc;
315 int (*available) (void);
316 SDL_VideoDevice *(*create) (int devindex);
317 } VideoBootStrap;
310 318
311 #if SDL_VIDEO_DRIVER_COCOA 319 #if SDL_VIDEO_DRIVER_COCOA
312 extern VideoBootStrap COCOA_bootstrap; 320 extern VideoBootStrap COCOA_bootstrap;
313 #endif 321 #endif
314 #if SDL_VIDEO_DRIVER_X11 322 #if SDL_VIDEO_DRIVER_X11
379 #endif 387 #endif
380 388
381 #define SDL_CurrentDisplay (_this->displays[_this->current_display]) 389 #define SDL_CurrentDisplay (_this->displays[_this->current_display])
382 390
383 extern SDL_VideoDevice *SDL_GetVideoDevice(); 391 extern SDL_VideoDevice *SDL_GetVideoDevice();
384 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); 392 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
385 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display); 393 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
386 extern SDL_bool 394 extern SDL_bool
387 SDL_AddDisplayMode(int displayIndex, 395 SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode);
388 const SDL_DisplayMode * mode); 396 extern void
389 extern void 397 SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver);
390 SDL_AddRenderDriver(int displayIndex, 398
391 const SDL_RenderDriver * driver); 399 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
392
393 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
394 extern SDL_Window *SDL_GetWindowFromID(SDL_WindowID windowID); 400 extern SDL_Window *SDL_GetWindowFromID(SDL_WindowID windowID);
395 extern SDL_VideoDisplay *SDL_GetDisplayFromWindow(SDL_Window * window); 401 extern SDL_VideoDisplay *SDL_GetDisplayFromWindow(SDL_Window * window);
396 402
397 extern void SDL_OnWindowShown(SDL_Window * window); 403 extern void SDL_OnWindowShown(SDL_Window * window);
398 extern void SDL_OnWindowHidden(SDL_Window * window); 404 extern void SDL_OnWindowHidden(SDL_Window * window);
399 extern void SDL_OnWindowResized(SDL_Window * window); 405 extern void SDL_OnWindowResized(SDL_Window * window);
400 extern void SDL_OnWindowFocusGained(SDL_Window * window); 406 extern void SDL_OnWindowFocusGained(SDL_Window * window);
401 extern void SDL_OnWindowFocusLost(SDL_Window * window); 407 extern void SDL_OnWindowFocusLost(SDL_Window * window);
402 extern SDL_WindowID SDL_GetFocusWindow(void); 408 extern SDL_WindowID SDL_GetFocusWindow(void);
403 409
404 #endif /* _SDL_sysvideo_h */ 410 #endif /* _SDL_sysvideo_h */
405 411
406 /* vi: set ts=4 sw=4 expandtab: */ 412 /* vi: set ts=4 sw=4 expandtab: */