Fixed conflict between VAO and OpenGL::BindBuffer

Former-commit-id: b1182e3b0327a73431a8e81106df9109e9a80cc2
This commit is contained in:
Lynix 2013-06-18 02:29:31 +02:00
parent 9e906c2568
commit 3e8ed9b1e4
3 changed files with 14 additions and 1 deletions

View File

@ -72,6 +72,7 @@ class NAZARA_API NzOpenGL
static void BindProgram(GLuint id);
static void BindTexture(nzImageType type, GLuint id);
static void BindTexture(unsigned int textureUnit, nzImageType type, GLuint id);
static void BindVertexArray(GLuint id);
static void DeleteBuffer(nzBufferType type, GLuint id);
static void DeleteProgram(GLuint id);

View File

@ -274,6 +274,15 @@ void NzOpenGL::BindTexture(unsigned int textureUnit, nzImageType type, GLuint id
}
}
void NzOpenGL::BindVertexArray(GLuint id)
{
// Je ne pense pas que ça soit une bonne idée de le mettre en cache, c'est un objet "spécial"
glBindVertexArray(id);
// On invalide les bindings des buffers (Overridés par le VertexArray)
std::memset(s_buffersBinding, 0, (nzBufferType_Max+1)*sizeof(GLuint));
}
void NzOpenGL::DeleteBuffer(nzBufferType type, GLuint id)
{
glDeleteBuffers(1, &id);

View File

@ -1498,6 +1498,7 @@ bool NzRenderer::EnsureStateUpdate()
VAO_Key key(NzContext::GetCurrent(), s_indexBuffer, s_vertexBuffer, s_instancing);
auto it = s_vaos.find(key);
if (it == s_vaos.end())
{
// On créé notre VAO
@ -1574,6 +1575,8 @@ bool NzRenderer::EnsureStateUpdate()
NzHardwareBuffer* indexBufferImpl = static_cast<NzHardwareBuffer*>(s_indexBuffer->GetBuffer()->GetImpl());
indexBufferImpl->Bind();
}
else
NzOpenGL::BindBuffer(nzBufferType_Index, 0);
}
if (s_useVertexArrayObjects)
@ -1583,7 +1586,7 @@ bool NzRenderer::EnsureStateUpdate()
glBindVertexArray(0);
// Nous (re)bindons le VAO pour définir les attributs de vertice
glBindVertexArray(vao);
NzOpenGL::BindVertexArray(vao);
}
s_updateFlags &= ~Update_VAO;