1 /* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20 */ 21 22 /** 23 * # CategoryVideo 24 * 25 * Header file for SDL video functions. 26 */ 27 28 #ifndef SDL_video_h_ 29 #define SDL_video_h_ 30 31 #include "SDL_stdinc.h" 32 #include "SDL_pixels.h" 33 #include "SDL_rect.h" 34 #include "SDL_surface.h" 35 36 #include "begin_code.h" 37 /* Set up for C function definitions, even when using C++ */ 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /** 43 * The structure that defines a display mode 44 * 45 * \sa SDL_GetNumDisplayModes 46 * \sa SDL_GetDisplayMode 47 * \sa SDL_GetDesktopDisplayMode 48 * \sa SDL_GetCurrentDisplayMode 49 * \sa SDL_GetClosestDisplayMode 50 * \sa SDL_SetWindowDisplayMode 51 * \sa SDL_GetWindowDisplayMode 52 */ 53 typedef struct SDL_DisplayMode 54 { 55 Uint32 format; /**< pixel format */ 56 int w; /**< width, in screen coordinates */ 57 int h; /**< height, in screen coordinates */ 58 int refresh_rate; /**< refresh rate (or zero for unspecified) */ 59 void *driverdata; /**< driver-specific data, initialize to 0 */ 60 } SDL_DisplayMode; 61 62 /** 63 * The opaque type used to identify a window. 64 * 65 * \sa SDL_CreateWindow 66 * \sa SDL_CreateWindowFrom 67 * \sa SDL_DestroyWindow 68 * \sa SDL_FlashWindow 69 * \sa SDL_GetWindowData 70 * \sa SDL_GetWindowFlags 71 * \sa SDL_GetWindowGrab 72 * \sa SDL_GetWindowKeyboardGrab 73 * \sa SDL_GetWindowMouseGrab 74 * \sa SDL_GetWindowPosition 75 * \sa SDL_GetWindowSize 76 * \sa SDL_GetWindowTitle 77 * \sa SDL_HideWindow 78 * \sa SDL_MaximizeWindow 79 * \sa SDL_MinimizeWindow 80 * \sa SDL_RaiseWindow 81 * \sa SDL_RestoreWindow 82 * \sa SDL_SetWindowData 83 * \sa SDL_SetWindowFullscreen 84 * \sa SDL_SetWindowGrab 85 * \sa SDL_SetWindowKeyboardGrab 86 * \sa SDL_SetWindowMouseGrab 87 * \sa SDL_SetWindowIcon 88 * \sa SDL_SetWindowPosition 89 * \sa SDL_SetWindowSize 90 * \sa SDL_SetWindowBordered 91 * \sa SDL_SetWindowResizable 92 * \sa SDL_SetWindowTitle 93 * \sa SDL_ShowWindow 94 */ 95 typedef struct SDL_Window SDL_Window; 96 97 /** 98 * The flags on a window 99 * 100 * \sa SDL_GetWindowFlags 101 */ 102 typedef enum SDL_WindowFlags 103 { 104 SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */ 105 SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ 106 SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */ 107 SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ 108 SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ 109 SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ 110 SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */ 111 SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */ 112 SDL_WINDOW_MOUSE_GRABBED = 0x00000100, /**< window has grabbed mouse input */ 113 SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ 114 SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ 115 SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), 116 SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ 117 SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported. 118 On macOS NSHighResolutionCapable must be set true in the 119 application's Info.plist for this to have any effect. */ 120 SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to MOUSE_GRABBED) */ 121 SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */ 122 SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */ 123 SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */ 124 SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */ 125 SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */ 126 SDL_WINDOW_KEYBOARD_GRABBED = 0x00100000, /**< window has grabbed keyboard input */ 127 SDL_WINDOW_VULKAN = 0x10000000, /**< window usable for Vulkan surface */ 128 SDL_WINDOW_METAL = 0x20000000, /**< window usable for Metal view */ 129 130 SDL_WINDOW_INPUT_GRABBED = SDL_WINDOW_MOUSE_GRABBED /**< equivalent to SDL_WINDOW_MOUSE_GRABBED for compatibility */ 131 } SDL_WindowFlags; 132 133 /** 134 * Used to indicate that you don't care what the window position is. 135 */ 136 #define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u 137 #define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) 138 #define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) 139 #define SDL_WINDOWPOS_ISUNDEFINED(X) \ 140 (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) 141 142 /** 143 * Used to indicate that the window position should be centered. 144 */ 145 #define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u 146 #define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) 147 #define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) 148 #define SDL_WINDOWPOS_ISCENTERED(X) \ 149 (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) 150 151 /** 152 * Event subtype for window events 153 */ 154 typedef enum SDL_WindowEventID 155 { 156 SDL_WINDOWEVENT_NONE, /**< Never used */ 157 SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */ 158 SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */ 159 SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be 160 redrawn */ 161 SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 162 */ 163 SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */ 164 SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as 165 a result of an API call or through the 166 system or user changing the window size. */ 167 SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */ 168 SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */ 169 SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size 170 and position */ 171 SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */ 172 SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */ 173 SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */ 174 SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */ 175 SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */ 176 SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */ 177 SDL_WINDOWEVENT_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */ 178 SDL_WINDOWEVENT_ICCPROF_CHANGED,/**< The ICC profile of the window's display has changed. */ 179 SDL_WINDOWEVENT_DISPLAY_CHANGED /**< Window has been moved to display data1. */ 180 } SDL_WindowEventID; 181 182 /** 183 * Event subtype for display events 184 */ 185 typedef enum SDL_DisplayEventID 186 { 187 SDL_DISPLAYEVENT_NONE, /**< Never used */ 188 SDL_DISPLAYEVENT_ORIENTATION, /**< Display orientation has changed to data1 */ 189 SDL_DISPLAYEVENT_CONNECTED, /**< Display has been added to the system */ 190 SDL_DISPLAYEVENT_DISCONNECTED, /**< Display has been removed from the system */ 191 SDL_DISPLAYEVENT_MOVED /**< Display has changed position */ 192 } SDL_DisplayEventID; 193 194 /** 195 * Display orientation 196 */ 197 typedef enum SDL_DisplayOrientation 198 { 199 SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */ 200 SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */ 201 SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */ 202 SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */ 203 SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */ 204 } SDL_DisplayOrientation; 205 206 /** 207 * Window flash operation 208 */ 209 typedef enum SDL_FlashOperation 210 { 211 SDL_FLASH_CANCEL, /**< Cancel any window flash state */ 212 SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */ 213 SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */ 214 } SDL_FlashOperation; 215 216 /** 217 * An opaque handle to an OpenGL context. 218 * 219 * \sa SDL_GL_CreateContext 220 */ 221 typedef void *SDL_GLContext; 222 223 /** 224 * OpenGL configuration attributes. 225 * 226 * While you can set most OpenGL attributes normally, the attributes listed 227 * above must be known before SDL creates the window that will be used with 228 * the OpenGL context. These attributes are set and read with 229 * SDL_GL_SetAttribute and SDL_GL_GetAttribute. 230 * 231 * In some cases, these attributes are minimum requests; the GL does not 232 * promise to give you exactly what you asked for. It's possible to ask for a 233 * 16-bit depth buffer and get a 24-bit one instead, for example, or to ask 234 * for no stencil buffer and still have one available. Context creation should 235 * fail if the GL can't provide your requested attributes at a minimum, but 236 * you should check to see exactly what you got. 237 * 238 * 239 * [Multisample anti-aliasing](http://en.wikipedia.org/wiki/Multisample_anti-aliasing) 240 * is a type of full screen anti-aliasing. Multipsampling defaults to off but 241 * can be turned on by setting SDL_GL_MULTISAMPLEBUFFERS to 1 and 242 * SDL_GL_MULTISAMPLESAMPLES to a value greater than 0. Typical values are 2 243 * and 4. 244 * 245 * SDL_GL_CONTEXT_PROFILE_MASK determines the type of context created, while 246 * both SDL_GL_CONTEXT_MAJOR_VERSION and SDL_GL_CONTEXT_MINOR_VERSION 247 * determine which version. All three attributes must be set prior to creating 248 * the first window, and in general you can't change the value of 249 * SDL_GL_CONTEXT_PROFILE_MASK without first destroying all windows created 250 * with the previous setting. 251 * 252 * SDL_GL_CONTEXT_RELEASE_BEHAVIOR can be set to 253 * SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE or 254 * SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH. 255 */ 256 typedef enum SDL_GLattr 257 { 258 SDL_GL_RED_SIZE, /**< the minimum number of bits for the red channel of the color buffer; defaults to 3. */ 259 SDL_GL_GREEN_SIZE, /**< the minimum number of bits for the green channel of the color buffer; defaults to 3. */ 260 SDL_GL_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the color buffer; defaults to 2. */ 261 SDL_GL_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the color buffer; defaults to 0. */ 262 SDL_GL_BUFFER_SIZE, /**< the minimum number of bits for frame buffer size; defaults to 0. */ 263 SDL_GL_DOUBLEBUFFER, /**< whether the output is single or double buffered; defaults to double buffering on. */ 264 SDL_GL_DEPTH_SIZE, /**< the minimum number of bits in the depth buffer; defaults to 16. */ 265 SDL_GL_STENCIL_SIZE, /**< the minimum number of bits in the stencil buffer; defaults to 0. */ 266 SDL_GL_ACCUM_RED_SIZE, /**< the minimum number of bits for the red channel of the accumulation buffer; defaults to 0. */ 267 SDL_GL_ACCUM_GREEN_SIZE, /**< the minimum number of bits for the green channel of the accumulation buffer; defaults to 0. */ 268 SDL_GL_ACCUM_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the accumulation buffer; defaults to 0. */ 269 SDL_GL_ACCUM_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the accumulation buffer; defaults to 0. */ 270 SDL_GL_STEREO, /**< whether the output is stereo 3D; defaults to off. */ 271 SDL_GL_MULTISAMPLEBUFFERS, /**< the number of buffers used for multisample anti-aliasing; defaults to 0. */ 272 SDL_GL_MULTISAMPLESAMPLES, /**< the number of samples used around the current pixel used for multisample anti-aliasing. */ 273 SDL_GL_ACCELERATED_VISUAL, /**< set to 1 to require hardware acceleration, set to 0 to force software rendering; defaults to allow either. */ 274 SDL_GL_RETAINED_BACKING, /**< not used (deprecated). */ 275 SDL_GL_CONTEXT_MAJOR_VERSION, /**< OpenGL context major version. */ 276 SDL_GL_CONTEXT_MINOR_VERSION, /**< OpenGL context minor version. */ 277 SDL_GL_CONTEXT_EGL, /**< deprecated: set SDL_GL_CONTEXT_PROFILE_MASK to SDL_GL_CONTEXT_PROFILE_ES to enable instead. */ 278 SDL_GL_CONTEXT_FLAGS, /**< some combination of 0 or more of elements of the SDL_GLcontextFlag enumeration; defaults to 0. */ 279 SDL_GL_CONTEXT_PROFILE_MASK, /**< type of GL context (Core, Compatibility, ES). See SDL_GLprofile; default value depends on platform. */ 280 SDL_GL_SHARE_WITH_CURRENT_CONTEXT, /**< OpenGL context sharing; defaults to 0. */ 281 SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB capable visual; defaults to 0. (>= SDL 2.0.1) */ 282 SDL_GL_CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior; defaults to 1. (>= SDL 2.0.4) */ 283 SDL_GL_CONTEXT_RESET_NOTIFICATION, 284 SDL_GL_CONTEXT_NO_ERROR, 285 SDL_GL_FLOATBUFFERS 286 } SDL_GLattr; 287 288 typedef enum SDL_GLprofile 289 { 290 SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, 291 SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, 292 SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ 293 } SDL_GLprofile; 294 295 typedef enum SDL_GLcontextFlag 296 { 297 SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, 298 SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, 299 SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, 300 SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 301 } SDL_GLcontextFlag; 302 303 typedef enum SDL_GLcontextReleaseFlag 304 { 305 SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000, 306 SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001 307 } SDL_GLcontextReleaseFlag; 308 309 typedef enum SDL_GLContextResetNotification 310 { 311 SDL_GL_CONTEXT_RESET_NO_NOTIFICATION = 0x0000, 312 SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 0x0001 313 } SDL_GLContextResetNotification; 314 315 /* Function prototypes */ 316 317 /** 318 * Get the number of video drivers compiled into SDL. 319 * 320 * \returns a number >= 1 on success or a negative error code on failure; call 321 * SDL_GetError() for more information. 322 * 323 * \since This function is available since SDL 2.0.0. 324 * 325 * \sa SDL_GetVideoDriver 326 */ 327 extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); 328 329 /** 330 * Get the name of a built in video driver. 331 * 332 * The video drivers are presented in the order in which they are normally 333 * checked during initialization. 334 * 335 * \param index the index of a video driver. 336 * \returns the name of the video driver with the given **index**. 337 * 338 * \since This function is available since SDL 2.0.0. 339 * 340 * \sa SDL_GetNumVideoDrivers 341 */ 342 extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); 343 344 /** 345 * Initialize the video subsystem, optionally specifying a video driver. 346 * 347 * This function initializes the video subsystem, setting up a connection to 348 * the window manager, etc, and determines the available display modes and 349 * pixel formats, but does not initialize a window or graphics mode. 350 * 351 * If you use this function and you haven't used the SDL_INIT_VIDEO flag with 352 * either SDL_Init() or SDL_InitSubSystem(), you should call SDL_VideoQuit() 353 * before calling SDL_Quit(). 354 * 355 * It is safe to call this function multiple times. SDL_VideoInit() will call 356 * SDL_VideoQuit() itself if the video subsystem has already been initialized. 357 * 358 * You can use SDL_GetNumVideoDrivers() and SDL_GetVideoDriver() to find a 359 * specific `driver_name`. 360 * 361 * \param driver_name the name of a video driver to initialize, or NULL for 362 * the default driver. 363 * \returns 0 on success or a negative error code on failure; call 364 * SDL_GetError() for more information. 365 * 366 * \since This function is available since SDL 2.0.0. 367 * 368 * \sa SDL_GetNumVideoDrivers 369 * \sa SDL_GetVideoDriver 370 * \sa SDL_InitSubSystem 371 * \sa SDL_VideoQuit 372 */ 373 extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name); 374 375 /** 376 * Shut down the video subsystem, if initialized with SDL_VideoInit(). 377 * 378 * This function closes all windows, and restores the original video mode. 379 * 380 * \since This function is available since SDL 2.0.0. 381 * 382 * \sa SDL_VideoInit 383 */ 384 extern DECLSPEC void SDLCALL SDL_VideoQuit(void); 385 386 /** 387 * Get the name of the currently initialized video driver. 388 * 389 * \returns the name of the current video driver or NULL if no driver has been 390 * initialized. 391 * 392 * \since This function is available since SDL 2.0.0. 393 * 394 * \sa SDL_GetNumVideoDrivers 395 * \sa SDL_GetVideoDriver 396 */ 397 extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); 398 399 /** 400 * Get the number of available video displays. 401 * 402 * \returns a number >= 1 or a negative error code on failure; call 403 * SDL_GetError() for more information. 404 * 405 * \since This function is available since SDL 2.0.0. 406 * 407 * \sa SDL_GetDisplayBounds 408 */ 409 extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); 410 411 /** 412 * Get the name of a display in UTF-8 encoding. 413 * 414 * \param displayIndex the index of display from which the name should be 415 * queried. 416 * \returns the name of a display or NULL for an invalid display index or 417 * failure; call SDL_GetError() for more information. 418 * 419 * \since This function is available since SDL 2.0.0. 420 * 421 * \sa SDL_GetNumVideoDisplays 422 */ 423 extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex); 424 425 /** 426 * Get the desktop area represented by a display. 427 * 428 * The primary display (`displayIndex` zero) is always located at 0,0. 429 * 430 * \param displayIndex the index of the display to query. 431 * \param rect the SDL_Rect structure filled in with the display bounds. 432 * \returns 0 on success or a negative error code on failure; call 433 * SDL_GetError() for more information. 434 * 435 * \since This function is available since SDL 2.0.0. 436 * 437 * \sa SDL_GetNumVideoDisplays 438 */ 439 extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); 440 441 /** 442 * Get the usable desktop area represented by a display. 443 * 444 * The primary display (`displayIndex` zero) is always located at 0,0. 445 * 446 * This is the same area as SDL_GetDisplayBounds() reports, but with portions 447 * reserved by the system removed. For example, on Apple's macOS, this 448 * subtracts the area occupied by the menu bar and dock. 449 * 450 * Setting a window to be fullscreen generally bypasses these unusable areas, 451 * so these are good guidelines for the maximum space available to a 452 * non-fullscreen window. 453 * 454 * The parameter `rect` is ignored if it is NULL. 455 * 456 * This function also returns -1 if the parameter `displayIndex` is out of 457 * range. 458 * 459 * \param displayIndex the index of the display to query the usable bounds 460 * from. 461 * \param rect the SDL_Rect structure filled in with the display bounds. 462 * \returns 0 on success or a negative error code on failure; call 463 * SDL_GetError() for more information. 464 * 465 * \since This function is available since SDL 2.0.5. 466 * 467 * \sa SDL_GetDisplayBounds 468 * \sa SDL_GetNumVideoDisplays 469 */ 470 extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect); 471 472 /** 473 * Get the dots/pixels-per-inch for a display. 474 * 475 * Diagonal, horizontal and vertical DPI can all be optionally returned if the 476 * appropriate parameter is non-NULL. 477 * 478 * A failure of this function usually means that either no DPI information is 479 * available or the `displayIndex` is out of range. 480 * 481 * **WARNING**: This reports the DPI that the hardware reports, and it is not 482 * always reliable! It is almost always better to use SDL_GetWindowSize() to 483 * find the window size, which might be in logical points instead of pixels, 484 * and then SDL_GL_GetDrawableSize(), SDL_Vulkan_GetDrawableSize(), 485 * SDL_Metal_GetDrawableSize(), or SDL_GetRendererOutputSize(), and compare 486 * the two values to get an actual scaling value between the two. We will be 487 * rethinking how high-dpi details should be managed in SDL3 to make things 488 * more consistent, reliable, and clear. 489 * 490 * \param displayIndex the index of the display from which DPI information 491 * should be queried. 492 * \param ddpi a pointer filled in with the diagonal DPI of the display; may 493 * be NULL. 494 * \param hdpi a pointer filled in with the horizontal DPI of the display; may 495 * be NULL. 496 * \param vdpi a pointer filled in with the vertical DPI of the display; may 497 * be NULL. 498 * \returns 0 on success or a negative error code on failure; call 499 * SDL_GetError() for more information. 500 * 501 * \since This function is available since SDL 2.0.4. 502 * 503 * \sa SDL_GetNumVideoDisplays 504 */ 505 extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi); 506 507 /** 508 * Get the orientation of a display. 509 * 510 * \param displayIndex the index of the display to query. 511 * \returns The SDL_DisplayOrientation enum value of the display, or 512 * `SDL_ORIENTATION_UNKNOWN` if it isn't available. 513 * 514 * \since This function is available since SDL 2.0.9. 515 * 516 * \sa SDL_GetNumVideoDisplays 517 */ 518 extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex); 519 520 /** 521 * Get the number of available display modes. 522 * 523 * The `displayIndex` needs to be in the range from 0 to 524 * SDL_GetNumVideoDisplays() - 1. 525 * 526 * \param displayIndex the index of the display to query. 527 * \returns a number >= 1 on success or a negative error code on failure; call 528 * SDL_GetError() for more information. 529 * 530 * \since This function is available since SDL 2.0.0. 531 * 532 * \sa SDL_GetDisplayMode 533 * \sa SDL_GetNumVideoDisplays 534 */ 535 extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex); 536 537 /** 538 * Get information about a specific display mode. 539 * 540 * The display modes are sorted in this priority: 541 * 542 * - width -> largest to smallest 543 * - height -> largest to smallest 544 * - bits per pixel -> more colors to fewer colors 545 * - packed pixel layout -> largest to smallest 546 * - refresh rate -> highest to lowest 547 * 548 * \param displayIndex the index of the display to query. 549 * \param modeIndex the index of the display mode to query. 550 * \param mode an SDL_DisplayMode structure filled in with the mode at 551 * `modeIndex`. 552 * \returns 0 on success or a negative error code on failure; call 553 * SDL_GetError() for more information. 554 * 555 * \since This function is available since SDL 2.0.0. 556 * 557 * \sa SDL_GetNumDisplayModes 558 */ 559 extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, 560 SDL_DisplayMode * mode); 561 562 /** 563 * Get information about the desktop's display mode. 564 * 565 * There's a difference between this function and SDL_GetCurrentDisplayMode() 566 * when SDL runs fullscreen and has changed the resolution. In that case this 567 * function will return the previous native display mode, and not the current 568 * display mode. 569 * 570 * \param displayIndex the index of the display to query. 571 * \param mode an SDL_DisplayMode structure filled in with the current display 572 * mode. 573 * \returns 0 on success or a negative error code on failure; call 574 * SDL_GetError() for more information. 575 * 576 * \since This function is available since SDL 2.0.0. 577 * 578 * \sa SDL_GetCurrentDisplayMode 579 * \sa SDL_GetDisplayMode 580 * \sa SDL_SetWindowDisplayMode 581 */ 582 extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode); 583 584 /** 585 * Get information about the current display mode. 586 * 587 * There's a difference between this function and SDL_GetDesktopDisplayMode() 588 * when SDL runs fullscreen and has changed the resolution. In that case this 589 * function will return the current display mode, and not the previous native 590 * display mode. 591 * 592 * \param displayIndex the index of the display to query. 593 * \param mode an SDL_DisplayMode structure filled in with the current display 594 * mode. 595 * \returns 0 on success or a negative error code on failure; call 596 * SDL_GetError() for more information. 597 * 598 * \since This function is available since SDL 2.0.0. 599 * 600 * \sa SDL_GetDesktopDisplayMode 601 * \sa SDL_GetDisplayMode 602 * \sa SDL_GetNumVideoDisplays 603 * \sa SDL_SetWindowDisplayMode 604 */ 605 extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode); 606 607 608 /** 609 * Get the closest match to the requested display mode. 610 * 611 * The available display modes are scanned and `closest` is filled in with the 612 * closest mode matching the requested mode and returned. The mode format and 613 * refresh rate default to the desktop mode if they are set to 0. The modes 614 * are scanned with size being first priority, format being second priority, 615 * and finally checking the refresh rate. If all the available modes are too 616 * small, then NULL is returned. 617 * 618 * \param displayIndex the index of the display to query. 619 * \param mode an SDL_DisplayMode structure containing the desired display 620 * mode. 621 * \param closest an SDL_DisplayMode structure filled in with the closest 622 * match of the available display modes. 623 * \returns the passed in value `closest` or NULL if no matching video mode 624 * was available; call SDL_GetError() for more information. 625 * 626 * \since This function is available since SDL 2.0.0. 627 * 628 * \sa SDL_GetDisplayMode 629 * \sa SDL_GetNumDisplayModes 630 */ 631 extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); 632 633 /** 634 * Get the index of the display containing a point 635 * 636 * \param point the point to query. 637 * \returns the index of the display containing the point or a negative error 638 * code on failure; call SDL_GetError() for more information. 639 * 640 * \since This function is available since SDL 2.24.0. 641 * 642 * \sa SDL_GetDisplayBounds 643 * \sa SDL_GetNumVideoDisplays 644 */ 645 extern DECLSPEC int SDLCALL SDL_GetPointDisplayIndex(const SDL_Point * point); 646 647 /** 648 * Get the index of the display primarily containing a rect 649 * 650 * \param rect the rect to query. 651 * \returns the index of the display entirely containing the rect or closest 652 * to the center of the rect on success or a negative error code on 653 * failure; call SDL_GetError() for more information. 654 * 655 * \since This function is available since SDL 2.24.0. 656 * 657 * \sa SDL_GetDisplayBounds 658 * \sa SDL_GetNumVideoDisplays 659 */ 660 extern DECLSPEC int SDLCALL SDL_GetRectDisplayIndex(const SDL_Rect * rect); 661 662 /** 663 * Get the index of the display associated with a window. 664 * 665 * \param window the window to query. 666 * \returns the index of the display containing the center of the window on 667 * success or a negative error code on failure; call SDL_GetError() 668 * for more information. 669 * 670 * \since This function is available since SDL 2.0.0. 671 * 672 * \sa SDL_GetDisplayBounds 673 * \sa SDL_GetNumVideoDisplays 674 */ 675 extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window); 676 677 /** 678 * Set the display mode to use when a window is visible at fullscreen. 679 * 680 * This only affects the display mode used when the window is fullscreen. To 681 * change the window size when the window is not fullscreen, use 682 * SDL_SetWindowSize(). 683 * 684 * \param window the window to affect. 685 * \param mode the SDL_DisplayMode structure representing the mode to use, or 686 * NULL to use the window's dimensions and the desktop's format 687 * and refresh rate. 688 * \returns 0 on success or a negative error code on failure; call 689 * SDL_GetError() for more information. 690 * 691 * \since This function is available since SDL 2.0.0. 692 * 693 * \sa SDL_GetWindowDisplayMode 694 * \sa SDL_SetWindowFullscreen 695 */ 696 extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, 697 const SDL_DisplayMode * mode); 698 699 /** 700 * Query the display mode to use when a window is visible at fullscreen. 701 * 702 * \param window the window to query. 703 * \param mode an SDL_DisplayMode structure filled in with the fullscreen 704 * display mode. 705 * \returns 0 on success or a negative error code on failure; call 706 * SDL_GetError() for more information. 707 * 708 * \since This function is available since SDL 2.0.0. 709 * 710 * \sa SDL_SetWindowDisplayMode 711 * \sa SDL_SetWindowFullscreen 712 */ 713 extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, 714 SDL_DisplayMode * mode); 715 716 /** 717 * Get the raw ICC profile data for the screen the window is currently on. 718 * 719 * Data returned should be freed with SDL_free. 720 * 721 * \param window the window to query. 722 * \param size the size of the ICC profile. 723 * \returns the raw ICC profile data on success or NULL on failure; call 724 * SDL_GetError() for more information. 725 * 726 * \since This function is available since SDL 2.0.18. 727 */ 728 extern DECLSPEC void* SDLCALL SDL_GetWindowICCProfile(SDL_Window * window, size_t* size); 729 730 /** 731 * Get the pixel format associated with the window. 732 * 733 * \param window the window to query. 734 * \returns the pixel format of the window on success or 735 * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more 736 * information. 737 * 738 * \since This function is available since SDL 2.0.0. 739 */ 740 extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); 741 742 /** 743 * Create a window with the specified position, dimensions, and flags. 744 * 745 * `flags` may be any of the following OR'd together: 746 * 747 * - `SDL_WINDOW_FULLSCREEN`: fullscreen window 748 * - `SDL_WINDOW_FULLSCREEN_DESKTOP`: fullscreen window at desktop resolution 749 * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context 750 * - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance 751 * - `SDL_WINDOW_METAL`: window usable with a Metal instance 752 * - `SDL_WINDOW_HIDDEN`: window is not visible 753 * - `SDL_WINDOW_BORDERLESS`: no window decoration 754 * - `SDL_WINDOW_RESIZABLE`: window can be resized 755 * - `SDL_WINDOW_MINIMIZED`: window is minimized 756 * - `SDL_WINDOW_MAXIMIZED`: window is maximized 757 * - `SDL_WINDOW_INPUT_GRABBED`: window has grabbed input focus 758 * - `SDL_WINDOW_ALLOW_HIGHDPI`: window should be created in high-DPI mode if 759 * supported (>= SDL 2.0.1) 760 * 761 * `SDL_WINDOW_SHOWN` is ignored by SDL_CreateWindow(). The SDL_Window is 762 * implicitly shown if SDL_WINDOW_HIDDEN is not set. `SDL_WINDOW_SHOWN` may be 763 * queried later using SDL_GetWindowFlags(). 764 * 765 * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist 766 * property to YES, otherwise you will not receive a High-DPI OpenGL canvas. 767 * 768 * If the window is created with the `SDL_WINDOW_ALLOW_HIGHDPI` flag, its size 769 * in pixels may differ from its size in screen coordinates on platforms with 770 * high-DPI support (e.g. iOS and macOS). Use SDL_GetWindowSize() to query the 771 * client area's size in screen coordinates, and SDL_GL_GetDrawableSize() or 772 * SDL_GetRendererOutputSize() to query the drawable size in pixels. Note that 773 * when this flag is set, the drawable size can vary after the window is 774 * created and should be queried after major window events such as when the 775 * window is resized or moved between displays. 776 * 777 * If the window is set fullscreen, the width and height parameters `w` and 778 * `h` will not be used. However, invalid size parameters (e.g. too large) may 779 * still fail. Window size is actually limited to 16384 x 16384 for all 780 * platforms at window creation. 781 * 782 * If the window is created with any of the SDL_WINDOW_OPENGL or 783 * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function 784 * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the 785 * corresponding UnloadLibrary function is called by SDL_DestroyWindow(). 786 * 787 * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver, 788 * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail. 789 * 790 * If SDL_WINDOW_METAL is specified on an OS that does not support Metal, 791 * SDL_CreateWindow() will fail. 792 * 793 * On non-Apple devices, SDL requires you to either not link to the Vulkan 794 * loader or link to a dynamic library version. This limitation may be removed 795 * in a future version of SDL. 796 * 797 * \param title the title of the window, in UTF-8 encoding. 798 * \param x the x position of the window, `SDL_WINDOWPOS_CENTERED`, or 799 * `SDL_WINDOWPOS_UNDEFINED`. 800 * \param y the y position of the window, `SDL_WINDOWPOS_CENTERED`, or 801 * `SDL_WINDOWPOS_UNDEFINED`. 802 * \param w the width of the window, in screen coordinates. 803 * \param h the height of the window, in screen coordinates. 804 * \param flags 0, or one or more SDL_WindowFlags OR'd together. 805 * \returns the `SDL_Window` that was created or NULL on failure; call 806 * SDL_GetError() for more information. 807 * 808 * \since This function is available since SDL 2.0.0. 809 * 810 * \sa SDL_CreateWindowFrom 811 * \sa SDL_DestroyWindow 812 */ 813 extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, 814 int x, int y, int w, 815 int h, Uint32 flags); 816 817 /** 818 * Create an SDL window from an existing native window. 819 * 820 * In some cases (e.g. OpenGL) and on some platforms (e.g. Microsoft Windows) 821 * the hint `SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT` needs to be configured 822 * before using SDL_CreateWindowFrom(). 823 * 824 * \param data a pointer to driver-dependent window creation data, typically 825 * your native window cast to a void*. 826 * \returns the window that was created or NULL on failure; call 827 * SDL_GetError() for more information. 828 * 829 * \since This function is available since SDL 2.0.0. 830 * 831 * \sa SDL_CreateWindow 832 * \sa SDL_DestroyWindow 833 */ 834 extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data); 835 836 /** 837 * Get the numeric ID of a window. 838 * 839 * The numeric ID is what SDL_WindowEvent references, and is necessary to map 840 * these events to specific SDL_Window objects. 841 * 842 * \param window the window to query. 843 * \returns the ID of the window on success or 0 on failure; call 844 * SDL_GetError() for more information. 845 * 846 * \since This function is available since SDL 2.0.0. 847 * 848 * \sa SDL_GetWindowFromID 849 */ 850 extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window); 851 852 /** 853 * Get a window from a stored ID. 854 * 855 * The numeric ID is what SDL_WindowEvent references, and is necessary to map 856 * these events to specific SDL_Window objects. 857 * 858 * \param id the ID of the window. 859 * \returns the window associated with `id` or NULL if it doesn't exist; call 860 * SDL_GetError() for more information. 861 * 862 * \since This function is available since SDL 2.0.0. 863 * 864 * \sa SDL_GetWindowID 865 */ 866 extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); 867 868 /** 869 * Get the window flags. 870 * 871 * \param window the window to query. 872 * \returns a mask of the SDL_WindowFlags associated with `window`. 873 * 874 * \since This function is available since SDL 2.0.0. 875 * 876 * \sa SDL_CreateWindow 877 * \sa SDL_HideWindow 878 * \sa SDL_MaximizeWindow 879 * \sa SDL_MinimizeWindow 880 * \sa SDL_SetWindowFullscreen 881 * \sa SDL_SetWindowGrab 882 * \sa SDL_ShowWindow 883 */ 884 extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window); 885 886 /** 887 * Set the title of a window. 888 * 889 * This string is expected to be in UTF-8 encoding. 890 * 891 * \param window the window to change. 892 * \param title the desired window title in UTF-8 format. 893 * 894 * \since This function is available since SDL 2.0.0. 895 * 896 * \sa SDL_GetWindowTitle 897 */ 898 extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, 899 const char *title); 900 901 /** 902 * Get the title of a window. 903 * 904 * \param window the window to query. 905 * \returns the title of the window in UTF-8 format or "" if there is no 906 * title. 907 * 908 * \since This function is available since SDL 2.0.0. 909 * 910 * \sa SDL_SetWindowTitle 911 */ 912 extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); 913 914 /** 915 * Set the icon for a window. 916 * 917 * \param window the window to change. 918 * \param icon an SDL_Surface structure containing the icon for the window. 919 * 920 * \since This function is available since SDL 2.0.0. 921 */ 922 extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, 923 SDL_Surface * icon); 924 925 /** 926 * Associate an arbitrary named pointer with a window. 927 * 928 * `name` is case-sensitive. 929 * 930 * \param window the window to associate with the pointer. 931 * \param name the name of the pointer. 932 * \param userdata the associated pointer. 933 * \returns the previous value associated with `name`. 934 * 935 * \since This function is available since SDL 2.0.0. 936 * 937 * \sa SDL_GetWindowData 938 */ 939 extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, 940 const char *name, 941 void *userdata); 942 943 /** 944 * Retrieve the data pointer associated with a window. 945 * 946 * \param window the window to query. 947 * \param name the name of the pointer. 948 * \returns the value associated with `name`. 949 * 950 * \since This function is available since SDL 2.0.0. 951 * 952 * \sa SDL_SetWindowData 953 */ 954 extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, 955 const char *name); 956 957 /** 958 * Set the position of a window. 959 * 960 * The window coordinate origin is the upper left of the display. 961 * 962 * \param window the window to reposition. 963 * \param x the x coordinate of the window in screen coordinates, or 964 * `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED`. 965 * \param y the y coordinate of the window in screen coordinates, or 966 * `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED`. 967 * 968 * \since This function is available since SDL 2.0.0. 969 * 970 * \sa SDL_GetWindowPosition 971 */ 972 extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, 973 int x, int y); 974 975 /** 976 * Get the position of a window. 977 * 978 * If you do not need the value for one of the positions a NULL may be passed 979 * in the `x` or `y` parameter. 980 * 981 * \param window the window to query. 982 * \param x a pointer filled in with the x position of the window, in screen 983 * coordinates, may be NULL. 984 * \param y a pointer filled in with the y position of the window, in screen 985 * coordinates, may be NULL. 986 * 987 * \since This function is available since SDL 2.0.0. 988 * 989 * \sa SDL_SetWindowPosition 990 */ 991 extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, 992 int *x, int *y); 993 994 /** 995 * Set the size of a window's client area. 996 * 997 * The window size in screen coordinates may differ from the size in pixels, 998 * if the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a platform 999 * with high-dpi support (e.g. iOS or macOS). Use SDL_GL_GetDrawableSize() or 1000 * SDL_GetRendererOutputSize() to get the real client area size in pixels. 1001 * 1002 * Fullscreen windows automatically match the size of the display mode, and 1003 * you should use SDL_SetWindowDisplayMode() to change their size. 1004 * 1005 * \param window the window to change. 1006 * \param w the width of the window in pixels, in screen coordinates, must be 1007 * > 0. 1008 * \param h the height of the window in pixels, in screen coordinates, must be 1009 * > 0. 1010 * 1011 * \since This function is available since SDL 2.0.0. 1012 * 1013 * \sa SDL_GetWindowSize 1014 * \sa SDL_SetWindowDisplayMode 1015 */ 1016 extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, 1017 int h); 1018 1019 /** 1020 * Get the size of a window's client area. 1021 * 1022 * NULL can safely be passed as the `w` or `h` parameter if the width or 1023 * height value is not desired. 1024 * 1025 * The window size in screen coordinates may differ from the size in pixels, 1026 * if the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a platform 1027 * with high-dpi support (e.g. iOS or macOS). Use SDL_GL_GetDrawableSize(), 1028 * SDL_Vulkan_GetDrawableSize(), or SDL_GetRendererOutputSize() to get the 1029 * real client area size in pixels. 1030 * 1031 * \param window the window to query the width and height from. 1032 * \param w a pointer filled in with the width of the window, in screen 1033 * coordinates, may be NULL. 1034 * \param h a pointer filled in with the height of the window, in screen 1035 * coordinates, may be NULL. 1036 * 1037 * \since This function is available since SDL 2.0.0. 1038 * 1039 * \sa SDL_GL_GetDrawableSize 1040 * \sa SDL_Vulkan_GetDrawableSize 1041 * \sa SDL_SetWindowSize 1042 */ 1043 extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, 1044 int *h); 1045 1046 /** 1047 * Get the size of a window's borders (decorations) around the client area. 1048 * 1049 * Note: If this function fails (returns -1), the size values will be 1050 * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the 1051 * window in question was borderless. 1052 * 1053 * Note: This function may fail on systems where the window has not yet been 1054 * decorated by the display server (for example, immediately after calling 1055 * SDL_CreateWindow). It is recommended that you wait at least until the 1056 * window has been presented and composited, so that the window system has a 1057 * chance to decorate the window and provide the border dimensions to SDL. 1058 * 1059 * This function also returns -1 if getting the information is not supported. 1060 * 1061 * \param window the window to query the size values of the border 1062 * (decorations) from. 1063 * \param top pointer to variable for storing the size of the top border; NULL 1064 * is permitted. 1065 * \param left pointer to variable for storing the size of the left border; 1066 * NULL is permitted. 1067 * \param bottom pointer to variable for storing the size of the bottom 1068 * border; NULL is permitted. 1069 * \param right pointer to variable for storing the size of the right border; 1070 * NULL is permitted. 1071 * \returns 0 on success or a negative error code on failure; call 1072 * SDL_GetError() for more information. 1073 * 1074 * \since This function is available since SDL 2.0.5. 1075 * 1076 * \sa SDL_GetWindowSize 1077 */ 1078 extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window * window, 1079 int *top, int *left, 1080 int *bottom, int *right); 1081 1082 /** 1083 * Get the size of a window in pixels. 1084 * 1085 * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI 1086 * drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a 1087 * platform with high-DPI support (Apple calls this "Retina"), and not 1088 * disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint. 1089 * 1090 * \param window the window from which the drawable size should be queried. 1091 * \param w a pointer to variable for storing the width in pixels, may be 1092 * NULL. 1093 * \param h a pointer to variable for storing the height in pixels, may be 1094 * NULL. 1095 * 1096 * \since This function is available since SDL 2.26.0. 1097 * 1098 * \sa SDL_CreateWindow 1099 * \sa SDL_GetWindowSize 1100 */ 1101 extern DECLSPEC void SDLCALL SDL_GetWindowSizeInPixels(SDL_Window * window, 1102 int *w, int *h); 1103 1104 /** 1105 * Set the minimum size of a window's client area. 1106 * 1107 * \param window the window to change. 1108 * \param min_w the minimum width of the window in pixels. 1109 * \param min_h the minimum height of the window in pixels. 1110 * 1111 * \since This function is available since SDL 2.0.0. 1112 * 1113 * \sa SDL_GetWindowMinimumSize 1114 * \sa SDL_SetWindowMaximumSize 1115 */ 1116 extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, 1117 int min_w, int min_h); 1118 1119 /** 1120 * Get the minimum size of a window's client area. 1121 * 1122 * \param window the window to query. 1123 * \param w a pointer filled in with the minimum width of the window, may be 1124 * NULL. 1125 * \param h a pointer filled in with the minimum height of the window, may be 1126 * NULL. 1127 * 1128 * \since This function is available since SDL 2.0.0. 1129 * 1130 * \sa SDL_GetWindowMaximumSize 1131 * \sa SDL_SetWindowMinimumSize 1132 */ 1133 extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, 1134 int *w, int *h); 1135 1136 /** 1137 * Set the maximum size of a window's client area. 1138 * 1139 * \param window the window to change. 1140 * \param max_w the maximum width of the window in pixels. 1141 * \param max_h the maximum height of the window in pixels. 1142 * 1143 * \since This function is available since SDL 2.0.0. 1144 * 1145 * \sa SDL_GetWindowMaximumSize 1146 * \sa SDL_SetWindowMinimumSize 1147 */ 1148 extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, 1149 int max_w, int max_h); 1150 1151 /** 1152 * Get the maximum size of a window's client area. 1153 * 1154 * \param window the window to query. 1155 * \param w a pointer filled in with the maximum width of the window, may be 1156 * NULL. 1157 * \param h a pointer filled in with the maximum height of the window, may be 1158 * NULL. 1159 * 1160 * \since This function is available since SDL 2.0.0. 1161 * 1162 * \sa SDL_GetWindowMinimumSize 1163 * \sa SDL_SetWindowMaximumSize 1164 */ 1165 extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, 1166 int *w, int *h); 1167 1168 /** 1169 * Set the border state of a window. 1170 * 1171 * This will add or remove the window's `SDL_WINDOW_BORDERLESS` flag and add 1172 * or remove the border from the actual window. This is a no-op if the 1173 * window's border already matches the requested state. 1174 * 1175 * You can't change the border state of a fullscreen window. 1176 * 1177 * \param window the window of which to change the border state. 1178 * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border. 1179 * 1180 * \since This function is available since SDL 2.0.0. 1181 * 1182 * \sa SDL_GetWindowFlags 1183 */ 1184 extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, 1185 SDL_bool bordered); 1186 1187 /** 1188 * Set the user-resizable state of a window. 1189 * 1190 * This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and 1191 * allow/disallow user resizing of the window. This is a no-op if the window's 1192 * resizable state already matches the requested state. 1193 * 1194 * You can't change the resizable state of a fullscreen window. 1195 * 1196 * \param window the window of which to change the resizable state. 1197 * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow. 1198 * 1199 * \since This function is available since SDL 2.0.5. 1200 * 1201 * \sa SDL_GetWindowFlags 1202 */ 1203 extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window * window, 1204 SDL_bool resizable); 1205 1206 /** 1207 * Set the window to always be above the others. 1208 * 1209 * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` flag. This 1210 * will bring the window to the front and keep the window above the rest. 1211 * 1212 * \param window The window of which to change the always on top state. 1213 * \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to 1214 * disable. 1215 * 1216 * \since This function is available since SDL 2.0.16. 1217 * 1218 * \sa SDL_GetWindowFlags 1219 */ 1220 extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window * window, 1221 SDL_bool on_top); 1222 1223 /** 1224 * Show a window. 1225 * 1226 * \param window the window to show. 1227 * 1228 * \since This function is available since SDL 2.0.0. 1229 * 1230 * \sa SDL_HideWindow 1231 * \sa SDL_RaiseWindow 1232 */ 1233 extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window); 1234 1235 /** 1236 * Hide a window. 1237 * 1238 * \param window the window to hide. 1239 * 1240 * \since This function is available since SDL 2.0.0. 1241 * 1242 * \sa SDL_ShowWindow 1243 */ 1244 extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); 1245 1246 /** 1247 * Raise a window above other windows and set the input focus. 1248 * 1249 * \param window the window to raise. 1250 * 1251 * \since This function is available since SDL 2.0.0. 1252 */ 1253 extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); 1254 1255 /** 1256 * Make a window as large as possible. 1257 * 1258 * \param window the window to maximize. 1259 * 1260 * \since This function is available since SDL 2.0.0. 1261 * 1262 * \sa SDL_MinimizeWindow 1263 * \sa SDL_RestoreWindow 1264 */ 1265 extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window); 1266 1267 /** 1268 * Minimize a window to an iconic representation. 1269 * 1270 * \param window the window to minimize. 1271 * 1272 * \since This function is available since SDL 2.0.0. 1273 * 1274 * \sa SDL_MaximizeWindow 1275 * \sa SDL_RestoreWindow 1276 */ 1277 extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window); 1278 1279 /** 1280 * Restore the size and position of a minimized or maximized window. 1281 * 1282 * \param window the window to restore. 1283 * 1284 * \since This function is available since SDL 2.0.0. 1285 * 1286 * \sa SDL_MaximizeWindow 1287 * \sa SDL_MinimizeWindow 1288 */ 1289 extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); 1290 1291 /** 1292 * Set a window's fullscreen state. 1293 * 1294 * `flags` may be `SDL_WINDOW_FULLSCREEN`, for "real" fullscreen with a 1295 * videomode change; `SDL_WINDOW_FULLSCREEN_DESKTOP` for "fake" fullscreen 1296 * that takes the size of the desktop; and 0 for windowed mode. 1297 * 1298 * Note that for some renderers, this function may trigger an 1299 * SDL_RENDER_TARGETS_RESET event. Your application should be prepared to 1300 * handle this event by reuploading textures! 1301 * 1302 * \param window the window to change. 1303 * \param flags `SDL_WINDOW_FULLSCREEN`, `SDL_WINDOW_FULLSCREEN_DESKTOP` or 0. 1304 * \returns 0 on success or a negative error code on failure; call 1305 * SDL_GetError() for more information. 1306 * 1307 * \since This function is available since SDL 2.0.0. 1308 * 1309 * \sa SDL_GetWindowDisplayMode 1310 * \sa SDL_SetWindowDisplayMode 1311 */ 1312 extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, 1313 Uint32 flags); 1314 1315 /** 1316 * Return whether the window has a surface associated with it. 1317 * 1318 * \returns SDL_TRUE if there is a surface associated with the window, or 1319 * SDL_FALSE otherwise. 1320 * 1321 * \since This function is available since SDL 2.28.0. 1322 * 1323 * \sa SDL_GetWindowSurface 1324 */ 1325 extern DECLSPEC SDL_bool SDLCALL SDL_HasWindowSurface(SDL_Window *window); 1326 1327 /** 1328 * Get the SDL surface associated with the window. 1329 * 1330 * A new surface will be created with the optimal format for the window, if 1331 * necessary. This surface will be freed when the window is destroyed. Do not 1332 * free this surface. 1333 * 1334 * This surface will be invalidated if the window is resized. After resizing a 1335 * window this function must be called again to return a valid surface. 1336 * 1337 * Note that on some platforms the pixels pointer of the surface may be 1338 * modified after each call to SDL_UpdateWindowSurface(), so that the platform 1339 * code can implement efficient double or triple buffering. 1340 * 1341 * You may not combine this with 3D or the rendering API on this window. 1342 * 1343 * This function is affected by `SDL_HINT_FRAMEBUFFER_ACCELERATION`. 1344 * 1345 * \param window the window to query. 1346 * \returns the surface associated with the window, or NULL on failure; call 1347 * SDL_GetError() for more information. 1348 * 1349 * \since This function is available since SDL 2.0.0. 1350 * 1351 * \sa SDL_DestroyWindowSurface 1352 * \sa SDL_HasWindowSurface 1353 * \sa SDL_UpdateWindowSurface 1354 * \sa SDL_UpdateWindowSurfaceRects 1355 */ 1356 extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window); 1357 1358 /** 1359 * Copy the window surface to the screen. 1360 * 1361 * This is the function you use to reflect any changes to the surface on the 1362 * screen. 1363 * 1364 * This function is equivalent to the SDL 1.2 API SDL_Flip(). 1365 * 1366 * \param window the window to update. 1367 * \returns 0 on success or a negative error code on failure; call 1368 * SDL_GetError() for more information. 1369 * 1370 * \since This function is available since SDL 2.0.0. 1371 * 1372 * \sa SDL_GetWindowSurface 1373 * \sa SDL_UpdateWindowSurfaceRects 1374 */ 1375 extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); 1376 1377 /** 1378 * Copy areas of the window surface to the screen. 1379 * 1380 * This is the function you use to reflect changes to portions of the surface 1381 * on the screen. 1382 * 1383 * This function is equivalent to the SDL 1.2 API SDL_UpdateRects(). 1384 * 1385 * Note that this function will update _at least_ the rectangles specified, 1386 * but this is only intended as an optimization; in practice, this might 1387 * update more of the screen (or all of the screen!), depending on what method 1388 * SDL uses to send pixels to the system. 1389 * 1390 * \param window the window to update. 1391 * \param rects an array of SDL_Rect structures representing areas of the 1392 * surface to copy, in pixels. 1393 * \param numrects the number of rectangles. 1394 * \returns 0 on success or a negative error code on failure; call 1395 * SDL_GetError() for more information. 1396 * 1397 * \since This function is available since SDL 2.0.0. 1398 * 1399 * \sa SDL_GetWindowSurface 1400 * \sa SDL_UpdateWindowSurface 1401 */ 1402 extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, 1403 const SDL_Rect * rects, 1404 int numrects); 1405 1406 /** 1407 * Destroy the surface associated with the window. 1408 * 1409 * \param window the window to update. 1410 * \returns 0 on success or a negative error code on failure; call 1411 * SDL_GetError() for more information. 1412 * 1413 * \since This function is available since SDL 2.28.0. 1414 * 1415 * \sa SDL_GetWindowSurface 1416 * \sa SDL_HasWindowSurface 1417 */ 1418 extern DECLSPEC int SDLCALL SDL_DestroyWindowSurface(SDL_Window *window); 1419 1420 /** 1421 * Set a window's input grab mode. 1422 * 1423 * When input is grabbed, the mouse is confined to the window. This function 1424 * will also grab the keyboard if `SDL_HINT_GRAB_KEYBOARD` is set. To grab the 1425 * keyboard without also grabbing the mouse, use SDL_SetWindowKeyboardGrab(). 1426 * 1427 * If the caller enables a grab while another window is currently grabbed, the 1428 * other window loses its grab in favor of the caller's window. 1429 * 1430 * \param window the window for which the input grab mode should be set. 1431 * \param grabbed SDL_TRUE to grab input or SDL_FALSE to release input. 1432 * 1433 * \since This function is available since SDL 2.0.0. 1434 * 1435 * \sa SDL_GetGrabbedWindow 1436 * \sa SDL_GetWindowGrab 1437 */ 1438 extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, 1439 SDL_bool grabbed); 1440 1441 /** 1442 * Set a window's keyboard grab mode. 1443 * 1444 * Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or 1445 * the Meta/Super key. Note that not all system keyboard shortcuts can be 1446 * captured by applications (one example is Ctrl+Alt+Del on Windows). 1447 * 1448 * This is primarily intended for specialized applications such as VNC clients 1449 * or VM frontends. Normal games should not use keyboard grab. 1450 * 1451 * When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the 1452 * window is full-screen to ensure the user is not trapped in your 1453 * application. If you have a custom keyboard shortcut to exit fullscreen 1454 * mode, you may suppress this behavior with 1455 * `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`. 1456 * 1457 * If the caller enables a grab while another window is currently grabbed, the 1458 * other window loses its grab in favor of the caller's window. 1459 * 1460 * \param window The window for which the keyboard grab mode should be set. 1461 * \param grabbed This is SDL_TRUE to grab keyboard, and SDL_FALSE to release. 1462 * 1463 * \since This function is available since SDL 2.0.16. 1464 * 1465 * \sa SDL_GetWindowKeyboardGrab 1466 * \sa SDL_SetWindowMouseGrab 1467 * \sa SDL_SetWindowGrab 1468 */ 1469 extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window * window, 1470 SDL_bool grabbed); 1471 1472 /** 1473 * Set a window's mouse grab mode. 1474 * 1475 * Mouse grab confines the mouse cursor to the window. 1476 * 1477 * \param window The window for which the mouse grab mode should be set. 1478 * \param grabbed This is SDL_TRUE to grab mouse, and SDL_FALSE to release. 1479 * 1480 * \since This function is available since SDL 2.0.16. 1481 * 1482 * \sa SDL_GetWindowMouseGrab 1483 * \sa SDL_SetWindowKeyboardGrab 1484 * \sa SDL_SetWindowGrab 1485 */ 1486 extern DECLSPEC void SDLCALL SDL_SetWindowMouseGrab(SDL_Window * window, 1487 SDL_bool grabbed); 1488 1489 /** 1490 * Get a window's input grab mode. 1491 * 1492 * \param window the window to query. 1493 * \returns SDL_TRUE if input is grabbed, SDL_FALSE otherwise. 1494 * 1495 * \since This function is available since SDL 2.0.0. 1496 * 1497 * \sa SDL_SetWindowGrab 1498 */ 1499 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); 1500 1501 /** 1502 * Get a window's keyboard grab mode. 1503 * 1504 * \param window the window to query. 1505 * \returns SDL_TRUE if keyboard is grabbed, and SDL_FALSE otherwise. 1506 * 1507 * \since This function is available since SDL 2.0.16. 1508 * 1509 * \sa SDL_SetWindowKeyboardGrab 1510 * \sa SDL_GetWindowGrab 1511 */ 1512 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window * window); 1513 1514 /** 1515 * Get a window's mouse grab mode. 1516 * 1517 * \param window the window to query. 1518 * \returns SDL_TRUE if mouse is grabbed, and SDL_FALSE otherwise. 1519 * 1520 * \since This function is available since SDL 2.0.16. 1521 * 1522 * \sa SDL_SetWindowKeyboardGrab 1523 * \sa SDL_GetWindowGrab 1524 */ 1525 extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window * window); 1526 1527 /** 1528 * Get the window that currently has an input grab enabled. 1529 * 1530 * \returns the window if input is grabbed or NULL otherwise. 1531 * 1532 * \since This function is available since SDL 2.0.4. 1533 * 1534 * \sa SDL_GetWindowGrab 1535 * \sa SDL_SetWindowGrab 1536 */ 1537 extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void); 1538 1539 /** 1540 * Confines the cursor to the specified area of a window. 1541 * 1542 * Note that this does NOT grab the cursor, it only defines the area a cursor 1543 * is restricted to when the window has mouse focus. 1544 * 1545 * \param window The window that will be associated with the barrier. 1546 * \param rect A rectangle area in window-relative coordinates. If NULL the 1547 * barrier for the specified window will be destroyed. 1548 * \returns 0 on success or a negative error code on failure; call 1549 * SDL_GetError() for more information. 1550 * 1551 * \since This function is available since SDL 2.0.18. 1552 * 1553 * \sa SDL_GetWindowMouseRect 1554 * \sa SDL_SetWindowMouseGrab 1555 */ 1556 extern DECLSPEC int SDLCALL SDL_SetWindowMouseRect(SDL_Window * window, const SDL_Rect * rect); 1557 1558 /** 1559 * Get the mouse confinement rectangle of a window. 1560 * 1561 * \param window The window to query. 1562 * \returns A pointer to the mouse confinement rectangle of a window, or NULL 1563 * if there isn't one. 1564 * 1565 * \since This function is available since SDL 2.0.18. 1566 * 1567 * \sa SDL_SetWindowMouseRect 1568 */ 1569 extern DECLSPEC const SDL_Rect * SDLCALL SDL_GetWindowMouseRect(SDL_Window * window); 1570 1571 /** 1572 * Set the brightness (gamma multiplier) for a given window's display. 1573 * 1574 * Despite the name and signature, this method sets the brightness of the 1575 * entire display, not an individual window. A window is considered to be 1576 * owned by the display that contains the window's center pixel. (The index of 1577 * this display can be retrieved using SDL_GetWindowDisplayIndex().) The 1578 * brightness set will not follow the window if it is moved to another 1579 * display. 1580 * 1581 * Many platforms will refuse to set the display brightness in modern times. 1582 * You are better off using a shader to adjust gamma during rendering, or 1583 * something similar. 1584 * 1585 * \param window the window used to select the display whose brightness will 1586 * be changed. 1587 * \param brightness the brightness (gamma multiplier) value to set where 0.0 1588 * is completely dark and 1.0 is normal brightness. 1589 * \returns 0 on success or a negative error code on failure; call 1590 * SDL_GetError() for more information. 1591 * 1592 * \since This function is available since SDL 2.0.0. 1593 * 1594 * \sa SDL_GetWindowBrightness 1595 * \sa SDL_SetWindowGammaRamp 1596 */ 1597 extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness); 1598 1599 /** 1600 * Get the brightness (gamma multiplier) for a given window's display. 1601 * 1602 * Despite the name and signature, this method retrieves the brightness of the 1603 * entire display, not an individual window. A window is considered to be 1604 * owned by the display that contains the window's center pixel. (The index of 1605 * this display can be retrieved using SDL_GetWindowDisplayIndex().) 1606 * 1607 * \param window the window used to select the display whose brightness will 1608 * be queried. 1609 * \returns the brightness for the display where 0.0 is completely dark and 1610 * 1.0 is normal brightness. 1611 * 1612 * \since This function is available since SDL 2.0.0. 1613 * 1614 * \sa SDL_SetWindowBrightness 1615 */ 1616 extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); 1617 1618 /** 1619 * Set the opacity for a window. 1620 * 1621 * The parameter `opacity` will be clamped internally between 0.0f 1622 * (transparent) and 1.0f (opaque). 1623 * 1624 * This function also returns -1 if setting the opacity isn't supported. 1625 * 1626 * \param window the window which will be made transparent or opaque. 1627 * \param opacity the opacity value (0.0f - transparent, 1.0f - opaque). 1628 * \returns 0 on success or a negative error code on failure; call 1629 * SDL_GetError() for more information. 1630 * 1631 * \since This function is available since SDL 2.0.5. 1632 * 1633 * \sa SDL_GetWindowOpacity 1634 */ 1635 extern DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window * window, float opacity); 1636 1637 /** 1638 * Get the opacity of a window. 1639 * 1640 * If transparency isn't supported on this platform, opacity will be reported 1641 * as 1.0f without error. 1642 * 1643 * The parameter `opacity` is ignored if it is NULL. 1644 * 1645 * This function also returns -1 if an invalid window was provided. 1646 * 1647 * \param window the window to get the current opacity value from. 1648 * \param out_opacity the float filled in (0.0f - transparent, 1.0f - opaque). 1649 * \returns 0 on success or a negative error code on failure; call 1650 * SDL_GetError() for more information. 1651 * 1652 * \since This function is available since SDL 2.0.5. 1653 * 1654 * \sa SDL_SetWindowOpacity 1655 */ 1656 extern DECLSPEC int SDLCALL SDL_GetWindowOpacity(SDL_Window * window, float * out_opacity); 1657 1658 /** 1659 * Set the window as a modal for another window. 1660 * 1661 * \param modal_window the window that should be set modal. 1662 * \param parent_window the parent window for the modal window. 1663 * \returns 0 on success or a negative error code on failure; call 1664 * SDL_GetError() for more information. 1665 * 1666 * \since This function is available since SDL 2.0.5. 1667 */ 1668 extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window * modal_window, SDL_Window * parent_window); 1669 1670 /** 1671 * Explicitly set input focus to the window. 1672 * 1673 * You almost certainly want SDL_RaiseWindow() instead of this function. Use 1674 * this with caution, as you might give focus to a window that is completely 1675 * obscured by other windows. 1676 * 1677 * \param window the window that should get the input focus. 1678 * \returns 0 on success or a negative error code on failure; call 1679 * SDL_GetError() for more information. 1680 * 1681 * \since This function is available since SDL 2.0.5. 1682 * 1683 * \sa SDL_RaiseWindow 1684 */ 1685 extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window * window); 1686 1687 /** 1688 * Set the gamma ramp for the display that owns a given window. 1689 * 1690 * Set the gamma translation table for the red, green, and blue channels of 1691 * the video hardware. Each table is an array of 256 16-bit quantities, 1692 * representing a mapping between the input and output for that channel. The 1693 * input is the index into the array, and the output is the 16-bit gamma value 1694 * at that index, scaled to the output color precision. 1695 * 1696 * Despite the name and signature, this method sets the gamma ramp of the 1697 * entire display, not an individual window. A window is considered to be 1698 * owned by the display that contains the window's center pixel. (The index of 1699 * this display can be retrieved using SDL_GetWindowDisplayIndex().) The gamma 1700 * ramp set will not follow the window if it is moved to another display. 1701 * 1702 * \param window the window used to select the display whose gamma ramp will 1703 * be changed. 1704 * \param red a 256 element array of 16-bit quantities representing the 1705 * translation table for the red channel, or NULL. 1706 * \param green a 256 element array of 16-bit quantities representing the 1707 * translation table for the green channel, or NULL. 1708 * \param blue a 256 element array of 16-bit quantities representing the 1709 * translation table for the blue channel, or NULL. 1710 * \returns 0 on success or a negative error code on failure; call 1711 * SDL_GetError() for more information. 1712 * 1713 * \since This function is available since SDL 2.0.0. 1714 * 1715 * \sa SDL_GetWindowGammaRamp 1716 */ 1717 extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, 1718 const Uint16 * red, 1719 const Uint16 * green, 1720 const Uint16 * blue); 1721 1722 /** 1723 * Get the gamma ramp for a given window's display. 1724 * 1725 * Despite the name and signature, this method retrieves the gamma ramp of the 1726 * entire display, not an individual window. A window is considered to be 1727 * owned by the display that contains the window's center pixel. (The index of 1728 * this display can be retrieved using SDL_GetWindowDisplayIndex().) 1729 * 1730 * \param window the window used to select the display whose gamma ramp will 1731 * be queried. 1732 * \param red a 256 element array of 16-bit quantities filled in with the 1733 * translation table for the red channel, or NULL. 1734 * \param green a 256 element array of 16-bit quantities filled in with the 1735 * translation table for the green channel, or NULL. 1736 * \param blue a 256 element array of 16-bit quantities filled in with the 1737 * translation table for the blue channel, or NULL. 1738 * \returns 0 on success or a negative error code on failure; call 1739 * SDL_GetError() for more information. 1740 * 1741 * \since This function is available since SDL 2.0.0. 1742 * 1743 * \sa SDL_SetWindowGammaRamp 1744 */ 1745 extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, 1746 Uint16 * red, 1747 Uint16 * green, 1748 Uint16 * blue); 1749 1750 /** 1751 * Possible return values from the SDL_HitTest callback. 1752 * 1753 * \sa SDL_HitTest 1754 */ 1755 typedef enum SDL_HitTestResult 1756 { 1757 SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */ 1758 SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */ 1759 SDL_HITTEST_RESIZE_TOPLEFT, 1760 SDL_HITTEST_RESIZE_TOP, 1761 SDL_HITTEST_RESIZE_TOPRIGHT, 1762 SDL_HITTEST_RESIZE_RIGHT, 1763 SDL_HITTEST_RESIZE_BOTTOMRIGHT, 1764 SDL_HITTEST_RESIZE_BOTTOM, 1765 SDL_HITTEST_RESIZE_BOTTOMLEFT, 1766 SDL_HITTEST_RESIZE_LEFT 1767 } SDL_HitTestResult; 1768 1769 /** 1770 * Callback used for hit-testing. 1771 * 1772 * \param win the SDL_Window where hit-testing was set on. 1773 * \param area an SDL_Point which should be hit-tested. 1774 * \param data what was passed as `callback_data` to SDL_SetWindowHitTest(). 1775 * \return an SDL_HitTestResult value. 1776 * 1777 * \sa SDL_SetWindowHitTest 1778 */ 1779 typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win, 1780 const SDL_Point *area, 1781 void *data); 1782 1783 /** 1784 * Provide a callback that decides if a window region has special properties. 1785 * 1786 * Normally windows are dragged and resized by decorations provided by the 1787 * system window manager (a title bar, borders, etc), but for some apps, it 1788 * makes sense to drag them from somewhere else inside the window itself; for 1789 * example, one might have a borderless window that wants to be draggable from 1790 * any part, or simulate its own title bar, etc. 1791 * 1792 * This function lets the app provide a callback that designates pieces of a 1793 * given window as special. This callback is run during event processing if we 1794 * need to tell the OS to treat a region of the window specially; the use of 1795 * this callback is known as "hit testing." 1796 * 1797 * Mouse input may not be delivered to your application if it is within a 1798 * special area; the OS will often apply that input to moving the window or 1799 * resizing the window and not deliver it to the application. 1800 * 1801 * Specifying NULL for a callback disables hit-testing. Hit-testing is 1802 * disabled by default. 1803 * 1804 * Platforms that don't support this functionality will return -1 1805 * unconditionally, even if you're attempting to disable hit-testing. 1806 * 1807 * Your callback may fire at any time, and its firing does not indicate any 1808 * specific behavior (for example, on Windows, this certainly might fire when 1809 * the OS is deciding whether to drag your window, but it fires for lots of 1810 * other reasons, too, some unrelated to anything you probably care about _and 1811 * when the mouse isn't actually at the location it is testing_). Since this 1812 * can fire at any time, you should try to keep your callback efficient, 1813 * devoid of allocations, etc. 1814 * 1815 * \param window the window to set hit-testing on. 1816 * \param callback the function to call when doing a hit-test. 1817 * \param callback_data an app-defined void pointer passed to **callback**. 1818 * \returns 0 on success or -1 on error (including unsupported); call 1819 * SDL_GetError() for more information. 1820 * 1821 * \since This function is available since SDL 2.0.4. 1822 */ 1823 extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window * window, 1824 SDL_HitTest callback, 1825 void *callback_data); 1826 1827 /** 1828 * Request a window to demand attention from the user. 1829 * 1830 * \param window the window to be flashed. 1831 * \param operation the flash operation. 1832 * \returns 0 on success or a negative error code on failure; call 1833 * SDL_GetError() for more information. 1834 * 1835 * \since This function is available since SDL 2.0.16. 1836 */ 1837 extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window * window, SDL_FlashOperation operation); 1838 1839 /** 1840 * Destroy a window. 1841 * 1842 * If `window` is NULL, this function will return immediately after setting 1843 * the SDL error message to "Invalid window". See SDL_GetError(). 1844 * 1845 * \param window the window to destroy. 1846 * 1847 * \since This function is available since SDL 2.0.0. 1848 * 1849 * \sa SDL_CreateWindow 1850 * \sa SDL_CreateWindowFrom 1851 */ 1852 extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); 1853 1854 1855 /** 1856 * Check whether the screensaver is currently enabled. 1857 * 1858 * The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2 1859 * the screensaver was enabled by default. 1860 * 1861 * The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`. 1862 * 1863 * \returns SDL_TRUE if the screensaver is enabled, SDL_FALSE if it is 1864 * disabled. 1865 * 1866 * \since This function is available since SDL 2.0.0. 1867 * 1868 * \sa SDL_DisableScreenSaver 1869 * \sa SDL_EnableScreenSaver 1870 */ 1871 extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void); 1872 1873 /** 1874 * Allow the screen to be blanked by a screen saver. 1875 * 1876 * \since This function is available since SDL 2.0.0. 1877 * 1878 * \sa SDL_DisableScreenSaver 1879 * \sa SDL_IsScreenSaverEnabled 1880 */ 1881 extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void); 1882 1883 /** 1884 * Prevent the screen from being blanked by a screen saver. 1885 * 1886 * If you disable the screensaver, it is automatically re-enabled when SDL 1887 * quits. 1888 * 1889 * The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2 1890 * the screensaver was enabled by default. 1891 * 1892 * \since This function is available since SDL 2.0.0. 1893 * 1894 * \sa SDL_EnableScreenSaver 1895 * \sa SDL_IsScreenSaverEnabled 1896 */ 1897 extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); 1898 1899 1900 /** 1901 * \name OpenGL support functions 1902 */ 1903 /* @{ */ 1904 1905 /** 1906 * Dynamically load an OpenGL library. 1907 * 1908 * This should be done after initializing the video driver, but before 1909 * creating any OpenGL windows. If no OpenGL library is loaded, the default 1910 * library will be loaded upon creation of the first OpenGL window. 1911 * 1912 * If you do this, you need to retrieve all of the GL functions used in your 1913 * program from the dynamic library using SDL_GL_GetProcAddress(). 1914 * 1915 * \param path the platform dependent OpenGL library name, or NULL to open the 1916 * default OpenGL library. 1917 * \returns 0 on success or a negative error code on failure; call 1918 * SDL_GetError() for more information. 1919 * 1920 * \since This function is available since SDL 2.0.0. 1921 * 1922 * \sa SDL_GL_GetProcAddress 1923 * \sa SDL_GL_UnloadLibrary 1924 */ 1925 extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); 1926 1927 /** 1928 * Get an OpenGL function by name. 1929 * 1930 * If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all 1931 * GL functions must be retrieved this way. Usually this is used to retrieve 1932 * function pointers to OpenGL extensions. 1933 * 1934 * There are some quirks to looking up OpenGL functions that require some 1935 * extra care from the application. If you code carefully, you can handle 1936 * these quirks without any platform-specific code, though: 1937 * 1938 * - On Windows, function pointers are specific to the current GL context; 1939 * this means you need to have created a GL context and made it current 1940 * before calling SDL_GL_GetProcAddress(). If you recreate your context or 1941 * create a second context, you should assume that any existing function 1942 * pointers aren't valid to use with it. This is (currently) a 1943 * Windows-specific limitation, and in practice lots of drivers don't suffer 1944 * this limitation, but it is still the way the wgl API is documented to 1945 * work and you should expect crashes if you don't respect it. Store a copy 1946 * of the function pointers that comes and goes with context lifespan. 1947 * - On X11, function pointers returned by this function are valid for any 1948 * context, and can even be looked up before a context is created at all. 1949 * This means that, for at least some common OpenGL implementations, if you 1950 * look up a function that doesn't exist, you'll get a non-NULL result that 1951 * is _NOT_ safe to call. You must always make sure the function is actually 1952 * available for a given GL context before calling it, by checking for the 1953 * existence of the appropriate extension with SDL_GL_ExtensionSupported(), 1954 * or verifying that the version of OpenGL you're using offers the function 1955 * as core functionality. 1956 * - Some OpenGL drivers, on all platforms, *will* return NULL if a function 1957 * isn't supported, but you can't count on this behavior. Check for 1958 * extensions you use, and if you get a NULL anyway, act as if that 1959 * extension wasn't available. This is probably a bug in the driver, but you 1960 * can code defensively for this scenario anyhow. 1961 * - Just because you're on Linux/Unix, don't assume you'll be using X11. 1962 * Next-gen display servers are waiting to replace it, and may or may not 1963 * make the same promises about function pointers. 1964 * - OpenGL function pointers must be declared `APIENTRY` as in the example 1965 * code. This will ensure the proper calling convention is followed on 1966 * platforms where this matters (Win32) thereby avoiding stack corruption. 1967 * 1968 * \param proc the name of an OpenGL function. 1969 * \returns a pointer to the named OpenGL function. The returned pointer 1970 * should be cast to the appropriate function signature. 1971 * 1972 * \since This function is available since SDL 2.0.0. 1973 * 1974 * \sa SDL_GL_ExtensionSupported 1975 * \sa SDL_GL_LoadLibrary 1976 * \sa SDL_GL_UnloadLibrary 1977 */ 1978 extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc); 1979 1980 /** 1981 * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). 1982 * 1983 * \since This function is available since SDL 2.0.0. 1984 * 1985 * \sa SDL_GL_LoadLibrary 1986 */ 1987 extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); 1988 1989 /** 1990 * Check if an OpenGL extension is supported for the current context. 1991 * 1992 * This function operates on the current GL context; you must have created a 1993 * context and it must be current before calling this function. Do not assume 1994 * that all contexts you create will have the same set of extensions 1995 * available, or that recreating an existing context will offer the same 1996 * extensions again. 1997 * 1998 * While it's probably not a massive overhead, this function is not an O(1) 1999 * operation. Check the extensions you care about after creating the GL 2000 * context and save that information somewhere instead of calling the function 2001 * every time you need to know. 2002 * 2003 * \param extension the name of the extension to check. 2004 * \returns SDL_TRUE if the extension is supported, SDL_FALSE otherwise. 2005 * 2006 * \since This function is available since SDL 2.0.0. 2007 */ 2008 extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char 2009 *extension); 2010 2011 /** 2012 * Reset all previously set OpenGL context attributes to their default values. 2013 * 2014 * \since This function is available since SDL 2.0.2. 2015 * 2016 * \sa SDL_GL_GetAttribute 2017 * \sa SDL_GL_SetAttribute 2018 */ 2019 extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); 2020 2021 /** 2022 * Set an OpenGL window attribute before window creation. 2023 * 2024 * This function sets the OpenGL attribute `attr` to `value`. The requested 2025 * attributes should be set before creating an OpenGL window. You should use 2026 * SDL_GL_GetAttribute() to check the values after creating the OpenGL 2027 * context, since the values obtained can differ from the requested ones. 2028 * 2029 * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to 2030 * set. 2031 * \param value the desired value for the attribute. 2032 * \returns 0 on success or a negative error code on failure; call 2033 * SDL_GetError() for more information. 2034 * 2035 * \since This function is available since SDL 2.0.0. 2036 * 2037 * \sa SDL_GL_GetAttribute 2038 * \sa SDL_GL_ResetAttributes 2039 */ 2040 extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); 2041 2042 /** 2043 * Get the actual value for an attribute from the current context. 2044 * 2045 * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to 2046 * get. 2047 * \param value a pointer filled in with the current value of `attr`. 2048 * \returns 0 on success or a negative error code on failure; call 2049 * SDL_GetError() for more information. 2050 * 2051 * \since This function is available since SDL 2.0.0. 2052 * 2053 * \sa SDL_GL_ResetAttributes 2054 * \sa SDL_GL_SetAttribute 2055 */ 2056 extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); 2057 2058 /** 2059 * Create an OpenGL context for an OpenGL window, and make it current. 2060 * 2061 * Windows users new to OpenGL should note that, for historical reasons, GL 2062 * functions added after OpenGL version 1.1 are not available by default. 2063 * Those functions must be loaded at run-time, either with an OpenGL 2064 * extension-handling library or with SDL_GL_GetProcAddress() and its related 2065 * functions. 2066 * 2067 * SDL_GLContext is an alias for `void *`. It's opaque to the application. 2068 * 2069 * \param window the window to associate with the context. 2070 * \returns the OpenGL context associated with `window` or NULL on error; call 2071 * SDL_GetError() for more details. 2072 * 2073 * \since This function is available since SDL 2.0.0. 2074 * 2075 * \sa SDL_GL_DeleteContext 2076 * \sa SDL_GL_MakeCurrent 2077 */ 2078 extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * 2079 window); 2080 2081 /** 2082 * Set up an OpenGL context for rendering into an OpenGL window. 2083 * 2084 * The context must have been created with a compatible window. 2085 * 2086 * \param window the window to associate with the context. 2087 * \param context the OpenGL context to associate with the window. 2088 * \returns 0 on success or a negative error code on failure; call 2089 * SDL_GetError() for more information. 2090 * 2091 * \since This function is available since SDL 2.0.0. 2092 * 2093 * \sa SDL_GL_CreateContext 2094 */ 2095 extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, 2096 SDL_GLContext context); 2097 2098 /** 2099 * Get the currently active OpenGL window. 2100 * 2101 * \returns the currently active OpenGL window on success or NULL on failure; 2102 * call SDL_GetError() for more information. 2103 * 2104 * \since This function is available since SDL 2.0.0. 2105 */ 2106 extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void); 2107 2108 /** 2109 * Get the currently active OpenGL context. 2110 * 2111 * \returns the currently active OpenGL context or NULL on failure; call 2112 * SDL_GetError() for more information. 2113 * 2114 * \since This function is available since SDL 2.0.0. 2115 * 2116 * \sa SDL_GL_MakeCurrent 2117 */ 2118 extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); 2119 2120 /** 2121 * Get the size of a window's underlying drawable in pixels. 2122 * 2123 * This returns info useful for calling glViewport(). 2124 * 2125 * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI 2126 * drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a 2127 * platform with high-DPI support (Apple calls this "Retina"), and not 2128 * disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint. 2129 * 2130 * \param window the window from which the drawable size should be queried. 2131 * \param w a pointer to variable for storing the width in pixels, may be 2132 * NULL. 2133 * \param h a pointer to variable for storing the height in pixels, may be 2134 * NULL. 2135 * 2136 * \since This function is available since SDL 2.0.1. 2137 * 2138 * \sa SDL_CreateWindow 2139 * \sa SDL_GetWindowSize 2140 */ 2141 extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, 2142 int *h); 2143 2144 /** 2145 * Set the swap interval for the current OpenGL context. 2146 * 2147 * Some systems allow specifying -1 for the interval, to enable adaptive 2148 * vsync. Adaptive vsync works the same as vsync, but if you've already missed 2149 * the vertical retrace for a given frame, it swaps buffers immediately, which 2150 * might be less jarring for the user during occasional framerate drops. If an 2151 * application requests adaptive vsync and the system does not support it, 2152 * this function will fail and return -1. In such a case, you should probably 2153 * retry the call with 1 for the interval. 2154 * 2155 * Adaptive vsync is implemented for some glX drivers with 2156 * GLX_EXT_swap_control_tear, and for some Windows drivers with 2157 * WGL_EXT_swap_control_tear. 2158 * 2159 * Read more on the Khronos wiki: 2160 * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync 2161 * 2162 * \param interval 0 for immediate updates, 1 for updates synchronized with 2163 * the vertical retrace, -1 for adaptive vsync. 2164 * \returns 0 on success or -1 if setting the swap interval is not supported; 2165 * call SDL_GetError() for more information. 2166 * 2167 * \since This function is available since SDL 2.0.0. 2168 * 2169 * \sa SDL_GL_GetSwapInterval 2170 */ 2171 extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval); 2172 2173 /** 2174 * Get the swap interval for the current OpenGL context. 2175 * 2176 * If the system can't determine the swap interval, or there isn't a valid 2177 * current context, this function will return 0 as a safe default. 2178 * 2179 * \returns 0 if there is no vertical retrace synchronization, 1 if the buffer 2180 * swap is synchronized with the vertical retrace, and -1 if late 2181 * swaps happen immediately instead of waiting for the next retrace; 2182 * call SDL_GetError() for more information. 2183 * 2184 * \since This function is available since SDL 2.0.0. 2185 * 2186 * \sa SDL_GL_SetSwapInterval 2187 */ 2188 extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void); 2189 2190 /** 2191 * Update a window with OpenGL rendering. 2192 * 2193 * This is used with double-buffered OpenGL contexts, which are the default. 2194 * 2195 * On macOS, make sure you bind 0 to the draw framebuffer before swapping the 2196 * window, otherwise nothing will happen. If you aren't using 2197 * glBindFramebuffer(), this is the default and you won't have to do anything 2198 * extra. 2199 * 2200 * \param window the window to change. 2201 * 2202 * \since This function is available since SDL 2.0.0. 2203 */ 2204 extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); 2205 2206 /** 2207 * Delete an OpenGL context. 2208 * 2209 * \param context the OpenGL context to be deleted. 2210 * 2211 * \since This function is available since SDL 2.0.0. 2212 * 2213 * \sa SDL_GL_CreateContext 2214 */ 2215 extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); 2216 2217 /* @} *//* OpenGL support functions */ 2218 2219 2220 /* Ends C function definitions when using C++ */ 2221 #ifdef __cplusplus 2222 } 2223 #endif 2224 #include "close_code.h" 2225 2226 #endif /* SDL_video_h_ */ 2227 2228 /* vi: set ts=4 sw=4 expandtab: */