Merge pull request #21387 from hpvb/fix-15324

Fall back to GLES2 if GLES3 is not working
This commit is contained in:
Rémi Verschelde 2018-08-27 16:54:22 +02:00 committed by GitHub
commit c1f687c681
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 417 additions and 171 deletions

View file

@ -789,6 +789,10 @@ public:
void end_frame(bool p_swap_buffers) {}
void finalize() {}
static Error is_viable() {
return OK;
}
static Rasterizer *_create_current() {
return memnew(RasterizerDummy);
}

View file

@ -136,26 +136,21 @@ RasterizerScene *RasterizerGLES2::get_scene() {
return scene;
}
void RasterizerGLES2::initialize() {
print_verbose("Using GLES2 video driver");
Error RasterizerGLES2::is_viable() {
#ifdef GLAD_ENABLED
if (!gladLoadGL()) {
ERR_PRINT("Error initializing GLAD");
return ERR_UNAVAILABLE;
}
// GLVersion seems to be used for both GL and GL ES, so we need different version checks for them
#ifdef OPENGL_ENABLED // OpenGL 2.1 Profile required
if (GLVersion.major < 2) {
#else // OpenGL ES 3.0
if (GLVersion.major < 2 || (GLVersion.major == 2 && GLVersion.minor < 1)) {
#else // OpenGL ES 2.0
if (GLVersion.major < 2) {
#endif
ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 2.1 / OpenGL ES 2.0, sorry :(\n"
"Try a drivers update, buy a new GPU or try software rendering on Linux; Godot will now crash with a segmentation fault.");
OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 2.1 / OpenGL ES 2.0, sorry :(\n"
"Godot Engine will self-destruct as soon as you acknowledge this error message.",
"Fatal error: Insufficient OpenGL / GLES driver support");
return ERR_UNAVAILABLE;
}
#ifdef GLES_OVER_GL
@ -181,14 +176,21 @@ void RasterizerGLES2::initialize() {
glGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameterivEXT;
glGenerateMipmap = glGenerateMipmapEXT;
} else {
ERR_PRINT("Your system's graphic drivers seem not to support GL_ARB(EXT)_framebuffer_object OpenGL extension, sorry :(\n"
"Try a drivers update, buy a new GPU or try software rendering on Linux; Godot will now crash with a segmentation fault.");
OS::get_singleton()->alert("Your system's graphic drivers seem not to support GL_ARB(EXT)_framebuffer_object OpenGL extension, sorry :(\n"
"Godot Engine will self-destruct as soon as you acknowledge this error message.",
"Fatal error: Insufficient OpenGL / GLES driver support");
return ERR_UNAVAILABLE;
}
}
#endif
#endif // GLAD_ENABLED
return OK;
}
void RasterizerGLES2::initialize() {
print_verbose("Using GLES2 video driver");
#ifdef GLAD_ENABLED
if (true || OS::get_singleton()->is_stdout_verbose()) {
if (GLAD_GL_ARB_debug_output) {
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
@ -198,7 +200,6 @@ void RasterizerGLES2::initialize() {
print_line("OpenGL debugging not supported!");
}
}
#endif // GLAD_ENABLED
// For debugging

View file

@ -61,9 +61,10 @@ public:
virtual void end_frame(bool p_swap_buffers);
virtual void finalize();
static Error is_viable();
static void make_current();
static void register_config();
RasterizerGLES2();
~RasterizerGLES2();
};

View file

@ -136,28 +136,32 @@ typedef void (*DEBUGPROCARB)(GLenum source,
typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);
Error RasterizerGLES3::is_viable() {
#ifdef GLAD_ENABLED
if (!gladLoadGL()) {
ERR_PRINT("Error initializing GLAD");
return ERR_UNAVAILABLE;
}
// GLVersion seems to be used for both GL and GL ES, so we need different version checks for them
#ifdef OPENGL_ENABLED // OpenGL 3.3 Core Profile required
if (GLVersion.major < 3 || (GLVersion.major == 3 && GLVersion.minor < 3)) {
#else // OpenGL ES 3.0
if (GLVersion.major < 3) {
#endif
return ERR_UNAVAILABLE;
}
#endif // GLAD_ENABLED
return OK;
}
void RasterizerGLES3::initialize() {
print_verbose("Using GLES3 video driver");
#ifdef GLAD_ENABLED
if (!gladLoadGL()) {
ERR_PRINT("Error initializing GLAD");
}
// GLVersion seems to be used for both GL and GL ES, so we need different version checks for them
#ifdef OPENGL_ENABLED // OpenGL 3.3 Core Profile required
if (GLVersion.major < 3 && GLVersion.minor < 3) {
#else // OpenGL ES 3.0
if (GLVersion.major < 3) {
#endif
ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 3.3 / OpenGL ES 3.0, sorry :(\n"
"Try a drivers update, buy a new GPU or try software rendering on Linux; Godot will now crash with a segmentation fault.");
OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 3.3 / OpenGL ES 3.0, sorry :(\n"
"Godot Engine will self-destruct as soon as you acknowledge this error message.",
"Fatal error: Insufficient OpenGL / GLES driver support");
}
if (OS::get_singleton()->is_stdout_verbose()) {
if (GLAD_GL_ARB_debug_output) {
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
@ -167,7 +171,6 @@ void RasterizerGLES3::initialize() {
print_line("OpenGL debugging not supported!");
}
}
#endif // GLAD_ENABLED
/* // For debugging

View file

@ -62,9 +62,10 @@ public:
virtual void end_frame(bool p_swap_buffers);
virtual void finalize();
static Error is_viable();
static void make_current();
static void register_config();
RasterizerGLES3();
~RasterizerGLES3();
};