Untitled Game engine no.5
1.0
|
30 offset(0), normalized(norm) {
37 case ShaderDataType::Int:
38 case ShaderDataType::Bool:
39 case ShaderDataType::Float:
return 1;
40 case ShaderDataType::Int2:
41 case ShaderDataType::Float2:
return 2;
42 case ShaderDataType::Int3:
43 case ShaderDataType::Float3:
return 3;
44 case ShaderDataType::Int4:
45 case ShaderDataType::Float4:
return 4;
46 case ShaderDataType::Mat3:
return 3 * 3;
47 case ShaderDataType::Mat4:
return 4 * 4;
48 default: Log::Warn(
"BUFFER ELEMENTS",
"Unknown ShaderDataType");
return 0;
61 std::vector<BufferElement> m_Elements;
63 uint32_t m_Stride = 0;
67 inline const std::vector<BufferElement>&
GetElements()
const {
return m_Elements; }
69 inline const uint32_t
GetStride()
const {
return m_Stride; }
74 : m_Elements(elements) {
75 CalculateOffsetsAndStride();
81 std::vector<BufferElement>::iterator
begin() {
return m_Elements.begin(); }
83 std::vector<BufferElement>::iterator
end() {
return m_Elements.end(); }
87 void CalculateOffsetsAndStride() {
90 for (
auto& e : m_Elements) {
110 virtual void Bind() = 0;
112 virtual void Unbind() = 0;
117 virtual void Load(
float verts[], std::size_t size) = 0;
119 virtual std::size_t GetSize() = 0;
131 virtual void Bind() = 0;
133 virtual void Unbind() = 0;
138 virtual void Load(
unsigned int inds[], std::size_t size) = 0;
140 virtual std::size_t GetSize() = 0;
ShaderDataType type
Definition: Buffer.hpp:16
Constructs the layout of a vertex buffer.
Definition: Buffer.hpp:58
std::string name
Name of this element.
Definition: Buffer.hpp:13
BufferLayout()
Creates an empty buffer layout.
Definition: Buffer.hpp:78
virtual ~VertexBuffer()
Constructor.
Definition: Buffer.hpp:107
Definition: Buffer.hpp:11
virtual void Load(unsigned int inds[], std::size_t size)=0
VertexBuffer()
Constructor.
Definition: Buffer.hpp:105
Interface for a buffer of vertices.
Definition: Buffer.hpp:101
virtual void Unbind()=0
Binds nothing for drawing.
ShaderDataType
data type enum for shader parameter
Definition: Shader.hpp:11
virtual void Bind()=0
Binds this vertex buffer for drawing.
virtual void Bind()=0
Binds this vertex buffer for drawing.
virtual void Load(float verts[], std::size_t size)=0
IndexBuffer()
Constructor.
Definition: Buffer.hpp:126
const std::vector< BufferElement > & GetElements() const
Definition: Buffer.hpp:67
const uint32_t GetStride() const
@retuns the stride of the elements of this buffer
Definition: Buffer.hpp:69
uint32_t GetComponentCount() const
Get the number of elements in this component.
Definition: Buffer.hpp:35
virtual ~IndexBuffer()
Destructor.
Definition: Buffer.hpp:128
BufferLayout(const std::initializer_list< BufferElement > &elements)
Definition: Buffer.hpp:73
uint32_t offset
Offset of component in the vertex.
Definition: Buffer.hpp:18
std::vector< BufferElement >::iterator end()
Wrapper around the elements vectory.
Definition: Buffer.hpp:83
virtual void Unbind()=0
Binds nothing for drawing.
BufferElement(ShaderDataType type, const std::string &name, bool norm=false)
Definition: Buffer.hpp:27
Definition: Animation.hpp:14
uint32_t size
Size of the datatype element.
Definition: Buffer.hpp:20
Interface for a buffer of indices.
Definition: Buffer.hpp:123
std::vector< BufferElement >::iterator begin()
Wrapper around the elements vectory.
Definition: Buffer.hpp:81