From 60cbbdec07ab7a5636eac5b3c024ae44e937f4d4 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 13 Dec 2021 00:07:19 +0800 Subject: +init --- Client/Source/Graphics/VertexAttribute.h | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Client/Source/Graphics/VertexAttribute.h (limited to 'Client/Source/Graphics/VertexAttribute.h') diff --git a/Client/Source/Graphics/VertexAttribute.h b/Client/Source/Graphics/VertexAttribute.h new file mode 100644 index 0000000..8f7bc82 --- /dev/null +++ b/Client/Source/Graphics/VertexAttribute.h @@ -0,0 +1,52 @@ +#pragma once + +#include + +#include "../Utilities/UtilMacros.h" + +#include "OpenGL.h" +#include "GPUDataBuffer.h" + +// component format +enum VertexAttrFormat +{ + VertexAttrFormat_Float = 0, // position\normal\tangent\uv\uv2\uv3\uv4 + VertexAttrFormat_Float16, + VertexAttrFormat_Color, // color + VertexAttrFormat_Byte, + VertexAttrFormat_Unsigned_Byte, + + VertexAttrFormat_Count +}; + +struct VertexAttributeDescriptor +{ + //union { + const void* pointer; // 内存地址,刚创建时留空 + int startOffset; // 显存中相对VBO的偏移值 + //}; + uint componentNum; // 向量维度1,2,3,4 + uint componentFormat; // 每个分量的类型 + uint16 stride; // 间隔 + bool normalize; // 是否归一化,只用于CustomVertexLayout + + // 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; + } + +}; + +namespace VertexAttribute +{ + + extern GLenum ConvertAttrFormatToGLFormat(uint fmt); + +} -- cgit v1.1-26-g67d0