include/SDL_syswm.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 18 Oct 2017 08:52:04 -0700
changeset 11630 ad4b5d85edee
parent 11287 4d2a6202caa4
child 11811 5d94cb6b24d3
permissions -rw-r--r--
Fixed bug 3821 - Allow SDL_CreateWindow and SDL_CreateRenderer with OpenGL ES 3.0 (GLES3) for Angle (Windows)

Carlos

Angle supports GLES3 but when using these functions (SDL_CreateWindow and SDL_CreateRenderer), defaults again to GLES2.0.

A current workaround (hack) to retrieve a GLES3.0 context with Angle is:

1) set

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

after InitSDL AND after calling SDL_CreateWindow (before SDL_CreateRenderer)

2) Comment lines 2032-2044 in SDL_render_gles2.c, funtion GLES2_CreateRenderer

window_flags = SDL_GetWindowFlags(window);
if (!(window_flags & SDL_WINDOW_OPENGL) ||
profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) {

changed_window = SDL_TRUE;
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR);

if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
goto error;
}
}

This retrives a GLES3 context as confirmed using glGetString(GL_VERSION). This should be fixed by modifying a few if's.
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@10737
     3
  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
slouken@0
    21
slouken@1895
    22
/**
slouken@3407
    23
 *  \file SDL_syswm.h
slouken@7191
    24
 *
slouken@3407
    25
 *  Include file for SDL custom system window manager hooks.
slouken@1895
    26
 */
slouken@0
    27
slouken@10638
    28
#ifndef SDL_syswm_h_
slouken@10638
    29
#define SDL_syswm_h_
slouken@0
    30
slouken@1356
    31
#include "SDL_stdinc.h"
slouken@1358
    32
#include "SDL_error.h"
slouken@1895
    33
#include "SDL_video.h"
slouken@0
    34
#include "SDL_version.h"
slouken@0
    35
slouken@0
    36
#include "begin_code.h"
slouken@0
    37
/* Set up for C function definitions, even when using C++ */
slouken@0
    38
#ifdef __cplusplus
slouken@0
    39
