Sparkle 0.0.1
Loading...
Searching...
No Matches
spk_program.hpp
1#pragma once
2
3#include "structure/design_pattern/spk_activable_object.hpp"
4#include "structure/design_pattern/spk_cached_data.hpp"
5#include "structure/opengl/spk_opengl_includes.hpp"
6#include "utils/spk_opengl_utils.hpp"
7#include <stdexcept>
8#include <string>
9#include <utility>
10
11namespace spk
12{
13 namespace OpenGL
14 {
26 class Program : public spk::ActivableObject
27 {
28 private:
30 std::string _vertexShaderCode;
31 std::string _fragmentShaderCode;
32
33 void _registerCallbacks();
34 GLuint _buildProgram() const;
35
36 public:
37 Program();
43 Program(std::string p_vertexShaderCode, std::string p_fragmentShaderCode);
44
49 Program(const Program &p_other);
55 Program &operator=(const Program &p_other);
56 Program(Program &&) = delete;
57 Program &operator=(Program &&) = delete;
58
63 GLuint id() const;
64
70 void render(GLsizei p_nbIndexes, GLsizei p_nbInstance);
77 void renderIndirect(GLintptr p_commandOffset, GLsizei p_drawCount, GLsizei p_stride);
78 };
79 }
80}
Stateful helper toggling between activated/deactivated states.
Definition spk_activable_object.hpp:20
Lazily generates and caches a value with optional custom destructor.
Definition spk_cached_data.hpp:26
GLuint id() const
Returns the GL program id, building if needed.
Definition spk_program.cpp:96
Program & operator=(const Program &p_other)
Assigns shader sources from another program instance.
Definition spk_program.cpp:70
void render(GLsizei p_nbIndexes, GLsizei p_nbInstance)
Renders using glDrawElementsInstanced with the current program.
Definition spk_program.cpp:101
void renderIndirect(GLintptr p_commandOffset, GLsizei p_drawCount, GLsizei p_stride)
Renders using glMultiDrawElementsIndirect with the current program.
Definition spk_program.cpp:110