2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2006 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "SDL_config.h"
24 #ifndef _SDL_sysvideo_h
25 #define _SDL_sysvideo_h
27 #include "SDL_mouse.h"
28 #include "SDL_keysym.h"
30 /* The SDL video driver */
32 typedef struct SDL_Window SDL_Window;
33 typedef struct SDL_Texture SDL_Texture;
34 typedef struct SDL_Renderer SDL_Renderer;
35 typedef struct SDL_RenderDriver SDL_RenderDriver;
36 typedef struct SDL_VideoDisplay SDL_VideoDisplay;
37 typedef struct SDL_VideoDevice SDL_VideoDevice;
39 /* Define the SDL texture structure */
44 Uint32 format; /**< The pixel format of the texture */
45 int access; /**< SDL_TextureAccess */
46 int w; /**< The width of the texture */
47 int h; /**< The height of the texture */
48 int modMode; /**< The texture modulation mode */
49 int blendMode; /**< The texture blend mode */
50 int scaleMode; /**< The texture scale mode */
51 Uint8 r, g, b, a; /**< Texture modulation values */
53 SDL_Renderer *renderer;
55 void *driverdata; /**< Driver specific texture representation */
60 /* Define the SDL renderer structure */
63 int (*ActivateRenderer) (SDL_Renderer * renderer);
64 int (*DisplayModeChanged) (SDL_Renderer * renderer);
65 int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
66 int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
67 void **pixels, int *pitch);
68 int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
69 const SDL_Color * colors, int firstcolor,
71 int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
72 SDL_Color * colors, int firstcolor,
74 int (*SetTextureColorMod) (SDL_Renderer * renderer,
75 SDL_Texture * texture);
76 int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
77 SDL_Texture * texture);
78 int (*SetTextureBlendMode) (SDL_Renderer * renderer,
79 SDL_Texture * texture);
80 int (*SetTextureScaleMode) (SDL_Renderer * renderer,
81 SDL_Texture * texture);
82 int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
83 const SDL_Rect * rect, const void *pixels,
85 int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
86 const SDL_Rect * rect, int markDirty, void **pixels,
88 void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
89 void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
90 int numrects, const SDL_Rect * rects);
91 int (*RenderFill) (SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
92 Uint8 a, const SDL_Rect * rect);
93 int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
94 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
95 void (*RenderPresent) (SDL_Renderer * renderer);
96 void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
98 void (*DestroyRenderer) (SDL_Renderer * renderer);
100 /* The current renderer info */
101 SDL_RendererInfo info;
103 /* The window associated with the renderer */
109 /* Define the SDL render driver structure */
110 struct SDL_RenderDriver
112 SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
114 /* Info about the renderer capabilities */
115 SDL_RendererInfo info;
118 /* Define the SDL window structure, corresponding to toplevel windows */
129 SDL_Renderer *renderer;
130 SDL_GLContext context;
135 #define FULLSCREEN_VISIBLE(W) \
136 (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
137 ((W)->flags & SDL_WINDOW_SHOWN) && \
138 !((W)->flags & SDL_WINDOW_MINIMIZED))
140 /* Define the SDL display structure
141 This corresponds to physical monitors attached to the system.
143 struct SDL_VideoDisplay
145 int max_display_modes;
146 int num_display_modes;
147 SDL_DisplayMode *display_modes;
148 SDL_DisplayMode desktop_mode;
149 SDL_DisplayMode current_mode;
150 SDL_DisplayMode fullscreen_mode;
151 SDL_Palette *palette;
154 Uint16 *saved_gamma; /* (just offset into gamma) */
156 int num_render_drivers;
157 SDL_RenderDriver *render_drivers;
162 SDL_Renderer *current_renderer;
164 /* The hash list of textures */
165 SDL_Texture *textures[64];
167 SDL_VideoDevice *device;
172 /* Define the SDL video driver structure */
173 #define _THIS SDL_VideoDevice *_this
175 struct SDL_VideoDevice
178 /* The name of this video driver */
182 /* Initialization/Query functions */
184 /* Initialize the native video subsystem, filling in the list
185 of displays for this driver, returning 0 or -1 if there's an error.
187 int (*VideoInit) (_THIS);
189 /* Reverse the effects VideoInit() -- called if VideoInit() fails
190 or if the application is shutting down the video subsystem.
192 void (*VideoQuit) (_THIS);
198 /* Get a list of the available display modes.
199 * e.g. SDL_AddDisplayMode(_this->current_display, mode)
201 void (*GetDisplayModes) (_THIS);
203 /* Setting the display mode is independent of creating windows,
204 * so when the display mode is changed, all existing windows
205 * should have their data updated accordingly, including the
206 * display surfaces associated with them.
208 int (*SetDisplayMode) (_THIS, SDL_DisplayMode * mode);
210 /* Set the color entries of the display palette */
211 int (*SetDisplayPalette) (_THIS, SDL_Palette * palette);
213 /* Get the color entries of the display palette */
214 int (*GetDisplayPalette) (_THIS, SDL_Palette * palette);
216 /* Set the gamma ramp */
217 int (*SetDisplayGammaRamp) (_THIS, Uint16 * ramp);
219 /* Get the gamma ramp */
220 int (*GetDisplayGammaRamp) (_THIS, Uint16 * ramp);
225 int (*CreateWindow) (_THIS, SDL_Window * window);
226 int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
227 void (*SetWindowTitle) (_THIS, SDL_Window * window);
228 void (*SetWindowPosition) (_THIS, SDL_Window * window);
229 void (*SetWindowSize) (_THIS, SDL_Window * window);
230 void (*ShowWindow) (_THIS, SDL_Window * window);
231 void (*HideWindow) (_THIS, SDL_Window * window);
232 void (*RaiseWindow) (_THIS, SDL_Window * window);
233 void (*MaximizeWindow) (_THIS, SDL_Window * window);
234 void (*MinimizeWindow) (_THIS, SDL_Window * window);
235 void (*RestoreWindow) (_THIS, SDL_Window * window);
236 void (*SetWindowGrab) (_THIS, SDL_Window * window);
237 void (*DestroyWindow) (_THIS, SDL_Window * window);
239 /* Get some platform dependent window information */
240 SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
241 struct SDL_SysWMinfo * info);
246 int (*GL_LoadLibrary) (_THIS, const char *path);
247 void *(*GL_GetProcAddress) (_THIS, const char *proc);
248 SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
249 int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
250 int (*GL_SetSwapInterval) (_THIS, int interval);
251 int (*GL_GetSwapInterval) (_THIS);
252 void (*GL_SwapWindow) (_THIS, SDL_Window * window);
253 void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
256 /* Event manager functions
258 void (*PumpEvents) (_THIS);
261 /* Data common to all drivers */
263 SDL_VideoDisplay *displays;
265 Uint32 next_object_id;
268 /* Data used by the GL drivers */
280 int accum_green_size;
282 int accum_alpha_size;
284 int multisamplebuffers;
285 int multisamplesamples;
288 char driver_path[256];
293 /* Data private to this driver */
295 struct SDL_GLDriverData *gl_data;
298 /* The function used to dispose of this structure */
299 void (*free) (_THIS);
302 typedef struct VideoBootStrap
306 int (*available) (void);
307 SDL_VideoDevice *(*create) (int devindex);
310 #if SDL_VIDEO_DRIVER_COCOA
311 extern VideoBootStrap COCOA_bootstrap;
313 #if SDL_VIDEO_DRIVER_X11
314 extern VideoBootStrap X11_bootstrap;
316 #if SDL_VIDEO_DRIVER_NANOX
317 extern VideoBootStrap NX_bootstrap;
319 #if SDL_VIDEO_DRIVER_IPOD
320 extern VideoBootStrap iPod_bootstrap;
322 #if SDL_VIDEO_DRIVER_WSCONS
323 extern VideoBootStrap WSCONS_bootstrap;
325 #if SDL_VIDEO_DRIVER_FBCON
326 extern VideoBootStrap FBCON_bootstrap;
328 #if SDL_VIDEO_DRIVER_DIRECTFB
329 extern VideoBootStrap DirectFB_bootstrap;
331 #if SDL_VIDEO_DRIVER_PS2GS
332 extern VideoBootStrap PS2GS_bootstrap;
334 #if SDL_VIDEO_DRIVER_VGL
335 extern VideoBootStrap VGL_bootstrap;
337 #if SDL_VIDEO_DRIVER_SVGALIB
338 extern VideoBootStrap SVGALIB_bootstrap;
340 #if SDL_VIDEO_DRIVER_GAPI
341 extern VideoBootStrap GAPI_bootstrap;
343 #if SDL_VIDEO_DRIVER_WIN32
344 extern VideoBootStrap WIN32_bootstrap;
346 #if SDL_VIDEO_DRIVER_BWINDOW
347 extern VideoBootStrap BWINDOW_bootstrap;
349 #if SDL_VIDEO_DRIVER_PHOTON
350 extern VideoBootStrap ph_bootstrap;
352 #if SDL_VIDEO_DRIVER_EPOC
353 extern VideoBootStrap EPOC_bootstrap;
355 #if SDL_VIDEO_DRIVER_XBIOS
356 extern VideoBootStrap XBIOS_bootstrap;
358 #if SDL_VIDEO_DRIVER_GEM
359 extern VideoBootStrap GEM_bootstrap;
361 #if SDL_VIDEO_DRIVER_DC
362 extern VideoBootStrap DC_bootstrap;
364 #if SDL_VIDEO_DRIVER_RISCOS
365 extern VideoBootStrap RISCOS_bootstrap;
367 #if SDL_VIDEO_DRIVER_OS2FS
368 extern VideoBootStrap OS2FSLib_bootstrap;
370 #if SDL_VIDEO_DRIVER_DUMMY
371 extern VideoBootStrap DUMMY_bootstrap;
374 #define SDL_CurrentDisplay (_this->displays[_this->current_display])
376 extern SDL_VideoDevice *SDL_GetVideoDevice();
377 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
378 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
379 extern SDL_bool SDL_AddDisplayMode(int displayIndex,
380 const SDL_DisplayMode * mode);
381 extern void SDL_AddRenderDriver(int displayIndex,
382 const SDL_RenderDriver * driver);
384 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
385 extern SDL_Window *SDL_GetWindowFromID(SDL_WindowID windowID);
386 extern SDL_VideoDisplay *SDL_GetDisplayFromWindow(SDL_Window * window);
388 extern void SDL_OnWindowShown(SDL_Window * window);
389 extern void SDL_OnWindowHidden(SDL_Window * window);
390 extern void SDL_OnWindowResized(SDL_Window * window);
391 extern void SDL_OnWindowFocusGained(SDL_Window * window);
392 extern void SDL_OnWindowFocusLost(SDL_Window * window);
393 extern SDL_WindowID SDL_GetFocusWindow(void);
395 #endif /* _SDL_sysvideo_h */
397 /* vi: set ts=4 sw=4 expandtab: */