mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Feat] (MG_Impl/Texture): Implement basic validators for texture.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user