mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 13:48:30 +09:00
[Feat] (MG_State/VertexArrayState): Implement default VAO at index 0.
This commit is contained in:
@@ -3,7 +3,14 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_State {
|
namespace MG_State {
|
||||||
namespace GLState {
|
namespace GLState {
|
||||||
VertexArrayState::VertexArrayState() : m_indexGenerator(1024, 1) {}
|
VertexArrayState::VertexArrayState() : m_indexGenerator(1024, 1) {
|
||||||
|
// Generate default VAO at index 0, which is not valid in core profile, but still remains for
|
||||||
|
// compatibility reasons.
|
||||||
|
m_indexGenerator.Insert(0);
|
||||||
|
auto defaultVAO = MakeShared<VertexArrayObject>();
|
||||||
|
m_vertexArrays.push_back(defaultVAO);
|
||||||
|
m_boundVertexArray = defaultVAO;
|
||||||
|
}
|
||||||
|
|
||||||
SharedPtr<VertexArrayObject> VertexArrayState::GetVertexArrayObject(Uint index) {
|
SharedPtr<VertexArrayObject> VertexArrayState::GetVertexArrayObject(Uint index) {
|
||||||
if (index >= m_vertexArrays.size())
|
if (index >= m_vertexArrays.size())
|
||||||
@@ -20,12 +27,6 @@ namespace MobileGL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VertexArrayState::Bind(Uint index) {
|
void VertexArrayState::Bind(Uint index) {
|
||||||
if (index == 0) {
|
|
||||||
// FIXME: should we make a dummy VAO at index 0?
|
|
||||||
m_boundVertexArray = nullptr;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_boundVertexArray = GetVertexArrayObject(index);
|
m_boundVertexArray = GetVertexArrayObject(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user