diff options
author | chai <chaifix@163.com> | 2021-11-02 09:30:25 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-02 09:30:25 +0800 |
commit | b7511abf1a1f302b5c7ebf50faaf65b62d7bb6ed (patch) | |
tree | 7265398e248b55ede4b3550ec47660be334bf1ff /Runtime/Graphics | |
parent | a11097e51fcaef4488218411f2d7b3ee34550000 (diff) |
* TextMesh
Diffstat (limited to 'Runtime/Graphics')
-rw-r--r-- | Runtime/Graphics/Color.h | 14 | ||||
-rw-r--r-- | Runtime/Graphics/VertexAttribute.cpp | 3 | ||||
-rw-r--r-- | Runtime/Graphics/VertexAttribute.h | 9 | ||||
-rw-r--r-- | Runtime/Graphics/VertexBuffer.cpp | 6 | ||||
-rw-r--r-- | Runtime/Graphics/VertexBuffer.h | 4 |
5 files changed, 22 insertions, 14 deletions
diff --git a/Runtime/Graphics/Color.h b/Runtime/Graphics/Color.h index abc0724..af8d3ba 100644 --- a/Runtime/Graphics/Color.h +++ b/Runtime/Graphics/Color.h @@ -5,9 +5,8 @@ namespace Internal { - class Color + struct Color { - public: Color(float r = 0, float g = 0, float b = 0, float a = 0) { this->r = r; @@ -18,18 +17,19 @@ namespace Internal float r, g, b, a; }; - class Color32 + struct Color32 { - public: - Color32(int r = 0, int g = 0, int b = 0, int a = 0) + Color32(unsigned char r = 0, unsigned char g = 0, unsigned char b = 0, unsigned char a = 0) { this->r = r; this->g = g; this->b = b; this->a = a; } - int r, g, b, a; - + unsigned char r, g, b, a; }; } + +typedef Internal::Color Color; +typedef Internal::Color32 Color32; diff --git a/Runtime/Graphics/VertexAttribute.cpp b/Runtime/Graphics/VertexAttribute.cpp index 0b0e8e4..e5f2ea7 100644 --- a/Runtime/Graphics/VertexAttribute.cpp +++ b/Runtime/Graphics/VertexAttribute.cpp @@ -8,7 +8,8 @@ namespace VertexAttribute GL_FLOAT, // VertexAttrFormat_Float GL_HALF_FLOAT, // VertexAttrFormat_Float16 GL_UNSIGNED_BYTE, // VertexAttrFormat_Color - GL_BYTE // VertexAttrFormat_Byte + GL_BYTE, // VertexAttrFormat_Byte + GL_UNSIGNED_BYTE, // VertexAttrFormat_Unsigned_Byte }; GLenum ConvertAttrFormatToGLFormat(uint fmt) diff --git a/Runtime/Graphics/VertexAttribute.h b/Runtime/Graphics/VertexAttribute.h index 2757c70..ae6d178 100644 --- a/Runtime/Graphics/VertexAttribute.h +++ b/Runtime/Graphics/VertexAttribute.h @@ -12,11 +12,12 @@ enum VertexAttrFormat { VertexAttrFormat_Float = 0, // position\normal\tangent\uv\uv2\uv3\uv4 - VertexAttrFormat_Float16 = 1, - VertexAttrFormat_Color = 2, // color - VertexAttrFormat_Byte = 3, + VertexAttrFormat_Float16, + VertexAttrFormat_Color, // color + VertexAttrFormat_Byte, + VertexAttrFormat_Unsigned_Byte, - VertexAttrFormat_Count = 4 + VertexAttrFormat_Count }; struct VertexAttributeDescriptor diff --git a/Runtime/Graphics/VertexBuffer.cpp b/Runtime/Graphics/VertexBuffer.cpp index 8423c2b..5d136ee 100644 --- a/Runtime/Graphics/VertexBuffer.cpp +++ b/Runtime/Graphics/VertexBuffer.cpp @@ -1,10 +1,14 @@ #include "VertexBuffer.h" #include "../Profiling/FrameStats.h" -VertexBuffer::VertexBuffer(VertexBufferType type) +VertexBuffer::VertexBuffer(int vbSize, int ibSize, VertexBufferType type) { + m_VB = GPU::ClaimBuffer(vbSize, GL_ARRAY_BUFFER); + m_IB = GPU::ClaimBuffer(ibSize, GL_ELEMENT_ARRAY_BUFFER); } VertexBuffer::~VertexBuffer() { + GPU::ReleaseBuffer(m_VB); + GPU::ReleaseBuffer(m_IB); } diff --git a/Runtime/Graphics/VertexBuffer.h b/Runtime/Graphics/VertexBuffer.h index b03df3b..c651bdb 100644 --- a/Runtime/Graphics/VertexBuffer.h +++ b/Runtime/Graphics/VertexBuffer.h @@ -23,9 +23,11 @@ public: VertexBufferType_Dynamic,// device }; - VertexBuffer(VertexBufferType type); + VertexBuffer(int vbSize, int ibSize, VertexBufferType type); ~VertexBuffer(); + + void Draw(); private: |