14 constexpr size_t sizes[] = {
20 sizeof(
float) * 3 * 3,
21 sizeof(float) * 4 * 4,
33 static_assert(
sizeof(sizes) /
sizeof(size_t) ==
static_cast<size_t>(
ShaderDataType::Bool) + 1,
"ShaderDataTypeSize: Size array is out of sync with ShaderDataType enum");
35 if (
CORI_CORE_CHECK(
static_cast<size_t>(type) <
sizeof(sizes) /
sizeof(
size_t),
"ShaderDataTypeSize: Unknown shader data type '{}'",
static_cast<int>(type))) {
return 0; }
37 return sizes[
static_cast<size_t>(type)];
41 constexpr size_t sizes[] = {
60 static_assert(
sizeof(sizes) /
sizeof(size_t) ==
static_cast<size_t>(
ShaderDataType::Bool) + 1,
"ShaderDataTypeComponentCount: Size array is out of sync with ShaderDataType enum");
62 if (
CORI_CORE_CHECK(
static_cast<size_t>(type) <
sizeof(sizes) /
sizeof(
size_t),
"ShaderDataTypeComponentCount: Unknown shader data type '{}'",
static_cast<int>(type))) {
return 0; }
64 return sizes[
static_cast<size_t>(type)];
81 return m_RuntimeID == other.m_RuntimeID;
85 return m_RuntimeID != other.m_RuntimeID;
95 m_RuntimeID(s_NextRuntimeID.fetch_add(1, std::memory_order_relaxed)) {}
98 :
m_Name(std::move(other.m_Name)),
104 m_RuntimeID(other.m_RuntimeID) {}
107 if (
this != &other) {
108 m_Name = std::move(other.m_Name);
120 const uint32_t m_RuntimeID{0};
121 inline static std::atomic<uint32_t> s_NextRuntimeID{1};
128 VBLayout(
const std::initializer_list<VBElement>& elements) : m_Elements(elements) {
129 for (
auto& element : m_Elements) {
130 element.m_Offset = m_Stride;
131 m_Stride += element.m_Size;
136 : m_Elements(other.m_Elements),
137 m_Stride(other.m_Stride) {}
140 if (
this == &other) {
145 m_Elements.reserve(other.m_Elements.size());
147 for (
const auto& src_element : other.m_Elements) {
148 m_Elements.emplace_back(src_element);
151 m_Stride = other.m_Stride;
157 : m_Elements(std::move(other.m_Elements)),
158 m_Stride(other.m_Stride) {
163 if (
this == &other) {
167 m_Elements = std::move(other.m_Elements);
168 m_Stride = other.m_Stride;
175 const std::vector<VBElement>&
GetElements()
const {
return m_Elements; }
182 std::vector<VBElement>::iterator
begin() {
return m_Elements.begin(); }
183 std::vector<VBElement>::iterator
end() {
return m_Elements.end(); }
184 std::vector<VBElement>::const_iterator
begin()
const {
return m_Elements.begin(); }
185 std::vector<VBElement>::const_iterator
end()
const {
return m_Elements.end(); }
188 std::vector<VBElement> m_Elements;
189 uint32_t m_Stride{ 0 };
200 virtual void Init(
const float* vertices, uint32_t size,
DRAW_TYPE drawTyPpe) = 0;
207 virtual void SetData(
const void* data, uint32_t size)
const = 0;
209 [[nodiscard]]
static std::shared_ptr<VertexBuffer>
Create();
218 [[nodiscard]]
virtual uint32_t
GetCount()
const = 0;
220 [[nodiscard]]
static std::shared_ptr<IndexBuffer>
Create(uint32_t* indices, uint32_t count);
#define CORI_CORE_CHECK(x,...)
virtual ~IndexBuffer()=default
virtual void Unbind() const =0
virtual uint32_t GetCount() const =0
virtual void Bind() const =0
static std::shared_ptr< IndexBuffer > Create(uint32_t *indices, uint32_t count)
size_t GetComponentCount() const
bool operator!=(const VBElement &other) const
VBElement(VBElement &&other) noexcept
bool operator==(const VBElement &other) const
VBElement & operator=(VBElement &&other) noexcept
VBElement(const ShaderDataType type, const std::string &name, const uint32_t divisor=0, const bool normalized=false)
VBElement(const VBElement &other)
const VBElement & front() const
std::vector< VBElement >::const_iterator end() const
const std::vector< VBElement > & GetElements() const
VBLayout & operator=(const VBLayout &other)
VBLayout & operator=(VBLayout &&other) noexcept
VBLayout(const VBLayout &other)
std::vector< VBElement >::iterator begin()
const VBElement & back() const
std::vector< VBElement >::const_iterator begin() const
uint32_t GetStride() const
std::vector< VBElement >::iterator end()
VBLayout(VBLayout &&other) noexcept
VBLayout(const std::initializer_list< VBElement > &elements)
virtual void Init(const float *vertices, uint32_t size, DRAW_TYPE drawTyPpe)=0
virtual void Unbind() const =0
virtual void Bind() const =0
static std::shared_ptr< VertexBuffer > Create()
virtual void SetData(const void *data, uint32_t size) const =0
virtual void SetLayout(const VBLayout &layout)=0
virtual ~VertexBuffer()=default
virtual const VBLayout & GetLayout() const =0
Almost everything connected to graphics is in this namespace.
static constexpr size_t ShaderDataTypeComponentCount(ShaderDataType type)
static constexpr size_t ShaderDataTypeSize(ShaderDataType type)