include/SDL_error.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 18 Oct 2017 08:52:04 -0700
changeset 11630 ad4b5d85edee
parent 10737 3406a0f8b041
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_error.h
slouken@7191
    24
 *
slouken@3407
    25
 *  Simple error message routines for SDL.
slouken@1895
    26
 */
slouken@0
    27
slouken@10638
    28
#ifndef SDL_error_h_
slouken@10638
    29
#define SDL_error_h_
slouken@0
    30
slouken@1356
    31
#include "SDL_stdinc.h"
slouken@1356
    32
slouken@0
    33
#include "begin_code.h"
slouken@0
    34
/* Set up for C function definitions, even when using C++ */
slouken@0
    35
#ifdef __cplusplus
slouken@0
    36
extern "C" {
slouken@0
    37
#endif
slouken@0
    38
slouken@0
    39
/* Public functions */
icculus@7037
    40
/* SDL_SetError() unconditionally returns -1. */
slouken@8820
    41
extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
slouken@4867
    42
extern DECLSPEC const char *SDLCALL SDL_GetError(void);
slouken@337
    43
extern DECLSPEC void SDLCALL SDL_ClearError(void);
slouken@0
    44
slouken@3407
    45
/**
slouken@3407
    46
 *  \name Internal error functions
slouken@7191
    47
 *
slouken@7191
    48
 *  \internal
slouken@5221
    49
 *  Private error reporting function - used internally.
slouken@3407
    50
 */
gabomdq@7678
    51
/* @{ */
slouken@7191
    52
#define SDL_OutOfMemory()   SDL_Error(SDL_ENOMEM)
slouken@7191
    53
#define SDL_Unsupported()   SDL_Error(SDL_UNSUPPORTED)
slouken@7191
    54
#define SDL_InvalidParamError(param)    SDL_SetError("Parameter '%s' is invalid", (param))
slouken@1895
    55
typedef enum
slouken@1895
    56
{
slouken@1895
    57
    SDL_ENOMEM,
slouken@1895
    58
    SDL_EFREAD,
slouken@1895
    59
    SDL_EFWRITE,
slouken@1895
    60
    SDL_EFSEEK,
slouken@1895
    61
    SDL_UNSUPPORTED,
slouken@1895
    62
    SDL_LASTERROR
slouken@0
    63
} SDL_errorcode;
icculus@7037
    64
/* SDL_Error() unconditionally returns -1. */
icculus@7037
    65
extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code);
gabomdq@7678
    66
/* @} *//* Internal error functions */
slouken@0
    67
slouken@0
    68
/* Ends C function definitions when using C++ */
slouken@0
    69
#ifdef __cplusplus
slouken@0
    70
}
slouken@0
    71
#endif
slouken@0
    72
#include "close_code.h"
slouken@0
    73
slouken@10638
    74
#endif /* SDL_error_h_ */
slouken@1895
    75
slouken@1895
    76
/* vi: set ts=4 sw=4 expandtab: */