[Feat] (MG_Impl/Texture): Implement basic validators for texture.

This commit is contained in:
BZLZHH
2025-08-12 18:17:14 +08:00
parent 4eba014513
commit 7ba3258150
2 changed files with 51 additions and 0 deletions
@@ -0,0 +1,40 @@
#include "Validators.h"
#include <MG_State/GLState/Core.h>
#include <MG_State/GLState/ErrorState/Error.h>
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
#include <MG_Util/Converters/GLToMG/TextureEnumConverter.h>
#include <MG_Util/Converters/MGToGL/TextureEnumConverter.h>
#include <MG_Util/Converters/MGToStr/TextureEnumConverter.h>
namespace MobileGL::MG_Impl::GLImpl {
namespace TextureImpl {
Bool ValidateTextureTarget(TextureTarget target) {
if (target == TextureTarget::Unknown) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidEnum,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateTextureTarget", "Invalid texture target"));
return false;
}
return true;
}
Bool ValidateTextureName(GLuint texture, Bool allowZero) {
if (texture == 0) {
if (allowZero) return true;
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateTextureName",
"Texture name cannot be zero"));
return false;
}
if (!MG_State::pGLContext->ValidateTextureName(texture)) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidValue,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateTextureName", "Invalid texture name"));
return false;
}
return true;
}
} // namespace TextureImpl
} // namespace MobileGL::MG_Impl::GLImpl
@@ -0,0 +1,11 @@
#pragma once
#include "MG_Util/Types.h"
#include <Includes.h>
#include <MG_State/GLState/TextureState/TextureObject.h>
namespace MobileGL::MG_Impl::GLImpl {
namespace TextureImpl {
Bool ValidateTextureTarget(TextureTarget target);
Bool ValidateTextureName(GLuint texture, Bool allowZero = false);
} // namespace TextureImpl
} // namespace MobileGL::MG_Impl::GLImpl