1 /* 2 SDL - Simple DirectMedia Layer 3 Copyright (C) 1997-2010 Sam Lantinga 4 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. 9 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. 14 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 18 19 Sam Lantinga 20 slouken@libsdl.org 21 */ 22 #include "SDL_config.h" 23 24 #ifndef _SDL_sysvideo_1_3_h 25 #define _SDL_sysvideo_1_3_h 26 27 #include "SDL_mouse.h" 28 #include "SDL_keysym.h" 29 #include "SDL_rect.h" 30 31 /* The SDL video driver */ 32 33 typedef struct SDL_Renderer SDL_Renderer; 34 typedef struct SDL_RenderDriver SDL_RenderDriver; 35 typedef struct SDL_VideoDisplay SDL_VideoDisplay; 36 typedef struct SDL_VideoDevice SDL_VideoDevice; 37 38 /* Define the SDL texture structure */ 39 struct SDL_Texture 40 { 41 const void *magic; 42 Uint32 format; /**< The pixel format of the texture */ 43 int access; /**< SDL_TextureAccess */ 44 int w; /**< The width of the texture */ 45 int h; /**< The height of the texture */ 46 int modMode; /**< The texture modulation mode */ 47 int blendMode; /**< The texture blend mode */ 48 int scaleMode; /**< The texture scale mode */ 49 Uint8 r, g, b, a; /**< Texture modulation values */ 50 51 SDL_Renderer *renderer; 52 53 void *driverdata; /**< Driver specific texture representation */ 54 55 SDL_Texture *prev; 56 SDL_Texture *next; 57 }; 58 59 /* Define the SDL renderer structure */ 60 struct SDL_Renderer 61 { 62 int (*ActivateRenderer) (SDL_Renderer * renderer); 63 int (*DisplayModeChanged) (SDL_Renderer * renderer); 64 int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture); 65 int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture, 66 void **pixels, int *pitch); 67 int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture, 68 const SDL_Color * colors, int firstcolor, 69 int ncolors); 70 int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture, 71 SDL_Color * colors, int firstcolor, 72 int ncolors); 73 int (*SetTextureColorMod) (SDL_Renderer * renderer, 74 SDL_Texture * texture); 75 int (*SetTextureAlphaMod) (SDL_Renderer * renderer, 76 SDL_Texture * texture); 77 int (*SetTextureBlendMode) (SDL_Renderer * renderer, 78 SDL_Texture * texture); 79 int (*SetTextureScaleMode) (SDL_Renderer * renderer, 80 SDL_Texture * texture); 81 int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, 82 const SDL_Rect * rect, const void *pixels, 83 int pitch); 84 int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, 85 const SDL_Rect * rect, int markDirty, void **pixels, 86 int *pitch); 87 void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); 88 void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture, 89 int numrects, const SDL_Rect * rects); 90 int (*SetDrawColor) (SDL_Renderer * renderer); 91 int (*SetDrawBlendMode) (SDL_Renderer * renderer); 92 int (*RenderClear) (SDL_Renderer * renderer); 93 int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points, 94 int count); 95 int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points, 96 int count); 97 int (*RenderDrawRects) (SDL_Renderer * renderer, const SDL_Rect ** rects, 98 int count); 99 int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects, 100 int count); 101 int (*RenderDrawEllipse) (SDL_Renderer * renderer, int x, int y, 102 int w, int h); 103 int (*RenderFillEllipse) (SDL_Renderer * renderer, int x, int y, 104 int w, int h); 105 int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture, 106 const SDL_Rect * srcrect, const SDL_Rect * dstrect); 107 int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect, 108 Uint32 format, void * pixels, int pitch); 109 int (*RenderWritePixels) (SDL_Renderer * renderer, const SDL_Rect * rect, 110 Uint32 format, const void * pixels, int pitch); 111 void (*RenderPresent) (SDL_Renderer * renderer); 112 void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture); 113 114 void (*DestroyRenderer) (SDL_Renderer * renderer); 115 116 /* The current renderer info */ 117 SDL_RendererInfo info; 118 119 /* The window associated with the renderer */ 120 SDL_Window *window; 121 122 /* The list of textures */ 123 SDL_Texture *textures; 124 125 Uint8 r, g, b, a; /**< Color for drawing operations values */ 126 int blendMode; /**< The drawing blend mode */ 127 128 void *driverdata; 129 }; 130 131 /* Define the SDL render driver structure */ 132 struct SDL_RenderDriver 133 { 134 SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags); 135 136 /* Info about the renderer capabilities */ 137 SDL_RendererInfo info; 138 /* Used for resizing renderer */ 139 size_t infoSize; 140 }; 141 142 /* Define the SDL window structure, corresponding to toplevel windows */ 143 struct SDL_Window 144 { 145 const void *magic; 146 Uint32 id; 147 char *title; 148 int x, y; 149 int w, h; 150 Uint32 flags; 151 152 SDL_VideoDisplay *display; 153 SDL_Renderer *renderer; 154 155 SDL_DisplayMode fullscreen_mode; 156 157 void *userdata; 158 void *driverdata; 159 160 SDL_Window *prev; 161 SDL_Window *next; 162 }; 163 #define FULLSCREEN_VISIBLE(W) \ 164 (((W)->flags & SDL_WINDOW_FULLSCREEN) && \ 165 ((W)->flags & SDL_WINDOW_SHOWN) && \ 166 !((W)->flags & SDL_WINDOW_MINIMIZED)) 167 168 /* 169 * Define the SDL display structure This corresponds to physical monitors 170 * attached to the system. 171 */ 172 struct SDL_VideoDisplay 173 { 174 int max_display_modes; 175 int num_display_modes; 176 SDL_DisplayMode *display_modes; 177 SDL_DisplayMode desktop_mode; 178 SDL_DisplayMode current_mode; 179 SDL_bool updating_fullscreen; 180 SDL_Palette *palette; 181 182 Uint16 *gamma; 183 Uint16 *saved_gamma; /* (just offset into gamma) */ 184 185 int num_render_drivers; 186 SDL_RenderDriver *render_drivers; 187 188 SDL_Window *windows; 189 SDL_Window *fullscreen_window; 190 191 SDL_Renderer *current_renderer; 192 193 SDL_VideoDevice *device; 194 195 void *driverdata; 196 }; 197 198 /* Define the SDL video driver structure */ 199 #define _THIS SDL_VideoDevice *_this 200 201 struct SDL_VideoDevice 202 { 203 /* * * */ 204 /* The name of this video driver */ 205 const char *name; 206 207 /* * * */ 208 /* Initialization/Query functions */ 209 210 /* 211 * Initialize the native video subsystem, filling in the list of 212 * displays for this driver, returning 0 or -1 if there's an error. 213 */ 214 int (*VideoInit) (_THIS); 215 216 /* 217 * Reverse the effects VideoInit() -- called if VideoInit() fails or 218 * if the application is shutting down the video subsystem. 219 */ 220 void (*VideoQuit) (_THIS); 221 222 /* * * */ 223 /* 224 * Display functions 225 */ 226 227 /* 228 * Get the bounds of a display 229 */ 230 int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); 231 232 /* 233 * Get a list of the available display modes. e.g. 234 * SDL_AddDisplayMode(_this->current_display, mode) 235 */ 236 void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display); 237 238 /* 239 * Setting the display mode is independent of creating windows, so 240 * when the display mode is changed, all existing windows should have 241 * their data updated accordingly, including the display surfaces 242 * associated with them. 243 */ 244 int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); 245 246 /* Set the color entries of the display palette */ 247 int (*SetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette); 248 249 /* Get the color entries of the display palette */ 250 int (*GetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette); 251 252 /* Set the gamma ramp */ 253 int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp); 254 255 /* Get the gamma ramp */ 256 int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp); 257 258 /* * * */ 259 /* 260 * Window functions 261 */ 262 int (*CreateWindow) (_THIS, SDL_Window * window); 263 int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data); 264 void (*SetWindowTitle) (_THIS, SDL_Window * window); 265 void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon); 266 void (*SetWindowPosition) (_THIS, SDL_Window * window); 267 void (*SetWindowSize) (_THIS, SDL_Window * window); 268 void (*ShowWindow) (_THIS, SDL_Window * window); 269 void (*HideWindow) (_THIS, SDL_Window * window); 270 void (*RaiseWindow) (_THIS, SDL_Window * window); 271 void (*MaximizeWindow) (_THIS, SDL_Window * window); 272 void (*MinimizeWindow) (_THIS, SDL_Window * window); 273 void (*RestoreWindow) (_THIS, SDL_Window * window); 274 void (*SetWindowGrab) (_THIS, SDL_Window * window); 275 void (*DestroyWindow) (_THIS, SDL_Window * window); 276 277 /* Get some platform dependent window information */ 278 SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window, 279 struct SDL_SysWMinfo * info); 280 281 /* * * */ 282 /* 283 * OpenGL support 284 */ 285 int (*GL_LoadLibrary) (_THIS, const char *path); 286 void *(*GL_GetProcAddress) (_THIS, const char *proc); 287 void (*GL_UnloadLibrary) (_THIS); 288 SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window); 289 int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context); 290 int (*GL_SetSwapInterval) (_THIS, int interval); 291 int (*GL_GetSwapInterval) (_THIS); 292 void (*GL_SwapWindow) (_THIS, SDL_Window * window); 293 void (*GL_DeleteContext) (_THIS, SDL_GLContext context); 294 295 /* * * */ 296 /* 297 * Event manager functions 298 */ 299 void (*PumpEvents) (_THIS); 300 301 /* Suspend the screensaver */ 302 void (*SuspendScreenSaver) (_THIS); 303 304 /* Text input */ 305 void (*StartTextInput) (_THIS); 306 void (*StopTextInput) (_THIS); 307 void (*SetTextInputRect) (_THIS, SDL_Rect *rect); 308 309 /* Clipboard */ 310 int (*SetClipboardText) (_THIS, const char *text); 311 char * (*GetClipboardText) (_THIS); 312 SDL_bool (*HasClipboardText) (_THIS); 313 314 /* * * */ 315 /* Data common to all drivers */ 316 SDL_bool suspend_screensaver; 317 int num_displays; 318 SDL_VideoDisplay *displays; 319 int current_display; 320 Uint8 window_magic; 321 Uint8 texture_magic; 322 Uint32 next_object_id; 323 char * clipboard_text; 324 325 /* * * */ 326 /* Data used by the GL drivers */ 327 struct 328 { 329 int red_size; 330 int green_size; 331 int blue_size; 332 int alpha_size; 333 int depth_size; 334 int buffer_size; 335 int stencil_size; 336 int double_buffer; 337 int accum_red_size; 338 int accum_green_size; 339 int accum_blue_size; 340 int accum_alpha_size; 341 int stereo; 342 int multisamplebuffers; 343 int multisamplesamples; 344 int accelerated; 345 int major_version; 346 int minor_version; 347 int retained_backing; 348 int driver_loaded; 349 char driver_path[256]; 350 void *dll_handle; 351 } gl_config; 352 353 /* * * */ 354 /* Data private to this driver */ 355 void *driverdata; 356 struct SDL_GLDriverData *gl_data; 357 358 #if SDL_VIDEO_DRIVER_PANDORA 359 struct SDL_PrivateGLESData *gles_data; 360 #endif 361 362 /* * * */ 363 /* The function used to dispose of this structure */ 364 void (*free) (_THIS); 365 }; 366 367 typedef struct VideoBootStrap 368 { 369 const char *name; 370 const char *desc; 371 int (*available) (void); 372 SDL_VideoDevice *(*create) (int devindex); 373 } VideoBootStrap; 374 375 #if SDL_VIDEO_DRIVER_COCOA 376 extern VideoBootStrap COCOA_bootstrap; 377 #endif 378 #if SDL_VIDEO_DRIVER_X11 379 extern VideoBootStrap X11_bootstrap; 380 #endif 381 #if SDL_VIDEO_DRIVER_FBCON 382 extern VideoBootStrap FBCON_bootstrap; 383 #endif 384 #if SDL_VIDEO_DRIVER_DIRECTFB 385 extern VideoBootStrap DirectFB_bootstrap; 386 #endif 387 #if SDL_VIDEO_DRIVER_PS3 388 extern VideoBootStrap PS3_bootstrap; 389 #endif 390 #if SDL_VIDEO_DRIVER_SVGALIB 391 extern VideoBootStrap SVGALIB_bootstrap; 392 #endif 393 #if SDL_VIDEO_DRIVER_GAPI 394 extern VideoBootStrap GAPI_bootstrap; 395 #endif 396 #if SDL_VIDEO_DRIVER_WIN32 397 extern VideoBootStrap WIN32_bootstrap; 398 #endif 399 #if SDL_VIDEO_DRIVER_BWINDOW 400 extern VideoBootStrap BWINDOW_bootstrap; 401 #endif 402 #if SDL_VIDEO_DRIVER_PHOTON 403 extern VideoBootStrap photon_bootstrap; 404 #endif 405 #if SDL_VIDEO_DRIVER_QNXGF 406 extern VideoBootStrap qnxgf_bootstrap; 407 #endif 408 #if SDL_VIDEO_DRIVER_EPOC 409 extern VideoBootStrap EPOC_bootstrap; 410 #endif 411 #if SDL_VIDEO_DRIVER_RISCOS 412 extern VideoBootStrap RISCOS_bootstrap; 413 #endif 414 #if SDL_VIDEO_DRIVER_UIKIT 415 extern VideoBootStrap UIKIT_bootstrap; 416 #endif 417 #if SDL_VIDEO_DRIVER_ANDROID 418 extern VideoBootStrap ANDROID_bootstrap; 419 #endif 420 #if SDL_VIDEO_DRIVER_DUMMY 421 extern VideoBootStrap DUMMY_bootstrap; 422 #endif 423 #if SDL_VIDEO_DRIVER_NDS 424 extern VideoBootStrap NDS_bootstrap; 425 #endif 426 #if SDL_VIDEO_DRIVER_PANDORA 427 extern VideoBootStrap PND_bootstrap; 428 #endif 429 430 #define SDL_CurrentDisplay (&_this->displays[_this->current_display]) 431 #define SDL_CurrentRenderer (SDL_CurrentDisplay->current_renderer) 432 433 extern SDL_VideoDevice *SDL_GetVideoDevice(void); 434 extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); 435 extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display); 436 extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode); 437 extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display); 438 extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode); 439 extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode); 440 extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode); 441 extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); 442 extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode); 443 extern int SDL_SetPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors); 444 extern int SDL_GetPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors); 445 extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue); 446 extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue); 447 extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver); 448 449 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); 450 451 extern void SDL_OnWindowShown(SDL_Window * window); 452 extern void SDL_OnWindowHidden(SDL_Window * window); 453 extern void SDL_OnWindowResized(SDL_Window * window); 454 extern void SDL_OnWindowMinimized(SDL_Window * window); 455 extern void SDL_OnWindowRestored(SDL_Window * window); 456 extern void SDL_OnWindowFocusGained(SDL_Window * window); 457 extern void SDL_OnWindowFocusLost(SDL_Window * window); 458 extern SDL_Window * SDL_GetFocusWindow(void); 459 460 #endif /* _SDL_sysvideo_h */ 461 462 /* vi: set ts=4 sw=4 expandtab: */ 463