diff options
Diffstat (limited to 'Runtime/GUI/UILine.cpp')
-rw-r--r-- | Runtime/GUI/UILine.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Runtime/GUI/UILine.cpp b/Runtime/GUI/UILine.cpp new file mode 100644 index 0000000..8db681e --- /dev/null +++ b/Runtime/GUI/UILine.cpp @@ -0,0 +1,48 @@ +#include "UILine.h" + +struct UILineLayout +{ + Vector2 position; +}; + +static CustomVertexLayout layout; + +InitializeStaticVariables([]() { + VertexAttributeDescriptor POSITION = VertexAttributeDescriptor(0, 2, VertexAttrFormat_Float, sizeof(UILineLayout)); + + layout.attributes.push_back(POSITION); +}); + +void UILine::Draw() +{ + const int nVerts = 2; + const int nIndices = 2; + + float pos[] = { + m_From.x, m_From.y, + m_To.x, m_To.y, + }; + + uint16 indices[] = { + 0, 1 + }; + + + uint8* vb; + uint16* ib; + + g_SharedVBO.GetChunk(sizeof(UILineLayout), sizeof(uint16), nVerts, nIndices, Primitive_Line, (void**)&vb, (void**)&ib); + + UILineLayout* dst = (UILineLayout*)vb; + + for (int i = 0; i < nVerts; ++i) + { + dst[i].position.Set(pos[2 * i], pos[2 * i + 1]); + } + + for (int i = 0; i < nIndices; ++i) + ib[i] = indices[i]; + + g_SharedVBO.ReleaseChunk(nVerts, nIndices); + g_SharedVBO.DrawChunk(layout); +}
\ No newline at end of file |