From b9948d67c733864e720f98f7728077c26159592a Mon Sep 17 00:00:00 2001 From: "gregory.hainaut@gmail.com" Date: Sun, 9 Jan 2011 17:19:41 +0000 Subject: [PATCH] zzogl: restore the opengl3 method for fill extension, fallback to the old method if not supported git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4194 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/zzogl-pg/opengl/ZZoglCreate.cpp | 96 ++++++++++++------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp index a42a2c0ce1..d2dd520174 100644 --- a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp @@ -374,60 +374,60 @@ inline bool CreateOpenShadersFile() // Read all extensions name and fill mapGLExtensions inline bool CreateFillExtensionsMap() { + int max_ext = 0; + string all_ext(""); -// This seems to cause crashes on some systems, so I'm temporarily reverting to the old version. -#if 0 - string temp(""); - int max_ext = 0; - glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext); - PFNGLGETSTRINGIPROC glGetStringi = 0; glGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi"); - for (GLint i = 0; i < max_ext; i++) - { - string extension((const char*)glGetStringi(GL_EXTENSIONS, i)); - mapGLExtensions[extension]; - - temp = temp + extension; - if (i != (max_ext - 1)) temp += ", "; - } - - // Write the extension list to the log, but only write it to the screen on a debug build. + + if (glGetStringi) { + // Get opengl extension (opengl3) + glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext); + for (GLint i = 0; i < max_ext; i++) + { + string extension((const char*)glGetStringi(GL_EXTENSIONS, i)); + mapGLExtensions[extension]; + + all_ext += extension; + if (i != (max_ext - 1)) all_ext += ", "; + } + } else { + // fallback to old method (pre opengl3, intel gma ...) + ZZLog::Error_Log("glGetStringi opengl 3 interface not supported, fallback to opengl 2"); + + const char* ptoken = (const char*)glGetString(GL_EXTENSIONS); + + if (ptoken == NULL) return false; + + const char* pend = NULL; + while (ptoken != NULL) + { + pend = strchr(ptoken, ' '); + + if (pend != NULL) + { + max_ext++; + mapGLExtensions[string(ptoken, pend-ptoken)]; + } + else + { + max_ext++; + mapGLExtensions[string(ptoken)]; + break; + } + + ptoken = pend; + while (*ptoken == ' ') ++ptoken; + } + all_ext = string(ptoken); + } + + #ifndef _DEBUG - ZZLog::Log("%d supported OpenGL Extensions: %s\n", max_ext, temp.c_str()); + ZZLog::Log("%d supported OpenGL Extensions: %s\n", max_ext, all_ext.c_str()); #endif - ZZLog::Debug_Log("%d supported OpenGL Extensions: %s\n", max_ext, temp.c_str()); + ZZLog::Debug_Log("%d supported OpenGL Extensions: %s\n", max_ext, all_ext.c_str()); -#else - const char* ptoken = (const char*)glGetString(GL_EXTENSIONS); - -#ifndef _DEBUG - ZZLog::Log("Supported OpenGL Extensions: %s\n", ptoken); -#endif - ZZLog::Debug_Log("Supported OpenGL Extensions:\n%s\n", ptoken); - - if (ptoken == NULL) return false; - - const char* pend = NULL; - while (ptoken != NULL) - { - pend = strchr(ptoken, ' '); - - if (pend != NULL) - { - mapGLExtensions[string(ptoken, pend-ptoken)]; - } - else - { - mapGLExtensions[string(ptoken)]; - break; - } - - ptoken = pend; - while (*ptoken == ' ') ++ptoken; - } -#endif - return true; }