Merge branch 'master' of github.com:Lauchmelder23/lol

This commit is contained in:
Lauchmelder 2021-12-27 15:42:42 +01:00
commit 9306dbaae7
20 changed files with 3312 additions and 202 deletions

3
.gitignore vendored
View file

@ -1,5 +1,6 @@
.vs/ .vs/
[Oo]ut/ [Oo]ut/
[Bb]uild/ [Bb]uild/
[Dd]oc/
*.json *.json

2642
Doxyfile Normal file

File diff suppressed because it is too large Load diff

View file

@ -10,17 +10,42 @@ namespace lol
{ {
/** /**
* @brief Represents a generic buffer object. The buffer is destroyed together with the object * @brief Represents a generic buffer object. The buffer is destroyed together with the object
*
* For instantiation the derived types should be used (e.g. VertexBuffer)
*/ */
class Buffer : public NonCopyable class Buffer : public NonCopyable
{ {
public: public:
/**
* @brief Maps the data of the Buffer to memory
*
* @param access The accessing mode for the memory buffer
* @return A pointer to the data in memory
*/
void* Map(Access access); void* Map(Access access);
/**
* @brief Unmap the Buffer
*/
void Unmap(); void Unmap();
/**
* @brief Binds the Buffer
*
*/
void Bind(); void Bind();
/**
* @brief Unbinds the Buffer
*/
void Unbind(); void Unbind();
protected: protected:
/**
* @brief Construct a new Buffer object of the desired type
*
* @param target Type of the buffer
*/
Buffer(BufferType target); Buffer(BufferType target);
virtual ~Buffer(); virtual ~Buffer();

View file

@ -9,6 +9,8 @@ namespace lol
// TODO: Find better name // TODO: Find better name
/** /**
* @brief A basic camera implementation
*
* A base camera object. It hides away part of the interface of a Transformable * A base camera object. It hides away part of the interface of a Transformable
* (because e.g. scaling doesn't make sense for a camera), and adds some other * (because e.g. scaling doesn't make sense for a camera), and adds some other
* transformation functions that are useful for cameras. * transformation functions that are useful for cameras.
@ -65,7 +67,7 @@ namespace lol
/** /**
* A camera using perspective projection * @brief A camera using perspective projection
*/ */
class Camera : public CameraBase class Camera : public CameraBase
{ {
@ -99,7 +101,7 @@ namespace lol
/** /**
* A camera using orthographic projection * @brief A camera using orthographic projection
*/ */
class OrthogonalCamera : public CameraBase class OrthogonalCamera : public CameraBase
{ {

View file

@ -11,7 +11,9 @@ namespace lol
class CameraBase; class CameraBase;
/** /**
* A class that can be displayed on a screen. * @brief A class that can be displayed on a screen.
*
* Has references to a VAO and a Shader that this class will use to render a scene to a camera
*/ */
class Drawable class Drawable
{ {

View file

@ -7,22 +7,85 @@
namespace lol namespace lol
{ {
/**
* @brief Stores and loads image data
*
* This class is used to store image pixel- and metadata as well as load
* image files from disk. It has no OpenGL equivalent
*/
class Image class Image
{ {
public: public:
/**
* @brief Create new "empty" Image
*
* An empty image has a width and height of 0, an empty pixel array and a default PixelFormat (RGB) and PixelType (UByte)
*/
Image(); Image();
/**
* @brief Create a new Image with the given metadata
*
* @param width Width of the image
* @param height Height of the image
* @param pixelFormat Pixel format of the image (i.e. what color channels exist)
* @param pixelType Pixel type of the image (i.e. what datatype each component has)
*/
Image(unsigned int width, unsigned int height, PixelFormat pixelFormat = PixelFormat::RGB, PixelType pixelType = PixelType::UByte); Image(unsigned int width, unsigned int height, PixelFormat pixelFormat = PixelFormat::RGB, PixelType pixelType = PixelType::UByte);
/**
* @brief Load an Image from disk.
*
* The meta- and pixeldata is acquired from an image file.
*
* @param filepath The image to be loaded
*/
Image(const std::string& filepath); Image(const std::string& filepath);
~Image(); ~Image();
/**
* @brief Copy data of another Image
*
* @param other The Image to copy from
*/
Image(const Image& other); Image(const Image& other);
/**
* @brief Assign this Image data of another Image
*
* @param other The Image to assign from
* @return The modified Image
*/
Image& operator=(const Image& other); Image& operator=(const Image& other);
inline const glm::uvec2& GetDimensions() const { return size; }
inline void* GetPixels() const { return pixels; }
/**
* @brief Get the dimensions of the image
*
* @return A glm::vec2 with the width and height of the image
*/
inline const glm::uvec2& GetDimensions() const { return size; }
/**
* @brief Get the raw image pixel data
*
* @return A pointer to an array of pixels that can be directly modified
*/
inline uint8_t* GetPixels() const { return pixels; }
/**
* @brief Get the format of the Image
*
* @return Format of the Image (i.e. what color channels it has)
*/
inline PixelFormat GetPixelFormat() const { return format; } inline PixelFormat GetPixelFormat() const { return format; }
/**
* @brief Get the datatype of the pixels in the Image
*
* @return Type of the pixels (i.e. what datatype each color component has)
*/
inline PixelType GetPixelType() const { return type; } inline PixelType GetPixelType() const { return type; }
private: private:

View file

@ -12,7 +12,7 @@
namespace lol namespace lol
{ {
/** /**
* Compiles shaders into a program and manages access to that program * @brief Compiles shaders into a program and manages access to that program
*/ */
class Shader : public NonCopyable class Shader : public NonCopyable
{ {
@ -37,6 +37,10 @@ namespace lol
* @brief Bind this shader program * @brief Bind this shader program
*/ */
void Bind(); void Bind();
/**
* @brief Unbinds the shader program
*/
void Unbind(); void Unbind();
/** /**

View file

@ -8,20 +8,58 @@ namespace lol
{ {
class Image; class Image;
/**
* @brief A generic OpenGL Texture
*
* This class is a *generic* texture object. It can represent *any* kind of OpenGL Texture.
* Consider using its derived classes (e.g. Texture1D, Texture2D, ...)
*/
class Texture : public NonCopyable class Texture : public NonCopyable
{ {
public: public:
/**
* @brief Generate a new Texture of the specified target
*
* @param target The target of the Texture
*/
Texture(TargetTexture target); Texture(TargetTexture target);
~Texture(); ~Texture();
/**
* @brief Bind the Texture
*
*/
void Bind(); void Bind();
/**
* @brief Unbind the Texture
*
*/
void Unbind(); void Unbind();
void SetWrap(TextureWrap s, TextureWrap t, TextureWrap r = TextureWrap::Repeat); /**
void SetBorderColor(float r, float g, float b, float a); * @brief Configures how the Texture should wrap
*
* Controls how the GPU will behave when sampling a Texture outside of the
* normal texture area ((0,0) to (1,1))
*
* @param s Wrapping behaviour in `s` direction ("horizontal")
* @param t Wrapping behaviour in `t` direction ("vertical")
* @param r Wrapping behaviour in `r` direction ("depth")
*/
void SetWrap(TextureWrap s, TextureWrap t = TextureWrap::Repeat, TextureWrap r = TextureWrap::Repeat);
// TODO: Remove again later /**
inline unsigned int GetID() const { return id; } * @brief Sets the textures border color
*
* Only effects textures with wrapping mode TextureWrap::ClampToBorder
*
* @param r Red component
* @param g Green component
* @param b Blue component
* @param a Alpha component
*/
void SetBorderColor(float r, float g, float b, float a);
protected: protected:
TargetTexture target; TargetTexture target;
@ -29,16 +67,47 @@ namespace lol
}; };
/**
* @brief A 2D Texture object
*/
class Texture2D : public Texture class Texture2D : public Texture
{ {
public: public:
/**
* @brief Construct a new 2D Texture from an Image
*
* @param image Image to fetch meta- and pixeldata from
* @param texFormat Format of the texture
*/
Texture2D(const Image& image, TextureFormat texFormat = TextureFormat::RGB); Texture2D(const Image& image, TextureFormat texFormat = TextureFormat::RGB);
}; };
/**
* @brief A 1D Texture object
*/
class Texture1D : public Texture class Texture1D : public Texture
{ {
public: public:
/**
* @brief Construct a new 1D Texture from raw data
*
* @param width Width of the texture
* @param data Array with pixel color data
* @param pixFormat Format of the pixel data
* @param pixType Datatype of each pixel
* @param texFormat Format of the texture
*/
Texture1D(unsigned int width, const void* data, PixelFormat pixFormat = PixelFormat::RGB, PixelType pixType = PixelType::UByte, TextureFormat texFormat = TextureFormat::RGB); Texture1D(unsigned int width, const void* data, PixelFormat pixFormat = PixelFormat::RGB, PixelType pixType = PixelType::UByte, TextureFormat texFormat = TextureFormat::RGB);
/**
* @brief Construct a new 1D Texture from an Image
*
* The image doesn't have to have a height of 1 pixel. The texture
* will only use the first row of pixels in the Image
*
* @param image Image to fetch meta- and pixeldata from.
* @param texFormat Format of the texture
*/
Texture1D(const Image& image, TextureFormat texFormat = TextureFormat::RGB); Texture1D(const Image& image, TextureFormat texFormat = TextureFormat::RGB);
}; };
} }

View file

@ -7,13 +7,16 @@ namespace lol
{ {
/** /**
* An object with a position, rotation and scale * @brief An object with a position, rotation and scale
*
* Represents an object in 3D space. This class handles all the
* calculations needed to create a model matrix
*/ */
class Transformable class Transformable
{ {
public: public:
/** /**
* Create new object at (0, 0, 0), no rotation and default scaling (1) * @brief Create new object at (0, 0, 0), no rotation and default scaling (1)
*/ */
Transformable(); Transformable();

View file

@ -10,24 +10,55 @@
namespace lol namespace lol
{ {
/** /**
* VAO structure that sets up the buffers and deletes them at the end of the lifecycle * @brief VAO structure that sets up the buffers and deletes them at the end of the lifecycle
*/ */
class VertexArray : public NonCopyable class VertexArray : public NonCopyable
{ {
public: public:
/** /**
* @brief Creates new VAO from a set of vertices and indices and a layout/usage description * @brief Creates new VAO without binding any buffers and without setting up attribute pointers
*/ */
VertexArray(); VertexArray();
/**
* @brief Construct a new VAO, binds the given buffers and sets up the attribute pointers
*
* @param vertexBuffer The VBO to bind to the VAO
* @param elementBuffer The EBO to bind to the VAO
*/
VertexArray(const std::shared_ptr<VertexBuffer>& vertexBuffer, const std::shared_ptr<ElementBuffer>& elementBuffer); VertexArray(const std::shared_ptr<VertexBuffer>& vertexBuffer, const std::shared_ptr<ElementBuffer>& elementBuffer);
virtual ~VertexArray(); virtual ~VertexArray();
/**
* @brief Set the EBO the VAO should use for rendering
*
* @param buffer The index buffer that will be rendered
*/
void SetElementBuffer(const std::shared_ptr<ElementBuffer>& buffer); void SetElementBuffer(const std::shared_ptr<ElementBuffer>& buffer);
/**
* @brief Set the VBO the EBO is indexing
*
* @param buffer The vertex buffer that is being indexed in the VAO
*/
void SetVertexBuffer(const std::shared_ptr<VertexBuffer>& buffer); void SetVertexBuffer(const std::shared_ptr<VertexBuffer>& buffer);
/**
* @brief Binds the VAO
*/
void Bind(); void Bind();
/**
* @brief Unbinds the VAO
*/
void Unbind(); void Unbind();
/**
* @brief Returns the number of indices inside the element buffer
*
* @return Number of elements in the EBO
*/
inline size_t GetIndexCount() { return elementBuffer->GetCount(); } inline size_t GetIndexCount() { return elementBuffer->GetCount(); }
private: private:

View file

@ -4,11 +4,25 @@
namespace lol namespace lol
{ {
/**
* @brief Represents an EBO and manages its state
*/
class ElementBuffer : public Buffer class ElementBuffer : public Buffer
{ {
public: public:
ElementBuffer(size_t count, const std::vector<unsigned int>& elements, Usage usage = Usage::StaticDraw); /**
* @brief Construct a new ElementBuffer
*
* @param elements Data to put into the buffer
* @param usage Hint OpenGL on how the buffer will be used
*/
ElementBuffer(const std::vector<unsigned int>& elements, Usage usage = Usage::StaticDraw);
/**
* @brief Get the number of indices in the buffer
*
* @return Number of indices inside the buffer
*/
inline size_t GetCount() const { return count; } inline size_t GetCount() const { return count; }
private: private:

View file

@ -4,27 +4,71 @@
namespace lol namespace lol
{ {
/**
* @brief Stores attribute data for one vertex
*
*/
struct VertexAttribute struct VertexAttribute
{ {
int size; int size; ///< Number of elements in this attribute
Type type; Type type; ///< Type of the attribute
bool normalized; bool normalized; ///< Whether the data is normalized
int offset; int offset; ///< Offset of the attribute into the vertex data
/**
* @brief Construct a new VertexAttribute
*
* @param type Datatype of the attribute
* @param count Number of elements in this attribute
* @param normalized If data is normalized
*/
VertexAttribute(Type type, unsigned int count, bool normalized) : VertexAttribute(Type type, unsigned int count, bool normalized) :
type(type), size(count), normalized(normalized), offset(0) type(type), size(count), normalized(normalized), offset(0)
{ } { }
}; };
/**
* @brief Stored the layout of a VertexBuffer
*/
class BufferLayout class BufferLayout
{ {
public: public:
/**
* @brief Construct a new BufferLayout
*
* @param attributes A list of vertex attributes making up the layout
*/
BufferLayout(const std::initializer_list<VertexAttribute>& attributes); BufferLayout(const std::initializer_list<VertexAttribute>& attributes);
/**
* @brief Returns the stored layout
*
* @return A list of VertexAttributes
*/
inline const std::vector<VertexAttribute>& GetLayout() const { return layout; } inline const std::vector<VertexAttribute>& GetLayout() const { return layout; }
/**
* @brief Get the stride of the layout
*
* The stride is the size of one vertex in the buffer in bytes.
* The more attributes a vertex has, the larger its stride will be
*
* @return Number of bytes per vertex
*/
inline int GetStride() const { return stride; } inline int GetStride() const { return stride; }
/**
* @brief Returns iterator to beginning of layout list
*
* @return Iterator to beginning of list
*/
std::vector<VertexAttribute>::const_iterator begin() const { return layout.begin(); } std::vector<VertexAttribute>::const_iterator begin() const { return layout.begin(); }
/**
* @brief Returns iterator to end of layout list
*
* @return Iterator to end of list
*/
std::vector<VertexAttribute>::const_iterator end() const { return layout.end(); } std::vector<VertexAttribute>::const_iterator end() const { return layout.end(); }
private: private:
@ -32,12 +76,32 @@ namespace lol
int stride; int stride;
}; };
/**
* @brief Represents a VBO and manages its state
*/
class VertexBuffer : public Buffer class VertexBuffer : public Buffer
{ {
public: public:
VertexBuffer(size_t size, const std::vector<float>& data, Usage usage = Usage::StaticDraw); /**
* @brief Construct a new VertexBuffer
*
* @param data Data to put into the buffer
* @param usage Hint OpenGL on how the buffer will be used
*/
VertexBuffer(const std::vector<float>& data, Usage usage = Usage::StaticDraw);
/**
* @brief Set the BufferLayout of this VBO
*
* @param layout The new layout to give to this buffer
*/
inline void SetLayout(const BufferLayout& layout) { this->layout = layout; }; inline void SetLayout(const BufferLayout& layout) { this->layout = layout; };
/**
* @brief Get the VBOs BufferLayout
*
* @return The stored BufferLayout
*/
inline const BufferLayout& GetLayout() { return layout; } inline const BufferLayout& GetLayout() { return layout; }
private: private:

View file

@ -3,12 +3,20 @@
namespace lol namespace lol
{ {
/**
* @brief Defines a rectangle via a point and its dimensions
*
*/
struct Rect struct Rect
{ {
float x, y; float x, y;
float w, h; float w, h;
}; };
/**
* @brief Defines a 3D area in space
*
*/
struct BoundingBox struct BoundingBox
{ {
float x, y, z; float x, y, z;

View file

@ -13,15 +13,16 @@ namespace lol
*/ */
enum class Type : GLenum enum class Type : GLenum
{ {
Byte = GL_BYTE, Byte = GL_BYTE, ///< Signed 8 bit integer
UByte = GL_UNSIGNED_BYTE, UByte = GL_UNSIGNED_BYTE, ///< Unsigned 8 bit integer
Short = GL_UNSIGNED_SHORT, Short = GL_SHORT, ///< Signed 16 bit integer
Int = GL_INT, UShort = GL_UNSIGNED_SHORT, ///< Unsigned 16 bit integer
UInt = GL_UNSIGNED_INT, Int = GL_INT, ///< Signed 32 bit integer
Half = GL_HALF_FLOAT, UInt = GL_UNSIGNED_INT, ///< Unsigned 32 bit integer
Float = GL_FLOAT, Half = GL_HALF_FLOAT, ///< 16 bit half-precision floating point number
Double = GL_DOUBLE, Float = GL_FLOAT, ///< 32 bit single-precision floating point number
Fixed = GL_FIXED Double = GL_DOUBLE, ///< 64 bit double-precision floating point number
Fixed = GL_FIXED ///< 32 bit 16.16 fixed decimal number
}; };
/** /**
@ -52,60 +53,124 @@ namespace lol
*/ */
enum class GLSLType : GLenum enum class GLSLType : GLenum
{ {
Float = GL_FLOAT, Float2 = GL_FLOAT_VEC2, Float3 = GL_FLOAT_VEC3, Float4 = GL_FLOAT_VEC4, Float = GL_FLOAT, ///< `float`
Double = GL_DOUBLE, Double2 = GL_DOUBLE_VEC2, Double3 = GL_DOUBLE_VEC3, Double4 = GL_DOUBLE_VEC4, Float2 = GL_FLOAT_VEC2, ///< `vec2`
Int = GL_INT, Int2 = GL_INT_VEC2, Int3 = GL_INT_VEC3, Int4 = GL_INT_VEC4, Float3 = GL_FLOAT_VEC3, ///< `vec3`
UInt = GL_UNSIGNED_INT, UInt2 = GL_UNSIGNED_INT_VEC2, UInt3 = GL_UNSIGNED_INT_VEC3, UInt4 = GL_UNSIGNED_INT_VEC4, Float4 = GL_FLOAT_VEC4, ///< `vec4`
Bool = GL_BOOL, Bool2 = GL_BOOL_VEC2, Bool3 = GL_BOOL_VEC3, Bool4 = GL_BOOL_VEC4,
Mat2 = GL_FLOAT_MAT2, Mat3 = GL_FLOAT_MAT3, Mat4 = GL_FLOAT_MAT4, Double = GL_DOUBLE, ///< `double`
Mat2x3 = GL_FLOAT_MAT2x3, Mat2x4 = GL_FLOAT_MAT2x4, Mat3x2 = GL_FLOAT_MAT3x2, Double2 = GL_DOUBLE_VEC2, ///< `dvec2`
Mat3x4 = GL_FLOAT_MAT3x4, Mat4x2 = GL_FLOAT_MAT4x2, Mat4x3 = GL_FLOAT_MAT4x3, Double3 = GL_DOUBLE_VEC3, ///< `dvec3`
Double4 = GL_DOUBLE_VEC4, ///< `dvec4`
DMat2 = GL_DOUBLE_MAT2, DMat3 = GL_DOUBLE_MAT3, DMat4 = GL_DOUBLE_MAT4, Int = GL_INT, ///< `int`
DMat2x3 = GL_DOUBLE_MAT2x3, DMat2x4 = GL_DOUBLE_MAT2x4, DMat3x2 = GL_DOUBLE_MAT3x2, Int2 = GL_INT_VEC2, ///< `ivec2`
DMat3x4 = GL_DOUBLE_MAT3x4, DMat4x2 = GL_DOUBLE_MAT4x2, DMat4x3 = GL_DOUBLE_MAT4x3, Int3 = GL_INT_VEC3, ///< `ivec3`
Int4 = GL_INT_VEC4, ///< `ivec4`
Sampler1D = GL_SAMPLER_1D, Sampler2D = GL_SAMPLER_2D, UInt = GL_UNSIGNED_INT, ///< `uint`
Sampler3D = GL_SAMPLER_3D, SamplerCube = GL_SAMPLER_CUBE, UInt2 = GL_UNSIGNED_INT_VEC2, ///< `uvec2`
Sampler1DShadow = GL_SAMPLER_1D_SHADOW, Sampler2DShadow = GL_SAMPLER_2D_SHADOW, UInt3 = GL_UNSIGNED_INT_VEC3, ///< `uvec3`
Sampler1DArray = GL_SAMPLER_1D_ARRAY, Sampler2DArray = GL_SAMPLER_2D_ARRAY, UInt4 = GL_UNSIGNED_INT_VEC4, ///< `uvec4`
Sampler1DArrayShadow = GL_SAMPLER_1D_ARRAY_SHADOW, Sampler2DArrayShadow = GL_SAMPLER_2D_ARRAY_SHADOW,
Sampler2DMS = GL_SAMPLER_2D_MULTISAMPLE, Sampler2DMSArray = GL_SAMPLER_2D_MULTISAMPLE_ARRAY,
SamplerCubeShadow = GL_SAMPLER_CUBE_SHADOW, SamplerBuffer = GL_SAMPLER_BUFFER,
Sampler2DRect = GL_SAMPLER_2D_RECT, Sampler2DRectShadow = GL_SAMPLER_2D_RECT_SHADOW,
ISampler1D = GL_INT_SAMPLER_1D, ISampler2D = GL_INT_SAMPLER_2D, Bool = GL_BOOL, ///< `bool`
ISampler3D = GL_INT_SAMPLER_3D, ISamplerCube = GL_INT_SAMPLER_CUBE, Bool2 = GL_BOOL_VEC2, ///< `bvec2`
ISampler1DArray = GL_INT_SAMPLER_1D_ARRAY, ISampler2DArray = GL_INT_SAMPLER_2D_ARRAY, Bool3 = GL_BOOL_VEC3, ///< `bvec3`
ISampler2DMS = GL_INT_SAMPLER_2D_MULTISAMPLE, ISampler2DMSArray = GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, Bool4 = GL_BOOL_VEC4, ///< `bvec4`
ISamplerBuffer = GL_INT_SAMPLER_BUFFER, ISampler2DRect = GL_INT_SAMPLER_2D_RECT,
USampler1D = GL_UNSIGNED_INT_SAMPLER_1D, USampler2D = GL_UNSIGNED_INT_SAMPLER_2D, Mat2 = GL_FLOAT_MAT2, ///< `mat2`
USampler3D = GL_UNSIGNED_INT_SAMPLER_3D, USamplerCube = GL_UNSIGNED_INT_SAMPLER_CUBE, Mat3 = GL_FLOAT_MAT3, ///< `mat3`
USampler1DArray = GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, USampler2DArray = GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, Mat4 = GL_FLOAT_MAT4, ///< `mat4`
USampler2DMS = GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, USampler2DMSArray = GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, Mat2x3 = GL_FLOAT_MAT2x3, ///< `mat2x3`
USamplerBuffer = GL_UNSIGNED_INT_SAMPLER_BUFFER, USampler2DRect = GL_UNSIGNED_INT_SAMPLER_2D_RECT, Mat2x4 = GL_FLOAT_MAT2x4, ///< `mat2x4`
Mat3x2 = GL_FLOAT_MAT3x2, ///< `mat3x2`
Mat3x4 = GL_FLOAT_MAT3x4, ///< `mat3x4`
Mat4x2 = GL_FLOAT_MAT4x2, ///< `mat4x2`
Mat4x3 = GL_FLOAT_MAT4x3, ///< `mat4x3`
Image1D = GL_IMAGE_1D, Image2D = GL_IMAGE_2D, DMat2 = GL_DOUBLE_MAT2, ///< `dmat2`
Image3D = GL_IMAGE_3D, Image2DRect = GL_IMAGE_2D_RECT, DMat3 = GL_DOUBLE_MAT3, ///< `dmat3`
ImageCube = GL_IMAGE_CUBE, ImageBuffer = GL_IMAGE_BUFFER, DMat4 = GL_DOUBLE_MAT4, ///< `dmat4`
Image1DArray = GL_IMAGE_1D_ARRAY, Image2DArray = GL_IMAGE_2D_ARRAY, DMat2x3 = GL_DOUBLE_MAT2x3, ///< `dmat2x3`
Image2DMS = GL_IMAGE_2D_MULTISAMPLE, Image2DMSArray = GL_IMAGE_2D_MULTISAMPLE_ARRAY, DMat2x4 = GL_DOUBLE_MAT2x4, ///< `dmat2x4`
DMat3x2 = GL_DOUBLE_MAT3x2, ///< `dmat3x2`
DMat3x4 = GL_DOUBLE_MAT3x4, ///< `dmat3x4`
DMat4x2 = GL_DOUBLE_MAT4x2, ///< `dmat4x2`
DMat4x3 = GL_DOUBLE_MAT4x3, ///< `dmat4x3`
IImage1D = GL_INT_IMAGE_1D, IImage2D = GL_INT_IMAGE_2D, Sampler1D = GL_SAMPLER_1D, ///< `sampler1D`
IImage3D = GL_INT_IMAGE_3D, IImage2DRect = GL_INT_IMAGE_2D_RECT, Sampler2D = GL_SAMPLER_2D, ///< `sampler2D`
IImageCube = GL_INT_IMAGE_CUBE, IImageBuffer = GL_INT_IMAGE_BUFFER, Sampler3D = GL_SAMPLER_3D, ///< `sampler3D`
IImage1DArray = GL_INT_IMAGE_1D_ARRAY, IImage2DArray = GL_INT_IMAGE_2D_ARRAY, SamplerCube = GL_SAMPLER_CUBE, ///< `samplerCube`
IImage2DMS = GL_INT_IMAGE_2D_MULTISAMPLE, IImage2DMSArray = GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY, Sampler1DArray = GL_SAMPLER_1D_ARRAY, ///< `sampler1DArray`
Sampler2DArray = GL_SAMPLER_2D_ARRAY, ///< `sampler2DArray`
Sampler2DMS = GL_SAMPLER_2D_MULTISAMPLE, ///< `sampler2DMS`
Sampler2DMSArray = GL_SAMPLER_2D_MULTISAMPLE_ARRAY, ///< `sampler2DMSArray`
SamplerBuffer = GL_SAMPLER_BUFFER, ///< `samplerBuffer`
Sampler2DRect = GL_SAMPLER_2D_RECT, ///< `sampler2DRect`
Sampler1DShadow = GL_SAMPLER_1D_SHADOW, ///< `sampler1DShadow`
Sampler2DShadow = GL_SAMPLER_2D_SHADOW, ///< `sampler2DShadow`
Sampler1DArrayShadow = GL_SAMPLER_1D_ARRAY_SHADOW, ///< `sampler1DArrayShadow`
Sampler2DArrayShadow = GL_SAMPLER_2D_ARRAY_SHADOW, ///< `sampler2DArrayShadow`
SamplerCubeShadow = GL_SAMPLER_CUBE_SHADOW, ///< `samplerCubeShadow`
Sampler2DRectShadow = GL_SAMPLER_2D_RECT_SHADOW, ///< `sampler2DRectShadow`
UImage1D = GL_UNSIGNED_INT_IMAGE_1D, UImage2D = GL_UNSIGNED_INT_IMAGE_2D, ISampler1D = GL_INT_SAMPLER_1D, ///< `isampler1D`
UImage3D = GL_UNSIGNED_INT_IMAGE_3D, UImage2DRect = GL_UNSIGNED_INT_IMAGE_2D_RECT, ISampler2D = GL_INT_SAMPLER_2D, ///< `isampler2D`
UImageCube = GL_UNSIGNED_INT_IMAGE_CUBE, UImageBuffer = GL_UNSIGNED_INT_IMAGE_BUFFER, ISampler3D = GL_INT_SAMPLER_3D, ///< `isampler3D`
UImage1DArray = GL_UNSIGNED_INT_IMAGE_1D_ARRAY, UImage2DArray = GL_UNSIGNED_INT_IMAGE_2D_ARRAY, ISamplerCube = GL_INT_SAMPLER_CUBE, ///< `isamplerCube`
UImage2DMS = GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE, UImage2DMSArray = GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY, ISampler1DArray = GL_INT_SAMPLER_1D_ARRAY, ///< `isampler1DArray`
ISampler2DArray = GL_INT_SAMPLER_2D_ARRAY, ///< `isampler2DArray`
ISampler2DMS = GL_INT_SAMPLER_2D_MULTISAMPLE, ///< `isampler2DMS`
ISampler2DMSArray = GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, ///< `isampler2DMSArray`
ISamplerBuffer = GL_INT_SAMPLER_BUFFER, ///< `isamplerBuffer`
ISampler2DRect = GL_INT_SAMPLER_2D_RECT, ///< `isampler2DRect`
USampler1D = GL_UNSIGNED_INT_SAMPLER_1D, ///< `usampler1D`
USampler2D = GL_UNSIGNED_INT_SAMPLER_2D, ///< `usampler2D`
USampler3D = GL_UNSIGNED_INT_SAMPLER_3D, ///< `usampler3D`
USamplerCube = GL_UNSIGNED_INT_SAMPLER_CUBE, ///< `usamplerCube`
USampler1DArray = GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, ///< `usampler1DArray`
USampler2DArray = GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, ///< `usampler2DArray`
USampler2DMS = GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, ///< `usampler2DMS`
USampler2DMSArray = GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, ///< `usampler2DMSArray`
USamplerBuffer = GL_UNSIGNED_INT_SAMPLER_BUFFER, ///< `usamplerBuffer`
USampler2DRect = GL_UNSIGNED_INT_SAMPLER_2D_RECT, ///< `usampler2DRect`
Image1D = GL_IMAGE_1D, ///< `image1D`
Image2D = GL_IMAGE_2D, ///< `image2D`
Image3D = GL_IMAGE_3D, ///< `image3D`
ImageCube = GL_IMAGE_CUBE, ///< `imageCube`
ImageBuffer = GL_IMAGE_BUFFER, ///< `imageBuffer`
Image1DArray = GL_IMAGE_1D_ARRAY, ///< `image1DArray`
Image2DArray = GL_IMAGE_2D_ARRAY, ///< `image2DArray`
Image2DMS = GL_IMAGE_2D_MULTISAMPLE, ///< `image2DMS`
Image2DMSArray = GL_IMAGE_2D_MULTISAMPLE_ARRAY, ///< `image2DMSArray`
Image2DRect = GL_IMAGE_2D_RECT, ///< `image2DRect`
AtomicUnit = GL_UNSIGNED_INT_ATOMIC_COUNTER IImage1D = GL_INT_IMAGE_1D, ///< `iimage1D`
IImage2D = GL_INT_IMAGE_2D, ///< `iimage2D`
IImage3D = GL_INT_IMAGE_3D, ///< `iimage3D`
IImage2DRect = GL_INT_IMAGE_2D_RECT, ///< `iimageCube`
IImageCube = GL_INT_IMAGE_CUBE, ///< `iimageBuffer`
IImageBuffer = GL_INT_IMAGE_BUFFER, ///< `iimage1DArray`
IImage1DArray = GL_INT_IMAGE_1D_ARRAY, ///< `iimage2DArray`
IImage2DArray = GL_INT_IMAGE_2D_ARRAY, ///< `iimage2DMS`
IImage2DMS = GL_INT_IMAGE_2D_MULTISAMPLE, ///< `iimage2DMSArray`
IImage2DMSArray = GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY, ///< `iimage2DRect`
UImage1D = GL_UNSIGNED_INT_IMAGE_1D, ///< `uimage1D`
UImage2D = GL_UNSIGNED_INT_IMAGE_2D, ///< `uimage2D`
UImage3D = GL_UNSIGNED_INT_IMAGE_3D, ///< `uimage3D`
UImage2DRect = GL_UNSIGNED_INT_IMAGE_2D_RECT, ///< `uimageCube`
UImageCube = GL_UNSIGNED_INT_IMAGE_CUBE, ///< `uimageBuffer`
UImageBuffer = GL_UNSIGNED_INT_IMAGE_BUFFER, ///< `uimage1DArray`
UImage1DArray = GL_UNSIGNED_INT_IMAGE_1D_ARRAY, ///< `uimage2DArray`
UImage2DArray = GL_UNSIGNED_INT_IMAGE_2D_ARRAY, ///< `uimage2DMS`
UImage2DMS = GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE, ///< `uimage2DMSArray`
UImage2DMSArray = GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY, ///< `uimage2DRect`
AtomicUnit = GL_UNSIGNED_INT_ATOMIC_COUNTER ///< `atomic_uint`
}; };
/** /**
@ -113,20 +178,20 @@ namespace lol
*/ */
enum class BufferType : GLenum enum class BufferType : GLenum
{ {
Array = GL_ARRAY_BUFFER, Array = GL_ARRAY_BUFFER, ///< Vertex attributes
AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, ///< Atomic counter storage
CopyRead = GL_COPY_READ_BUFFER, CopyRead = GL_COPY_READ_BUFFER, ///< Buffer copy source
CopyWrite = GL_COPY_WRITE_BUFFER, CopyWrite = GL_COPY_WRITE_BUFFER, ///< Buffer copy destination
DispatchIndirect = GL_DISPATCH_INDIRECT_BUFFER, DispatchIndirect = GL_DISPATCH_INDIRECT_BUFFER, ///< Indirect compute dispatch commands
DrawIndirect = GL_DRAW_INDIRECT_BUFFER, DrawIndirect = GL_DRAW_INDIRECT_BUFFER, ///< Indirect command arguments
ElementArray = GL_ELEMENT_ARRAY_BUFFER, ElementArray = GL_ELEMENT_ARRAY_BUFFER, ///< Vertex array indices
PixelPack = GL_PIXEL_PACK_BUFFER, PixelPack = GL_PIXEL_PACK_BUFFER, ///< Pixel read target
PixelUnpack = GL_PIXEL_UNPACK_BUFFER, PixelUnpack = GL_PIXEL_UNPACK_BUFFER, ///< Texture data source
Query = GL_QUERY_BUFFER, Query = GL_QUERY_BUFFER, ///< Query result buffer
ShaderStorage = GL_SHADER_STORAGE_BUFFER, ShaderStorage = GL_SHADER_STORAGE_BUFFER, ///< Read-write storage for shaders
Texture = GL_TEXTURE_BUFFER, Texture = GL_TEXTURE_BUFFER, ///< Texture data buffer
TransformFeedback = GL_TRANSFORM_FEEDBACK_BUFFER, TransformFeedback = GL_TRANSFORM_FEEDBACK_BUFFER, ///< Transform feedback buffer
Uniform = GL_UNIFORM_BUFFER Uniform = GL_UNIFORM_BUFFER ///< Uniform block storage
}; };
/** /**
@ -134,17 +199,17 @@ namespace lol
*/ */
enum class Usage : GLenum enum class Usage : GLenum
{ {
StaticDraw = GL_STATIC_DRAW, StaticDraw = GL_STATIC_DRAW, ///< Data is only written, and is only modified once
StaticRead = GL_STATIC_READ, StaticRead = GL_STATIC_READ, ///< Data is only read, and is only modified once
StaticCopy = GL_STATIC_COPY, StaticCopy = GL_STATIC_COPY, ///< Data is never written or read, and is only modified once
StreamDraw = GL_STREAM_DRAW, StreamDraw = GL_STREAM_DRAW, ///< Data is only written, and is modified after every use
StreamRead = GL_STREAM_READ, StreamRead = GL_STREAM_READ, ///< Data is only read, and is modified after every use
StreamCopy = GL_STREAM_COPY, StreamCopy = GL_STREAM_COPY, ///< Data is never written or read, and is modified after every use
DynamicDraw = GL_DYNAMIC_DRAW, DynamicDraw = GL_DYNAMIC_DRAW, ///< Data is only written, and is modified occasionally
DynamicRead = GL_DYNAMIC_READ, DynamicRead = GL_DYNAMIC_READ, ///< Data is only read, and is modified occasionally
DynamicCopy = GL_DYNAMIC_COPY DynamicCopy = GL_DYNAMIC_COPY ///< Data is never written or read, and is modified occasionally
}; };
/** /**
@ -152,21 +217,21 @@ namespace lol
*/ */
enum class DrawMode : GLenum enum class DrawMode : GLenum
{ {
Points = GL_POINTS, Points = GL_POINTS, ///< Render vertices as individual points
Lines = GL_LINES, Lines = GL_LINES, ///< Render pairs of vertices as individual lines (0 and 1 are a line, 2 and 3 are a line, etc)
LineStrip = GL_LINE_STRIP, LineStrip = GL_LINE_STRIP, ///< Render consecutive vertices as connected lines (0 and 1 are a line, 1 and 2 are a line, etc)
LineLoop = GL_LINE_LOOP, LineLoop = GL_LINE_LOOP, ///< Similar to DrawMode::LineStrip, but the first and last vertex are also connected
LineStripAdjacency = GL_LINE_STRIP_ADJACENCY, LineStripAdjacency = GL_LINE_STRIP_ADJACENCY, ///< Allow geometry shaders to access vertex data of adjacent lines
LinesAdjacency = GL_LINES_ADJACENCY, LinesAdjacency = GL_LINES_ADJACENCY, ///< Allow geometry shaders to access vertex data of adjacent lines
Triangles = GL_TRIANGLES, Triangles = GL_TRIANGLES, ///< Render triplets of vertices as individual triangles (0, 1, 2 are a triangle, 3, 4, 5 are a triangle, etc)
TriangleStrip = GL_TRIANGLE_STRIP, TriangleStrip = GL_TRIANGLE_STRIP, ///< Every triplet of vertices is a triangle (0, 1, 2 are a triangle, 1, 2, 3 are a triangle, etc)
TriangleFan = GL_TRIANGLE_FAN, TriangleFan = GL_TRIANGLE_FAN, ///< Every pair of vertices forms a triangle with the first vertex (0, 1, 2 is a triangle, 0, 2, 3 is a triangle, etc)
TriangleStripAdjacency = GL_TRIANGLE_STRIP_ADJACENCY, TriangleStripAdjacency = GL_TRIANGLE_STRIP_ADJACENCY, ///< Allow geometry shaders to access vertex data of adjacent triangles
TrianglesAdjacency = GL_TRIANGLES_ADJACENCY, TrianglesAdjacency = GL_TRIANGLES_ADJACENCY, ///< Allow geometry shaders to access vertex data of adjacent triangles
Patches = GL_PATCHES Patches = GL_PATCHES ///< Used for tesselation
}; };
/** /**
@ -174,9 +239,9 @@ namespace lol
*/ */
enum class Access : GLenum enum class Access : GLenum
{ {
ReadOnly = GL_READ_ONLY, ReadOnly = GL_READ_ONLY, ///< Read-only access
WriteOnly = GL_WRITE_ONLY, WriteOnly = GL_WRITE_ONLY, ///< Write-only access
ReadWrite = GL_READ_WRITE ReadWrite = GL_READ_WRITE ///< Read-Write access
}; };
/** /**
@ -184,17 +249,17 @@ namespace lol
*/ */
enum class TargetTexture : GLenum enum class TargetTexture : GLenum
{ {
Texture1D = GL_TEXTURE_1D, Texture1D = GL_TEXTURE_1D, ///< A single 1D Texture (Image has only width)
Texture2D = GL_TEXTURE_2D, Texture2D = GL_TEXTURE_2D, ///< A single 2D Texture (Image has width and height)
Texture3D = GL_TEXTURE_3D, Texture3D = GL_TEXTURE_3D, ///< A single 3D Texture (Image has width, height and depth)
Array1D = GL_TEXTURE_1D_ARRAY, Array1D = GL_TEXTURE_1D_ARRAY, ///< Multiple 1D Textures stored in one Texture
Array2D = GL_TEXTURE_2D_ARRAY, Array2D = GL_TEXTURE_2D_ARRAY, ///< Multiple 2D Textures stored in one Texture
Rectangle = GL_TEXTURE_RECTANGLE, Rectangle = GL_TEXTURE_RECTANGLE, ///< A single 2D Texture, texture coordinates are not normalized
Cubemap = GL_TEXTURE_CUBE_MAP, Cubemap = GL_TEXTURE_CUBE_MAP, ///< A single Cubemap (6 distinct sets of 2D square-shaped images of the same size)
CubemapArray = GL_TEXTURE_CUBE_MAP_ARRAY, CubemapArray = GL_TEXTURE_CUBE_MAP_ARRAY, ///< Multiple Cubemaps stored in one Texture
Buffer = GL_TEXTURE_BUFFER, Buffer = GL_TEXTURE_BUFFER, ///< A single 1D Texture, the data comes from a Buffer
Multisample = GL_TEXTURE_2D_MULTISAMPLE, Multisample = GL_TEXTURE_2D_MULTISAMPLE, ///< A single 2D Texture, each pixel contains multiple samples instead of one
MultisampleArra = GL_TEXTURE_2D_MULTISAMPLE_ARRAY MultisampleArra = GL_TEXTURE_2D_MULTISAMPLE_ARRAY ///< Multiple multisampled Textures
}; };
/** /**
@ -202,66 +267,109 @@ namespace lol
*/ */
enum class TextureFormat : GLenum enum class TextureFormat : GLenum
{ {
DepthComponent = GL_DEPTH_COMPONENT, DepthComponent = GL_DEPTH_COMPONENT, ///< Texture stores depth information
DepthStencil = GL_DEPTH_STENCIL, DepthStencil = GL_DEPTH_STENCIL, ///< Texture stores depth and stencil information
R = GL_RED, R = GL_RED, ///< 1 channel, unsigned normalized integer
RG = GL_RG, RG = GL_RG, ///< 2 channels, unsigned normalized integers, OpenGL chooses the bitdepth
RGB = GL_RGB, RGB = GL_RGB, ///< 3 channels, unsigned normalized integers, OpenGL chooses the bitdepth
RGBA = GL_RGBA, RGBA = GL_RGBA, ///< 4 channels, unsigned normalized integers, OpenGL chooses the bitdepth
R8 = GL_R8, ///< 1 channel, unsigned normalized integers, 8 bits per channel
R8 = GL_R8, R8S = GL_R8_SNORM, R16 = GL_R16, R16S = GL_R16_SNORM, R8S = GL_R8_SNORM, ///< 1 channel, signed normalized integers, 8 bits per channel
RG8 = GL_RG8, RG8S = GL_RG8_SNORM, RG16 = GL_RG16, RG16S = GL_RG16_SNORM, R16 = GL_R16, ///< 1 channel, unsigned normalized integers, 16 bits per channel
R3G3B2 = GL_R3_G3_B2, RGB4 = GL_RGB4, RGB5 = GL_RGB5, RGB8 = GL_RGB8, R16S = GL_R16_SNORM, ///< 1 channel, signed normalized integers, 16 bits per channel
RGB8S = GL_RGB8_SNORM, RGB10 = GL_RGB10, RGB12 = GL_RGB12, RGB16S = GL_RGB16_SNORM, RG8 = GL_RG8, ///< 2 channels, unsigned normalized integers, 8 bits per channel
RGBA2 = GL_RGBA2, RGBA4 = GL_RGBA4, RGB5A1 = GL_RGB5_A1, RGBA8 = GL_RGBA8, RG8S = GL_RG8_SNORM, ///< 2 channels, signed normalized integers, 8 bits per channel
RGBA8S = GL_RGBA8_SNORM, RGB10A2 = GL_RGB10_A2, RGB10A2UI = GL_RGB10_A2UI, RGBA12 = GL_RGBA12, RG16 = GL_RG16, ///< 2 channels, unsigned normalized integers, 16 bits per channel
RGBA16 = GL_RGBA16, SRGB8 = GL_SRGB8, SRGB8A8 = GL_SRGB8_ALPHA8, R16F = GL_R16F, RG16S = GL_RG16_SNORM, ///< 2 channels, signed normalized integers, 16 bits per channel
RG16F = GL_RG16F, RGB16F = GL_RGB16F, RGBA16F = GL_RGBA16F, R32F = GL_R32F, R3G3B2 = GL_R3_G3_B2, ///< 3 channels, unsigned normalized integers, 3 bits for R and G, 2 bits for B
RG32F = GL_RG32F, RGB32F = GL_RGB32F, RGBA32F = GL_RGBA32F, R11FG11FB10F = GL_R11F_G11F_B10F, RGB4 = GL_RGB4, ///< 3 channels, unsigned normalized integers, 4 bits per channel
RGB9E5 = GL_RGB9_E5, R8I = GL_R8I, R8UI = GL_R8UI, R16I = GL_R16I, RGB5 = GL_RGB5, ///< 3 channels, unsigned normalized integers, 5 bits per channel
R16UI = GL_R16UI, R32I = GL_R32I, R32UI = GL_R32UI, RG8I = GL_RG8I, RGB8 = GL_RGB8, ///< 3 channels, unsigned normalized integers, 8 bits per channel
RG8UI = GL_RG8UI, RG16I = GL_RG16I, RG16UI = GL_RG16UI, RG32I = GL_RG32I, RGB8S = GL_RGB8_SNORM, ///< 3 channels, signed normalized integers, 8 bits per channel
RG32UI = GL_RG32UI, RGB8I = GL_RGB8I, RGB8UI = GL_RGB8UI, RGB16I = GL_RGB16I, RGB10 = GL_RGB10, ///< 3 channels, unsigned normalized integers, 10 bits per channel
RGB16UI = GL_RGB16UI, RGB32I = GL_RGB32I, RGB32UI = GL_RGB32UI, RGBA8I = GL_RGBA8I, RGB12 = GL_RGB12, ///< 3 channels, unsigned normalized integers, 12 bits per channel
RGBA8UI = GL_RGBA8UI, RGBA16I = GL_RGBA16I, RGBA16UI = GL_RGBA16UI, RGBA32I = GL_RGBA32I, RGB16S = GL_RGB16_SNORM, ///< 3 channels, signed normalized integers, 16 bits per channel
RGBA32UI = GL_RGBA32UI, RGBA2 = GL_RGBA2, ///< 4 channels, unsigned normalized integers, 2 bits per channel
RGBA4 = GL_RGBA4, ///< 4 channels, unsigned normalized integers, 4 bits per channel
CR = GL_COMPRESSED_RED, RGB5A1 = GL_RGB5_A1, ///< 4 channels, unsigned normalized integers, 5 bits for R, G and B, 1 bit for A
CRG = GL_COMPRESSED_RG, RGBA8 = GL_RGBA8, ///< 4 channels, unsigned normalized integers, 8 bits per channel
CRGB = GL_COMPRESSED_RGB, RGBA8S = GL_RGBA8_SNORM, ///< 4 channels, signed normalized integers, 8 bits per channel
CRGBA = GL_COMPRESSED_RGBA, RGB10A2 = GL_RGB10_A2, ///< 4 channels, unsigned normalized integers, 10 bits for R, G and B, 2 bits for A
CSRGB = GL_COMPRESSED_SRGB, RGB10A2UI = GL_RGB10_A2UI, ///< 4 channels, unsigned integers, 10 bits for R, G and B, 2 bits for A
CSRGBA = GL_COMPRESSED_SRGB_ALPHA, RGBA12 = GL_RGBA12, ///< 4 channels, unsigned normalized integers, 12 bits per channel
CR_RGTC1 = GL_COMPRESSED_RED_RGTC1, RGBA16 = GL_RGBA16, ///< 4 channels, unsigned normalized integers, 16 bits per channel
CRS_RGTC1 = GL_COMPRESSED_SIGNED_RED_RGTC1, SRGB8 = GL_SRGB8, ///< 3 sRGB channels, unsigned normalized integers, 8 bits per channel
CRG_RGTC2 = GL_COMPRESSED_RG_RGTC2, SRGB8A8 = GL_SRGB8_ALPHA8, ///< 4 sRGB channels, unsigned normalized integers, 8 bits per channel
CRGS_RGTC2 = GL_COMPRESSED_SIGNED_RG_RGTC2, R16F = GL_R16F, ///< 1 channel, floating points, 16 bits per channel
CRGBA_BPTC = GL_COMPRESSED_RGBA_BPTC_UNORM, RG16F = GL_RG16F, ///< 2 channels, floating points, 16 bits per channel
CSRGBA_BPTC = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, RGB16F = GL_RGB16F, ///< 3 channels, floating points, 16 bits per channel
CRGB_BPTC_SF = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, RGBA16F = GL_RGBA16F, ///< 4 channels, floating points, 16 bits per channel
CRGB_BPTC_UF = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, R32F = GL_R32F, ///< 1 channel, floating points, 32 bits per channel
}; RG32F = GL_RG32F, ///< 2 channels, floating points, 32 bits per channel
RGB32F = GL_RGB32F, ///< 3 channels, floating points, 32 bits per channel
RGBA32F = GL_RGBA32F, ///< 4 channels, floating points, 32 bits per channel
R11FG11FB10F = GL_R11F_G11F_B10F, ///< 3 channels, floating points, 11 bits for R and G, 10 bits for B
RGB9E5 = GL_RGB9_E5, ///< 3 channels, floating points, 9 bits per channel, all channels share the same exponent
R8I = GL_R8I, ///< 1 channel, signed integers, 8 bits per channel
R8UI = GL_R8UI, ///< 1 channel, unsigned integers, 8 bits per channel
R16I = GL_R16I, ///< 1 channel, signed integers, 16 bits per channel
R16UI = GL_R16UI, ///< 1 channel, unsigned integers, 16 bits per channel
R32I = GL_R32I, ///< 1 channel, signed integers, 32 bits per channel
R32UI = GL_R32UI, ///< 1 channel, unsigned integers, 16 bits per channel
RG8I = GL_RG8I, ///< 2 channels, signed integers, 8 bits per channel
RG8UI = GL_RG8UI, ///< 2 channels, unsigned integers, 8 bits per channel
RG16I = GL_RG16I, ///< 2 channels, signed integers, 16 bits per channel
RG16UI = GL_RG16UI, ///< 2 channels, unsigned integers, 16 bits per channel
RG32I = GL_RG32I, ///< 2 channels, signed integers, 32 bits per channel
RG32UI = GL_RG32UI, ///< 2 channels, unsigned integers, 16 bits per channel
RGB8I = GL_RGB8I, ///< 3 channels, signed integers, 8 bits per channel
RGB8UI = GL_RGB8UI, ///< 3 channels, unsigned integers, 8 bits per channel
RGB16I = GL_RGB16I, ///< 3 channels, signed integers, 16 bits per channel
RGB16UI = GL_RGB16UI, ///< 3 channels, unsigned integers, 16 bits per channel
RGB32I = GL_RGB32I, ///< 3 channels, signed integers, 32 bits per channel
RGB32UI = GL_RGB32UI, ///< 3 channels, unsigned integers, 16 bits per channel
RGBA8I = GL_RGBA8I, ///< 4 channels, signed integers, 8 bits per channel
RGBA8UI = GL_RGBA8UI, ///< 4 channels, unsigned integers, 8 bits per channel
RGBA16I = GL_RGBA16I, ///< 4 channels, signed integers, 16 bits per channel
RGBA16UI = GL_RGBA16UI, ///< 4 channels, unsigned integers, 16 bits per channel
RGBA32I = GL_RGBA32I, ///< 4 channels, signed integers, 32 bits per channel
RGBA32UI = GL_RGBA32UI, ///< 4 channels, unsigned integers, 16 bits per channel
CR = GL_COMPRESSED_RED, ///< 1 channel, unsigned normalized integers, compressed
CRG = GL_COMPRESSED_RG, ///< 2 channels, unsigned normalized integers, compressed
CRGB = GL_COMPRESSED_RGB, ///< 3 channels, unsigned normalized integers, compressed
CRGBA = GL_COMPRESSED_RGBA, ///< 4 channels, unsigned normalized integers, compressed
CSRGB = GL_COMPRESSED_SRGB, ///< 3 sRGB channels, unsigned normalized integers, compressed
CSRGBA = GL_COMPRESSED_SRGB_ALPHA, ///< 4 sRGB channels, unsigned normalized integers, compressed
CR_RGTC1 = GL_COMPRESSED_RED_RGTC1, ///< 1 channel, unsigned normalized integers, red/green compressed
CRS_RGTC1 = GL_COMPRESSED_SIGNED_RED_RGTC1, ///< 1 channel, signed normalized integers, red/green compressed
CRG_RGTC2 = GL_COMPRESSED_RG_RGTC2, ///< 2 channels, unsigned normalized integers, red/green compressed
CRGS_RGTC2 = GL_COMPRESSED_SIGNED_RG_RGTC2, ///< 2 channels, signed normalized integers, red/green compressed
CRGBA_BPTC = GL_COMPRESSED_RGBA_BPTC_UNORM, ///< 4 channels, unsigned normalized integers, BPTC compressed
CSRGBA_BPTC = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, ///< 4 sRGB channels, unsigned normalized integers, BPTC compressed
CRGB_BPTC_SF = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, ///< 3 channels, signed floating points, BPTC compressed
CRGB_BPTC_UF = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, ///< 3 channels, unsigned floating points, BPTC compressed
};
/** /**
* @brief OpenGL internal pixel formats * @brief OpenGL internal pixel formats
*/ */
enum class PixelFormat : GLenum enum class PixelFormat : GLenum
{ {
R = GL_RED, R = GL_RED, ///< R
RG = GL_RG, RG = GL_RG, ///< RG
RGB = GL_RGB, RGB = GL_RGB, ///< RGB
BGR = GL_BGR, BGR = GL_BGR, ///< BGR
RGBA = GL_RGBA, RGBA = GL_RGBA, ///< RGBA
BGRA = GL_BGRA, BGRA = GL_BGRA, ///< BGRA
RI = GL_RED_INTEGER, RI = GL_RED_INTEGER, ///< R, integer values
RGI = GL_RG_INTEGER, RGI = GL_RG_INTEGER, ///< RG, integer values
RGBI = GL_RGB_INTEGER, RGBI = GL_RGB_INTEGER, ///< RGB, integer values
BGRI = GL_BGR_INTEGER, BGRI = GL_BGR_INTEGER, ///< BGR, integer values
RGBAI = GL_RGBA_INTEGER, RGBAI = GL_RGBA_INTEGER, ///< RGBA, integer values
BGRAI = GL_BGRA_INTEGER, BGRAI = GL_BGRA_INTEGER, ///< BGRA, integer values
StencilIndex = GL_STENCIL_INDEX, StencilIndex = GL_STENCIL_INDEX, ///< Depth stencil indexed
DepthComponent = GL_DEPTH_COMPONENT, DepthComponent = GL_DEPTH_COMPONENT, ///< Depth values (range [0, 1])
DepthStencil = GL_DEPTH_STENCIL, DepthStencil = GL_DEPTH_STENCIL, ///< Depth, Stencil pairs
}; };
/** /**
@ -269,17 +377,26 @@ namespace lol
*/ */
enum class PixelType : GLenum enum class PixelType : GLenum
{ {
UByte = GL_UNSIGNED_BYTE, Byte = GL_BYTE, UByte = GL_UNSIGNED_BYTE, ///< All channels are unsigned bytes
UShort = GL_UNSIGNED_SHORT, Short = GL_SHORT, Byte = GL_BYTE, ///< All channels are signed bytes
UInt = GL_UNSIGNED_INT, Int = GL_INT, UShort = GL_UNSIGNED_SHORT, ///< All channels are unsigned shorts
Float = GL_FLOAT, Short = GL_SHORT, ///< All channels are signed bytes
UInt = GL_UNSIGNED_INT, ///< All channels are unsigned integers
Int = GL_INT, ///< All channels are signed integers
Float = GL_FLOAT, ///< All channels are floating points
UByte332 = GL_UNSIGNED_BYTE_3_3_2, UByte233Rev = GL_UNSIGNED_BYTE_2_3_3_REV, UByte332 = GL_UNSIGNED_BYTE_3_3_2, ///< R = 3 Bits, G = 3 Bits, B = 2 Bits (RGB)
UShort565 = GL_UNSIGNED_SHORT_5_6_5, UShort565Rev = GL_UNSIGNED_SHORT_5_6_5_REV, UByte233Rev = GL_UNSIGNED_BYTE_2_3_3_REV, ///< R = 3 Bits, G = 3 Bits, B = 2 Bits (BGR)
UShort4444 = GL_UNSIGNED_SHORT_4_4_4_4, UShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV, UShort565 = GL_UNSIGNED_SHORT_5_6_5, ///< R = 5 Bits, G = 6 Bits, B = 5 Bits (RGB)
UShort5551 = GL_UNSIGNED_SHORT_5_5_5_1, UShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV, UShort565Rev = GL_UNSIGNED_SHORT_5_6_5_REV, ///< R = 5 Bits, G = 6 Bits, B = 5 Bits (BGR)
UInt8888 = GL_UNSIGNED_INT_8_8_8_8, UInt8888Rev = GL_UNSIGNED_INT_8_8_8_8_REV, UShort4444 = GL_UNSIGNED_SHORT_4_4_4_4, ///< R = 4 Bits, G = 4 Bits, B = 4 Bits, A = 4 Bits (RGBA)
UInt1010102 = GL_UNSIGNED_INT_10_10_10_2, UInt1010102Rev = GL_UNSIGNED_INT_2_10_10_10_REV UShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV, ///< R = 4 Bits, G = 4 Bits, B = 4 Bits, A = 4 Bits (ABGR)
UShort5551 = GL_UNSIGNED_SHORT_5_5_5_1, ///< R = 5 Bits, G = 5 Bits, B = 5 Bits, A = 1 Bits (RGBA)
UShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV, ///< R = 5 Bits, G = 5 Bits, B = 5 Bits, A = 1 Bits (ABGR)
UInt8888 = GL_UNSIGNED_INT_8_8_8_8, ///< R = 8 Bits, G = 8 Bits, B = 8 Bits, A = 8 Bits (RGBA)
UInt8888Rev = GL_UNSIGNED_INT_8_8_8_8_REV, ///< R = 8 Bits, G = 8 Bits, B = 8 Bits, A = 8 Bits (ABGR)
UInt1010102 = GL_UNSIGNED_INT_10_10_10_2, ///< R = 10 Bits, G = 10 Bits, B = 10 Bits, A = 10 Bits (RGBA)
UInt1010102Rev = GL_UNSIGNED_INT_2_10_10_10_REV ///< R = 10 Bits, G = 10 Bits, B = 10 Bits, A = 10 Bits (ABGR)
}; };
/** /**
@ -330,10 +447,10 @@ namespace lol
enum class TextureWrap : GLenum enum class TextureWrap : GLenum
{ {
ClampToEdge = GL_CLAMP_TO_EDGE, ClampToEdge = GL_CLAMP_TO_EDGE, ///< Pixels outside of texture get the textures edge color
ClampToBorder = GL_CLAMP_TO_BORDER, ClampToBorder = GL_CLAMP_TO_BORDER, ///< Pixels outside of texture get the border color
MirroredRepeat = GL_MIRRORED_REPEAT, MirroredRepeat = GL_MIRRORED_REPEAT, ///< Texture is mirrored and repeated
Repeat = GL_REPEAT, Repeat = GL_REPEAT, ///< Texture is repeated
MirrorClampToEdge = GL_MIRROR_CLAMP_TO_EDGE MirrorClampToEdge = GL_MIRROR_CLAMP_TO_EDGE ///< Texture is mirrored once and then clamped
}; };
} }

View file

@ -1,14 +1,26 @@
#pragma once #pragma once
#include <stdexcept> #include <stdexcept>
#include <string>
#define TYPENAME(x) #x #define TYPENAME(x) #x
namespace lol namespace lol
{ {
/**
* @brief The requested object was not found
*
* Thrown by ObjectManager::Get() if the specified ID isn't associated
* with any objects in the manager
*/
class ObjectNotFoundException : public std::runtime_error class ObjectNotFoundException : public std::runtime_error
{ {
public: public:
/**
* @brief Construct a new ObjectNotFoundException
*
* @param id ID of the object that was not found
*/
ObjectNotFoundException(unsigned int id) : ObjectNotFoundException(unsigned int id) :
std::runtime_error("Failed to Get() object with ID " + std::to_string(id) + " from ObjectManager. It does not exist.") std::runtime_error("Failed to Get() object with ID " + std::to_string(id) + " from ObjectManager. It does not exist.")
{ } { }

View file

@ -3,7 +3,8 @@
namespace lol namespace lol
{ {
/** /**
* A object without copy constructors or assignment operators. * @brief An object without copy constructors or assignment operators.
*
* Any object inheriting from this will not be able to be copied anymore * Any object inheriting from this will not be able to be copied anymore
*/ */
class NonCopyable class NonCopyable

View file

@ -10,6 +10,8 @@ namespace lol
{ {
/** /**
* @brief Manages objects and cleans them up if they're not needed anymore.
*
* Some objects should only exist once but be available to multiple objects (e.g. multiple * Some objects should only exist once but be available to multiple objects (e.g. multiple
* models sharing the same VAO and shaders. Any object can register objects here and other * models sharing the same VAO and shaders. Any object can register objects here and other
* objects can then retrieve them if they have the ID. * objects can then retrieve them if they have the ID.
@ -23,8 +25,24 @@ namespace lol
class ObjectManager : public NonCopyable class ObjectManager : public NonCopyable
{ {
public: public:
/**
* @brief Construct a new ObjectManager
*
*/
ObjectManager() {} ObjectManager() {}
/**
* @brief Tell the ObjectManager to create a new object of type T
*
* The object will be constructed by the manager, ObjectManager will
* own it.
*
* @tparam T Type of the object to create
* @tparam Args
* @param id ID to give this object in the manager
* @param args Argumnts to pass to T's constructor
* @return A shared pointer to the newly constructed object
*/
template<typename T, typename... Args> template<typename T, typename... Args>
std::shared_ptr<T> Create(unsigned int id, Args... args) std::shared_ptr<T> Create(unsigned int id, Args... args)
{ {
@ -35,15 +53,30 @@ namespace lol
} }
/** /**
* Remove object from manager * @brief Remove object from manager
*
* @param id ID of the object to remove
*/ */
void Delete(unsigned int id); void Delete(unsigned int id);
/** /**
* Retrieve object from manager * @brief Retrieve a generic object from manager
*
* The object returned will essentially be a void*.
* The ObjectManager performs no casting.
*
* @param id ID of the object to retrieve
* @return A void* to a blob of data making up the object
*/ */
std::shared_ptr<void> Get(unsigned int id); std::shared_ptr<void> Get(unsigned int id);
/**
* @brief Retriege an object of a specific type from the manager
*
* @tparam T Type of the object
* @param id ID of the object
* @return A pointer to the object
*/
template<typename T> template<typename T>
std::shared_ptr<T> Get(unsigned int id) std::shared_ptr<T> Get(unsigned int id)
{ {
@ -52,7 +85,22 @@ namespace lol
return std::static_pointer_cast<T>(object); return std::static_pointer_cast<T>(object);
} }
/**
* @brief Removes any objects that aren't in use by anyone anymore
*
* Deletes any stored shared_ptr if their use count is equal to 1.
* Note that if you're holding a weak pointer to one of the objects it
* might be deleted at any time
*/
void ClearUnused(); void ClearUnused();
/**
* @brief Removes all objects from the manager
*
* If an object holds a shared_ptr from the manager then this
* will not break the object. This merely causes the manager
* to "untrack" all objects.
*/
void Clear(); void Clear();
private: private:

View file

@ -6,7 +6,7 @@
namespace lol namespace lol
{ {
Image::Image() : Image::Image() :
size(0), pixels(nullptr), format(PixelFormat::RGBA), type(PixelType::UByte) size(0), pixels(nullptr), format(PixelFormat::RGB), type(PixelType::UByte)
{ {
} }

View file

@ -3,8 +3,12 @@
namespace lol namespace lol
{ {
ElementBuffer::ElementBuffer(const std::vector<unsigned int>& elements, Usage usage) : ElementBuffer::ElementBuffer(const std::vector<unsigned int>& elements, Usage usage) :
<<<<<<< HEAD
Buffer(BufferType::ElementArray), count(elements.size()) Buffer(BufferType::ElementArray), count(elements.size())
=======
Buffer(BufferType::ElementArray), count(count)
>>>>>>> 7b071b2db64f25ad5bfd602c42dd8f17b75e3948
{ {
glBufferData(NATIVE(type), count * sizeof(unsigned int), elements.data(), NATIVE(usage)); glBufferData(NATIVE(type), elements.size() * sizeof(unsigned int), elements.data(), NATIVE(usage));
} }
} }

View file

@ -14,9 +14,9 @@ namespace lol
} }
VertexBuffer::VertexBuffer(size_t size, const std::vector<float>& data, Usage usage) : VertexBuffer::VertexBuffer(const std::vector<float>& data, Usage usage) :
Buffer(BufferType::Array), layout{} Buffer(BufferType::Array), layout{}
{ {
glBufferData(NATIVE(type), size * sizeof(float), data.data(), NATIVE(usage)); glBufferData(NATIVE(type), data.size() * sizeof(float), data.data(), NATIVE(usage));
} }
} }