MCPcopy Create free account
hub / github.com/Illation/ETEngine / UpdateBuffer

Method UpdateBuffer

Engine/source/EtRendering/Extensions/DebugRenderer.cpp:55–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void DebugRenderer::UpdateBuffer()
56{
57 I_GraphicsApiContext* const api = Viewport::GetCurrentApiContext();
58
59 //Bind Object vertex array
60 api->BindVertexArray(m_VAO);
61
62 //Send the vertex buffer again
63 api->BindBuffer(E_BufferType::Vertex, m_VBO);
64
65 bool bufferResize = m_Lines.size() * sizeof(LineVertex) > m_BufferSize;
66 if (!m_VBO || bufferResize) //first creation or resize
67 {
68 if (bufferResize)
69 {
70 m_BufferSize = (uint32)m_Lines.size() * sizeof(LineVertex);
71 }
72
73 api->SetBufferData(E_BufferType::Vertex, m_BufferSize, m_Lines.data(), E_UsageHint::Dynamic);
74 }
75 else
76 {
77 void* p = api->MapBuffer(E_BufferType::Vertex, E_AccessMode::Write);
78 memcpy(p, m_Lines.data(), sizeof(LineVertex)*m_Lines.size());
79 api->UnmapBuffer(E_BufferType::Vertex);
80 }
81
82
83 api->BindBuffer(E_BufferType::Vertex, 0);
84}
85
86void DebugRenderer::Draw(Camera const& camera)
87{

Callers

nothing calls this directly

Calls 5

BindVertexArrayMethod · 0.80
BindBufferMethod · 0.80
SetBufferDataMethod · 0.80
MapBufferMethod · 0.80
UnmapBufferMethod · 0.80

Tested by

no test coverage detected