This commit is contained in:
2025-08-13 14:20:36 +08:00
23 changed files with 1090 additions and 67 deletions
+11 -7
View File
@@ -21,13 +21,19 @@ set(SOURCE_FILES
MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.cpp
MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.cpp
MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.cpp
MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.cpp
MobileGL/MG_Util/Converters/GLToGlslang/GLShaderLangConverter.cpp
MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.cpp
MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.cpp
MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.cpp
MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.cpp
MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.cpp
MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.cpp
MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.cpp
MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp
MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp
MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp
MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp
@@ -37,18 +43,16 @@ set(SOURCE_FILES
# @INSERTION_POINT:SOURCE_FILE_GLIMPL@ #
MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp
MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp
MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp
MobileGL/MG_Impl/GLImpl/Texture/Validators.cpp
MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp
MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp
MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp
MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp
MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp
MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp
MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp
MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp
MobileGL/MG_Backend/Init.cpp
MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp
MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp
MobileGL/MG_State/GLState/Core.cpp
MobileGL/MG_State/GLState/ErrorState/Error.cpp
MobileGL/MG_State/GLState/BufferState/BufferState.cpp
@@ -78,7 +82,7 @@ if(MACOS)
${iOS_LIB_DIR}/libMachineIndependent.a
${iOS_LIB_DIR}/libOSDependent.a
${iOS_LIB_DIR}/libSPIRV-Tools-diff.a
${iOS_LIB_DIR}/libSPIRV-Tools-link.a
${iOS_LIB_DIR}/libSPIRV-Tools-link.aBuffer
${iOS_LIB_DIR}/libSPIRV-Tools-lint.a
${iOS_LIB_DIR}/libSPIRV-Tools-opt.a
${iOS_LIB_DIR}/libSPIRV-Tools-reduce.a
+2 -2
View File
@@ -24,7 +24,7 @@ namespace MobileGL {
for (SizeT i = 0; i < static_cast<SizeT>(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;
+10 -1
View File
@@ -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<GenericErrorInfo>("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(
+1 -1
View File
@@ -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<BufferMappingAccessBit> accessBits);
} // namespace BufferImpl
+257 -44
View File
@@ -1,166 +1,379 @@
#include "GL_Texture.h"
#include "Validators.h"
#include <MG_State/GLState/Core.h>
#include <MG_State/GLState/ErrorState/Error.h>
#include <MG_Util/Converters/GLToMG/TextureEnumConverter.h>
#include <MG_Util/Converters/MGToGL/TextureEnumConverter.h>
#include <MG_Util/Converters/MGToStr/TextureEnumConverter.h>
namespace MobileGL {
namespace MG_Impl::GLImpl {
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels) {
void TexSubImage3D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels) {
// TODO: implement
}
void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
GLenum format, GLenum type, const void* pixels) {
void TexSubImage2D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLenum type, const void* pixels) {
// TODO: implement
}
void TexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type,
const GLvoid* pixels) {
void TexSubImage1D_State(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type,
const GLvoid* pixels) {
// TODO: implement
}
void TexParameterf(GLenum target, GLenum pname, GLfloat param) {
void TexParameterf_State(GLenum target, GLenum pname, GLfloat param) {
// TODO: implement
}
void TexParameteri(GLenum target, GLenum pname, GLint param) {
void TexParameteri_State(GLenum target, GLenum pname, GLint param) {
// TODO: implement
}
void TexImage3DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height,
GLsizei depth, GLboolean fixedsamplelocations) {
void TexImage3DMultisample_State(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width,
GLsizei height, GLsizei depth, GLboolean fixedsamplelocations) {
// TODO: implement
}
void TexImage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height,
GLboolean fixedsamplelocations) {
void TexImage2DMultisample_State(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width,
GLsizei height, GLboolean fixedsamplelocations) {
// TODO: implement
}
void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type, const void* pixels) {
void TexImage3D_State(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels) {
// TODO: implement
}
void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border,
GLenum format, GLenum type, const void* pixels) {
void TexImage2D_State(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
GLint border, GLenum format, GLenum type, const void* pixels) {
// TODO: implement
}
void TexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format,
GLenum type, const GLvoid* pixels) {
void TexImage1D_State(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border,
GLenum format, GLenum type, const GLvoid* pixels) {
// TODO: implement
}
void TexBuffer(GLenum target, GLenum internalformat, GLuint buffer) {
void TexBuffer_State(GLenum target, GLenum internalformat, GLuint texture) {
// TODO: implement
}
GLboolean IsTexture(GLuint texture) {
GLboolean IsTexture_State(GLuint texture) {
// TODO: implement
return GL_FALSE;
}
void GetTexParameterIuiv(GLenum target, GLenum pname, GLuint* params) {
void GetTexParameterIuiv_State(GLenum target, GLenum pname, GLuint* params) {
// TODO: implement
}
void GetTexParameterIiv_State(GLenum target, GLenum pname, GLint* params) {
// TODO: implement
}
void GetTexParameteriv_State(GLenum target, GLenum pname, GLint* params) {
// TODO: implement
}
void GetTexParameterfv_State(GLenum target, GLenum pname, GLfloat* params) {
// TODO: implement
}
void GetTexLevelParameteriv_State(GLenum target, GLint level, GLenum pname, GLint* params) {
// TODO: implement
}
void GetTexLevelParameterfv_State(GLenum target, GLint level, GLenum pname, GLfloat* params) {
// TODO: implement
}
void GetTexImage_State(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) {
// TODO: implement
}
void GetCompressedTexImage_State(GLenum target, GLint level, void* img) {
// TODO: implement
}
void GenTextures_State(GLsizei n, GLuint* textures) {
if (n < 0) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidValue,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GenTextures_State", "n must be non-negative"));
return;
}
auto textureNames = MG_State::pGLContext->GenTextureNames(n);
Copy(textureNames.data(), textures, textureNames.size());
}
void DeleteTextures_State(GLsizei n, const GLuint* textures) {
if (n < 0) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidValue,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteTextures_State", "n must be non-negative."));
return;
}
if (!textures) {
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "DeleteTextures_State",
"Texture names array cannot be null."));
return;
}
for (SizeT i = 0; i < static_cast<SizeT>(n); ++i) {
Uint textureName = textures[i];
if (textureName == 0) continue;
if (!TextureImpl::ValidateTextureName(textureName, true)) continue;
MG_State::pGLContext->MarkTextureObjectForDeletion(textureName);
}
}
void CopyTexSubImage3D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x,
GLint y, GLsizei width, GLsizei height) {
// TODO: implement
}
void CopyTexSubImage2D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
GLsizei width, GLsizei height) {
// TODO: implement
}
void CopyTexSubImage1D_State(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) {
// TODO: implement
}
void CopyTexImage2D_State(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
GLsizei height, GLint border) {
// TODO: implement
}
void CopyTexImage1D_State(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
GLint border) {
// TODO: implement
}
void CompressedTexSubImage3D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format,
GLsizei imageSize, const void* data) {
// TODO: implement
}
void CompressedTexSubImage2D_State(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLsizei imageSize, const void* data) {
// TODO: implement
}
void CompressedTexSubImage1D_State(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format,
GLsizei imageSize, const void* data) {
// TODO: implement
}
void CompressedTexImage3D_State(GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLsizei depth, GLint border, GLsizei imageSize,
const void* data) {
// TODO: implement
}
void CompressedTexImage2D_State(GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLsizei imageSize, const void* data) {
// TODO: implement
}
void CompressedTexImage1D_State(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border,
GLsizei imageSize, const void* data) {
// TODO: implement
}
void BindTexture_State(GLenum target, GLuint texture) {
if (!TextureImpl::ValidateTextureName(texture, true)) return;
TextureTarget textureTarget = MG_Util::ConvertGLEnumToTextureTarget(target);
if (!TextureImpl::ValidateTextureTarget(textureTarget)) return;
auto textureObject = MG_State::pGLContext->GetTextureObject(texture);
if (!textureObject) {
textureObject = MG_State::pGLContext->CreateTextureObject(texture, textureTarget);
} else if (textureObject->GetTarget() != textureTarget) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BindTexture_State",
"Texture target does not match the previously created texture"));
return;
}
auto& currentUnit =
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
auto& bindingSlot = currentUnit.GetBindingSlot(textureTarget);
bindingSlot.Bind(textureObject);
}
void ActiveTexture_State(GLenum texture) {
// TODO: implement
}
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width,
GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels) {
TexSubImage3D_State(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
}
void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
GLenum format, GLenum type, const void* pixels) {
TexSubImage2D_State(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
void TexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type,
const GLvoid* pixels) {
TexSubImage1D_State(target, level, xoffset, width, format, type, pixels);
}
void TexParameterf(GLenum target, GLenum pname, GLfloat param) {
TexParameterf_State(target, pname, param);
}
void TexParameteri(GLenum target, GLenum pname, GLint param) {
TexParameteri_State(target, pname, param);
}
void TexImage3DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height,
GLsizei depth, GLboolean fixedsamplelocations) {
TexImage3DMultisample_State(target, samples, internalformat, width, height, depth, fixedsamplelocations);
}
void TexImage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height,
GLboolean fixedsamplelocations) {
TexImage2DMultisample_State(target, samples, internalformat, width, height, fixedsamplelocations);
}
void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type, const void* pixels) {
TexImage3D_State(target, level, internalformat, width, height, depth, border, format, type, pixels);
}
void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border,
GLenum format, GLenum type, const void* pixels) {
TexImage2D_State(target, level, internalformat, width, height, border, format, type, pixels);
}
void TexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format,
GLenum type, const GLvoid* pixels) {
TexImage1D_State(target, level, internalFormat, width, border, format, type, pixels);
}
void TexBuffer(GLenum target, GLenum internalformat, GLuint texture) {
TexBuffer_State(target, internalformat, texture);
}
GLboolean IsTexture(GLuint texture) {
return IsTexture_State(texture);
}
void GetTexParameterIuiv(GLenum target, GLenum pname, GLuint* params) {
GetTexParameterIuiv_State(target, pname, params);
}
void GetTexParameterIiv(GLenum target, GLenum pname, GLint* params) {
// TODO: implement
GetTexParameterIiv_State(target, pname, params);
}
void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) {
// TODO: implement
GetTexParameteriv_State(target, pname, params);
}
void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) {
// TODO: implement
GetTexParameterfv_State(target, pname, params);
}
void GetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint* params) {
// TODO: implement
GetTexLevelParameteriv_State(target, level, pname, params);
}
void GetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat* params) {
// TODO: implement
GetTexLevelParameterfv_State(target, level, pname, params);
}
void GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) {
// TODO: implement
GetTexImage_State(target, level, format, type, pixels);
}
void GetCompressedTexImage(GLenum target, GLint level, void* img) {
// TODO: implement
GetCompressedTexImage_State(target, level, img);
}
void GenTextures(GLsizei n, GLuint* textures) {
// TODO: implement
GenTextures_State(n, textures);
}
void DeleteTextures(GLsizei n, const GLuint* textures) {
// TODO: implement
DeleteTextures_State(n, textures);
}
void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x,
GLint y, GLsizei width, GLsizei height) {
// TODO: implement
CopyTexSubImage3D_State(target, level, xoffset, yoffset, zoffset, x, y, width, height);
}
void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
GLsizei width, GLsizei height) {
// TODO: implement
CopyTexSubImage2D_State(target, level, xoffset, yoffset, x, y, width, height);
}
void CopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) {
// TODO: implement
CopyTexSubImage1D_State(target, level, xoffset, x, y, width);
}
void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
GLsizei height, GLint border) {
// TODO: implement
CopyTexImage2D_State(target, level, internalformat, x, y, width, height, border);
}
void CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
GLint border) {
// TODO: implement
CopyTexImage1D_State(target, level, internalformat, x, y, width, border);
}
void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize,
const void* data) {
// TODO: implement
CompressedTexSubImage3D_State(target, level, xoffset, yoffset, zoffset, width, height, depth, format,
imageSize, data);
}
void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLsizei imageSize, const void* data) {
// TODO: implement
CompressedTexSubImage2D_State(target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
void CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format,
GLsizei imageSize, const void* data) {
// TODO: implement
CompressedTexSubImage1D_State(target, level, xoffset, width, format, imageSize, data);
}
void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
GLsizei depth, GLint border, GLsizei imageSize, const void* data) {
// TODO: implement
CompressedTexImage3D_State(target, level, internalformat, width, height, depth, border, imageSize, data);
}
void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
GLint border, GLsizei imageSize, const void* data) {
// TODO: implement
CompressedTexImage2D_State(target, level, internalformat, width, height, border, imageSize, data);
}
void CompressedTexImage1D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border,
GLsizei imageSize, const void* data) {
// TODO: implement
CompressedTexImage1D_State(target, level, internalformat, width, border, imageSize, data);
}
void BindTexture(GLenum target, GLuint texture) {
// TODO: implement
BindTexture_State(target, texture);
}
void ActiveTexture(GLenum texture) {
// TODO: implement
ActiveTexture_State(texture);
}
} // namespace MG_Impl::GLImpl
@@ -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
@@ -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)) {
@@ -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<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateVertexArrayName",
"Vertex array name 0 is not supported."));
@@ -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);
+2 -2
View File
@@ -136,8 +136,8 @@ namespace MobileGL {
m_textureState.MarkTextureObjectForDeletion(index);
}
TextureUnit& GLContext::GetTextureUnitObject() {
return m_textureState.GetUnitObject();
TextureUnit& GLContext::GetTextureUnitObject(Int unit) {
return m_textureState.GetUnitObject(unit);
}
Bool GLContext::ValidateTextureName(Uint index) const {
+2 -1
View File
@@ -48,7 +48,7 @@ namespace MobileGL {
SharedPtr<ITextureObject> GetTextureObject(Uint index);
SharedPtr<ITextureObject> CreateTextureObject(Uint index, TextureTarget target);
void MarkTextureObjectForDeletion(Uint index);
TextureUnit& GetTextureUnitObject();
TextureUnit& GetTextureUnitObject(Int unit);
Bool ValidateTextureName(Uint index) const;
Bool ValidateTextureObject(Uint index) const;
Int GetActiveTextureUnit() const;
@@ -64,6 +64,7 @@ namespace MobileGL {
SharedPtr<ProgramObject> GetProgramObject(Uint index);
SharedPtr<ShaderObject> GetShaderObject(Uint index);
void UseProgram(Uint program);
private:
// Error
ErrorState m_errorState;
@@ -21,7 +21,7 @@ namespace MobileGL {
Red,
RG,
RGB,
BFR,
BGR,
RGBA,
BGRA,
RInteger,
@@ -64,11 +64,11 @@ namespace MobileGL {
}
}
TextureUnit& TextureState::GetUnitObject() {
if (m_activeTextureUnit < 0 || m_activeTextureUnit >= MAX_TEXTURE_IMAGE_UNITS) {
TextureUnit& TextureState::GetUnitObject(Int unit) {
if (unit < 0 || unit >= MAX_TEXTURE_IMAGE_UNITS) {
THROW_EXCEPTION("Active texture unit is out of range");
}
return m_textureUnits[m_activeTextureUnit];
return m_textureUnits[unit];
}
Int TextureState::GetActiveTextureUnit() const {
@@ -16,7 +16,7 @@ namespace MobileGL {
Vector<Uint> GenerateNames(Uint number);
SharedPtr<ITextureObject> CreateTextureObject(Uint index, TextureTarget target);
SharedPtr<ITextureObject> GetTextureObject(Uint index);
TextureUnit& GetUnitObject();
TextureUnit& GetUnitObject(Int unit);
Int GetActiveTextureUnit() const;
void SetActiveTextureUnit(Int unit);
void MarkTextureObjectForDeletion(Uint index);
@@ -18,6 +18,10 @@ namespace MobileGL {
GetAllBindingSlots() {
return m_slots;
}
void TextureUnit::SetSamplerObject(SharedPtr<SamplerObject> sampler) {
m_sampler = sampler;
}
} // namespace GLState
} // namespace MG_State
} // namespace MobileGL
@@ -13,6 +13,7 @@ namespace MobileGL {
BindingSlot<ITextureObject>& GetBindingSlot(TextureTarget target);
SharedPtr<SamplerObject> GetSamplerObject() const;
Array<BindingSlot<ITextureObject>, (int)TextureTarget::TextureTargetCount>& GetAllBindingSlots();
void SetSamplerObject(SharedPtr<SamplerObject> sampler);
private:
Array<BindingSlot<ITextureObject>, (int)TextureTarget::TextureTargetCount> m_slots;
@@ -0,0 +1,238 @@
#include "TextureEnumConverter.h"
namespace MobileGL {
namespace MG_Util {
TextureTarget ConvertGLEnumToTextureTarget(GLenum target) {
switch (target) {
case GL_TEXTURE_1D:
return TextureTarget::Texture1D;
case GL_TEXTURE_2D:
return TextureTarget::Texture2D;
case GL_TEXTURE_3D:
return TextureTarget::Texture3D;
case GL_TEXTURE_CUBE_MAP:
return TextureTarget::TextureCubeMap;
case GL_TEXTURE_2D_ARRAY:
return TextureTarget::Texture2DArray;
case GL_TEXTURE_2D_MULTISAMPLE:
return TextureTarget::Texture2DMultisample;
case GL_TEXTURE_CUBE_MAP_ARRAY:
return TextureTarget::TextureCubeMapArray;
default:
return TextureTarget::Unknown;
}
}
TextureInputFormat ConvertGLEnumToTextureInputFormat(GLenum format) {
switch (format) {
case GL_RED:
return TextureInputFormat::Red;
case GL_RG:
return TextureInputFormat::RG;
case GL_RGB:
return TextureInputFormat::RGB;
case GL_BGR:
return TextureInputFormat::BGR;
case GL_RGBA:
return TextureInputFormat::RGBA;
case GL_BGRA:
return TextureInputFormat::BGRA;
case GL_RED_INTEGER:
return TextureInputFormat::RInteger;
case GL_RG_INTEGER:
return TextureInputFormat::RGInteger;
case GL_RGB_INTEGER:
return TextureInputFormat::RGBInteger;
case GL_BGR_INTEGER:
return TextureInputFormat::BGRInteger;
case GL_RGBA_INTEGER:
return TextureInputFormat::RGBAInteger;
case GL_BGRA_INTEGER:
return TextureInputFormat::BGRAInteger;
case GL_STENCIL_INDEX:
return TextureInputFormat::StencilIndex;
case GL_DEPTH_COMPONENT:
return TextureInputFormat::DepthComponent;
case GL_DEPTH_STENCIL:
return TextureInputFormat::DepthStencil;
default:
return TextureInputFormat::Unknown;
}
}
TextureSizedInternalFormat ConvertGLEnumToTextureSizedInternalFormat(GLenum internalformat) {
switch (internalformat) {
case GL_R8:
return TextureSizedInternalFormat::R8;
case GL_R8_SNORM:
return TextureSizedInternalFormat::R8Snorm;
case GL_R16:
return TextureSizedInternalFormat::R16;
case GL_R16_SNORM:
return TextureSizedInternalFormat::R16Snorm;
case GL_RG8:
return TextureSizedInternalFormat::RG8;
case GL_RG8_SNORM:
return TextureSizedInternalFormat::RG8Snorm;
case GL_RG16:
return TextureSizedInternalFormat::RG16;
case GL_RG16_SNORM:
return TextureSizedInternalFormat::RG16Snorm;
case GL_R3_G3_B2:
return TextureSizedInternalFormat::R3G3B2;
case GL_RGB4:
return TextureSizedInternalFormat::RGB4;
case GL_RGB5:
return TextureSizedInternalFormat::RGB5;
case GL_RGB8:
return TextureSizedInternalFormat::RGB8;
case GL_RGB8_SNORM:
return TextureSizedInternalFormat::RGB8Snorm;
case GL_RGB10:
return TextureSizedInternalFormat::RGB10;
case GL_RGB12:
return TextureSizedInternalFormat::RGB12;
case GL_RGB16_SNORM:
return TextureSizedInternalFormat::RGB16Snorm;
case GL_RGBA2:
return TextureSizedInternalFormat::RGBA2;
case GL_RGBA4:
return TextureSizedInternalFormat::RGBA4;
case GL_RGB5_A1:
return TextureSizedInternalFormat::RGB5A1;
case GL_RGBA8:
return TextureSizedInternalFormat::RGBA8;
case GL_RGBA8_SNORM:
return TextureSizedInternalFormat::RGBA8Snorm;
case GL_RGB10_A2:
return TextureSizedInternalFormat::RGB10A2;
case GL_RGB10_A2UI:
return TextureSizedInternalFormat::RGB10A2UI;
case GL_RGBA12:
return TextureSizedInternalFormat::RGBA12;
case GL_RGBA16:
return TextureSizedInternalFormat::RGBA16;
case GL_SRGB8:
return TextureSizedInternalFormat::SRGB8;
case GL_SRGB8_ALPHA8:
return TextureSizedInternalFormat::SRGB8Alpha8;
case GL_R16F:
return TextureSizedInternalFormat::R16F;
case GL_RG16F:
return TextureSizedInternalFormat::RG16F;
case GL_RGB16F:
return TextureSizedInternalFormat::RGB16F;
case GL_RGBA16F:
return TextureSizedInternalFormat::RGBA16F;
case GL_R32F:
return TextureSizedInternalFormat::R32F;
case GL_RG32F:
return TextureSizedInternalFormat::RG32F;
case GL_RGB32F:
return TextureSizedInternalFormat::RGB32F;
case GL_RGBA32F:
return TextureSizedInternalFormat::RGBA32F;
case GL_R11F_G11F_B10F:
return TextureSizedInternalFormat::R11FG11FB10F;
case GL_RGB9_E5:
return TextureSizedInternalFormat::RGB9E5;
case GL_R8I:
return TextureSizedInternalFormat::R8I;
case GL_R8UI:
return TextureSizedInternalFormat::R8UI;
case GL_R16I:
return TextureSizedInternalFormat::R16I;
case GL_R16UI:
return TextureSizedInternalFormat::R16UI;
case GL_R32I:
return TextureSizedInternalFormat::R32I;
case GL_R32UI:
return TextureSizedInternalFormat::R32UI;
case GL_RG8I:
return TextureSizedInternalFormat::RG8I;
case GL_RG8UI:
return TextureSizedInternalFormat::RG8UI;
case GL_RG16I:
return TextureSizedInternalFormat::RG16I;
case GL_RG16UI:
return TextureSizedInternalFormat::RG16UI;
case GL_RG32I:
return TextureSizedInternalFormat::RG32I;
case GL_RG32UI:
return TextureSizedInternalFormat::RG32UI;
case GL_RGB8I:
return TextureSizedInternalFormat::RGB8I;
case GL_RGB8UI:
return TextureSizedInternalFormat::RGB8UI;
case GL_RGB16I:
return TextureSizedInternalFormat::RGB16I;
case GL_RGB16UI:
return TextureSizedInternalFormat::RGB16UI;
case GL_RGB32I:
return TextureSizedInternalFormat::RGB32I;
case GL_RGB32UI:
return TextureSizedInternalFormat::RGB32UI;
case GL_RGBA8I:
return TextureSizedInternalFormat::RGBA8I;
case GL_RGBA8UI:
return TextureSizedInternalFormat::RGBA8UI;
case GL_RGBA16I:
return TextureSizedInternalFormat::RGBA16I;
case GL_RGBA16UI:
return TextureSizedInternalFormat::RGBA16UI;
case GL_RGBA32I:
return TextureSizedInternalFormat::RGBA32I;
case GL_RGBA32UI:
return TextureSizedInternalFormat::RGBA32UI;
default:
return TextureSizedInternalFormat::Unknown;
}
}
TexturePixelDataType ConvertGLEnumToTexturePixelDataType(GLenum type) {
switch (type) {
case GL_UNSIGNED_BYTE:
return TexturePixelDataType::UnsignedByte;
case GL_BYTE:
return TexturePixelDataType::Byte;
case GL_UNSIGNED_SHORT:
return TexturePixelDataType::UnsignedShort;
case GL_SHORT:
return TexturePixelDataType::Short;
case GL_UNSIGNED_INT:
return TexturePixelDataType::UnsignedInt;
case GL_INT:
return TexturePixelDataType::Int;
case GL_FLOAT:
return TexturePixelDataType::Float;
case GL_UNSIGNED_BYTE_3_3_2:
return TexturePixelDataType::UnsignedByte332;
case GL_UNSIGNED_BYTE_2_3_3_REV:
return TexturePixelDataType::UnsignedByte233Rev;
case GL_UNSIGNED_SHORT_5_6_5:
return TexturePixelDataType::UnsignedShort565;
case GL_UNSIGNED_SHORT_5_6_5_REV:
return TexturePixelDataType::UnsignedShort565Rev;
case GL_UNSIGNED_SHORT_4_4_4_4:
return TexturePixelDataType::UnsignedShort4444;
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
return TexturePixelDataType::UnsignedShort4444Rev;
case GL_UNSIGNED_SHORT_5_5_5_1:
return TexturePixelDataType::UnsignedShort5551;
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
return TexturePixelDataType::UnsignedShort1555Rev;
case GL_UNSIGNED_INT_8_8_8_8:
return TexturePixelDataType::UnsignedInt8888;
case GL_UNSIGNED_INT_8_8_8_8_REV:
return TexturePixelDataType::UnsignedInt8888Rev;
case GL_UNSIGNED_INT_10F_11F_11F_REV:
return TexturePixelDataType::UnsignedInt1010102;
case GL_UNSIGNED_INT_2_10_10_10_REV:
return TexturePixelDataType::UnsignedInt2101010Rev;
default:
return TexturePixelDataType::Unknown;
}
}
} // namespace MG_Util
} // namespace MobileGL
@@ -0,0 +1,12 @@
#pragma once
#include <Includes.h>
#include <MG_State/GLState/TextureState/TextureObject.h>
namespace MobileGL {
namespace MG_Util {
TextureTarget ConvertGLEnumToTextureTarget(GLenum target);
TextureInputFormat ConvertGLEnumToTextureInputFormat(GLenum format);
TextureSizedInternalFormat ConvertGLEnumToTextureSizedInternalFormat(GLenum internalformat);
TexturePixelDataType ConvertGLEnumToTexturePixelDataType(GLenum type);
} // namespace MG_Util
} // namespace MobileGL
@@ -0,0 +1,234 @@
#include "TextureEnumConverter.h"
namespace MobileGL {
namespace MG_Util {
GLenum ConvertTextureTargetToGLEnum(TextureTarget target) {
switch (target) {
case TextureTarget::Texture1D:
return GL_TEXTURE_1D;
case TextureTarget::Texture2D:
return GL_TEXTURE_2D;
case TextureTarget::Texture3D:
return GL_TEXTURE_3D;
case TextureTarget::TextureCubeMap:
return GL_TEXTURE_CUBE_MAP;
case TextureTarget::Texture2DArray:
return GL_TEXTURE_2D_ARRAY;
case TextureTarget::Texture2DMultisample:
return GL_TEXTURE_2D_MULTISAMPLE;
case TextureTarget::TextureCubeMapArray:
return GL_TEXTURE_CUBE_MAP_ARRAY;
default:
return GL_UNKNOWN_MGL;
}
}
GLenum ConvertTextureInputFormatToGLEnum(TextureInputFormat format) {
switch (format) {
case TextureInputFormat::Red:
return GL_RED;
case TextureInputFormat::RG:
return GL_RG;
case TextureInputFormat::RGB:
return GL_RGB;
case TextureInputFormat::BGR:
return GL_BGR;
case TextureInputFormat::RGBA:
return GL_RGBA;
case TextureInputFormat::BGRA:
return GL_BGRA;
case TextureInputFormat::RInteger:
return GL_RED_INTEGER;
case TextureInputFormat::RGInteger:
return GL_RG_INTEGER;
case TextureInputFormat::RGBInteger:
return GL_RGB_INTEGER;
case TextureInputFormat::BGRInteger:
return GL_BGR_INTEGER;
case TextureInputFormat::RGBAInteger:
return GL_RGBA_INTEGER;
case TextureInputFormat::BGRAInteger:
return GL_BGRA_INTEGER;
case TextureInputFormat::StencilIndex:
return GL_STENCIL_INDEX;
case TextureInputFormat::DepthComponent:
return GL_DEPTH_COMPONENT;
case TextureInputFormat::DepthStencil:
return GL_DEPTH_STENCIL;
default:
return GL_UNKNOWN_MGL;
}
}
GLenum ConvertTextureSizedInternalFormatToGLEnum(TextureSizedInternalFormat format) {
switch (format) {
case TextureSizedInternalFormat::R8:
return GL_R8;
case TextureSizedInternalFormat::R8Snorm:
return GL_R8_SNORM;
case TextureSizedInternalFormat::R16:
return GL_R16;
case TextureSizedInternalFormat::R16Snorm:
return GL_R16_SNORM;
case TextureSizedInternalFormat::RG8:
return GL_RG8;
case TextureSizedInternalFormat::RG8Snorm:
return GL_RG8_SNORM;
case TextureSizedInternalFormat::RG16:
return GL_RG16;
case TextureSizedInternalFormat::RG16Snorm:
return GL_RG16_SNORM;
case TextureSizedInternalFormat::R3G3B2:
return GL_R3_G3_B2;
case TextureSizedInternalFormat::RGB4:
return GL_RGB4;
case TextureSizedInternalFormat::RGB5:
return GL_RGB5;
case TextureSizedInternalFormat::RGB8:
return GL_RGB8;
case TextureSizedInternalFormat::RGB8Snorm:
return GL_RGB8_SNORM;
case TextureSizedInternalFormat::RGB10:
return GL_RGB10;
case TextureSizedInternalFormat::RGB12:
return GL_RGB12;
case TextureSizedInternalFormat::RGB16Snorm:
return GL_RGB16_SNORM;
case TextureSizedInternalFormat::RGBA2:
return GL_RGBA2;
case TextureSizedInternalFormat::RGBA4:
return GL_RGBA4;
case TextureSizedInternalFormat::RGB5A1:
return GL_RGB5_A1;
case TextureSizedInternalFormat::RGBA8:
return GL_RGBA8;
case TextureSizedInternalFormat::RGBA8Snorm:
return GL_RGBA8_SNORM;
case TextureSizedInternalFormat::RGB10A2:
return GL_RGB10_A2;
case TextureSizedInternalFormat::RGB10A2UI:
return GL_RGB10_A2UI;
case TextureSizedInternalFormat::RGBA12:
return GL_RGBA12;
case TextureSizedInternalFormat::RGBA16:
return GL_RGBA16;
case TextureSizedInternalFormat::SRGB8:
return GL_SRGB8;
case TextureSizedInternalFormat::SRGB8Alpha8:
return GL_SRGB8_ALPHA8;
case TextureSizedInternalFormat::R16F:
return GL_R16F;
case TextureSizedInternalFormat::RG16F:
return GL_RG16F;
case TextureSizedInternalFormat::RGB16F:
return GL_RGB16F;
case TextureSizedInternalFormat::RGBA16F:
return GL_RGBA16F;
case TextureSizedInternalFormat::R32F:
return GL_R32F;
case TextureSizedInternalFormat::RG32F:
return GL_RG32F;
case TextureSizedInternalFormat::RGB32F:
return GL_RGB32F;
case TextureSizedInternalFormat::RGBA32F:
return GL_RGBA32F;
case TextureSizedInternalFormat::R11FG11FB10F:
return GL_R11F_G11F_B10F;
case TextureSizedInternalFormat::RGB9E5:
return GL_RGB9_E5;
case TextureSizedInternalFormat::R8I:
return GL_R8I;
case TextureSizedInternalFormat::R8UI:
return GL_R8UI;
case TextureSizedInternalFormat::R16I:
return GL_R16I;
case TextureSizedInternalFormat::R16UI:
return GL_R16UI;
case TextureSizedInternalFormat::R32I:
return GL_R32I;
case TextureSizedInternalFormat::R32UI:
return GL_R32UI;
case TextureSizedInternalFormat::RG8I:
return GL_RG8I;
case TextureSizedInternalFormat::RG8UI:
return GL_RG8UI;
case TextureSizedInternalFormat::RG16I:
return GL_RG16I;
case TextureSizedInternalFormat::RG16UI:
return GL_RG16UI;
case TextureSizedInternalFormat::RG32I:
return GL_RG32I;
case TextureSizedInternalFormat::RG32UI:
return GL_RG32UI;
case TextureSizedInternalFormat::RGB8I:
return GL_RGB8I;
case TextureSizedInternalFormat::RGB8UI:
return GL_RGB8UI;
case TextureSizedInternalFormat::RGB16I:
return GL_RGB16I;
case TextureSizedInternalFormat::RGB16UI:
return GL_RGB16UI;
case TextureSizedInternalFormat::RGB32I:
return GL_RGB32I;
case TextureSizedInternalFormat::RGB32UI:
return GL_RGB32UI;
case TextureSizedInternalFormat::RGBA8I:
return GL_RGBA8I;
case TextureSizedInternalFormat::RGBA8UI:
return GL_RGBA8UI;
case TextureSizedInternalFormat::RGBA16I:
return GL_RGBA16I;
case TextureSizedInternalFormat::RGBA16UI:
return GL_RGBA16UI;
case TextureSizedInternalFormat::RGBA32I:
return GL_RGBA32I;
case TextureSizedInternalFormat::RGBA32UI:
return GL_RGBA32UI;
default:
return GL_UNKNOWN_MGL;
}
}
GLenum ConvertTexturePixelDataTypeToGLEnum(TexturePixelDataType type) {
switch (type) {
case TexturePixelDataType::UnsignedByte:
return GL_UNSIGNED_BYTE;
case TexturePixelDataType::Byte:
return GL_BYTE;
case TexturePixelDataType::UnsignedShort:
return GL_UNSIGNED_SHORT;
case TexturePixelDataType::Short:
return GL_SHORT;
case TexturePixelDataType::UnsignedInt:
return GL_UNSIGNED_INT;
case TexturePixelDataType::Int:
return GL_INT;
case TexturePixelDataType::Float:
return GL_FLOAT;
case TexturePixelDataType::UnsignedByte332:
return GL_UNSIGNED_BYTE_3_3_2;
case TexturePixelDataType::UnsignedByte233Rev:
return GL_UNSIGNED_BYTE_2_3_3_REV;
case TexturePixelDataType::UnsignedShort565:
return GL_UNSIGNED_SHORT_5_6_5;
case TexturePixelDataType::UnsignedShort565Rev:
return GL_UNSIGNED_SHORT_5_6_5_REV;
case TexturePixelDataType::UnsignedShort4444:
return GL_UNSIGNED_SHORT_4_4_4_4;
case TexturePixelDataType::UnsignedShort4444Rev:
return GL_UNSIGNED_SHORT_4_4_4_4_REV;
case TexturePixelDataType::UnsignedShort5551:
return GL_UNSIGNED_SHORT_5_5_5_1;
case TexturePixelDataType::UnsignedShort1555Rev:
return GL_UNSIGNED_SHORT_1_5_5_5_REV;
case TexturePixelDataType::UnsignedInt8888Rev:
return GL_UNSIGNED_INT_8_8_8_8_REV;
case TexturePixelDataType::UnsignedInt1010102:
return GL_UNSIGNED_INT_10_10_10_2;
default:
return GL_UNKNOWN_MGL;
}
}
} // namespace MG_Util
} // namespace MobileGL
@@ -0,0 +1,12 @@
#pragma once
#include <Includes.h>
#include <MG_State/GLState/TextureState/TextureObject.h>
namespace MobileGL {
namespace MG_Util {
GLenum ConvertTextureTargetToGLEnum(TextureTarget target);
GLenum ConvertTextureInputFormatToGLEnum(TextureInputFormat format);
GLenum ConvertTextureSizedInternalFormatToGLEnum(TextureSizedInternalFormat internalformat);
GLenum ConvertTexturePixelDataTypeToGLEnum(TexturePixelDataType type);
} // namespace MG_Util
} // namespace MobileGL
@@ -0,0 +1,230 @@
#include "TextureEnumConverter.h"
#include "MG_Util/Types.h"
namespace MobileGL {
namespace MG_Util {
String ConvertTextureTargetToString(TextureTarget target) {
switch (target) {
case TextureTarget::Texture1D:
return "Texture1D";
case TextureTarget::Texture2D:
return "Texture2D";
case TextureTarget::Texture3D:
return "Texture3D";
case TextureTarget::TextureCubeMap:
return "TextureCubeMap";
case TextureTarget::Texture2DArray:
return "Texture2DArray";
case TextureTarget::Texture2DMultisample:
return "Texture2DMultisample";
case TextureTarget::TextureCubeMapArray:
return "TextureCubeMapArray";
default:
return "Unknown";
}
}
String ConvertTextureInputFormatToString(TextureInputFormat format) {
switch (format) {
case TextureInputFormat::Red:
return "Red";
case TextureInputFormat::RG:
return "RG";
case TextureInputFormat::RGB:
return "RGB";
case TextureInputFormat::BGR:
return "BGR";
case TextureInputFormat::RGBA:
return "RGBA";
case TextureInputFormat::BGRA:
return "BGRA";
case TextureInputFormat::RInteger:
return "RInteger";
case TextureInputFormat::RGInteger:
return "RGInteger";
case TextureInputFormat::RGBInteger:
return "RGBInteger";
case TextureInputFormat::BGRInteger:
return "BGRInteger";
case TextureInputFormat::RGBAInteger:
return "RGBAInteger";
case TextureInputFormat::BGRAInteger:
return "BGRAInteger";
case TextureInputFormat::StencilIndex:
return "StencilIndex";
case TextureInputFormat::DepthComponent:
return "DepthComponent";
case TextureInputFormat::DepthStencil:
return "DepthStencil";
default:
return "Unknown";
}
}
String ConvertTextureSizedInternalFormatToString(TextureSizedInternalFormat format) {
switch (format) {
case TextureSizedInternalFormat::R8:
return "R8";
case TextureSizedInternalFormat::R8Snorm:
return "R8Snorm";
case TextureSizedInternalFormat::R16:
return "R16";
case TextureSizedInternalFormat::R16Snorm:
return "R16Snorm";
case TextureSizedInternalFormat::RG8:
return "RG8";
case TextureSizedInternalFormat::RG8Snorm:
return "RG8Snorm";
case TextureSizedInternalFormat::RG16:
return "RG16";
case TextureSizedInternalFormat::RG16Snorm:
return "RG16Snorm";
case TextureSizedInternalFormat::R3G3B2:
return "R3G3B2";
case TextureSizedInternalFormat::RGB4:
return "RGB4";
case TextureSizedInternalFormat::RGB5:
return "RGB5";
case TextureSizedInternalFormat::RGB8:
return "RGB8";
case TextureSizedInternalFormat::RGB8Snorm:
return "RGB8Snorm";
case TextureSizedInternalFormat::RGB10:
return "RGB10";
case TextureSizedInternalFormat::RGB12:
return "RGB12";
case TextureSizedInternalFormat::RGB16Snorm:
return "RGB16Snorm";
case TextureSizedInternalFormat::RGBA2:
return "RGBA2";
case TextureSizedInternalFormat::RGBA4:
return "RGBA4";
case TextureSizedInternalFormat::RGB5A1:
return "RGB5A1";
case TextureSizedInternalFormat::RGBA8:
return "RGBA8";
case TextureSizedInternalFormat::RGBA8Snorm:
return "RGBA8Snorm";
case TextureSizedInternalFormat::RGB10A2:
return "RGB10A2";
case TextureSizedInternalFormat::RGB10A2UI:
return "RGB10A2UI";
case TextureSizedInternalFormat::RGBA12:
return "RGBA12";
case TextureSizedInternalFormat::RGBA16:
return "RGBA16";
case TextureSizedInternalFormat::SRGB8:
return "SRGB8";
case TextureSizedInternalFormat::SRGB8Alpha8:
return "SRGB8Alpha8";
case TextureSizedInternalFormat::R16F:
return "R16F";
case TextureSizedInternalFormat::RG16F:
return "RG16F";
case TextureSizedInternalFormat::RGB16F:
return "RGB16F";
case TextureSizedInternalFormat::RGBA16F:
return "RGBA16F";
case TextureSizedInternalFormat::R32F:
return "R32F";
case TextureSizedInternalFormat::RG32F:
return "RG32F";
case TextureSizedInternalFormat::RGB32F:
return "RGB32F";
case TextureSizedInternalFormat::RGBA32F:
return "RGBA32F";
case TextureSizedInternalFormat::R11FG11FB10F:
return "R11FG11FB10F";
case TextureSizedInternalFormat::RGB9E5:
return "RGB9E5";
case TextureSizedInternalFormat::R8I:
return "R8I";
case TextureSizedInternalFormat::R8UI:
return "R8UI";
case TextureSizedInternalFormat::R16I:
return "R16I";
case TextureSizedInternalFormat::R16UI:
return "R16UI";
case TextureSizedInternalFormat::R32I:
return "R32I";
case TextureSizedInternalFormat::R32UI:
return "R32UI";
case TextureSizedInternalFormat::RG8I:
return "RG8I";
case TextureSizedInternalFormat::RG8UI:
return "RG8UI";
case TextureSizedInternalFormat::RG16I:
return "RG16I";
case TextureSizedInternalFormat::RG16UI:
return "RG16UI";
case TextureSizedInternalFormat::RG32I:
return "RG32I";
case TextureSizedInternalFormat::RG32UI:
return "RG32UI";
case TextureSizedInternalFormat::RGB8I:
return "RGB8I";
case TextureSizedInternalFormat::RGB8UI:
return "RGB8UI";
case TextureSizedInternalFormat::RGB16I:
return "RGB16I";
case TextureSizedInternalFormat::RGB16UI:
return "RGB16UI";
case TextureSizedInternalFormat::RGB32I:
return "RGB32I";
case TextureSizedInternalFormat::RGB32UI:
return "RGB32UI";
case TextureSizedInternalFormat::RGBA8I:
return "RGBA8I";
case TextureSizedInternalFormat::RGBA8UI:
return "RGBA8UI";
case TextureSizedInternalFormat::RGBA16I:
return "RGBA16I";
case TextureSizedInternalFormat::RGBA16UI:
return "RGBA16UI";
case TextureSizedInternalFormat::RGBA32I:
return "RGBA32I";
case TextureSizedInternalFormat::RGBA32UI:
return "RGBA32UI";
default:
return "Unknown";
}
}
String ConvertTexturePixelDataTypeToString(TexturePixelDataType type) {
switch (type) {
case TexturePixelDataType::UnsignedByte:
return "UnsignedByte";
case TexturePixelDataType::Byte:
return "Byte";
case TexturePixelDataType::UnsignedShort:
return "UnsignedShort";
case TexturePixelDataType::Short:
return "Short";
case TexturePixelDataType::UnsignedInt:
return "UnsignedInt";
case TexturePixelDataType::Int:
return "Int";
case TexturePixelDataType::Float:
return "Float";
case TexturePixelDataType::UnsignedByte332:
return "UnsignedByte332";
case TexturePixelDataType::UnsignedByte233Rev:
return "UnsignedByte233Rev";
case TexturePixelDataType::UnsignedShort565:
return "UnsignedShort565";
case TexturePixelDataType::UnsignedShort565Rev:
return "UnsignedShort565Rev";
case TexturePixelDataType::UnsignedShort4444:
return "UnsignedShort4444";
case TexturePixelDataType::UnsignedShort4444Rev:
return "UnsignedShort4444Rev";
case TexturePixelDataType::UnsignedShort5551:
return "UnsignedShort5551";
case TexturePixelDataType::UnsignedShort1555Rev:
return "UnsignedShort1555Rev";
default:
return "Unknown";
}
}
} // namespace MG_Util
} // namespace MobileGL
@@ -0,0 +1,12 @@
#pragma once
#include <Includes.h>
#include <MG_State/GLState/TextureState/TextureObject.h>
namespace MobileGL {
namespace MG_Util {
String ConvertTextureTargetToString(TextureTarget target);
String ConvertTextureInputFormatToString(TextureInputFormat format);
String ConvertTextureSizedInternalFormatToString(TextureSizedInternalFormat internalformat);
String ConvertTexturePixelDataTypeToString(TexturePixelDataType type);
} // namespace MG_Util
} // namespace MobileGL