Merge branch 'master' of github.com:Lauchmelder23/lol
This commit is contained in:
commit
40b4e292c2
|
@ -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:
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -199,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
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,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
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -239,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
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -249,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
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,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
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,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)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -395,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
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -7,9 +7,20 @@
|
||||||
|
|
||||||
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.")
|
||||||
{ }
|
{ }
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace lol
|
namespace lol
|
||||||
{
|
{
|
||||||
ElementBuffer::ElementBuffer(size_t count, const std::vector<unsigned int>& elements, Usage usage) :
|
ElementBuffer::ElementBuffer(const std::vector<unsigned int>& elements, Usage usage) :
|
||||||
Buffer(BufferType::ElementArray), count(count)
|
Buffer(BufferType::ElementArray), count(elements.size())
|
||||||
{
|
{
|
||||||
glBufferData(NATIVE(type), count * sizeof(unsigned int), elements.data(), NATIVE(usage));
|
glBufferData(NATIVE(type), elements.size() * sizeof(unsigned int), elements.data(), NATIVE(usage));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue