CG_Labs  2021.2
opengl.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <glad/glad.h>
4 #include <GLFW/glfw3.h>
5 
6 #include <string>
7 #include <vector>
8 
9 
10 namespace utils
11 {
12 
13 namespace opengl
14 {
15 
16 namespace debug
17 {
18 
19 bool isSupported();
20 std::string getStringForType(GLenum type);
21 std::string getStringForSource(GLenum source);
22 std::string getStringForSeverity(GLenum severity);
23 
35 void beginDebugGroup(std::string const& message, GLuint id = 0u);
36 
40 void endDebugGroup();
41 
53 void nameObject(GLenum type, GLuint id, std::string const& label);
54 
55 void
56 #ifdef _WIN32
57 APIENTRY
58 #endif
59 opengl_error_callback( GLenum source, GLenum type, GLuint id
60  , GLenum severity, GLsizei /*length*/
61  , GLchar const* msg, void const* /*data*/
62  );
63 
64 } // end of namespace debug
65 
66 namespace shader
67 {
68 
69 bool source_and_build_shader(GLuint id, std::string const& source);
70 GLuint generate_shader(GLenum type, std::string const& source);
71 bool link_program(GLuint id);
72 void reload_program(GLuint id, std::vector<GLuint> const& ids, std::vector<std::string> const& sources);
73 GLuint generate_program(std::vector<GLuint> const& shaders_id);
74 
75 } // end of namespace shader
76 
77 namespace fullscreen
78 {
79 
80 void init(std::string const& vs_path, std::string const& fs_path, size_t width, size_t height);
81 void deinit();
82 void draw();
83 GLuint get_texture_id();
84 
85 } // end of namespace fullscreen
86 
87 } // end of namespace opengl
88 
89 } // end of namespace utils
GLuint shader
Definition: helpers.cpp:23
void beginDebugGroup(std::string const &message, GLuint id)
Start a new debug group.
Definition: opengl.cpp:97
std::string getStringForSeverity(GLenum severity)
Definition: opengl.cpp:79
bool isSupported()
Definition: opengl.cpp:21
void nameObject(GLenum type, GLuint id, std::string const &label)
Label an OpenGL object with a custon string.
Definition: opengl.cpp:115
std::string getStringForSource(GLenum source)
Definition: opengl.cpp:56
std::string getStringForType(GLenum type)
Definition: opengl.cpp:27
void opengl_error_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei, GLchar const *msg, void const *)
Definition: opengl.cpp:127
void endDebugGroup()
End the most recently-started debug group.
Definition: opengl.cpp:106
void deinit()
Definition: opengl.cpp:331
void init(std::string const &vs_path, std::string const &fs_path, size_t width, size_t height)
Definition: opengl.cpp:287
GLuint get_texture_id()
Definition: opengl.cpp:366
void draw()
Definition: opengl.cpp:372
void reload_program(GLuint id, std::vector< GLuint > const &ids, std::vector< std::string > const &sources)
Definition: opengl.cpp:251
bool source_and_build_shader(GLuint id, std::string const &source)
Definition: opengl.cpp:168
GLuint generate_program(std::vector< GLuint > const &shaders_id)
Definition: opengl.cpp:260
bool link_program(GLuint id)
Definition: opengl.cpp:219
GLuint generate_shader(GLenum type, std::string const &source)
Definition: opengl.cpp:205
Definition: opengl.cpp:13