From 6863f21c65f416759afd77fb55d35df0cf8b5c29 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 1 Dec 2015 22:58:27 +0300 Subject: Fix OpenGL GLES version detection. --- src/graphicsmanager.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/graphicsmanager.cpp') diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index 22850848d..719f072c6 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -764,11 +764,19 @@ std::string GraphicsManager::getGLString(const int num) void GraphicsManager::setGLVersion() { mGlVersionString = getGLString(GL_VERSION); - sscanf(mGlVersionString.c_str(), "%5d.%5d", &mMajor, &mMinor); + std::string version = mGlVersionString; + cutFirst(version, "OpenGL ES "); + sscanf(version.c_str(), "%5d.%5d", &mMajor, &mMinor); + logger->log("Detected gl version: %d.%d", mMajor, mMinor); mGlVendor = getGLString(GL_VENDOR); mGlRenderer = getGLString(GL_RENDERER); mGlShaderVersionString = getGLString(GL_SHADING_LANGUAGE_VERSION); - sscanf(mGlShaderVersionString.c_str(), "%5d.%5d", &mSLMajor, &mSLMinor); + version = mGlShaderVersionString; + cutFirst(version, "OpenGL ES GLSL ES "); + cutFirst(version, "OpenGL ES GLSL "); + cutFirst(version, "OpenGL ES "); + sscanf(version.c_str(), "%5d.%5d", &mSLMajor, &mSLMinor); + logger->log("Detected glsl version: %d.%d", mSLMajor, mSLMinor); } void GraphicsManager::logVersion() const @@ -1227,6 +1235,12 @@ void GraphicsManager::updateLimits() logger->log("GL_MAX_ELEMENTS_INDICES: %d", value); if (value < mMaxVertices) mMaxVertices = value; + if (!mMaxVertices) + { + logger->log("Got 0 max amount of vertices or indicies. " + "Overriding to 500"); + mMaxVertices = 500; + } value = 0; glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value); -- cgit v1.2.3-70-g09d2