GPU-Accelerated Coverage  0.1.0
Compute coverage tours for known environment with articulated objects on GPU
Utilities.h
1 /*
2  * Copyright (c) 2018, Stefan Osswald
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef INCLUDE_ARTICULATION_UTILITIES_H_
32 #define INCLUDE_ARTICULATION_UTILITIES_H_
33 
34 #include <cstdio>
35 #include <exception>
36 #include <cstring>
37 #include <string>
38 #include GL_INCLUDE
39 
40 #if HAS_GLES
41 #define glPolygonMode(...)
42 #define glPushDebugGroup(...)
43 #define glPopDebugGroup(...)
44 #define GL_FILL 0x1B02
45 #endif
46 
47 #define GET_API(FRAMEWORK) FRAMEWORK##_##OPENGL_API
48 
49 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
50 
51 #ifdef __ANDROID__
52 #include <android/log.h>
53 #define logInfo(FORMAT, ...) ((void)__android_log_print(ANDROID_LOG_INFO, "articulation", "%s:%d: " FORMAT, __FILENAME__, __LINE__, ##__VA_ARGS__))
54 #define logWarn(FORMAT, ...) ((void)__android_log_print(ANDROID_LOG_WARN, "articulation", "%s:%d: " FORMAT, __FILENAME__, __LINE__, ##__VA_ARGS__))
55 #define logError(FORMAT, ...) ((void)__android_log_print(ANDROID_LOG_ERROR, "articulation", "%s:%d: " FORMAT, __FILENAME__, __LINE__, ##__VA_ARGS__))
56 #else
57 #define logInfo(FORMAT, ...) fprintf(stdout, "[INFO] %s:%d: " FORMAT "\n", __FILENAME__, __LINE__, ##__VA_ARGS__)
58 #define logWarn(FORMAT, ...) fprintf(stderr, "[WARN] %s:%d: " FORMAT "\n", __FILENAME__, __LINE__, ##__VA_ARGS__)
59 #define logError(FORMAT, ...) fprintf(stderr, "[ERR ] %s:%d: " FORMAT "\n", __FILENAME__, __LINE__, ##__VA_ARGS__)
60 #endif
61 
62 namespace gpu_coverage {
63 
67 class GLException: public std::exception {
68 public:
75  GLException(const GLenum code, const char * const file, const int line);
79  virtual ~GLException() throw ();
84  const char* what() const throw ();
85 
86 protected:
87  const GLenum code;
88  std::string text;
89 };
90 
99 void doCheckGLError(const char * const file, const int line);
100 #ifndef checkGLError
101 #ifdef DEBUG
102 #define checkGLError() doCheckGLError(__FILE__, __LINE__)
103 #else
104 #define checkGLError()
105 #endif
106 #endif
107 
108 } /* namespace gpu_coverage */
109 
110 #endif /* INCLUDE_ARTICULATION_UTILITIES_H_ */
const GLenum code
OpenGL error code.
Definition: Utilities.h:87
Custom OpenGL exception.
Definition: Utilities.h:67
const char * what() const
Returns the human-readable description of the error.
GLException(const GLenum code, const char *const file, const int line)
Constructor.
Definition: AbstractCamera.h:41
std::string text
Description string.
Definition: Utilities.h:88
virtual ~GLException()
Destructor.