cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

SDL_sysvideo.h (12780B)


      1/*
      2  Simple DirectMedia Layer
      3  Copyright (C) 1997-2014 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#include "../SDL_internal.h"
     22
     23#ifndef _SDL_sysvideo_h
     24#define _SDL_sysvideo_h
     25
     26#include "SDL_messagebox.h"
     27#include "SDL_shape.h"
     28#include "SDL_thread.h"
     29
     30/* The SDL video driver */
     31
     32typedef struct SDL_WindowShaper SDL_WindowShaper;
     33typedef struct SDL_ShapeDriver SDL_ShapeDriver;
     34typedef struct SDL_VideoDisplay SDL_VideoDisplay;
     35typedef struct SDL_VideoDevice SDL_VideoDevice;
     36
     37/* Define the SDL window-shaper structure */
     38struct SDL_WindowShaper
     39{
     40    /* The window associated with the shaper */
     41    SDL_Window *window;
     42
     43    /* The user's specified coordinates for the window, for once we give it a shape. */
     44    Uint32 userx,usery;
     45
     46    /* The parameters for shape calculation. */
     47    SDL_WindowShapeMode mode;
     48
     49    /* Has this window been assigned a shape? */
     50    SDL_bool hasshape;
     51
     52    void *driverdata;
     53};
     54
     55/* Define the SDL shape driver structure */
     56struct SDL_ShapeDriver
     57{
     58    SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
     59    int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
     60    int (*ResizeWindowShape)(SDL_Window *window);
     61};
     62
     63typedef struct SDL_WindowUserData
     64{
     65    char *name;
     66    void *data;
     67    struct SDL_WindowUserData *next;
     68} SDL_WindowUserData;
     69
     70/* Define the SDL window structure, corresponding to toplevel windows */
     71struct SDL_Window
     72{
     73    const void *magic;
     74    Uint32 id;
     75    char *title;
     76    SDL_Surface *icon;
     77    int x, y;
     78    int w, h;
     79    int min_w, min_h;
     80    int max_w, max_h;
     81    Uint32 flags;
     82    Uint32 last_fullscreen_flags;
     83
     84    /* Stored position and size for windowed mode */
     85    SDL_Rect windowed;
     86
     87    SDL_DisplayMode fullscreen_mode;
     88
     89    float brightness;
     90    Uint16 *gamma;
     91    Uint16 *saved_gamma;        /* (just offset into gamma) */
     92
     93    SDL_Surface *surface;
     94    SDL_bool surface_valid;
     95
     96    SDL_bool is_hiding;
     97    SDL_bool is_destroying;
     98
     99    SDL_WindowShaper *shaper;
    100
    101    SDL_HitTest hit_test;
    102    void *hit_test_data;
    103
    104    SDL_WindowUserData *data;
    105
    106    void *driverdata;
    107
    108    SDL_Window *prev;
    109    SDL_Window *next;
    110};
    111#define FULLSCREEN_VISIBLE(W) \
    112    (((W)->flags & SDL_WINDOW_FULLSCREEN) && \
    113     ((W)->flags & SDL_WINDOW_SHOWN) && \
    114     !((W)->flags & SDL_WINDOW_MINIMIZED))
    115
    116/*
    117 * Define the SDL display structure This corresponds to physical monitors
    118 * attached to the system.
    119 */
    120struct SDL_VideoDisplay
    121{
    122    char *name;
    123    int max_display_modes;
    124    int num_display_modes;
    125    SDL_DisplayMode *display_modes;
    126    SDL_DisplayMode desktop_mode;
    127    SDL_DisplayMode current_mode;
    128
    129    SDL_Window *fullscreen_window;
    130
    131    SDL_VideoDevice *device;
    132
    133    void *driverdata;
    134};
    135
    136/* Forward declaration */
    137struct SDL_SysWMinfo;
    138
    139/* Define the SDL video driver structure */
    140#define _THIS   SDL_VideoDevice *_this
    141
    142struct SDL_VideoDevice
    143{
    144    /* * * */
    145    /* The name of this video driver */
    146    const char *name;
    147
    148    /* * * */
    149    /* Initialization/Query functions */
    150
    151    /*
    152     * Initialize the native video subsystem, filling in the list of
    153     * displays for this driver, returning 0 or -1 if there's an error.
    154     */
    155    int (*VideoInit) (_THIS);
    156
    157    /*
    158     * Reverse the effects VideoInit() -- called if VideoInit() fails or
    159     * if the application is shutting down the video subsystem.
    160     */
    161    void (*VideoQuit) (_THIS);
    162
    163    /* * * */
    164    /*
    165     * Display functions
    166     */
    167
    168    /*
    169     * Get the bounds of a display
    170     */
    171    int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
    172
    173    /*
    174     * Get a list of the available display modes for a display.
    175     */
    176    void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
    177
    178    /*
    179     * Setting the display mode is independent of creating windows, so
    180     * when the display mode is changed, all existing windows should have
    181     * their data updated accordingly, including the display surfaces
    182     * associated with them.
    183     */
    184    int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    185
    186    /* * * */
    187    /*
    188     * Window functions
    189     */
    190    int (*CreateWindow) (_THIS, SDL_Window * window);
    191    int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
    192    void (*SetWindowTitle) (_THIS, SDL_Window * window);
    193    void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
    194    void (*SetWindowPosition) (_THIS, SDL_Window * window);
    195    void (*SetWindowSize) (_THIS, SDL_Window * window);
    196    void (*SetWindowMinimumSize) (_THIS, SDL_Window * window);
    197    void (*SetWindowMaximumSize) (_THIS, SDL_Window * window);
    198    void (*ShowWindow) (_THIS, SDL_Window * window);
    199    void (*HideWindow) (_THIS, SDL_Window * window);
    200    void (*RaiseWindow) (_THIS, SDL_Window * window);
    201    void (*MaximizeWindow) (_THIS, SDL_Window * window);
    202    void (*MinimizeWindow) (_THIS, SDL_Window * window);
    203    void (*RestoreWindow) (_THIS, SDL_Window * window);
    204    void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
    205    void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
    206    int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
    207    int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
    208    void (*SetWindowGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
    209    void (*DestroyWindow) (_THIS, SDL_Window * window);
    210    int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
    211    int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
    212    void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window);
    213    void (*OnWindowEnter) (_THIS, SDL_Window * window);
    214
    215    /* * * */
    216    /*
    217     * Shaped-window functions
    218     */
    219    SDL_ShapeDriver shape_driver;
    220
    221    /* Get some platform dependent window information */
    222    SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
    223                                struct SDL_SysWMinfo * info);
    224
    225    /* * * */
    226    /*
    227     * OpenGL support
    228     */
    229    int (*GL_LoadLibrary) (_THIS, const char *path);
    230    void *(*GL_GetProcAddress) (_THIS, const char *proc);
    231    void (*GL_UnloadLibrary) (_THIS);
    232      SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
    233    int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
    234    void (*GL_GetDrawableSize) (_THIS, SDL_Window * window, int *w, int *h);
    235    int (*GL_SetSwapInterval) (_THIS, int interval);
    236    int (*GL_GetSwapInterval) (_THIS);
    237    void (*GL_SwapWindow) (_THIS, SDL_Window * window);
    238    void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
    239
    240    /* * * */
    241    /*
    242     * Event manager functions
    243     */
    244    void (*PumpEvents) (_THIS);
    245
    246    /* Suspend the screensaver */
    247    void (*SuspendScreenSaver) (_THIS);
    248
    249    /* Text input */
    250    void (*StartTextInput) (_THIS);
    251    void (*StopTextInput) (_THIS);
    252    void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
    253
    254    /* Screen keyboard */
    255    SDL_bool (*HasScreenKeyboardSupport) (_THIS);
    256    void (*ShowScreenKeyboard) (_THIS, SDL_Window *window);
    257    void (*HideScreenKeyboard) (_THIS, SDL_Window *window);
    258    SDL_bool (*IsScreenKeyboardShown) (_THIS, SDL_Window *window);
    259
    260    /* Clipboard */
    261    int (*SetClipboardText) (_THIS, const char *text);
    262    char * (*GetClipboardText) (_THIS);
    263    SDL_bool (*HasClipboardText) (_THIS);
    264
    265    /* MessageBox */
    266    int (*ShowMessageBox) (_THIS, const SDL_MessageBoxData *messageboxdata, int *buttonid);
    267
    268    /* Hit-testing */
    269    int (*SetWindowHitTest)(SDL_Window * window, SDL_bool enabled);
    270
    271    /* * * */
    272    /* Data common to all drivers */
    273    SDL_bool suspend_screensaver;
    274    int num_displays;
    275    SDL_VideoDisplay *displays;
    276    SDL_Window *windows;
    277    Uint8 window_magic;
    278    Uint32 next_object_id;
    279    char * clipboard_text;
    280
    281    /* * * */
    282    /* Data used by the GL drivers */
    283    struct
    284    {
    285        int red_size;
    286        int green_size;
    287        int blue_size;
    288        int alpha_size;
    289        int depth_size;
    290        int buffer_size;
    291        int stencil_size;
    292        int double_buffer;
    293        int accum_red_size;
    294        int accum_green_size;
    295        int accum_blue_size;
    296        int accum_alpha_size;
    297        int stereo;
    298        int multisamplebuffers;
    299        int multisamplesamples;
    300        int accelerated;
    301        int major_version;
    302        int minor_version;
    303        int flags;
    304        int profile_mask;
    305        int share_with_current_context;
    306        int framebuffer_srgb_capable;
    307        int retained_backing;
    308        int driver_loaded;
    309        char driver_path[256];
    310        void *dll_handle;
    311    } gl_config;
    312
    313    /* * * */
    314    /* Cache current GL context; don't call the OS when it hasn't changed. */
    315    /* We have the global pointers here so Cocoa continues to work the way
    316       it always has, and the thread-local storage for the general case.
    317     */
    318    SDL_Window *current_glwin;
    319    SDL_GLContext current_glctx;
    320    SDL_TLSID current_glwin_tls;
    321    SDL_TLSID current_glctx_tls;
    322
    323    /* * * */
    324    /* Data private to this driver */
    325    void *driverdata;
    326    struct SDL_GLDriverData *gl_data;
    327    
    328#if SDL_VIDEO_OPENGL_EGL
    329    struct SDL_EGL_VideoData *egl_data;
    330#endif
    331    
    332#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
    333    struct SDL_PrivateGLESData *gles_data;
    334#endif
    335
    336    /* * * */
    337    /* The function used to dispose of this structure */
    338    void (*free) (_THIS);
    339};
    340
    341typedef struct VideoBootStrap
    342{
    343    const char *name;
    344    const char *desc;
    345    int (*available) (void);
    346    SDL_VideoDevice *(*create) (int devindex);
    347} VideoBootStrap;
    348
    349#if SDL_VIDEO_DRIVER_COCOA
    350extern VideoBootStrap COCOA_bootstrap;
    351#endif
    352#if SDL_VIDEO_DRIVER_X11
    353extern VideoBootStrap X11_bootstrap;
    354#endif
    355#if SDL_VIDEO_DRIVER_MIR
    356extern VideoBootStrap MIR_bootstrap;
    357#endif
    358#if SDL_VIDEO_DRIVER_DIRECTFB
    359extern VideoBootStrap DirectFB_bootstrap;
    360#endif
    361#if SDL_VIDEO_DRIVER_WINDOWS
    362extern VideoBootStrap WINDOWS_bootstrap;
    363#endif
    364#if SDL_VIDEO_DRIVER_WINRT
    365extern VideoBootStrap WINRT_bootstrap;
    366#endif
    367#if SDL_VIDEO_DRIVER_HAIKU
    368extern VideoBootStrap HAIKU_bootstrap;
    369#endif
    370#if SDL_VIDEO_DRIVER_PANDORA
    371extern VideoBootStrap PND_bootstrap;
    372#endif
    373#if SDL_VIDEO_DRIVER_UIKIT
    374extern VideoBootStrap UIKIT_bootstrap;
    375#endif
    376#if SDL_VIDEO_DRIVER_ANDROID
    377extern VideoBootStrap Android_bootstrap;
    378#endif
    379#if SDL_VIDEO_DRIVER_PSP
    380extern VideoBootStrap PSP_bootstrap;
    381#endif
    382#if SDL_VIDEO_DRIVER_RPI
    383extern VideoBootStrap RPI_bootstrap;
    384#endif
    385#if SDL_VIDEO_DRIVER_DUMMY
    386extern VideoBootStrap DUMMY_bootstrap;
    387#endif
    388#if SDL_VIDEO_DRIVER_WAYLAND
    389extern VideoBootStrap Wayland_bootstrap;
    390#endif
    391#if SDL_VIDEO_DRIVER_NACL
    392extern VideoBootStrap NACL_bootstrap;
    393#endif
    394#if SDL_VIDEO_DRIVER_VIVANTE
    395extern VideoBootStrap VIVANTE_bootstrap;
    396#endif
    397
    398extern SDL_VideoDevice *SDL_GetVideoDevice(void);
    399extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
    400extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
    401extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
    402extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
    403extern void *SDL_GetDisplayDriverData( int displayIndex );
    404
    405extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
    406
    407extern void SDL_OnWindowShown(SDL_Window * window);
    408extern void SDL_OnWindowHidden(SDL_Window * window);
    409extern void SDL_OnWindowResized(SDL_Window * window);
    410extern void SDL_OnWindowMinimized(SDL_Window * window);
    411extern void SDL_OnWindowRestored(SDL_Window * window);
    412extern void SDL_OnWindowEnter(SDL_Window * window);
    413extern void SDL_OnWindowLeave(SDL_Window * window);
    414extern void SDL_OnWindowFocusGained(SDL_Window * window);
    415extern void SDL_OnWindowFocusLost(SDL_Window * window);
    416extern void SDL_UpdateWindowGrab(SDL_Window * window);
    417extern SDL_Window * SDL_GetFocusWindow(void);
    418
    419extern SDL_bool SDL_ShouldAllowTopmost(void);
    420
    421#endif /* _SDL_sysvideo_h */
    422
    423/* vi: set ts=4 sw=4 expandtab: */