void VertexArrayBuffer::Build(ref_ptr<GpuProgram> program) { ASSERT(m_VAO == 0 && m_program == nullptr, ("No-no-no! You can't rebuild VertexArrayBuffer")); m_program = program; /// if OES_vertex_array_object not supported, than buffers will be bind on each Render call if (!GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject)) return; if (m_staticBuffers.empty()) return; m_VAO = GLFunctions::glGenVertexArray(); Bind(); BindStaticBuffers(); }
void VertexArrayBuffer::RenderRange(IndicesRange const & range) { if (!(m_staticBuffers.empty() && m_dynamicBuffers.empty()) && GetIndexCount() > 0) { ASSERT(m_program != nullptr, ("Somebody not call Build. It's very bad. Very very bad")); /// if OES_vertex_array_object is supported than all bindings already saved in VAO /// and we need only bind VAO. In Bind method have ASSERT("bind already called") if (GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject)) Bind(); else BindStaticBuffers(); BindDynamicBuffers(); GetIndexBuffer()->Bind(); GLFunctions::glDrawElements(dp::IndexStorage::SizeOfIndex(), range.m_idxCount, range.m_idxStart); } }
void VertexArrayBuffer::Render() { if (!(m_staticBuffers.empty() && m_dynamicBuffers.empty())) { ASSERT(!m_program.IsNull(), ("Somebody not call Build. It's very bad. Very very bad")); /// if OES_vertex_array_object is supported than all bindings already saved in VAO /// and we need only bind VAO. In Bind method have ASSERT("bind already called") if (GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject)) Bind(); else BindStaticBuffers(); BindDynamicBuffers(); m_indexBuffer->Bind(); GLFunctions::glDrawElements(m_indexBuffer->GetCurrentSize()); } }