From cb84f5a719fef9b58401b10dcbc4abe700353ecb Mon Sep 17 00:00:00 2001 From: Robert Menzel Date: Fri, 28 Jun 2013 20:05:37 +0200 Subject: [PATCH] added debug message in init(), cleaned up external defines, added new gl error checks --- CMakeListsStaticInclude.txt | 11 +++++++ include/ACGL/Base/CompileTimeSettings.hh | 11 +++++-- .../HardwareSupport/SpaceNavPollInterface.hh | 2 +- include/ACGL/OpenGL/GL.hh | 32 +++++++------------ include/ACGL/OpenGL/Tools.hh | 3 ++ include/ACGL/OpenGL/glloaders/extensions.hh | 12 +++---- src/ACGL/ACGL.cc | 19 +++++++++++ .../HardwareSupport/SpaceNavPollInterface.cc | 5 ++- 8 files changed, 62 insertions(+), 33 deletions(-) diff --git a/CMakeListsStaticInclude.txt b/CMakeListsStaticInclude.txt index adf1cbd..df1b413 100644 --- a/CMakeListsStaticInclude.txt +++ b/CMakeListsStaticInclude.txt @@ -16,3 +16,14 @@ SET(HEADER_FILES ${HEADER_FILES} ${HEADER_FILES_H} ${HEADER_FILES_HH} ${HEADER_F SET(SOURCE_FILES ${SOURCE_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_CC} ${SOURCE_FILES_CPP}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/include) + +# set debug build with: cmake -DCMAKE_BUILD_TYPE=Debug ... +IF(CMAKE_BUILD_TYPE MATCHES Debug) + ADD_DEFINITIONS(-DDEBUG) +ENDIF(CMAKE_BUILD_TYPE MATCHES Debug) +IF(CMAKE_BUILD_TYPE MATCHES debug) + ADD_DEFINITIONS(-DDEBUG) +ENDIF(CMAKE_BUILD_TYPE MATCHES debug) +IF(CMAKE_BUILD_TYPE MATCHES DEBUG) + ADD_DEFINITIONS(-DDEBUG) +ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG) diff --git a/include/ACGL/Base/CompileTimeSettings.hh b/include/ACGL/Base/CompileTimeSettings.hh index 58c76d7..54b76e3 100644 --- a/include/ACGL/Base/CompileTimeSettings.hh +++ b/include/ACGL/Base/CompileTimeSettings.hh @@ -32,6 +32,13 @@ * Note that all error levels also include the higher ones (COMMON also adds CRITICAL). */ +// try to detect a debug build: +#if defined( DEBUG ) || defined (_DEBUG) +#define ACGL_DEBUG +#endif + +//#error foo + /* * Map CMake generated error-level defines to internally used, more readable defines */ @@ -54,8 +61,8 @@ # ifndef ACGL_CHECK_COMMON_GL_ERRORS # ifndef ACGL_CHECK_RARE_GL_ERRORS // if nothing is defined, use defaults: -# ifdef DEBUG -# define ACGL_CHECK_COMMON_GL_ERRORS +# ifdef ACGL_DEBUG +# define ACGL_CHECK_RARE_GL_ERRORS # else # define ACGL_CHECK_CRITICAL_GL_ERRORS # endif diff --git a/include/ACGL/HardwareSupport/SpaceNavPollInterface.hh b/include/ACGL/HardwareSupport/SpaceNavPollInterface.hh index dc8842a..7ae42f1 100644 --- a/include/ACGL/HardwareSupport/SpaceNavPollInterface.hh +++ b/include/ACGL/HardwareSupport/SpaceNavPollInterface.hh @@ -16,7 +16,7 @@ namespace HardwareSupport{ * Linux: do nothing * MacOS X: link to 3DconnexionClient, * e.g. add 'SET(LIBRARIES -Wl,-framework,3DconnexionClient)' to CMakeLists.txt - * to build a version without space nav support, define NO_SPACE_NAVIGATOR_SUPPORT + * define ACGL_SPACE_NAVIGATOR_SUPPORT * Windows: only dummy functionality will get build */ diff --git a/include/ACGL/OpenGL/GL.hh b/include/ACGL/OpenGL/GL.hh index b14028b..e2157c8 100644 --- a/include/ACGL/OpenGL/GL.hh +++ b/include/ACGL/OpenGL/GL.hh @@ -19,7 +19,8 @@ * ACGL_OPENGL_PROFILE_CORE : if defined: if possible include/load only core OpenGL functions * if not defined: support for CORE and deprecated functions * (NOTE: the OpenGL context itself is not created by ACGL!) - * ACGL_OPENGL_ES : if defined: assume OpenGL ES (2.0 or 3.0) + * ACGL_OPENGLES_VERSION_20 : if defined: OpenGL ES 2.0 + * ACGL_OPENGLES_VERSION_30 : if defined: OpenGL ES 3.0 * ACGL_OPENGL_VERSION_41 : (or other versions): minimal OpenGL version that can be assumed to be present. * The app can't run on older contexts and will probably terminate at startup. * Set this to a low version and it will run on lost machines @@ -38,7 +39,7 @@ * (full/compatibility profile). */ -// Android: +// Android autodetection: #ifdef __ANDROID__ # define ACGL_OPENGL_ES # define PLATFORM_ANDROID @@ -56,14 +57,6 @@ # endif #endif -//manually enforced ES: -#ifdef ACGL_PLATFORM_MOBILE -// ...but mobile: -// maybe maemo or android: first one to program for these plattforms should add -// the correct includes here! -# define ACGL_OPENGL_ES -#endif - // To compare the OpenGL version number we define a new ACGL_OPENGL_VERSION XY define here // analog to ACGL_OPENGL_VERSION_XY @@ -71,9 +64,11 @@ #ifdef ACGL_OPENGL_ES # if defined (ACGL_OPENGLES_VERSION_30) # define ACGL_OPENGLES_VERSION 30 +# define ACGL_OPENGL_VERSION 0 # else # define ACGL_OPENGLES_VERSION_20 # define ACGL_OPENGLES_VERSION 20 +# define ACGL_OPENGL_VERSION 0 # endif #else // Desktop: @@ -170,18 +165,12 @@ #endif #endif #ifdef ACGL_USE_GLEW - // if GLEW_STATIC is defined, GLEW gets linked statically. GLEW itself needs this define - // but for us its the sign that a local version of GLEW gets used, so we find it on - // GL/glew.h on every system. - #ifdef GLEW_STATIC - #include "GL/glew.h" + #define ACGL_EXTENSION_LOADER_GLEW + #if defined(__APPLE__) || defined(MACOSX) + #include #else - #if defined(__APPLE__) || defined(MACOSX) - #include - #else - #include - #endif - #endif // !GLEW_LOCAL_PATH + #include + #endif #else // use the internal loader: #define ACGL_EXTENSION_LOADER_GLLOADGEN @@ -231,6 +220,7 @@ #endif // ACGL_USE_GLEW #else #define ACGL_USE_GLEW + #define ACGL_EXTENSION_LOADER_GLEW #endif // __GLEW__ #endif // ACGL_OPENGL_ES diff --git a/include/ACGL/OpenGL/Tools.hh b/include/ACGL/OpenGL/Tools.hh index 14bae8e..37f7f78 100644 --- a/include/ACGL/OpenGL/Tools.hh +++ b/include/ACGL/OpenGL/Tools.hh @@ -195,6 +195,9 @@ GLenum openGLError_( const char *_fileName, const unsigned long _lineNumber ); inline GLenum openGLErrorDummy() { return GL_NO_ERROR; } inline bool openGLErrorOccuredDummy() { return false; } +#define openGLCheckError() ACGL::OpenGL::openGLError_( __FILE__, __LINE__ ) +#define openGLErrorOccured() (ACGL::OpenGL::openGLError_( __FILE__, __LINE__ ) != GL_NO_ERROR) + #ifdef ACGL_CHECK_CRITICAL_GL_ERRORS # define openGLCriticalError() ACGL::OpenGL::openGLError_( __FILE__, __LINE__ ) # define openGLCriticalErrorOccured() (ACGL::OpenGL::openGLError_( __FILE__, __LINE__ ) != GL_NO_ERROR) diff --git a/include/ACGL/OpenGL/glloaders/extensions.hh b/include/ACGL/OpenGL/glloaders/extensions.hh index 899b091..a91c3f6 100644 --- a/include/ACGL/OpenGL/glloaders/extensions.hh +++ b/include/ACGL/OpenGL/glloaders/extensions.hh @@ -30,7 +30,7 @@ namespace OpenGL{ inline bool ACGL_EXT_texture_filter_anisotrophic() { #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN return (ogl_ext_EXT_texture_filter_anisotropic != ogl_LOAD_FAILED); - #elif ACGL_USE_GLEW + #elif ACGL_EXTENSION_LOADER_GLEW return GLEW_EXT_texture_filter_anisotropic; #else // if needed define the constants so the code will compile, it @@ -49,7 +49,7 @@ inline bool ACGL_EXT_texture_filter_anisotrophic() { inline bool ACGL_EXT_geometry_shader4() { #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN return (ogl_ext_EXT_geometry_shader4 != ogl_LOAD_FAILED); - #elif ACGL_USE_GLEW + #elif ACGL_EXTENSION_LOADER_GLEW return GLEW_EXT_geometry_shader4; #else return false; @@ -60,7 +60,7 @@ inline bool ACGL_EXT_geometry_shader4() { inline bool ACGL_ARB_geometry_shader4() { #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN return (ogl_ext_ARB_geometry_shader4 != ogl_LOAD_FAILED); - #elif ACGL_USE_GLEW + #elif ACGL_EXTENSION_LOADER_GLEW return GLEW_ARB_geometry_shader4; #else return false; @@ -70,7 +70,7 @@ inline bool ACGL_ARB_geometry_shader4() { inline bool ACGL_ARB_tessellation_shader() { #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN return (ogl_ext_ARB_tessellation_shader != ogl_LOAD_FAILED); - #elif ACGL_USE_GLEW + #elif ACGL_EXTENSION_LOADER_GLEW return GLEW_ARB_tessellation_shader; #else return false; @@ -80,7 +80,7 @@ inline bool ACGL_ARB_tessellation_shader() { inline bool ACGL_ARB_compute_shader() { #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN return (ogl_ext_ARB_compute_shader != ogl_LOAD_FAILED); - #elif ACGL_USE_GLEW + #elif ACGL_EXTENSION_LOADER_GLEW return GLEW_ARB_compute_shader; #else return false; @@ -91,7 +91,7 @@ inline bool ACGL_ARB_compute_shader() { inline bool ACGL_ARB_debug_output() { #ifdef ACGL_EXTENSION_LOADER_GLLOADGEN return (ogl_ext_ARB_debug_output != ogl_LOAD_FAILED); - #elif ACGL_USE_GLEW + #elif ACGL_EXTENSION_LOADER_GLEW return GLEW_ARB_debug_output; #else return false; diff --git a/src/ACGL/ACGL.cc b/src/ACGL/ACGL.cc index 1c3436f..26efa2e 100644 --- a/src/ACGL/ACGL.cc +++ b/src/ACGL/ACGL.cc @@ -14,6 +14,25 @@ namespace ACGL bool init() { + Utils::debug() << "ACGL was compiled for " + #ifdef ACGL_DEBUG + << "debug" << std::endl; + #else + << "release" << std::endl; + #endif + + Utils::debug() << "OpenGL error checking is set to " + #if defined( ACGL_CHECK_NO_GL_ERRORS ) + << "NO checks" << std::endl; + #elif defined( ACGL_CHECK_RARE_GL_ERRORS ) + << "check a lot (for debugging)" << std::endl; + #elif defined( ACGL_CHECK_COMMON_GL_ERRORS ) + << "normal" << std::endl; + #elif defined( ACGL_CHECK_CRITICAL_GL_ERRORS ) + << "only most critical checks" << std::endl; + #endif + + // // init GLEW or own extension loader, do nothing on ES // diff --git a/src/ACGL/HardwareSupport/SpaceNavPollInterface.cc b/src/ACGL/HardwareSupport/SpaceNavPollInterface.cc index 1c3dd66..27f0c71 100644 --- a/src/ACGL/HardwareSupport/SpaceNavPollInterface.cc +++ b/src/ACGL/HardwareSupport/SpaceNavPollInterface.cc @@ -16,10 +16,9 @@ namespace ACGL{ namespace HardwareSupport{ // -// define NO_SPACE_NAVIGATOR_SUPPORT to only build dummy functions for the space nav support -// not needed on linux as the linux library gets loaded at runtime +// define ACGL_SPACE_NAVIGATOR_SUPPORT to build functions for the space nav support // -#if !defined(NO_SPACE_NAVIGATOR_SUPPORT) +#if defined(ACGL_SPACE_NAVIGATOR_SUPPORT) #if defined(__gnu_linux__) #include -- 2.22.2