Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
GlTools.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef GLTOOLS_H
22#define GLTOOLS_H
23#ifndef DOXYGEN_NOTFOR_DEVEL
24#include <tulip/tulipconf.h>
25#include <tulip/Color.h>
26#include <tulip/Coord.h>
27#include <tulip/Size.h>
28#include <tulip/Matrix.h>
29
30#include <tulip/OpenGlIncludes.h>
31
32namespace tlp {
33
34struct BoundingBox;
35
36typedef Matrix<float, 4> MatrixGL;
37TLP_GL_SCOPE const std::string &glGetErrorDescription(GLuint errorCode);
38TLP_GL_SCOPE void glTest(const std::string &message = std::string("(no description)"),
39 int line = -1, bool throwException = true);
40#ifndef NDEBUG
41#define GL_TEST(throwEx) glTest(__FILE__, __LINE__, throwEx)
42#define GL_TEST_ERROR() GL_TEST(false)
43#define GL_THROW_ON_ERROR() GL_TEST(true)
44#else
45#define GL_TEST(throwEx)
46#define GL_TEST_ERROR()
47#define GL_THROW_ON_ERROR()
48#endif
49TLP_GL_SCOPE void setColor(const Color &c);
50TLP_GL_SCOPE void setColor(GLfloat *);
51TLP_GL_SCOPE void setMaterial(const Color &c);
52TLP_GL_SCOPE bool cameraIs3D();
53/*
54 * Project point on screen according to the transformation matrix (modelview * projection)
55 * and the viewport (x, y, width, height) given in parameter.
56 */
57TLP_GL_SCOPE Coord projectPoint(const Coord &obj, const MatrixGL &, const Vector<int, 4> &viewport);
58/*
59 * UnProject point from screen to 3D world according to the inverse transformation matrix (modelview
60 * * projection)^-1
61 * and the viewport (x, y, width, height) given in parameter.
62 */
63TLP_GL_SCOPE Coord unprojectPoint(const Coord &obj, const MatrixGL &,
64 const tlp::Vector<int, 4> &viewport);
65TLP_GL_SCOPE GLfloat projectSize(const BoundingBox &bb, const MatrixGL &, const MatrixGL &,
66 const Vector<int, 4> &viewport);
67TLP_GL_SCOPE GLfloat projectSize(const Coord &position, const Size &size, const MatrixGL &,
68 const MatrixGL &, const Vector<int, 4> &viewport);
69TLP_GL_SCOPE float calculateAABBSize(const BoundingBox &bb, const Coord &eye,
70 const Matrix<float, 4> &transformMatrix,
71 const Vector<int, 4> &globalViewport,
72 const Vector<int, 4> &currentViewport);
73TLP_GL_SCOPE float calculate2DLod(const BoundingBox &bb, const Vector<int, 4> &globalViewport,
74 const Vector<int, 4> &currentViewport);
75
76/**
77 * Computes the normals associated to the vertices of a triangulated mesh.
78 *
79 * @since Tulip 4.8
80 *
81 * @param vertices a vector containing the vertices to compute associated normals
82 * @param facesIndices a vector containing the unsigned short indices of the triangles faces (its
83 * size must be a multiple of 3)
84 * @return a vector, with the same size as the one holding vertices, filled with the computed
85 * normals
86 *
87 */
88TLP_GL_SCOPE std::vector<Coord> computeNormals(const std::vector<Coord> &vertices,
89 const std::vector<unsigned short> &facesIndices);
90
91/**
92 * Computes the normals associated to the vertices of a triangulated mesh.
93 *
94 * @since Tulip 4.8
95 *
96 * @param vertices a vector containing the vertices to compute associated normals
97 * @param facesIndices a vector containing the unsigned int indices of the triangles faces (its size
98 * must be a multiple of 3)
99 * @return a vector, with the same size as the one holding vertices, filled with the computed
100 * normals
101 *
102 */
103TLP_GL_SCOPE std::vector<Coord> computeNormals(const std::vector<Coord> &vertices,
104 const std::vector<unsigned int> &facesIndices);
105
106TLP_GL_SCOPE void tesselateFontIcon(const std::string &fontFile, unsigned int iconCodePoint,
107 GLuint &renderingDataBuffer, GLuint &indicesBuffer,
108 unsigned int &nbVertices, unsigned int &nbIndices,
109 unsigned int &nbOutlineIndices, BoundingBox &boundingBox);
110} // namespace tlp
111
112#endif // DOXYGEN_NOTFOR_DEVEL
113#endif
114///@endcond