Final merge of Google Summer of Code 2008 work...
Port SDL 1.3 to the Nintendo DS
by Darren Alton, mentored by Sam Lantinga
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;
134 #define FULLSCREEN_VISIBLE(W) \
135 (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
136 ((W)->flags & SDL_WINDOW_SHOWN) && \
137 !((W)->flags & SDL_WINDOW_MINIMIZED))
139 /* Define the SDL display structure
140 This corresponds to physical monitors attached to the system.
142 struct SDL_VideoDisplay
144 int max_display_modes;
145 int num_display_modes;
146 SDL_DisplayMode *display_modes;
147 SDL_DisplayMode desktop_mode;
148 SDL_DisplayMode current_mode;
149 SDL_DisplayMode fullscreen_mode;
150 SDL_Palette *palette;
153 Uint16 *saved_gamma; /* (just offset into gamma) */
155 int num_render_drivers;
156 SDL_RenderDriver *render_drivers;
161 SDL_Renderer *current_renderer;
163 /* The hash list of textures */
164 SDL_Texture *textures[64];
166 SDL_VideoDevice *device;
171 /* Define the SDL video driver structure */
172 #define _THIS SDL_VideoDevice *_this
174 struct SDL_VideoDevice
177 /* The name of this video driver */
181 /* Initialization/Query functions */
183 /* Initialize the native video subsystem, filling in the list
184 of displays for this driver, returning 0 or -1 if there's an error.
186 int (*VideoInit) (_THIS);
188 /* Reverse the effects VideoInit() -- called if VideoInit() fails
189 or if the application is shutting down the video subsystem.
191 void (*VideoQuit) (_THIS);
197 /* Get a list of the available display modes.
198 * e.g. SDL_AddDisplayMode(_this->current_display, mode)
200 void (*GetDisplayModes) (_THIS);
202 /* Setting the display mode is independent of creating windows,
203 * so when the display mode is changed, all existing windows
204 * should have their data updated accordingly, including the
205 * display surfaces associated with them.
207 int (*SetDisplayMode) (_THIS, SDL_DisplayMode * mode);
209 /* Set the color entries of the display palette */
210 int (*SetDisplayPalette) (_THIS, SDL_Palette * palette);
212 /* Get the color entries of the display palette */
213 int (*GetDisplayPalette) (_THIS, SDL_Palette * palette);
215 /* Set the gamma ramp */
216 int (*SetDisplayGammaRamp) (_THIS, Uint16 * ramp);
218 /* Get the gamma ramp */
219 int (*GetDisplayGammaRamp) (_THIS, Uint16 * ramp);
224 int (*CreateWindow) (_THIS, SDL_Window * window);
225 int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
226 void (*SetWindowTitle) (_THIS, SDL_Window * window);
227 void (*SetWindowPosition) (_THIS, SDL_Window * window);
228 void (*SetWindowSize) (_THIS, SDL_Window * window);
229 void (*ShowWindow) (_THIS, SDL_Window * window);
230 void (*HideWindow) (_THIS, SDL_Window * window);
231 void (*RaiseWindow) (_THIS, SDL_Window * window);
232 void (*MaximizeWindow) (_THIS, SDL_Window * window);
233 void (*MinimizeWindow) (_THIS, SDL_Window * window);
234 void (*RestoreWindow) (_THIS, SDL_Window * window);
235 void (*SetWindowGrab) (_THIS, SDL_Window * window);
236 void (*DestroyWindow) (_THIS, SDL_Window * window);
238 /* Get some platform dependent window information */
239 SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
240 struct SDL_SysWMinfo * info);
245 int (*GL_LoadLibrary) (_THIS, const char *path);
246 void *(*GL_GetProcAddress) (_THIS, const char *proc);
247 SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
248 int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
249 int (*GL_SetSwapInterval) (_THIS, int interval);
250 int (*GL_GetSwapInterval) (_THIS);
251 void (*GL_SwapWindow) (_THIS, SDL_Window * window);
252 void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
255 /* Event manager functions
257 void (*PumpEvents) (_THIS);
260 /* Data common to all drivers */
262 SDL_VideoDisplay *displays;
264 Uint32 next_object_id;
267 /* Data used by the GL drivers */
279 int accum_green_size;
281 int accum_alpha_size;
283 int multisamplebuffers;
284 int multisamplesamples;
287 char driver_path[256];
292 /* Data private to this driver */
294 struct SDL_GLDriverData *gl_data;
297 /* The function used to dispose of this structure */
298 void (*free) (_THIS);
301 typedef struct VideoBootStrap
305 int (*available) (void);
306 SDL_VideoDevice *(*create) (int devindex);
309 #if SDL_VIDEO_DRIVER_COCOA
310 extern VideoBootStrap COCOA_bootstrap;
312 #if SDL_VIDEO_DRIVER_X11
313 extern VideoBootStrap X11_bootstrap;
315 #if SDL_VIDEO_DRIVER_NANOX
316 extern VideoBootStrap NX_bootstrap;
318 #if SDL_VIDEO_DRIVER_IPOD
319 extern VideoBootStrap iPod_bootstrap;
321 #if SDL_VIDEO_DRIVER_WSCONS
322 extern VideoBootStrap WSCONS_bootstrap;
324 #if SDL_VIDEO_DRIVER_FBCON
325 extern VideoBootStrap FBCON_bootstrap;
327 #if SDL_VIDEO_DRIVER_DIRECTFB
328 extern VideoBootStrap DirectFB_bootstrap;
330 #if SDL_VIDEO_DRIVER_PS2GS
331 extern VideoBootStrap PS2GS_bootstrap;
333 #if SDL_VIDEO_DRIVER_VGL
334 extern VideoBootStrap VGL_bootstrap;
336 #if SDL_VIDEO_DRIVER_SVGALIB
337 extern VideoBootStrap SVGALIB_bootstrap;
339 #if SDL_VIDEO_DRIVER_GAPI
340 extern VideoBootStrap GAPI_bootstrap;
342 #if SDL_VIDEO_DRIVER_WIN32
343 extern VideoBootStrap WIN32_bootstrap;
345 #if SDL_VIDEO_DRIVER_BWINDOW
346 extern VideoBootStrap BWINDOW_bootstrap;
348 #if SDL_VIDEO_DRIVER_PHOTON
349 extern VideoBootStrap ph_bootstrap;
351 #if SDL_VIDEO_DRIVER_EPOC
352 extern VideoBootStrap EPOC_bootstrap;
354 #if SDL_VIDEO_DRIVER_XBIOS
355 extern VideoBootStrap XBIOS_bootstrap;
357 #if SDL_VIDEO_DRIVER_GEM
358 extern VideoBootStrap GEM_bootstrap;
360 #if SDL_VIDEO_DRIVER_DC
361 extern VideoBootStrap DC_bootstrap;
363 #if SDL_VIDEO_DRIVER_RISCOS
364 extern VideoBootStrap RISCOS_bootstrap;
366 #if SDL_VIDEO_DRIVER_OS2FS
367 extern VideoBootStrap OS2FSLib_bootstrap;
369 #if SDL_VIDEO_DRIVER_DUMMY
370 extern VideoBootStrap DUMMY_bootstrap;
372 #if SDL_VIDEO_DRIVER_NDS
373 extern VideoBootStrap NDS_bootstrap;
376 #define SDL_CurrentDisplay (_this->displays[_this->current_display])
378 extern SDL_VideoDevice *SDL_GetVideoDevice();
379 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
380 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
381 extern SDL_bool SDL_AddDisplayMode(int displayIndex,
382 const SDL_DisplayMode * mode);
383 extern void SDL_AddRenderDriver(int displayIndex,
384 const SDL_RenderDriver * driver);
386 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
387 extern SDL_Window *SDL_GetWindowFromID(SDL_WindowID windowID);
388 extern SDL_VideoDisplay *SDL_GetDisplayFromWindow(SDL_Window * window);
390 extern void SDL_OnWindowShown(SDL_Window * window);
391 extern void SDL_OnWindowHidden(SDL_Window * window);
392 extern void SDL_OnWindowResized(SDL_Window * window);
393 extern void SDL_OnWindowFocusGained(SDL_Window * window);
394 extern void SDL_OnWindowFocusLost(SDL_Window * window);
395 extern SDL_WindowID SDL_GetFocusWindow(void);
397 #endif /* _SDL_sysvideo_h */
399 /* vi: set ts=4 sw=4 expandtab: */