docs/README-windows.md
author Sam Lantinga <slouken@libsdl.org>
Wed, 18 Oct 2017 08:52:04 -0700
changeset 11630 ad4b5d85edee
parent 11381 2610f8f0a9c6
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.
icculus@11365
     1
Windows
icculus@11365
     2
================================================================================
icculus@11365
     3
icculus@11365
     4
================================================================================
icculus@11365
     5
OpenGL ES 2.x support
icculus@11365
     6
================================================================================
icculus@11365
     7
icculus@11365
     8
SDL has support for OpenGL ES 2.x under Windows via two alternative 
icculus@11365
     9
implementations. 
icculus@11365
    10
The most straightforward method consists in running your app in a system with 
icculus@11365
    11
a graphic card paired with a relatively recent (as of November of 2013) driver 
icculus@11365
    12
which supports the WGL_EXT_create_context_es2_profile extension. Vendors known 
icculus@11365
    13
to ship said extension on Windows currently include nVidia and Intel.
icculus@11365
    14
icculus@11365
    15
The other method involves using the ANGLE library (https://code.google.com/p/angleproject/)
icculus@11365
    16
If an OpenGL ES 2.x context is requested and no WGL_EXT_create_context_es2_profile
icculus@11365
    17
extension is found, SDL will try to load the libEGL.dll library provided by
icculus@11365
    18
ANGLE.
icculus@11365
    19
To obtain the ANGLE binaries, you can either compile from source from
icculus@11365
    20
https://chromium.googlesource.com/angle/angle or copy the relevant binaries from
icculus@11365
    21
a recent Chrome/Chromium install for Windows. The files you need are:
icculus@11365
    22
    
icculus@11365
    23
    * libEGL.dll
icculus@11365
    24
    * libGLESv2.dll
icculus@11365
    25
    * d3dcompiler_46.dll (supports Windows Vista or later, better shader compiler)
icculus@11365
    26
    or...
icculus@11365
    27
    * d3dcompiler_43.dll (supports Windows XP or later)
icculus@11365
    28
    
icculus@11365
    29
If you compile ANGLE from source, you can configure it so it does not need the
icculus@11365
    30
d3dcompiler_* DLL at all (for details on this, see their documentation). 
icculus@11365
    31
However, by default SDL will try to preload the d3dcompiler_46.dll to
icculus@11365
    32
comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to
icculus@11365
    33
support Windows XP) or to skip this step at all, you can use the 
icculus@11365
    34
SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details).
icculus@11365
    35
icculus@11365
    36
Known Bugs:
icculus@11365
    37
    
icculus@11365
    38
    * SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
icculus@11365
    39
      that there's a bug in the library which prevents the window contents from
icculus@11365
    40
      refreshing if this is set to anything other than the default value.
icculus@11365
    41
     
icculus@11365
    42
Vulkan Surface Support
icculus@11365
    43
==============
icculus@11365
    44
slouken@11381
    45
Support for creating Vulkan surfaces is configured on by default. To disable it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to use Vulkan graphics in your application.