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