include/SDL_opengles2_gl2platform.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 18 Oct 2017 08:52:04 -0700
changeset 11630 ad4b5d85edee
parent 8808 da1e1d6e84c4
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.
jorgen@8806
     1
#ifndef __gl2platform_h_
jorgen@8806
     2
#define __gl2platform_h_
jorgen@8806
     3
jorgen@8806
     4
/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
jorgen@8806
     5
jorgen@8806
     6
/*
jorgen@8806
     7
 * This document is licensed under the SGI Free Software B License Version
jorgen@8806
     8
 * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
jorgen@8806
     9
 */
jorgen@8806
    10
jorgen@8806
    11
/* Platform-specific types and definitions for OpenGL ES 2.X  gl2.h
jorgen@8806
    12
 *
jorgen@8806
    13
 * Adopters may modify khrplatform.h and this file to suit their platform.
jorgen@8806
    14
 * You are encouraged to submit all modifications to the Khronos group so that
jorgen@8806
    15
 * they can be included in future versions of this file.  Please submit changes
jorgen@8806
    16
 * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
jorgen@8806
    17
 * by filing a bug against product "OpenGL-ES" component "Registry".
jorgen@8806
    18
 */
jorgen@8806
    19
jorgen@8806
    20
/*#include <KHR/khrplatform.h>*/
jorgen@8806
    21
jorgen@8806
    22
#ifndef GL_APICALL
jorgen@8806
    23
#define GL_APICALL  KHRONOS_APICALL
jorgen@8806
    24
#endif
jorgen@8806
    25
jorgen@8806
    26
#ifndef GL_APIENTRY
jorgen@8806
    27
#define GL_APIENTRY KHRONOS_APIENTRY
jorgen@8806
    28
#endif
jorgen@8806
    29
jorgen@8806
    30
#endif /* __gl2platform_h_ */