extern "C" {
slouken@0
    40
#endif
slouken@0
    41
slouken@3407
    42
/**
slouken@3407
    43
 *  \file SDL_syswm.h
slouken@7191
    44
 *
slouken@3407
    45
 *  Your application has access to a special type of event ::SDL_SYSWMEVENT,
slouken@3407
    46
 *  which contains window-manager specific information and arrives whenever
slouken@3407
    47
 *  an unhandled window event occurs.  This event is ignored by default, but
slouken@3407
    48
 *  you can enable it with SDL_EventState().
slouken@3407
    49
 */
slouken@0
    50
#ifdef SDL_PROTOTYPES_ONLY
slouken@0
    51
struct SDL_SysWMinfo;
slouken@0
    52
#else
slouken@0
    53
slouken@5062
    54
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
jorgen@8968
    55
#ifndef WIN32_LEAN_AND_MEAN
slouken@4900
    56
#define WIN32_LEAN_AND_MEAN
jorgen@8968
    57
#endif
slouken@4900
    58
#include <windows.h>
slouken@4900
    59
#endif
slouken@4900
    60
dludwig@8463
    61
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8527
    62
#include <Inspectable.h>
dludwig@8463
    63
#endif
dludwig@8463
    64
slouken@1361
    65
/* This is the structure for custom window manager events */
slouken@1626
    66
#if defined(SDL_VIDEO_DRIVER_X11)
icculus@1133
    67
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    68
/* conflicts with Quickdraw.h */
icculus@1133
    69
#define Cursor X11Cursor
icculus@1133
    70
#endif
icculus@1133
    71
slouken@0
    72
#include <X11/Xlib.h>
slouken@0
    73
#include <X11/Xatom.h>
slouken@0
    74
icculus@1133
    75
#if defined(__APPLE__) && defined(__MACH__)
slouken@1487
    76
/* matches the re-define above */
icculus@1133
    77
#undef Cursor
icculus@1133
    78
#endif
icculus@1133
    79
slouken@4899
    80
#endif /* defined(SDL_VIDEO_DRIVER_X11) */
slouken@4899
    81
slouken@4899
    82
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@5199
    83
#include <directfb.h>
slouken@4899
    84
#endif
slouken@4900
    85
slouken@4900
    86
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
    87
#ifdef __OBJC__
jorgen@8812
    88
@class NSWindow;
slouken@4900
    89
#else
slouken@4900
    90
typedef struct _NSWindow NSWindow;
slouken@4900
    91
#endif
slouken@4900
    92
#endif
slouken@4900
    93
slouken@5056
    94
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
    95
#ifdef __OBJC__
slouken@5056
    96
#include <UIKit/UIKit.h>
slouken@5056
    97
#else
slouken@5056
    98
typedef struct _UIWindow UIWindow;
dludwig@8305
    99
typedef struct _UIViewController UIViewController;
slouken@5056
   100
#endif
slime73@9540
   101
typedef Uint32 GLuint;
slouken@5056
   102
#endif
slouken@5056
   103
slouken@8799
   104
#if defined(SDL_VIDEO_DRIVER_ANDROID)
slouken@8799
   105
typedef struct ANativeWindow ANativeWindow;
slouken@8799
   106
typedef void *EGLSurface;
slouken@8799
   107
#endif
slouken@8799
   108
slouken@10055
   109
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
slouken@10055
   110
#include "SDL_egl.h"
slouken@10055
   111
#endif
slouken@10055
   112
slouken@7191
   113
/**
slouken@4900
   114
 *  These are the various supported windowing subsystems
slouken@3407
   115
 */
slouken@1895
   116
typedef enum
slouken@1895
   117
{
slouken@4900
   118
    SDL_SYSWM_UNKNOWN,
slouken@4900
   119
    SDL_SYSWM_WINDOWS,
slouken@4899
   120
    SDL_SYSWM_X11,
slouken@4899
   121
    SDL_SYSWM_DIRECTFB,
slouken@4900
   122
    SDL_SYSWM_COCOA,
slouken@5056
   123
    SDL_SYSWM_UIKIT,
gabomdq@8134
   124
    SDL_SYSWM_WAYLAND,
icculus@8153
   125
    SDL_SYSWM_MIR,
slouken@8799
   126
    SDL_SYSWM_WINRT,
slouken@10055
   127
    SDL_SYSWM_ANDROID,
slouken@11287
   128
    SDL_SYSWM_VIVANTE,
slouken@11287
   129
    SDL_SYSWM_OS2
slouken@0
   130
} SDL_SYSWM_TYPE;
slouken@0
   131
slouken@3407
   132
/**
slouken@4900
   133
 *  The custom event structure.
slouken@3407
   134
 */
slouken@1895
   135
struct SDL_SysWMmsg
slouken@1895
   136
{
slouken@1895
   137
    SDL_version version;
slouken@1895
   138
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   139
    union
slouken@1895
   140
    {
slouken@5062
   141
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   142
        struct {
slouken@4900
   143
            HWND hwnd;                  /**< The window for the message */
slouken@4900
   144
            UINT msg;                   /**< The type of message */
slouken@4900
   145
            WPARAM wParam;              /**< WORD message parameter */
slouken@4900
   146
            LPARAM lParam;              /**< LONG message parameter */
slouken@4900
   147
        } win;
slouken@5065
   148
#endif
slouken@5065
   149
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@4900
   150
        struct {
slouken@4900
   151
            XEvent event;
slouken@4900
   152
        } x11;
slouken@5065
   153
#endif
slouken@5065
   154
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4900
   155
        struct {
slouken@4900
   156
            DFBEvent event;
slouken@4900
   157
        } dfb;
slouken@5065
   158
#endif
slouken@5065
   159
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   160
        struct
slouken@4900
   161
        {
jorgen@9153
   162
            /* Latest version of Xcode clang complains about empty structs in C v. C++:
jorgen@9153
   163
                 error: empty struct has size 0 in C, size 1 in C++
jorgen@9153
   164
             */
jorgen@9153
   165
            int dummy;
slouken@4900
   166
            /* No Cocoa window events yet */
slouken@4900
   167
        } cocoa;
slouken@5065
   168
#endif
slouken@5065
   169
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   170
        struct
slouken@5056
   171
        {
slime73@9586
   172
            int dummy;
slouken@5056
   173
            /* No UIKit window events yet */
slouken@5056
   174
        } uikit;
slouken@5065
   175
#endif
slouken@10055
   176
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
slouken@10055
   177
        struct
slouken@10055
   178
        {
slouken@10055
   179
            int dummy;
slouken@10055
   180
            /* No Vivante window events yet */
slouken@10055
   181
        } vivante;
slouken@10055
   182
#endif
slouken@5063
   183
        /* Can't have an empty union */
slouken@5063
   184
        int dummy;
slouken@5056
   185
    } msg;
slouken@0
   186
};
slouken@0
   187
slouken@3407
   188
/**
slouken@4900
   189
 *  The custom window manager information structure.
slouken@3407
   190
 *
slouken@3407
   191
 *  When this structure is returned, it holds information about which
slouken@3407
   192
 *  low level system it is using, and will be one of SDL_SYSWM_TYPE.
slouken@0
   193
 */
slouken@1895
   194
struct SDL_SysWMinfo
slouken@1895
   195
{
slouken@1895
   196
    SDL_version version;
slouken@1895
   197
    SDL_SYSWM_TYPE subsystem;
slouken@1895
   198
    union
slouken@1895
   199
    {
slouken@5062
   200
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
slouken@4900
   201
        struct
slouken@4900
   202
        {
slouken@4903
   203
            HWND window;                /**< The window handle */
icculus@9422
   204
            HDC hdc;                    /**< The window device context */
slouken@10634
   205
            HINSTANCE hinstance;        /**< The instance handle */
slouken@4900
   206
        } win;
slouken@5065
   207
#endif
dludwig@8411
   208
#if defined(SDL_VIDEO_DRIVER_WINRT)
dludwig@8411
   209
        struct
dludwig@8411
   210
        {
dludwig@8527
   211
            IInspectable * window;      /**< The WinRT CoreWindow */
dludwig@8411
   212
        } winrt;
dludwig@8411
   213
#endif
slouken@5065
   214
#if defined(SDL_VIDEO_DRIVER_X11)
slouken@1895
   215
        struct
slouken@1895
   216
        {
slouken@4900
   217
            Display *display;           /**< The X11 display */
slouken@4903
   218
            Window window;              /**< The X11 window */
slouken@1895
   219
        } x11;
slouken@5065
   220
#endif
slouken@5065
   221
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
slouken@4899
   222
        struct
slouken@4899
   223
        {
slouken@4903
   224
            IDirectFB *dfb;             /**< The directfb main interface */
slouken@4903
   225
            IDirectFBWindow *window;    /**< The directfb window handle */
slouken@4903
   226
            IDirectFBSurface *surface;  /**< The directfb client surface */
slouken@4900
   227
        } dfb;
slouken@5065
   228
#endif
slouken@5065
   229
#if defined(SDL_VIDEO_DRIVER_COCOA)
slouken@4900
   230
        struct
slouken@4900
   231
        {
slouken@9099
   232
#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
philipp@11065
   233
            NSWindow __unsafe_unretained *window; /**< The Cocoa window */
icculus@9035
   234
#else
philipp@11065
   235
            NSWindow *window;                     /**< The Cocoa window */
icculus@9035
   236
#endif
slouken@4900
   237
        } cocoa;
slouken@5065
   238
#endif
slouken@5065
   239
#if defined(SDL_VIDEO_DRIVER_UIKIT)
slouken@5056
   240
        struct
slouken@5056
   241
        {
slouken@9099
   242
#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
philipp@11065
   243
            UIWindow __unsafe_unretained *window; /**< The UIKit window */
icculus@9035
   244
#else
philipp@11065
   245
            UIWindow *window;                     /**< The UIKit window */
icculus@9035
   246
#endif
philipp@11065
   247
            GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */
philipp@11065
   248
            GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */
philipp@11065
   249
            GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
slouken@5056
   250
        } uikit;
slouken@5065
   251
#endif
gabomdq@8134
   252
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
gabomdq@8134
   253
        struct
gabomdq@8134
   254
        {
gabomdq@8134
   255
            struct wl_display *display;            /**< Wayland display */
gabomdq@8134
   256
            struct wl_surface *surface;            /**< Wayland surface */
gabomdq@8134
   257
            struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
gabomdq@8134
   258
        } wl;
gabomdq@8134
   259
#endif
icculus@8155
   260
#if defined(SDL_VIDEO_DRIVER_MIR)
icculus@8155
   261
        struct
icculus@8155
   262
        {
brandon@8731
   263
            struct MirConnection *connection;  /**< Mir display server connection */
brandon@8731
   264
            struct MirSurface *surface;  /**< Mir surface */
icculus@8155
   265
        } mir;
icculus@8155
   266
#endif
icculus@8155
   267
slouken@8799
   268
#if defined(SDL_VIDEO_DRIVER_ANDROID)
slouken@8799
   269
        struct
slouken@8799
   270
        {
slouken@8799
   271
            ANativeWindow *window;
slouken@8799
   272
            EGLSurface surface;
slouken@8799
   273
        } android;
slouken@8799
   274
#endif
slouken@8799
   275
slouken@10055
   276
#if defined(SDL_VIDEO_DRIVER_VIVANTE)
slouken@10055
   277
        struct
slouken@10055
   278
        {
slouken@10055
   279
            EGLNativeDisplayType display;
slouken@10055
   280
            EGLNativeWindowType window;
slouken@10055
   281
        } vivante;
slouken@10055
   282
#endif
slouken@10055
   283
icculus@11088
   284
        /* Make sure this union is always 64 bytes (8 64-bit pointers). */
icculus@11088
   285
        /* Be careful not to overflow this if you add a new target! */
icculus@11088
   286
        Uint8 dummy[64];
slouken@5056
   287
    } info;
slouken@1895
   288
};
slouken@0
   289
slouken@0
   290
#endif /* SDL_PROTOTYPES_ONLY */
slouken@0
   291
slouken@1895
   292
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
slouken@1895
   293
slouken@0
   294
/* Function prototypes */
slouken@1895
   295
/**
slouken@3407
   296
 *  \brief This function allows access to driver-dependent window information.
slouken@7191
   297
 *
slouken@4530
   298
 *  \param window The window about which information is being requested
slouken@7191
   299
 *  \param info This structure must be initialized with the SDL version, and is
slouken@3407
   300
 *              then filled in with information about the given window.
slouken@7191
   301
 *
slouken@7191
   302
 *  \return SDL_TRUE if the function is implemented and the version member of
slouken@3407
   303
 *          the \c info struct is valid, SDL_FALSE otherwise.
slouken@7191
   304
 *
slouken@3407
   305
 *  You typically use this function like this:
slouken@3407
   306
 *  \code
slouken@4895
   307
 *  SDL_SysWMinfo info;
slouken@3407
   308
 *  SDL_VERSION(&info.version);
slouken@7455
   309
 *  if ( SDL_GetWindowWMInfo(window, &info) ) { ... }
slouken@3407
   310
 *  \endcode
slouken@0
   311
 */
slouken@3685
   312
extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window,
slouken@1895
   313
                                                     SDL_SysWMinfo * info);
slouken@0
   314
slouken@0
   315
slouken@0
   316
/* Ends C function definitions when using C++ */
slouken@0
   317
#ifdef __cplusplus
slouken@0
   318
}
slouken@0
   319
#endif
slouken@0
   320
#include "close_code.h"
slouken@0
   321
slouken@10638
   322
#endif /* SDL_syswm_h_ */
slouken@1895
   323
slouken@1895
   324
/* vi: set ts=4 sw=4 expandtab: */