Jason McKesson avatar Jason McKesson committed 69aaeb0

Fix for bug #39

Comments (0)

Files changed (1)

glload/source/gll_c.c

 static int iMinorVersion = 0;
 
 
+#define LOAD_FUNCS_FROM_CORE(major, minor)\
+	if((iMajorVersion == major) && (iMinorVersion == minor))\
+	{\
+		found = 1;\
+		if(!gleIntLoad_Version_ ## major ## _ ## minor ())\
+			eCurrLoadStatus = LS_LOAD_FUNCTIONS_SOME;\
+	}
 
+#define LOAD_FUNCS_FROM_COMPATIBILITY(major, minor)\
+	if((iMajorVersion == major) && (iMinorVersion == minor))\
+	{\
+		found = 1;\
+		if(!gleIntLoad_Version_ ## major ## _ ## minor ## _Comp ())\
+			eCurrLoadStatus = LS_LOAD_FUNCTIONS_SOME;\
+	}
 
 int LoadFunctions()
 {
 	{
 		int iProfileMask = 0;
 		glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &iProfileMask);
-		if(iProfileMask)
+
+		if(!iProfileMask)
 		{
-			if(iProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
+			if(CheckCompatibilityExt())
+				iProfileMask &= GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
+			else
+				iProfileMask &= GL_CONTEXT_CORE_PROFILE_BIT;
+		}
+
+		if(iProfileMask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
+		{
+			int found = 0;
+			LOAD_FUNCS_FROM_COMPATIBILITY(3, 2);
+			LOAD_FUNCS_FROM_COMPATIBILITY(3, 3);
+			LOAD_FUNCS_FROM_COMPATIBILITY(4, 0);
+			LOAD_FUNCS_FROM_COMPATIBILITY(4, 1);
+			LOAD_FUNCS_FROM_COMPATIBILITY(4, 2);
+			LOAD_FUNCS_FROM_COMPATIBILITY(4, 3);
+			if(!found)
 			{
-				if(!gleIntLoad_Version_3_2_Comp()) eCurrLoadStatus = LS_LOAD_FUNCTIONS_SOME;
-			}
-			else
-			{
-				if(!gleIntLoad_Version_3_2()) eCurrLoadStatus = LS_LOAD_FUNCTIONS_SOME;
+				//Unknown OpenGL version. Just load the latest.
+				if(!gleIntLoad_Version_4_3_Comp()) eCurrLoadStatus = LS_LOAD_FUNCTIONS_SOME;
 			}
 		}
 		else
 		{
-			//Hack to fix NVIDIA stupidity.
-			if(CheckCompatibilityExt())
+			int found = 0;
+			LOAD_FUNCS_FROM_CORE(3, 2);
+			LOAD_FUNCS_FROM_CORE(3, 3);
+			LOAD_FUNCS_FROM_CORE(4, 0);
+			LOAD_FUNCS_FROM_CORE(4, 1);
+			LOAD_FUNCS_FROM_CORE(4, 2);
+			LOAD_FUNCS_FROM_CORE(4, 3);
+			if(!found)
 			{
-				if(!gleIntLoad_Version_3_2_Comp()) eCurrLoadStatus = LS_LOAD_FUNCTIONS_SOME;
-			}
-			else
-			{
-				if(!gleIntLoad_Version_3_2()) eCurrLoadStatus = LS_LOAD_FUNCTIONS_SOME;
+				//Unknown OpenGL version. Just load the latest.
+				if(!gleIntLoad_Version_4_3()) eCurrLoadStatus = LS_LOAD_FUNCTIONS_SOME;
 			}
 		}
 	}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.