diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp index 96523e7b..7841d573 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp @@ -506,6 +506,22 @@ namespace MobileGL { auto& point = MG_State::pGLContext->GetBufferBindingPoint(bufferTarget, index); point.Bind(bufferObject); + point.ClearRange(); + } + + void BindBufferRange_State(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) { + BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); + if (!BufferImpl::ValidateBufferBindingPointTarget(bufferTarget)) return; + + auto bufferObject = MG_State::pGLContext->GetBufferObject(buffer); + if (!bufferObject) { + MG_State::pGLContext->CreateBufferObject(buffer); + bufferObject = MG_State::pGLContext->GetBufferObject(buffer); + } + + auto& point = MG_State::pGLContext->GetBufferBindingPoint(bufferTarget, index); + point.Bind(bufferObject); + point.SetRange(Range1D(offset, offset + size)); } /* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */ @@ -561,5 +577,9 @@ namespace MobileGL { void BindBufferBase(GLenum target, GLuint index, GLuint buffer) { BindBufferBase_State(target, index, buffer); } + + void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) { + BindBufferRange_State(target, index, buffer, offset, size); + } } // namespace MG_Impl::GLImpl } // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h index a75efc54..3f6b5fa4 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h +++ b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h @@ -18,5 +18,7 @@ namespace MobileGL { void BindBuffer(GLenum target, GLuint buffer); void GenBuffers(GLsizei n, GLuint* buffers); void BindBufferBase(GLenum target, GLuint index, GLuint buffer); + void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + } // namespace MG_Impl::GLImpl } // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp b/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp index d2f7369c..94348f5f 100644 --- a/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp +++ b/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp @@ -213,7 +213,7 @@ DECLARE_GL_FUNCTION_HEAD(GLboolean, IsVertexArray, GLuint array) DECLARE_GL_FUNC DECLARE_GL_FUNCTION_STUB_HEAD(void, GetIntegeri_v, GLenum target, GLuint index, GLint* data) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetIntegeri_v, target, index, data) DECLARE_GL_FUNCTION_STUB_HEAD(void, BeginTransformFeedback, GLenum primitiveMode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BeginTransformFeedback, primitiveMode) DECLARE_GL_FUNCTION_STUB_HEAD(void, EndTransformFeedback) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, EndTransformFeedback) -DECLARE_GL_FUNCTION_STUB_HEAD(void, BindBufferRange, GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BindBufferRange, target, index, buffer, offset, size) +DECLARE_GL_FUNCTION_HEAD(void, BindBufferRange, GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindBufferRange, target, index, buffer, offset, size) DECLARE_GL_FUNCTION_HEAD(void, BindBufferBase, GLenum target, GLuint index, GLuint buffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindBufferBase, target, index, buffer) DECLARE_GL_FUNCTION_STUB_HEAD(void, TransformFeedbackVaryings, GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, TransformFeedbackVaryings, program, count, varyings, bufferMode) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetTransformFeedbackVarying, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetTransformFeedbackVarying, program, index, bufSize, length, size, type, name) diff --git a/MobileGL/MG_State/GLState/BufferState/BufferState.cpp b/MobileGL/MG_State/GLState/BufferState/BufferState.cpp index 46268e29..595f3932 100644 --- a/MobileGL/MG_State/GLState/BufferState/BufferState.cpp +++ b/MobileGL/MG_State/GLState/BufferState/BufferState.cpp @@ -62,7 +62,7 @@ namespace MobileGL { return m_bufferObjects.find(index) != m_bufferObjects.end(); } - BindingSlot & + BindingSlotRange1D & BufferState::GetBindingPoint(BufferTarget target, Uint index) { for (SizeT i = 0; i < BufferBindPointTargets.size(); ++i) { if (BufferBindPointTargets[i] == target) { diff --git a/MobileGL/MG_State/GLState/BufferState/BufferState.h b/MobileGL/MG_State/GLState/BufferState/BufferState.h index c6b2597b..e774b50d 100644 --- a/MobileGL/MG_State/GLState/BufferState/BufferState.h +++ b/MobileGL/MG_State/GLState/BufferState/BufferState.h @@ -24,7 +24,7 @@ namespace MobileGL { SharedPtr CreateBufferObject(Uint index); BindingSlot& GetBindingSlot(BufferTarget target); // For glBindBufferBase / glBindBufferRange - BindingSlot& GetBindingPoint(BufferTarget target, Uint index); + BindingSlotRange1D& GetBindingPoint(BufferTarget target, Uint index); void MarkBufferObjectForDeletion(Uint index); Bool ValidateName(Uint index) const; Bool ValidateBufferObject(Uint index) const; @@ -35,7 +35,7 @@ namespace MobileGL { Array, GlobalBufferTargets.size()> m_bindingSlots; // TODO: query the count somewhere globally? // For glBindBufferBase / glBindBufferRange - Array, 14>, BufferBindPointTargets.size()> m_bufferBindPointTargets; + Array, 14>, BufferBindPointTargets.size()> m_bufferBindPointTargets; }; } // namespace GLState } // namespace MG_State diff --git a/MobileGL/MG_State/GLState/Core.cpp b/MobileGL/MG_State/GLState/Core.cpp index 1eab2c7b..d75233a5 100644 --- a/MobileGL/MG_State/GLState/Core.cpp +++ b/MobileGL/MG_State/GLState/Core.cpp @@ -65,7 +65,7 @@ namespace MobileGL { return m_bufferState.GetBindingSlot(target); } - BindingSlot& GLContext::GetBufferBindingPoint(BufferTarget target, Uint index) { + BindingSlotRange1D& GLContext::GetBufferBindingPoint(BufferTarget target, Uint index) { return m_bufferState.GetBindingPoint(target, index); } diff --git a/MobileGL/MG_State/GLState/Core.h b/MobileGL/MG_State/GLState/Core.h index bcfb75be..ffa66572 100644 --- a/MobileGL/MG_State/GLState/Core.h +++ b/MobileGL/MG_State/GLState/Core.h @@ -32,7 +32,7 @@ namespace MobileGL { Vector GenBufferNames(Uint number); SharedPtr GetBufferObject(Uint index); BindingSlot& GetBufferBindingSlot(BufferTarget target); - BindingSlot& GetBufferBindingPoint(BufferTarget target, Uint index); + BindingSlotRange1D& GetBufferBindingPoint(BufferTarget target, Uint index); SharedPtr CreateBufferObject(Uint index); void MarkBufferObjectForDeletion(Uint index); Bool ValidateBufferName(Uint index) const;