From 95bcda409d7b6ff4e538801f8717ac2c77bcc803 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 21 Jan 2018 09:17:24 -0800 Subject: [PATCH] GLES: Fix segfault on GL 2.x. --- ext/native/thin3d/GLQueueRunner.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index a7072931bb..a895ed4649 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -22,7 +22,9 @@ GLuint g_defaultFBO = 0; void GLQueueRunner::CreateDeviceObjects() { glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropyLevel_); - glGenVertexArrays(1, &globalVAO_); + if (gl_extensions.ARB_vertex_array_object) { + glGenVertexArrays(1, &globalVAO_); + } // An eternal optimist. sawOutOfMemory_ = false; @@ -47,7 +49,9 @@ void GLQueueRunner::DestroyDeviceObjects() { glDeleteTextures((GLsizei)nameCache_.size(), &nameCache_[0]); nameCache_.clear(); } - glDeleteVertexArrays(1, &globalVAO_); + if (gl_extensions.ARB_vertex_array_object) { + glDeleteVertexArrays(1, &globalVAO_); + } } void GLQueueRunner::RunInitSteps(const std::vector &steps) { @@ -479,7 +483,9 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) { #endif */ - glBindVertexArray(globalVAO_); + if (gl_extensions.ARB_vertex_array_object) { + glBindVertexArray(globalVAO_); + } GLRFramebuffer *fb = step.render.framebuffer; GLRProgram *curProgram = nullptr; @@ -889,7 +895,9 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) { // Wipe out the current state. glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindVertexArray(0); + if (gl_extensions.ARB_vertex_array_object) { + glBindVertexArray(0); + } glDisable(GL_SCISSOR_TEST); glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST);