[Fix] (MG_State/BufferState, VertexArrayState): Correct IBO binding slot.

This commit is contained in:
BZLZHH
2025-08-03 18:56:50 +08:00
parent 972a4efed1
commit 3d18e702b0
13 changed files with 168 additions and 61 deletions
@@ -384,13 +384,6 @@ namespace MobileGL {
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
bindingSlot.Bind(bufferObject);
if (bufferTarget == BufferTarget::Index) {
auto currentVAO = MG_State::pGLContext->GetBoundVertexArray();
if (currentVAO) {
currentVAO->BindElementBuffer(bufferObject);
}
}
}
void GenBuffers_State(GLsizei n, GLuint* buffers) {
+18 -10
View File
@@ -3,17 +3,25 @@
namespace MobileGL::MG_Impl::GLImpl {
namespace BufferImpl {
bool ValidateBufferTarget(BufferTarget target) {
if (target != BufferTarget::Unknown)
return true;
if (target == BufferTarget::Unknown) {
using namespace MG_Util;
String bufferTargetStr = ConvertBufferTargetToString(target);
String glTargetStr = ConvertGLEnumToString(ConvertBufferTargetToGLEnum(target));
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
std::format("Target {} ({}) is not valid.",
bufferTargetStr, glTargetStr)));
return false;
}
if (target == BufferTarget::Index && MG_State::pGLContext->GetBoundVertexArray() == nullptr) {
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
"No vertex array object is bound."));
return false;
}
using namespace MG_Util;
String bufferTargetStr = ConvertBufferTargetToString(target);
String glTargetStr = ConvertGLEnumToString(ConvertBufferTargetToGLEnum(target));
MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget",
std::format("Target {} ({}) is not valid.",
bufferTargetStr, glTargetStr)));
return false;
return true;
}
bool ValidateBufferName(Uint index) {
@@ -16,6 +16,7 @@ namespace MobileGL::MG_Impl::GLImpl {
MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName",
std::format("Vertex array name {} is not valid.", index)));
return false;
}
return true;
}