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 #include <jni.h>
25 #include <android/log.h>
26 #include <GLES2/gl2.h>
27 #include <GLES2/gl2ext.h>
28 #include <tango_support_api.h>
29 
30 #include "glm/glm.hpp"
32 #include "glm/gtc/quaternion.hpp"
33 #include "glm/gtc/type_ptr.hpp"
35 
36 #define LOG_TAG "rtabmap"
37 #ifdef DISABLE_LOG
38 #define LOGD(...) ;
39 #define LOGI(...) ;
40 #define LOGW(...) ;
41 #else
42 #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
43 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
44 #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
45 #endif
46 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
47 
48 #ifndef M_PI
49 #define M_PI 3.1415926f
50 #endif
51 
52 #define RADIAN_2_DEGREE 57.2957795f
53 #define DEGREE_2_RADIANS 0.0174532925f
54 
55 namespace tango_gl {
56 namespace util {
57  void CheckGlError(const char* operation);
58 
59  GLuint CreateProgram(const char* vertex_source,
60  const char* fragment_source);
61 
62  void DecomposeMatrix(const glm::mat4& transform_mat,
63  glm::vec3& translation,
65  glm::vec3& scale);
66 
67  // Get a 3x1 column from the upper 3x4 of a transformation matrix. Columns
68  // 0, 1, 2 are the rotation/scale portion, and column 3 is the translation.
69  glm::vec3 GetColumnFromMatrix(const glm::mat4& mat, const int col);
70 
71  // Get the translation component of a transformation matrix.
73 
74  float Clamp(float value, float min, float max);
75  void PrintMatrix(const glm::mat4& matrix);
76  void PrintVector(const glm::vec3& vector);
77  void PrintQuaternion(const glm::quat& quat);
78 
79  glm::vec3 LerpVector(const glm::vec3& x, const glm::vec3& y, float a);
80  float DistanceSquared(const glm::vec3& v1, const glm::vec3& v2);
81 
82  bool SegmentAABBIntersect(const glm::vec3& aabb_min, const glm::vec3& aabb_max,
83  const glm::vec3& start, const glm::vec3& end);
84 
85  glm::vec3 ApplyTransform(const glm::mat4& mat, const glm::vec3& vec);
86 
87  // Get the Android rotation integer value from color camera to display.
88  // This function is used to compute the orientation difference to handle
89  // the portrait and landscape mode for color camera display.
90  //
91  // @param display: integer value of display orientation, values available
92  // are 0, 1, 2 ,3. Followed by Android display orientation standard:
93  // https://developer.android.com/reference/android/view/Display.html#getRotation()
94  // @param color_camera: integer value of color camera oreintation, values
95  // available are 0, 90, 180, 270. Followed by Android camera orientation
96  // standard:
97  // https://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation
98  TangoSupportRotation GetAndroidRotationFromColorCameraToDisplay(
99  int display_rotation, int color_camera_rotation);
100 
101  // Get the Android rotation integer value from color camera to display.
102  // This function is used to compute the orientation difference to handle
103  // the portrait and landscape mode for color camera display.
104  //
105  // @param display: the device display orientation.
106  // @param color_camera: integer value of color camera oreintation, values
107  // available are 0, 90, 180, 270. Followed by Android camera orientation
108  // standard:
109  // https://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation
110  TangoSupportRotation GetAndroidRotationFromColorCameraToDisplay(
111  TangoSupportRotation display_rotation, int color_camera_rotation);
112 
113 } // namespace util
114 } // namespace tango_gl
115 #endif // TANGO_GL_RENDERER_GL_UTIL
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
glm::vec3 GetTranslationFromMatrix(const glm::mat4 &mat)
Definition: util.cpp:161
void PrintQuaternion(const glm::quat &quat)
Definition: util.cpp:184
highp_quat quat
Quaternion of default single-precision floating-point numbers.
Definition: fwd.hpp:68
GLM_FUNC_DECL detail::tmat4x4< T, P > scale(detail::tmat4x4< T, P > const &m, detail::tvec3< T, P > const &v)
GLuint CreateProgram(const char *vertex_source, const char *fragment_source)
Definition: util.cpp:75
unsigned int GLuint
Definition: dummy.cpp:78
float DistanceSquared(const glm::vec3 &v1, const glm::vec3 &v2)
Definition: util.cpp:193
TangoSupportRotation GetAndroidRotationFromColorCameraToDisplay(int display_rotation, int color_camera_rotation)
Definition: util.cpp:241
void PrintMatrix(const glm::mat4 &matrix)
Definition: util.cpp:170
glm::vec3 ApplyTransform(const glm::mat4 &mat, const glm::vec3 &vec)
Definition: util.cpp:237
float Clamp(float value, float min, float max)
Definition: util.cpp:165
glm::vec3 LerpVector(const glm::vec3 &x, const glm::vec3 &y, float a)
Definition: util.cpp:189
GLM_FUNC_DECL detail::tquat< T, P > rotation(detail::tvec3< T, P > const &orig, detail::tvec3< T, P > const &dest)
void PrintVector(const glm::vec3 &vector)
Definition: util.cpp:179
void CheckGlError(const char *operation)
Definition: util.cpp:43
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
glm::vec3 GetColumnFromMatrix(const glm::mat4 &mat, const int col)
Definition: util.cpp:157
bool SegmentAABBIntersect(const glm::vec3 &aabb_min, const glm::vec3 &aabb_max, const glm::vec3 &start, const glm::vec3 &end)
Definition: util.cpp:198
void DecomposeMatrix(const glm::mat4 &transform_mat, glm::vec3 &translation, glm::quat &rotation, glm::vec3 &scale)
Definition: util.cpp:115


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:43:40