summaryrefslogtreecommitdiff
path: root/Client/Source/Graphics/CustomVertexLayout.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-12-13 00:07:19 +0800
committerchai <chaifix@163.com>2021-12-13 00:07:19 +0800
commit60cbbdec07ab7a5636eac5b3c024ae44e937f4d4 (patch)
treeb2c7b0a868f18159dbc43d8954e1bd7668549a88 /Client/Source/Graphics/CustomVertexLayout.cpp
+init
Diffstat (limited to 'Client/Source/Graphics/CustomVertexLayout.cpp')
-rw-r--r--Client/Source/Graphics/CustomVertexLayout.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/Client/Source/Graphics/CustomVertexLayout.cpp b/Client/Source/Graphics/CustomVertexLayout.cpp
new file mode 100644
index 0000000..aa6be9b
--- /dev/null
+++ b/Client/Source/Graphics/CustomVertexLayout.cpp
@@ -0,0 +1,23 @@
+#include "CustomVertexLayout.h"
+
+namespace VertexLayout
+{
+
+ void SetupCustomVertexLayout(CustomVertexLayout& info)
+ {
+ glBindBuffer(GL_ARRAY_BUFFER, info.buffer);
+ for (int i = 0; i < info.attributes.size(); ++i)
+ {
+ VertexAttributeDescriptor& attr = info.attributes[i];
+ glEnableVertexAttribArray(i);
+ int numCompo = attr.componentNum;
+ GLenum compoType = VertexAttribute::ConvertAttrFormatToGLFormat(attr.componentFormat);
+ bool normalized = attr.normalize;
+ uint stride = attr.stride;
+ const void* pointer = attr.pointer;
+
+ glVertexAttribPointer(i, numCompo, compoType, normalized ? GL_TRUE : GL_FALSE, stride, pointer);
+ }
+ }
+
+}