diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp index dd294058..7ca6141f 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp @@ -24,7 +24,7 @@ namespace MobileGL { for (SizeT i = 0; i < static_cast(n); ++i) { Uint bufferName = buffers[i]; if (bufferName == 0) continue; - if (!BufferImpl::ValidateBufferName(bufferName)) continue; + if (!BufferImpl::ValidateBufferName(bufferName, true)) continue; MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName); } } @@ -410,7 +410,7 @@ namespace MobileGL { } void BindBuffer_State(GLenum target, GLuint buffer) { - if (buffer != 0 && !BufferImpl::ValidateBufferName(buffer)) return; + if (!BufferImpl::ValidateBufferName(buffer, true)) return; BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp b/MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp index 0cda7813..8c4d3b43 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp +++ b/MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp @@ -31,7 +31,16 @@ namespace MobileGL::MG_Impl::GLImpl { return true; } - Bool ValidateBufferName(Uint index) { + Bool ValidateBufferName(Uint index, Bool allowZero) { + if (index == 0) { + if (allowZero) return true; + + MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl/BufferImpl", + "ValidateBufferName", + "Buffer name 0 is not valid.")); + return false; + } Bool isValid = MG_State::pGLContext->ValidateBufferName(index); if (isValid) return true; MG_State::pGLContext->RecordError( diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/Validators.h b/MobileGL/MG_Impl/GLImpl/Buffer/Validators.h index 65e8c1bc..1b4b6cee 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/Validators.h +++ b/MobileGL/MG_Impl/GLImpl/Buffer/Validators.h @@ -5,7 +5,7 @@ namespace MobileGL::MG_Impl::GLImpl { namespace BufferImpl { Bool ValidateBufferTarget(BufferTarget target); - Bool ValidateBufferName(Uint index); + Bool ValidateBufferName(Uint index, Bool allowZero = false); Bool ValidateBufferUsage(BufferUsage usage); Bool ValidateBufferMappingAccess(Flags accessBits); } // namespace BufferImpl diff --git a/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp b/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp index fc0bad81..3ea3add9 100644 --- a/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp +++ b/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp @@ -107,7 +107,7 @@ namespace MobileGL { return; } - if (!VertexArrayImpl::ValidateVertexArrayName(array)) return; + if (!VertexArrayImpl::ValidateVertexArrayName(array, true)) return; if (!MG_State::pGLContext->ValidateVertexArrayObject(array)) { MG_State::pGLContext->CreateVertexArrayObject(array); @@ -128,7 +128,7 @@ namespace MobileGL { GLuint vao = arrays[i]; if (vao == 0) continue; - if (!VertexArrayImpl::ValidateVertexArrayName(vao)) continue; + if (!VertexArrayImpl::ValidateVertexArrayName(vao, true)) continue; if (MG_State::pGLContext->GetBoundVertexArray() && MG_State::pGLContext->GetBoundVertexArray() == MG_State::pGLContext->GetVertexArrayObject(vao)) { diff --git a/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp b/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp index b0dd360a..374a923a 100644 --- a/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp +++ b/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp @@ -7,8 +7,10 @@ namespace MobileGL::MG_Impl::GLImpl { namespace VertexArrayImpl { - Bool ValidateVertexArrayName(Uint index) { + Bool ValidateVertexArrayName(Uint index, Bool allowZero) { if (index == 0) { + if (allowZero) return true; + MG_State::pGLContext->RecordError( ErrorCode::InvalidValue, MakeShared("MG_Impl/GLImpl", "ValidateVertexArrayName", "Vertex array name 0 is not supported.")); diff --git a/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.h b/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.h index f7bbd0e0..e6865744 100644 --- a/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.h +++ b/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.h @@ -4,7 +4,7 @@ namespace MobileGL::MG_Impl::GLImpl { namespace VertexArrayImpl { - Bool ValidateVertexArrayName(Uint index); + Bool ValidateVertexArrayName(Uint index, Bool allowZero = false); Bool ValidateVertexArrayObject(Uint index); Bool ValidateVertexAttributeIndex(Uint index); Bool ValidateVertexAttribPointerParams(Uint index, SizeT size, DataType type, Int stride);