21#define OPENGL_ES_2_0 1
24#define OPENGL_VERSION OPENGL_2_1
45 explicit Texture(
bool interpolation =
false,
bool wrap =
false);
79 return std::bit_cast<void*>(uintptr_t(
textureId));
114 void resize(GLsizei width, GLsizei height);
116 [[nodiscard]] GLsizei
getWidth ()
const {
return width; }
117 [[nodiscard]] GLsizei
getHeight()
const {
return height; }
130 : bufferId(other.bufferId)
135 std::swap(bufferId, other.bufferId);
145 GLint previousId = 0;
241 : allocated(std::move(other.allocated))
244 , height(other.height)
252 std::swap(allocated, other.allocated);
254 std::swap(width, other.width);
255 std::swap(height, other.height);
273 allocated.resize(width * height);
298 auto offset = x + size_t(width) * y;
302 return &allocated[offset];
313 return allocated.data();
340 [[nodiscard]]
bool isOK()
const;
347 Shader(GLenum type, std::string_view filename) {
348 init(type, {}, filename);
350 Shader(GLenum type, std::string_view header, std::string_view filename) {
351 init(type, header, filename);
356 void init(GLenum type, std::string_view header,
357 std::string_view filename);
375 :
Shader(GL_VERTEX_SHADER, filename) {}
377 :
Shader(GL_VERTEX_SHADER, header, filename) {}
390 :
Shader(GL_FRAGMENT_SHADER, filename) {}
392 :
Shader(GL_FRAGMENT_SHADER, header, filename) {}
424 [[nodiscard]] GLuint
get()
const {
return handle; }
429 [[nodiscard]]
bool isOK()
const;
471 : bufferId(other.bufferId)
476 std::swap(bufferId, other.bufferId);
480 [[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 unmap() const
Unmaps the contents of this buffer.
void unbind() const
Unbind this buffer.
void setImage(GLuint width, GLuint height)
Sets the image for this buffer.
T * getOffset(GLuint x, GLuint y)
Gets a pointer relative to the start of this buffer.
PixelBuffer(PixelBuffer &&other) noexcept
void bind() const
Bind this PixelBuffer.
PixelBuffer & operator=(const PixelBuffer &other)=delete
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)