[Piglit] [PATCH 4/4] util/framework/glut: Auto-detect glutInitErrorFunc support.

jfonseca at vmware.com jfonseca at vmware.com
Mon Jun 9 08:39:22 PDT 2014


From: José Fonseca <jfonseca at vmware.com>

Should fix https://bugs.freedesktop.org/show_bug.cgi?id=79745
---
 cmake/target_api/gl/CMakeLists.txt                     | 11 +++++++++++
 tests/util/piglit-framework-gl/piglit_glut_framework.c |  8 +++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/cmake/target_api/gl/CMakeLists.txt b/cmake/target_api/gl/CMakeLists.txt
index 0a3c3b7..d7084d6 100644
--- a/cmake/target_api/gl/CMakeLists.txt
+++ b/cmake/target_api/gl/CMakeLists.txt
@@ -11,6 +11,17 @@ if(NOT PIGLIT_USE_WAFFLE)
 	link_libraries(
 		${GLUT_glut_LIBRARY}
 		)
+
+	# Check if glutInitErrorFunc is available
+	if (NOT APPLE)
+		include(CheckSymbolExists)
+		set(CMAKE_REQUIRED_INCLUDES "${GLUT_INCLUDE_DIR}")
+		set(CMAKE_REQUIRED_LIBRARIES "${GLUT_glut_LIBRARY}")
+		check_symbol_exists ("glutInitErrorFunc" "GL/glut.h;GL/freeglut_ext.h" PIGLIT_USE_GLUT_INIT_ERROR_FUNC)
+		if (PIGLIT_USE_GLUT_INIT_ERROR_FUNC)
+			add_definitions(-DPIGLIT_USE_GLUT_INIT_ERROR_FUNC)
+		endif ()
+	endif ()
 endif()
 
 add_subdirectory(${piglit_SOURCE_DIR}/tests
diff --git a/tests/util/piglit-framework-gl/piglit_glut_framework.c b/tests/util/piglit-framework-gl/piglit_glut_framework.c
index f5116a8..7c872fb 100644
--- a/tests/util/piglit-framework-gl/piglit_glut_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_glut_framework.c
@@ -128,8 +128,12 @@ init_glut(void)
 	                   test_config->window_height);
 	glutInitDisplayMode(flags);
 
-#ifdef GLUT_CORE_PROFILE
+#ifdef PIGLIT_USE_GLUT_INIT_ERROR_FUNC
 	glutInitErrorFunc(error_func);
+#else
+	(void)error_func;
+#endif
+#ifdef GLUT_CORE_PROFILE
 	if (test_config->supports_gl_core_version) {
 		glutInitContextVersion(test_config->supports_gl_core_version / 10,
 				       test_config->supports_gl_core_version % 10);
@@ -138,8 +142,6 @@ init_glut(void)
 		glutInitContextVersion(test_config->supports_gl_compat_version / 10,
 				       test_config->supports_gl_compat_version % 10);
 	}
-#else
-	(void)error_func;
 #endif
 
 	glut_fw.window = glutCreateWindow("Piglit");
-- 
1.9.1



More information about the Piglit mailing list