Open3D (C++ API)  0.18.0+5c982c7
GLHelper.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Avoid warning caused by redefinition of APIENTRY macro
11 // defined also in glfw3.h
12 #ifdef _WIN32
13 #include <windows.h>
14 #endif
15 
16 #include <GL/glew.h> // Make sure glew.h is included before gl.h
17 #include <GLFW/glfw3.h>
18 
19 #include <Eigen/Core>
20 #include <string>
21 #include <unordered_map>
22 
23 namespace open3d {
24 namespace visualization {
25 namespace gl_util {
26 
27 const static std::unordered_map<int, GLenum> texture_format_map_ = {
28  {1, GL_RED}, {3, GL_RGB}, {4, GL_RGBA}};
29 const static std::unordered_map<int, GLenum> texture_type_map_ = {
30  {1, GL_UNSIGNED_BYTE}, {2, GL_UNSIGNED_SHORT}, {4, GL_FLOAT}};
31 
32 typedef Eigen::Matrix<GLfloat, 3, 1, Eigen::ColMajor> GLVector3f;
33 typedef Eigen::Matrix<GLfloat, 4, 1, Eigen::ColMajor> GLVector4f;
34 typedef Eigen::Matrix<GLfloat, 4, 4, Eigen::ColMajor> GLMatrix4f;
35 
36 GLMatrix4f LookAt(const Eigen::Vector3d &eye,
37  const Eigen::Vector3d &lookat,
38  const Eigen::Vector3d &up);
39 
40 GLMatrix4f Perspective(double field_of_view_,
41  double aspect,
42  double z_near,
43  double z_far);
44 
45 GLMatrix4f Ortho(double left,
46  double right,
47  double bottom,
48  double top,
49  double z_near,
50  double z_far);
51 
52 Eigen::Vector3d Project(const Eigen::Vector3d &point,
53  const GLMatrix4f &mvp_matrix,
54  const int width,
55  const int height);
56 
57 Eigen::Vector3d Unproject(const Eigen::Vector3d &screen_point,
58  const GLMatrix4f &mvp_matrix,
59  const int width,
60  const int height);
61 
62 int ColorCodeToPickIndex(const Eigen::Vector4i &color);
63 
64 } // namespace gl_util
65 } // namespace visualization
66 } // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:45
int width
Definition: FilePCD.cpp:52
int height
Definition: FilePCD.cpp:53
GLMatrix4f Ortho(double left, double right, double bottom, double top, double z_near, double z_far)
Definition: GLHelper.cpp:51
Eigen::Matrix< GLfloat, 4, 4, Eigen::ColMajor > GLMatrix4f
Definition: GLHelper.h:34
GLMatrix4f Perspective(double field_of_view_, double aspect, double z_near, double z_far)
Definition: GLHelper.cpp:36
int ColorCodeToPickIndex(const Eigen::Vector4i &color)
Definition: GLHelper.cpp:99
Eigen::Matrix< GLfloat, 4, 1, Eigen::ColMajor > GLVector4f
Definition: GLHelper.h:33
Eigen::Matrix< GLfloat, 3, 1, Eigen::ColMajor > GLVector3f
Definition: GLHelper.h:32
Eigen::Vector3d Project(const Eigen::Vector3d &point, const GLMatrix4f &mvp_matrix, const int width, const int height)
Definition: GLHelper.cpp:68
Eigen::Vector3d Unproject(const Eigen::Vector3d &screen_point, const GLMatrix4f &mvp_matrix, const int width, const int height)
Definition: GLHelper.cpp:83
GLMatrix4f LookAt(const Eigen::Vector3d &eye, const Eigen::Vector3d &lookat, const Eigen::Vector3d &up)
Definition: GLHelper.cpp:17
Definition: PinholeCameraIntrinsic.cpp:16