ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
GLHelper.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.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 cloudViewer {
24 namespace visualization {
25 namespace gl_util {
26 
27 // static std::unordered_map<int, unsigned int> GetTextureFormatMap();
28 // static std::unordered_map<int, unsigned int> GetTextureTypeMap();
29 
30 const std::unordered_map<int, unsigned int> &GetTextureFormatMap();
31 const std::unordered_map<int, unsigned int> &GetTextureTypeMap();
32 
33 typedef Eigen::Matrix<float, 3, 1, Eigen::ColMajor> GLVector3f;
34 typedef Eigen::Matrix<float, 4, 1, Eigen::ColMajor> GLVector4f;
35 typedef Eigen::Matrix<float, 4, 4, Eigen::ColMajor> GLMatrix4f;
36 
37 GLMatrix4f LookAt(const Eigen::Vector3d &eye,
38  const Eigen::Vector3d &lookat,
39  const Eigen::Vector3d &up);
40 
41 GLMatrix4f Perspective(double field_of_view_,
42  double aspect,
43  double z_near,
44  double z_far);
45 
46 GLMatrix4f Ortho(double left,
47  double right,
48  double bottom,
49  double top,
50  double z_near,
51  double z_far);
52 
53 Eigen::Vector3d Project(const Eigen::Vector3d &point,
54  const GLMatrix4f &mvp_matrix,
55  const int width,
56  const int height);
57 
58 Eigen::Vector3d Unproject(const Eigen::Vector3d &screen_point,
59  const GLMatrix4f &mvp_matrix,
60  const int width,
61  const int height);
62 
64 
65 } // namespace gl_util
66 } // namespace visualization
67 } // namespace cloudViewer
int width
int height
math::float4 color
GLMatrix4f LookAt(const Eigen::Vector3d &eye, const Eigen::Vector3d &lookat, const Eigen::Vector3d &up)
Definition: GLHelper.cpp:31
const std::unordered_map< int, unsigned int > & GetTextureTypeMap()
Definition: GLHelper.cpp:27
GLMatrix4f Perspective(double field_of_view_, double aspect, double z_near, double z_far)
Definition: GLHelper.cpp:50
Eigen::Matrix< float, 4, 1, Eigen::ColMajor > GLVector4f
Definition: GLHelper.h:34
const std::unordered_map< int, unsigned int > & GetTextureFormatMap()
Definition: GLHelper.cpp:23
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > GLMatrix4f
Definition: GLHelper.h:35
Eigen::Vector3d Unproject(const Eigen::Vector3d &screen_point, const GLMatrix4f &mvp_matrix, const int width, const int height)
Definition: GLHelper.cpp:97
Eigen::Vector3d Project(const Eigen::Vector3d &point, const GLMatrix4f &mvp_matrix, const int width, const int height)
Definition: GLHelper.cpp:82
Eigen::Matrix< float, 3, 1, Eigen::ColMajor > GLVector3f
Definition: GLHelper.h:33
int ColorCodeToPickIndex(const Eigen::Vector4i &color)
Definition: GLHelper.cpp:113
GLMatrix4f Ortho(double left, double right, double bottom, double top, double z_near, double z_far)
Definition: GLHelper.cpp:65
Generic file read and write utility for python interface.
Eigen::Matrix< Index, 4, 1 > Vector4i
Definition: knncpp.h:31
Definition: lsd.c:149