Fixed: Don't crash if GL_VERSION returns NULL (it should never happen)

--HG--
branch : develop
This commit is contained in:
kervala 2015-12-27 16:06:35 +01:00
parent ba7c4ae4d4
commit d8bc7384ae
2 changed files with 17 additions and 8 deletions

View file

@ -1352,9 +1352,9 @@ void CDriverGL::getZBufferPart (std::vector<float> &zbuffer, NLMISC::CRect &rec
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
glReadPixels (rect.X, rect.Y, rect.Width, rect.Height, GL_DEPTH_COMPONENT16_OES, GL_FLOAT, &(zbuffer[0])); glReadPixels (rect.X, rect.Y, rect.Width, rect.Height, GL_DEPTH_COMPONENT16_OES, GL_FLOAT, &(zbuffer[0]));
#else #else
glPixelTransferf(GL_DEPTH_SCALE, 1.0f) ; glPixelTransferf(GL_DEPTH_SCALE, 1.0f);
glPixelTransferf(GL_DEPTH_BIAS, 0.f) ; glPixelTransferf(GL_DEPTH_BIAS, 0.f);
glReadPixels (rect.X, rect.Y, rect.Width, rect.Height, GL_DEPTH_COMPONENT , GL_FLOAT, &(zbuffer[0])); glReadPixels(rect.X, rect.Y, rect.Width, rect.Height, GL_DEPTH_COMPONENT , GL_FLOAT, &(zbuffer[0]));
#endif #endif
} }
} }

View file

@ -1566,12 +1566,21 @@ void registerGlExtensions(CGlExtensions &ext)
H_AUTO_OGL(registerGlExtensions); H_AUTO_OGL(registerGlExtensions);
// OpenGL 1.2 ?? // OpenGL 1.2 ??
const char *nglVersion= (const char *)glGetString (GL_VERSION); const char *nglVersion = (const char *)glGetString (GL_VERSION);
sint a=0, b=0;
// 1.2*** ??? if (nglVersion)
sscanf(nglVersion, "%d.%d", &a, &b); {
ext.Version1_2 = (a==1 && b>=2) || (a>=2); 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 *vendor = (const char *) glGetString (GL_VENDOR);
const char *renderer = (const char *) glGetString (GL_RENDERER); const char *renderer = (const char *) glGetString (GL_RENDERER);