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.
3 # Simple DirectMedia Layer
4 # Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
6 # This software is provided 'as-is', without any express or implied
7 # warranty. In no event will the authors be held liable for any damages
8 # arising from the use of this software.
10 # Permission is granted to anyone to use this software for any purpose,
11 # including commercial applications, and to alter it and redistribute it
12 # freely, subject to the following restrictions:
14 # 1. The origin of this software must not be misrepresented; you must not
15 # claim that you wrote the original software. If you use this software
16 # in a product, an acknowledgment in the product documentation would be
17 # appreciated but is not required.
18 # 2. Altered source versions must be plainly marked as such, and must not be
19 # misrepresented as being the original software.
20 # 3. This notice may not be removed or altered from any source distribution.
23 # When you add a public API to SDL, please run this script, make sure the
24 # output looks sane (hg diff, it adds to existing files), and commit it.
25 # It keeps the dynamic API jump table operating correctly.
27 # If you wanted this to be readable, you shouldn't have used perl.
33 chdir(dirname(__FILE__) . '/../..');
34 my $sdl_dynapi_procs_h = "src/dynapi/SDL_dynapi_procs.h";
35 my $sdl_dynapi_overrides_h = "src/dynapi/SDL_dynapi_overrides.h";
38 if (-f $sdl_dynapi_procs_h) {
39 open(SDL_DYNAPI_PROCS_H, '<', $sdl_dynapi_procs_h) or die("Can't open $sdl_dynapi_procs_h: $!\n");
40 while (<SDL_DYNAPI_PROCS_H>) {
41 if (/\ASDL_DYNAPI_PROC\(.*?,(.*?),/) {
45 close(SDL_DYNAPI_PROCS_H)
48 open(SDL_DYNAPI_PROCS_H, '>>', $sdl_dynapi_procs_h) or die("Can't open $sdl_dynapi_procs_h: $!\n");
49 open(SDL_DYNAPI_OVERRIDES_H, '>>', $sdl_dynapi_overrides_h) or die("Can't open $sdl_dynapi_overrides_h: $!\n");
51 opendir(HEADERS, 'include') or die("Can't open include dir: $!\n");
52 while (readdir(HEADERS)) {
54 my $header = "include/$_";
55 open(HEADER, '<', $header) or die("Can't open $header: $!\n");
58 next if not /\A\s*extern\s+DECLSPEC/;
60 if (not $decl =~ /\)\s*;/) {
71 #print("DECL: [$decl]\n");
73 if ($decl =~ /\A\s*extern\s+DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) {
77 next if $existing{$fn}; # already slotted into the jump table.
79 my @params = split(',', $6);
81 #print("rc == '$rc', fn == '$fn', params == '$params'\n");
83 my $retstr = ($rc eq 'void') ? '' : 'return';
91 #print("1PARAM: $str\n");
94 } elsif ($str eq '...') {
99 } elsif ($str =~ /\A\s*((const\s+|)(unsigned\s+|)([a-zA-Z0-9_]*)\s*([\*\s]*))\s*(.*?)\Z/) {
100 #print("PARSED: [$1], [$2], [$3], [$4], [$5]\n");
107 $type =~ s/\s*\*\Z/*/g;
108 $type =~ s/\s*(\*+)\Z/ $1/;
109 #print("SPLIT: ($type, $var)\n");
110 my $name = chr(ord('a') + $i);
115 my $spc = ($type =~ /\*\Z/) ? '' : ' ';
116 $paramstr .= "$type$spc$name";
122 $paramstr = '(void' if ($i == 0); # Just to make this consistent.
127 print("NEW: $decl\n");
128 print SDL_DYNAPI_PROCS_H "SDL_DYNAPI_PROC($rc,$fn,$paramstr,$argstr,$retstr)\n";
129 print SDL_DYNAPI_OVERRIDES_H "#define $fn ${fn}_REAL\n";
131 print("Failed to parse decl [$decl]!\n");
138 close(SDL_DYNAPI_PROCS_H);
139 close(SDL_DYNAPI_OVERRIDES_H);
141 # vi: set ts=4 sw=4 expandtab: