From 5b35ff6a2745fbb6e191299cdcc81a9f7f24618f Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 27 Dec 2015 16:06:35 +0100 Subject: [PATCH] Fixed: Don't crash if GL_VERSION returns NULL (it should never happen) --- .../src/3d/driver/opengl/driver_opengl.cpp | 6 +++--- .../driver/opengl/driver_opengl_extension.cpp | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index fa2894229..2b7f76515 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -1352,9 +1352,9 @@ void CDriverGL::getZBufferPart (std::vector &zbuffer, NLMISC::CRect &rec #ifdef USE_OPENGLES glReadPixels (rect.X, rect.Y, rect.Width, rect.Height, GL_DEPTH_COMPONENT16_OES, GL_FLOAT, &(zbuffer[0])); #else - glPixelTransferf(GL_DEPTH_SCALE, 1.0f) ; - glPixelTransferf(GL_DEPTH_BIAS, 0.f) ; - glReadPixels (rect.X, rect.Y, rect.Width, rect.Height, GL_DEPTH_COMPONENT , GL_FLOAT, &(zbuffer[0])); + glPixelTransferf(GL_DEPTH_SCALE, 1.0f); + glPixelTransferf(GL_DEPTH_BIAS, 0.f); + glReadPixels(rect.X, rect.Y, rect.Width, rect.Height, GL_DEPTH_COMPONENT , GL_FLOAT, &(zbuffer[0])); #endif } } diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index 59ca38a57..d9850a039 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -1566,12 +1566,21 @@ void registerGlExtensions(CGlExtensions &ext) H_AUTO_OGL(registerGlExtensions); // OpenGL 1.2 ?? - const char *nglVersion= (const char *)glGetString (GL_VERSION); - sint a=0, b=0; + const char *nglVersion = (const char *)glGetString (GL_VERSION); - // 1.2*** ??? - sscanf(nglVersion, "%d.%d", &a, &b); - ext.Version1_2 = (a==1 && b>=2) || (a>=2); + if (nglVersion) + { + sint a = 0, b = 0; + + // 1.2*** ??? + sscanf(nglVersion, "%d.%d", &a, &b); + ext.Version1_2 = (a==1 && b>=2) || (a>=2); + } + else + { + nlwarning("3D: Unable to get GL_VERSION, OpenGL 1.2 should be supported on all recent GPU..."); + ext.Version1_2 = true; + } const char *vendor = (const char *) glGetString (GL_VENDOR); const char *renderer = (const char *) glGetString (GL_RENDERER);