22#define OPENGL_ES_2_0 1
25#define OPENGL_VERSION OPENGL_2_1
46 explicit Texture(
bool interpolation =
false,
bool wrap =
false);
80 return std::bit_cast<void*>(uintptr_t(
textureId));
115 void resize(GLsizei width, GLsizei height);
117 [[nodiscard]] GLsizei
getWidth ()
const {
return width; }
118 [[nodiscard]] GLsizei
getHeight()
const {
return height; }
131 : bufferId(other.bufferId)
136 std::swap(bufferId, other.bufferId);
146 GLint previousId = 0;
228 : allocated(std::move(other.allocated))
239 std::swap(allocated, other.allocated);
240 std::swap(size, other.size);
258 allocated.resize(size);
285 return {allocated.data(), size};
312 [[nodiscard]]
bool isOK()
const;
319 Shader(GLenum type, std::string_view filename) {
320 init(type, {}, filename);
322 Shader(GLenum type, std::string_view header, std::string_view filename) {
323 init(type, header, filename);
328 void init(GLenum type, std::string_view header,
329 std::string_view filename);
347 :
Shader(GL_VERTEX_SHADER, filename) {}
349 :
Shader(GL_VERTEX_SHADER, header, filename) {}
362 :
Shader(GL_FRAGMENT_SHADER, filename) {}
364 :
Shader(GL_FRAGMENT_SHADER, header, filename) {}
396 [[nodiscard]] GLuint
get()
const {
return handle; }
401 [[nodiscard]]
bool isOK()
const;
443 : bufferId(other.bufferId)
448 std::swap(bufferId, other.bufferId);
452 [[nodiscard]] GLuint
get()
const {
return bufferId; }
BufferObject & operator=(BufferObject &&other) noexcept
BufferObject(BufferObject &&other) noexcept
BufferObject & operator=(const BufferObject &)=delete
BufferObject(const BufferObject &)=delete
GLsizei getHeight() const
void resize(GLsizei width, GLsizei height)
ColorTexture()=default
Default constructor, zero-sized texture.
Wrapper around an OpenGL fragment shader: a program executed on the GPU that computes the colors of p...
FragmentShader(std::string_view header, std::string_view filename)
FragmentShader(std::string_view filename)
Instantiates a fragment shader.
FrameBufferObject()=default
FrameBufferObject(FrameBufferObject &&other) noexcept
FrameBufferObject & operator=(FrameBufferObject &&other) noexcept
Wrapper around a pixel buffer.
PixelBuffer(const PixelBuffer &other)=delete
PixelBuffer & operator=(PixelBuffer &&other) noexcept
void allocate(GLuint size)
Allocate the maximum required size for this buffer.
void unmap() const
Unmaps the contents of this buffer.
void unbind() const
Unbind this buffer.
PixelBuffer(PixelBuffer &&other) noexcept
void bind() const
Bind this PixelBuffer.
PixelBuffer & operator=(const PixelBuffer &other)=delete
std::span< T > mapWrite()
Maps the contents of this buffer into memory.
Wrapper around an OpenGL program: a collection of vertex and fragment shaders.
ShaderProgram & operator=(const ShaderProgram &)=delete
void activate() const
Makes this program the active shader program.
GLuint get() const
Returns the underlying openGL handler id.
bool isOK() const
Returns true iff this program was linked without errors.
void attach(const Shader &shader)
Adds a given shader to this program.
ShaderProgram(ShaderProgram &&)=delete
ShaderProgram(Null)
Create null handler (don't yet allocate a openGL object).
void allocate()
Allocate a shader program handle.
ShaderProgram & operator=(ShaderProgram &&)=delete
~ShaderProgram()
Destroy handler object (release the underlying openGL object).
ShaderProgram(const ShaderProgram &)=delete
ShaderProgram()
Create handler and allocate underlying openGL object.
void reset()
Release the shader program handle.
void link()
Links all attached shaders together into one program.
void bindAttribLocation(unsigned index, const char *name)
Bind the given name for a vertex shader attribute to the given location.
GLint getUniformLocation(const char *name) const
Gets a reference to a uniform variable declared in the shader source.
Wrapper around an OpenGL shader: a program executed on the GPU.
Shader & operator=(Shader &&)=delete
Shader(const Shader &)=delete
Shader & operator=(const Shader &)=delete
bool isOK() const
Returns true iff this shader is loaded and compiled without errors.
Shader(GLenum type, std::string_view filename)
Instantiates a shader.
Shader(GLenum type, std::string_view header, std::string_view filename)
Most basic/generic texture: only contains a texture ID.
Texture & operator=(Texture &&other) noexcept
void reset()
Release openGL texture name.
Texture(const Texture &)=delete
void bind() const
Makes this texture the active GL texture.
void setWrapMode(bool wrap)
void setInterpolation(bool interpolation)
Enable/disable bilinear interpolation for this texture.
~Texture()
Release openGL texture name.
GLuint get() const
Returns the underlying openGL handler id.
void allocate()
Allocate an openGL texture name.
void * getImGui() const
Return as a 'void*' (needed for 'Dear ImGui').
Texture(Texture &&other) noexcept
Move constructor and assignment.
Texture & operator=(const Texture &)=delete
Texture(Null)
Create null-handle (not yet allocate an openGL handle).
Wrapper around an OpenGL vertex shader: a program executed on the GPU that computes per-vertex stuff.
VertexShader(std::string_view filename)
Instantiates a vertex shader.
VertexShader(std::string_view header, std::string_view filename)
This class manages the lifetime of a block of memory.
void checkGLError(std::string_view prefix)