diff options
author | chai <chaifix@163.com> | 2021-10-28 01:52:12 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-28 01:52:12 +0800 |
commit | 80dca084b568e4e77d2a4031ce8625cdabc660ab (patch) | |
tree | d8c0172aeddca648ec89cbbbda72a938f3ef7433 /Runtime/Graphics/CustomVertexLayout.cpp | |
parent | 1b6f71b2777bdc74d63f988346a8cfee766718b0 (diff) |
+ custom vertex buffer
Diffstat (limited to 'Runtime/Graphics/CustomVertexLayout.cpp')
-rw-r--r-- | Runtime/Graphics/CustomVertexLayout.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Runtime/Graphics/CustomVertexLayout.cpp b/Runtime/Graphics/CustomVertexLayout.cpp index e69de29..aa6be9b 100644 --- a/Runtime/Graphics/CustomVertexLayout.cpp +++ b/Runtime/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); + } + } + +} |