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
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
M_PI
constexpr double M_PI
Pi.
Definition: CVConst.h:19
knncpp::Vector4i
Eigen::Matrix< Index, 4, 1 > Vector4i
Definition: knncpp.h:31
cloudViewer::visualization::gl_util::GetTextureFormatMap
const std::unordered_map< int, unsigned int > & GetTextureFormatMap()
Definition: GLHelper.cpp:23
cloudViewer::visualization::gl_util::Project
Eigen::Vector3d Project(const Eigen::Vector3d &point, const GLMatrix4f &mvp_matrix, const int width, const int height)
Definition: GLHelper.cpp:82
cloudViewer::visualization::gl_util::texture_format_map_
static const std::unordered_map< int, unsigned int > texture_format_map_
Definition: GLHelper.cpp:17
cloudViewer::visualization::gl_util::Ortho
GLMatrix4f Ortho(double left, double right, double bottom, double top, double z_near, double z_far)
Definition: GLHelper.cpp:65
color
math::float4 color
Definition: LineSetBuffers.cpp:46
width
int width
Definition: FileIOFactory.cpp:142
cloudViewer::visualization::gl_util::texture_type_map_
static const std::unordered_map< int, unsigned int > texture_type_map_
Definition: GLHelper.cpp:20
cloudViewer::visualization::gl_util::GLMatrix4f
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > GLMatrix4f
Definition: GLHelper.h:35
height
int height
Definition: FileIOFactory.cpp:143
cloudViewer::visualization::gl_util::GLVector3f
Eigen::Matrix< float, 3, 1, Eigen::ColMajor > GLVector3f
Definition: GLHelper.h:33
cloudViewer::visualization::gl_util::GLVector4f
Eigen::Matrix< float, 4, 1, Eigen::ColMajor > GLVector4f
Definition: GLHelper.h:34
cloudViewer::visualization::gl_util::LookAt
GLMatrix4f LookAt(const Eigen::Vector3d &eye, const Eigen::Vector3d &lookat, const Eigen::Vector3d &up)
Definition: GLHelper.cpp:31
cloudViewer::visualization::gl_util::Unproject
Eigen::Vector3d Unproject(const Eigen::Vector3d &screen_point, const GLMatrix4f &mvp_matrix, const int width, const int height)
Definition: GLHelper.cpp:97
cloudViewer::visualization::gl_util::GetTextureTypeMap
const std::unordered_map< int, unsigned int > & GetTextureTypeMap()
Definition: GLHelper.cpp:27
GLHelper.h
cloudViewer::visualization::gl_util::Perspective
GLMatrix4f Perspective(double field_of_view_, double aspect, double z_near, double z_far)
Definition: GLHelper.cpp:50
cloudViewer::visualization::gl_util::ColorCodeToPickIndex
int ColorCodeToPickIndex(const Eigen::Vector4i &color)
Definition: GLHelper.cpp:113