summaryrefslogtreecommitdiff
path: root/Client/Source/Graphics/VertexBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Source/Graphics/VertexBuffer.h')
-rw-r--r--Client/Source/Graphics/VertexBuffer.h52
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;
+
+};