ACGL.hh 4.79 KB
Newer Older
1 2 3 4 5
/***********************************************************************
 * Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
 * All rights reserved.                                                *
 * Distributed under the terms of the MIT License (see LICENSE.TXT).   *
 **********************************************************************/
Robert Menzel's avatar
Robert Menzel committed
6

7 8
#ifndef ACGL_ACGL_HH
#define ACGL_ACGL_HH
Robert Menzel's avatar
Robert Menzel committed
9

Robert Menzel's avatar
Robert Menzel committed
10
/*!
Robert Menzel's avatar
Robert Menzel committed
11 12 13
 * Include this in all ACGL (header)-files. It will include stuff that is used in
 * almost every file:
   * the used datatypes
14
     * including shared/weak pointers!
Robert Menzel's avatar
Robert Menzel committed
15 16
   * macros and defines used at compile-time
   * logging
17 18
 *
 * Also the librarys init function is defined here.
Robert Menzel's avatar
Robert Menzel committed
19 20
 */

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/*!
 * ACGL needs shared and weak pointers that behave like the C++11 smartpointers.
 * The C++11, TR1 and boost variants should all be fine, you can also plug-in
 * your own compatible pointers here.
 *
 * Place them in the ptr:: namespace with aliases.
 *
 * A detection for TR1 is missing, it is assumed that a pre-C++11 compiler has TR1.
 * In case of porting this to a non-C++11/non-TR1 compiler add a check and e.g.
 * add the boost shared and smart pointers:
 *
 * #include <boost...>
 * namespace ptr = boost::tr1;
 *
 * Or roll your own pointers (in this case, add a compileflag and default to the
 * std pointers!):
 *
 * # include <myOwnAwsomeSharedPointer.hh>
 * namespace ptr = ACGL::Base;
 *
 */
Robert Menzel's avatar
Robert Menzel committed
42

43 44 45 46 47 48 49 50 51 52 53 54
// defines a one-macro version number for easy compare functions: e.g. gcc 4.6.2 -> 406020
// see http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers for macros to detect compilers
#if defined(__GNUC__)
# if defined(__GNUC_PATCHLEVEL__)
#  define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
# else
#  define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
# endif
#else
#  define __GNUC_VERSION__ 0
#endif

55 56 57 58 59 60 61 62 63 64 65 66
// defines a one-macro version number for easy compare functions: e.g. gcc 4.6.2 -> 406020
// see http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers for macros to detect compilers
#if defined(__GNUC__)
# if defined(__GNUC_PATCHLEVEL__)
#  define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
# else
#  define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
# endif
#else
#  define __GNUC_VERSION__ 0
#endif

67 68
#if ((__cplusplus >= 201103L) || (__STDC_VERSION__ >= 201112L) || defined(__GXX_EXPERIMENTAL_CXX0X__))
   // last C++11 draft or final C++11 standart or C++11 via -std=c++0x on gcc:
69 70
#  include <memory>
   namespace ptr = std;
71
#  define ACGL_UNIQUE_POINTER_SUPPORTED 1
72 73 74
#  define CORRECT_PTR_INCLUDES_FOUND
#endif

75 76 77 78 79 80 81
#if (defined (__clang__))
// newer llvms on MacOS need this version:
#  include <memory>
namespace ptr = std;
#  define ACGL_UNIQUE_POINTER_SUPPORTED 1
#  define CORRECT_PTR_INCLUDES_FOUND
#endif
82

83
#if (!defined(CORRECT_PTR_INCLUDES_FOUND) && ((__GNUC_VERSION__ >= 40400) ))
84 85 86 87 88 89 90 91 92 93
   // gcc 4.4 or newer without -std=c++0x or clang++
#  include <tr1/memory>
   namespace ptr = std::tr1;
#  define ACGL_UNIQUE_POINTER_SUPPORTED 0
#  define CORRECT_PTR_INCLUDES_FOUND
#endif


#if (!defined(CORRECT_PTR_INCLUDES_FOUND) && (_MSC_VER >= 1600))
   // VStudio 2010 supports some C++11 features
94 95 96
#  include <memory>
   namespace ptr = std;
#  define ACGL_UNIQUE_POINTER_SUPPORTED 1
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
#  define CORRECT_PTR_INCLUDES_FOUND
#endif
   
   
#if (!defined(CORRECT_PTR_INCLUDES_FOUND) && (_MSC_VER >= 1500))
   // VStudio 2008 supports some C++11 features
#  include <memory>
   namespace ptr = std::tr1;
#  define ACGL_UNIQUE_POINTER_SUPPORTED 0
#  define CORRECT_PTR_INCLUDES_FOUND
#endif


#if (!defined(CORRECT_PTR_INCLUDES_FOUND) && defined(__INTEL_COMPILER))
   // intel icpc
#  include <memory>
   namespace ptr = std;
#  define ACGL_UNIQUE_POINTER_SUPPORTED 0
#  define CORRECT_PTR_INCLUDES_FOUND
116 117
#endif

118 119 120 121 122 123 124 125 126 127 128 129

#if (!defined CORRECT_PTR_INCLUDES_FOUND)
   // guessing is needed
#  warning "can't detect C++ version or shared pointer variant supported by this compiler -> guessing"
   // hope for TR1 equivalents
#  include <tr1/memory>
   namespace ptr = std::tr1;
#  define ACGL_UNIQUE_POINTER_SUPPORTED 0
#endif



Robert Menzel's avatar
Robert Menzel committed
130
#include <ACGL/Base/CompileTimeSettings.hh>
131
#include <ACGL/Base/Macros.hh>
Robert Menzel's avatar
Robert Menzel committed
132 133 134 135 136 137
#include <ACGL/Types.hh>
#include <ACGL/Utils/Log.hh>

namespace ACGL
{

138 139
/*
 * This should get called as soon as a valid OpenGL context exists,
140
 * it will init glew (if used) or the internal GL function loader.
141 142
 * Call this before calling any OpenGL functions or OpenGL related
 * ACGL stuff.
143 144 145
 *
 * Returns false if a critical error occured, in that case the ACGL behavior is
 * not defined.
146 147 148 149
 *
 * parameter forDebugging: if true, register a debug callback for OpenGL and simulate
 * a debug context (slow) in case the application is not running in a native debug
 * context.
150
 */
151
bool init( bool forceDebuggingContext = true );
Robert Menzel's avatar
Robert Menzel committed
152
    
153
}
Robert Menzel's avatar
Robert Menzel committed
154

155
#endif // ACGL_ACGL_HH
Robert Menzel's avatar
Robert Menzel committed
156