summaryrefslogtreecommitdiff
path: root/Runtime/Graphics/DefaultVertexLayout.h
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Graphics/DefaultVertexLayout.h')
-rw-r--r--Runtime/Graphics/DefaultVertexLayout.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/Runtime/Graphics/DefaultVertexLayout.h b/Runtime/Graphics/DefaultVertexLayout.h
new file mode 100644
index 0000000..2d78518
--- /dev/null
+++ b/Runtime/Graphics/DefaultVertexLayout.h
@@ -0,0 +1,52 @@
+#pragma once
+
+#include <vector>
+#include "../Utilities/UtilMacros.h"
+#include "../Shaders/ShaderChannel.h"
+#include "OpenGL.h"
+#include "GPUDataBuffer.h"
+#include "VertexAttribute.h"
+
+// 默认的顶点布局,适用于Mesh导入的结果,保持shader的一致性
+// 如果需要修改布局,比如编辑器UI中,用CustomVertexLayout
+
+// 默认的顶点属性以及顺序
+enum EVertexAttr
+{
+ VertexAttr_Position = 0,
+ VertexAttr_Normal,
+ VertexAttr_Tangent,
+ VertexAttr_Color,
+ VertexAttr_UV,
+ VertexAttr_UV2,
+ VertexAttr_UV3,
+ VertexAttr_UV4,
+
+ VertexAttr_Count
+};
+
+// GPU侧的默认顶点属性
+struct DefaultVertexLayout
+{
+ uint32 enableMask;
+ GLuint buffer; // vbo或者0(pinned memory)
+ VertexAttributeDescriptor attributes[VertexAttr_Count];
+};
+
+namespace VertexLayout
+{
+ extern uint GetDefaultIndexSize();
+ extern GLenum GetDefaultIndexFormat();
+
+ extern uint32 GetDynamicChunkStride(uint32 vertexAttrMask);
+ extern bool IsGLVertexAttrNeedNormalized(uint attr);
+ extern uint GetDefaultShaderChannelFormat(uint attr);
+ extern uint32 GetDefaultVertexAttrSize(int attr);
+ extern uint GetDefaultVertexAttrDimension(uint attr);
+ extern uint GetDefaultShaderChannelDimension(uint attr);
+ extern GLenum GetDefaultVertexAttrComponentType(uint attr);
+
+ void SetupDefaultVertexLayout(const DefaultVertexLayout& info);
+ void InvalidateVertexInputCache();
+
+}