Debian Codegraph @

utils/fgpanel/GL_utils.hxx

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2016 Gaetan Allaert
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <boost/utility.hpp>
7 #include <stack>
8
9 #if defined (SG_MAC)
10 #include <OpenGL/gl.h>
11 #elif defined (_GLES2)
12 #include <GLES2/gl2.h>
13 #else
14 #include <GL/glew.h> // Must be included before <GL/gl.h>
15 #include <GL/gl.h>
16 #endif
17
18
19 class GL_utils : private boost::noncopyable {
20 public:
21 static GL_utils& instance ();
22
23 enum GLenum_Mode {
24 GL_UTILS_MODELVIEW,
25 GL_UTILS_PROJECTION,
26 GL_UTILS_TEXTURE,
27 GL_UTILS_COLOR,
28 GL_UTILS_LAST,
29 GL_UTILS_UNSET
30 };
31
32 GLuint load_program (const char *vert_shader_src, const char *frag_shader_src);
33
34 void glMatrixMode (const GL_utils::GLenum_Mode mode);
35 void glLoadIdentity ();
36 void gluOrtho2D (const GLfloat left,
37 const GLfloat right,
38 const GLfloat bottom,
39 const GLfloat top);
40 void glOrtho (const GLfloat left,
41 const GLfloat right,
42 const GLfloat bottom,
43 const GLfloat top,
44 const GLfloat nearVal,
45 const GLfloat farVal);
46 void glTranslatef (const GLfloat x, const GLfloat y, const GLfloat z);
47 void glRotatef (const GLfloat angle, const GLfloat x, const GLfloat y, const GLfloat z);
48 void glScalef (const GLfloat x, const GLfloat y, const GLfloat z);
49 // C' = C X M
50 void glMultMatrixf (const GLfloat m[4][4]);
51 void glPushMatrix ();
52 void glPopMatrix ();
53 GLfloat* get_top_matrix (const GL_utils::GLenum_Mode mode);
54 void Debug (const GL_utils::GLenum_Mode mode) const;
55
56 private:
57 explicit GL_utils ();
58 virtual ~GL_utils ();
59
60 GLuint load_shader (GLenum type, const char *shader_src);
61
62 typedef struct {
63 GLfloat m[4][4];
64 } Matrix;
65
66 std::stack <Matrix> m_Matrix[GL_UTILS_LAST];
67 GLenum_Mode m_Current_Matrix_Mode;
68 };