tango-gl/include/tango-gl/util.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef TANGO_GL_GL_UTIL_H_
18 #define TANGO_GL_GL_UTIL_H_
19 #define GLM_FORCE_RADIANS
20 
21 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
22 
23 #include <stdlib.h>
24 #ifdef __ANDROID__
25 #include <jni.h>
26 #include <android/log.h>
27 #include <GLES2/gl2.h>
28 #include <GLES2/gl2ext.h>
29 #else // __APPLE__
30 #include <OpenGLES/ES2/gl.h>
31 #include <OpenGLES/ES2/glext.h>
32 #include <syslog.h>
33 #endif
34 
35 #include "glm/glm.hpp"
37 #include "glm/gtc/quaternion.hpp"
38 #include "glm/gtc/type_ptr.hpp"
40 
41 #define LOG_TAG "rtabmap"
42 #if defined(DISABLE_LOG)
43 #define LOGD(...) ;
44 #define LOGI(...) ;
45 #define LOGW(...) ;
46 #else
47 #ifdef __APPLE__
48 #define LOGD(...) fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n")
49 #define LOGI(...) fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n")
50 #define LOGW(...) fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n")
51 #else
52 #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
53 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
54 #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
55 #endif
56 #endif
57 #ifdef __APPLE__
58 #define LOGE(...) fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n")
59 #define LOGF(...) fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n")
60 #else
61 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
62 #define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,LOG_TAG,__VA_ARGS__)
63 #endif
64 
65 #ifndef M_PI
66 #define M_PI 3.1415926f
67 #endif
68 
69 #define RADIAN_2_DEGREE 57.2957795f
70 #define DEGREE_2_RADIANS 0.0174532925f
71 
72 namespace tango_gl {
73 namespace util {
74  void CheckGlError(const char* operation);
75 
76  GLuint CreateProgram(const char* vertex_source,
77  const char* fragment_source);
78 
79  void DecomposeMatrix(const glm::mat4& transform_mat,
82  glm::vec3& scale);
83 
84  // Get a 3x1 column from the upper 3x4 of a transformation matrix. Columns
85  // 0, 1, 2 are the rotation/scale portion, and column 3 is the translation.
86  glm::vec3 GetColumnFromMatrix(const glm::mat4& mat, const int col);
87 
88  // Get the translation component of a transformation matrix.
90 
91  float Clamp(float value, float min, float max);
92  void PrintMatrix(const glm::mat4& matrix);
93  void PrintVector(const glm::vec3& vector);
94  void PrintQuaternion(const glm::quat& quat);
95 
96  glm::vec3 LerpVector(const glm::vec3& x, const glm::vec3& y, float a);
97  float DistanceSquared(const glm::vec3& v1, const glm::vec3& v2);
98 
99  bool SegmentAABBIntersect(const glm::vec3& aabb_min, const glm::vec3& aabb_max,
100  const glm::vec3& start, const glm::vec3& end);
101 
102  glm::vec3 ApplyTransform(const glm::mat4& mat, const glm::vec3& vec);
103 
104 } // namespace util
105 } // namespace tango_gl
106 #endif // TANGO_GL_RENDERER_GL_UTIL
glm::min
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
tango_gl::util::PrintQuaternion
void PrintQuaternion(const glm::quat &quat)
Definition: util.cpp:184
tango_gl::util::PrintVector
void PrintVector(const glm::vec3 &vector)
Definition: util.cpp:179
tango_gl::util::DecomposeMatrix
void DecomposeMatrix(const glm::mat4 &transform_mat, glm::vec3 &translation, glm::quat &rotation, glm::vec3 &scale)
Definition: util.cpp:115
v1
v1
tango_gl::util::ApplyTransform
glm::vec3 ApplyTransform(const glm::mat4 &mat, const glm::vec3 &vec)
Definition: util.cpp:237
glm.hpp
matrix_decompose.hpp
glm::quat
highp_quat quat
Quaternion of default single-precision floating-point numbers.
Definition: fwd.hpp:68
tango_gl::util::CheckGlError
void CheckGlError(const char *operation)
Definition: util.cpp:43
matrix_transform.hpp
end
end
col
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ColXpr col(Index i) const
y
Matrix3f y
tango_gl::util::PrintMatrix
void PrintMatrix(const glm::mat4 &matrix)
Definition: util.cpp:170
glm::detail::tquat
Definition: fwd.hpp:41
glm::detail::tvec3
Definition: type_mat.hpp:37
glm::detail::tmat4x4
Definition: type_mat.hpp:47
quaternion.hpp
tango_gl::util::SegmentAABBIntersect
bool SegmentAABBIntersect(const glm::vec3 &aabb_min, const glm::vec3 &aabb_max, const glm::vec3 &start, const glm::vec3 &end)
Definition: util.cpp:198
translation
translation
GLuint
unsigned int GLuint
Definition: dummy.cpp:78
scale
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics scale
tango_gl::util::CreateProgram
GLuint CreateProgram(const char *vertex_source, const char *fragment_source)
Definition: util.cpp:75
glm::max
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
x
x
a
ArrayXXi a
glm::rotation
GLM_FUNC_DECL detail::tquat< T, P > rotation(detail::tvec3< T, P > const &orig, detail::tvec3< T, P > const &dest)
tango_gl::util::Clamp
float Clamp(float value, float min, float max)
Definition: util.cpp:165
type_ptr.hpp
tango_gl
Definition: axis.cpp:20
matrix
Map< const Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(const T *data, int rows, int cols, int stride)
tango_gl::util::GetTranslationFromMatrix
glm::vec3 GetTranslationFromMatrix(const glm::mat4 &mat)
Definition: util.cpp:161
value
value
tango_gl::util::GetColumnFromMatrix
glm::vec3 GetColumnFromMatrix(const glm::mat4 &mat, const int col)
Definition: util.cpp:157
tango_gl::util::DistanceSquared
float DistanceSquared(const glm::vec3 &v1, const glm::vec3 &v2)
Definition: util.cpp:193
mat
else mat
tango_gl::util::LerpVector
glm::vec3 LerpVector(const glm::vec3 &x, const glm::vec3 &y, float a)
Definition: util.cpp:189
v2
v2


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jul 1 2024 02:42:40