Commit cb84f5a7 authored by Robert Menzel's avatar Robert Menzel

added debug message in init(), cleaned up external defines, added new gl error checks

parent 53320bc1
......@@ -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)
......@@ -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
......
......@@ -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
*/
......
......@@ -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 <OpenGL/glew.h>
#else
#if defined(__APPLE__) || defined(MACOSX)
#include <OpenGL/glew.h>
#else
#include <GL/glew.h>
#endif
#endif // !GLEW_LOCAL_PATH
#include <GL/glew.h>
#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
......
......@@ -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)
......
......@@ -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;
......
......@@ -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
//
......
......@@ -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 <ACGL/HardwareSupport/mini_spnav.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment