From 80dca084b568e4e77d2a4031ce8625cdabc660ab Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 28 Oct 2021 01:52:12 +0800 Subject: + custom vertex buffer --- Runtime/Graphics/VertexAttribute.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Runtime/Graphics/VertexAttribute.h') diff --git a/Runtime/Graphics/VertexAttribute.h b/Runtime/Graphics/VertexAttribute.h index 2e6e59f..4e50a1a 100644 --- a/Runtime/Graphics/VertexAttribute.h +++ b/Runtime/Graphics/VertexAttribute.h @@ -21,10 +21,26 @@ enum VertexAttrFormat struct VertexAttributeDescriptor { - const void* pointer; // 内存地址或显存中相对VBO的偏移值 + // for default vertex layout + VertexAttributeDescriptor() {} + // for custom vertex layout + VertexAttributeDescriptor(int startOff, uint num, uint fmt, uint16 strd, bool normalized = false) + { + startOffset = startOff; + componentNum = num; + componentFormat = fmt; + stride = strd; + normalize = normalized; + } + + union { + const void* pointer; // 内存地址或显存中相对VBO的偏移值 + int startOffset; + }; uint componentNum; // 向量维度1,2,3,4 uint componentFormat; // 每个分量的类型 uint16 stride; // 间隔 + bool normalize; // 是否归一化,只用于CustomVertexLayout }; namespace VertexAttribute -- cgit v1.1-26-g67d0