diff options
author | chai <chaifix@163.com> | 2021-12-13 00:07:19 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-12-13 00:07:19 +0800 |
commit | 60cbbdec07ab7a5636eac5b3c024ae44e937f4d4 (patch) | |
tree | b2c7b0a868f18159dbc43d8954e1bd7668549a88 /Client/Source/Graphics/VertexBuffer.h |
+init
Diffstat (limited to 'Client/Source/Graphics/VertexBuffer.h')
-rw-r--r-- | Client/Source/Graphics/VertexBuffer.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Client/Source/Graphics/VertexBuffer.h b/Client/Source/Graphics/VertexBuffer.h new file mode 100644 index 0000000..b907337 --- /dev/null +++ b/Client/Source/Graphics/VertexBuffer.h @@ -0,0 +1,52 @@ +#pragma once + +#include <vector> + +#include "../Utilities/UtilMacros.h" + +#include "OpenGL.h" +#include "GPUDataBuffer.h" +#include "DefaultVertexLayout.h" +#include "CustomVertexLayout.h" +#include "Primitive.h" + +// 实际使用过程中,通常是一个VBO和一个IBO一起,submesh对应的是IBO中的不同的段,而不是不同的IBO + +class VertexBuffer +{ +public: + enum VertexBufferType + { + VertexBufferType_Static, // device + VertexBufferType_Stream, // pinned (best performance) + VertexBufferType_Dynamic,// device + }; + + VertexBuffer(int vbSize, int ibSize, VertexBufferType type); + ~VertexBuffer(); + + // 填充数据 + void GetChunk(uint sizePerVert, uint sizePerIndex, int maxVerts, int maxIndices, EPrimitive primitive, void **out_vb, void **out_ib); + // 提交数据 + void FlushChunk(int actualVerts, int actualIndices); + + GET(GPU::DataBuffer*, VB, m_VB); + GET(GPU::DataBuffer*, IB, m_IB); + + void Draw(CustomVertexLayout& layout); + +private: + void FillCustomVertexLayout(CustomVertexLayout& dst); + + VertexBufferType m_Type; + + GPU::DataBuffer* m_VB; + GPU::DataBuffer* m_IB; + + int m_SizePerVertex; + + int m_CurIndexCount; + + EPrimitive m_Primitive; + +}; |