diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index afdab8751..4e6be67e0 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -5135,6 +5135,11 @@ namespace bgfx { namespace gl m_instanceData[used] = -1; } + void ProgramGL::bindAttributesBegin() + { + bx::memCopy(m_unboundUsedAttrib, m_used, sizeof(m_unboundUsedAttrib)); + } + void ProgramGL::bindAttributes(const VertexLayout& _layout, uint32_t _baseVertex) { for (uint32_t ii = 0, iiEnd = m_usedCount; ii < iiEnd; ++ii) @@ -5184,6 +5189,34 @@ namespace bgfx { namespace gl } } + void ProgramGL::bindInstanceData(uint32_t _stride, uint32_t _baseVertex) const + { + uint32_t baseVertex = _baseVertex; + for (uint32_t ii = 0; -1 != m_instanceData[ii]; ++ii) + { + GLint loc = m_instanceData[ii]; + lazyEnableVertexAttribArray(loc); + GL_CHECK(glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, _stride, (void*)(uintptr_t)baseVertex)); + GL_CHECK(glVertexAttribDivisor(loc, 1)); + baseVertex += 16; + } + } + + void ProgramGL::bindAttributesEnd() + { + for (uint32_t ii = 0, iiEnd = m_usedCount; ii < iiEnd; ++ii) + { + if (Attrib::Count != m_unboundUsedAttrib[ii]) + { + Attrib::Enum attr = Attrib::Enum(m_unboundUsedAttrib[ii]); + GLint loc = m_attributes[attr]; + lazyDisableVertexAttribArray(loc); + } + } + + applyLazyEnabledVertexAttributes(); + } + void ProgramGL::unbindAttributes() { for(uint32_t ii = 0, iiEnd = m_usedCount; ii < iiEnd; ++ii) @@ -5197,19 +5230,6 @@ namespace bgfx { namespace gl } } - void ProgramGL::bindInstanceData(uint32_t _stride, uint32_t _baseVertex) const - { - uint32_t baseVertex = _baseVertex; - for (uint32_t ii = 0; -1 != m_instanceData[ii]; ++ii) - { - GLint loc = m_instanceData[ii]; - lazyEnableVertexAttribArray(loc); - GL_CHECK(glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, _stride, (void*)(uintptr_t)baseVertex) ); - GL_CHECK(glVertexAttribDivisor(loc, 1) ); - baseVertex += 16; - } - } - void ProgramGL::unbindInstanceData() const { for(uint32_t ii = 0; -1 != m_instanceData[ii]; ++ii) diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 34a896156..d52efc768 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -1484,32 +1484,12 @@ namespace bgfx { namespace gl void create(const ShaderGL& _vsh, const ShaderGL& _fsh); void destroy(); void init(); - void bindInstanceData(uint32_t _stride, uint32_t _baseVertex = 0) const; - void unbindInstanceData() const; - - void bindAttributesBegin() - { - bx::memCopy(m_unboundUsedAttrib, m_used, sizeof(m_unboundUsedAttrib) ); - } + void bindAttributesBegin(); void bindAttributes(const VertexLayout& _layout, uint32_t _baseVertex = 0); - - void bindAttributesEnd() - { - for (uint32_t ii = 0, iiEnd = m_usedCount; ii < iiEnd; ++ii) - { - if (Attrib::Count != m_unboundUsedAttrib[ii]) - { - Attrib::Enum attr = Attrib::Enum(m_unboundUsedAttrib[ii]); - GLint loc = m_attributes[attr]; - lazyDisableVertexAttribArray(loc); - } - } - - extern void applyLazyEnabledVertexAttributes(); - applyLazyEnabledVertexAttributes(); - } - + void bindInstanceData(uint32_t _stride, uint32_t _baseVertex = 0) const; + void bindAttributesEnd(); + void unbindInstanceData() const; void unbindAttributes(); GLuint m_id;