diff --git a/CMakeLists.txt b/CMakeLists.txt index 265adf12..57a10372 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -fvisibility=hidden -funwind-tables -g -D_THREAD_SAFE -fPIC -stdlib=libc++") -set(PROFILING OFF) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_library(GLSLANG_LIB glslang PATHS ${CMAKE_SOURCE_DIR}/libraries/arm64-v8a/) -add_library(${CMAKE_PROJECT_NAME} SHARED +set(SOURCE_FILES MobileGL/Init.cpp MobileGL/MG_Util/Debug/Log.cpp @@ -54,6 +54,10 @@ add_library(${CMAKE_PROJECT_NAME} SHARED MobileGL/MG_State/GLState/BufferState/BufferObject.cpp MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.cpp MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.cpp + ) + +add_library(${CMAKE_PROJECT_NAME} SHARED + ${SOURCE_FILES} ) target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE @@ -79,8 +83,9 @@ target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE # add_subdirectory(3rdparty/DiligentCore) -target_include_directories(MobileGL PUBLIC +target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/MobileGL ) target_link_libraries(MobileGL diff --git a/MobileGL/Config.h b/MobileGL/Config.h index 2ae1da0e..642dc9ac 100644 --- a/MobileGL/Config.h +++ b/MobileGL/Config.h @@ -1,32 +1,22 @@ #pragma once - -#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_DEBUG - -#define MOBILEGL_LOG_ENABLE_CONSOLE 0 -#define MOBILEGL_LOG_ENABLE_FILE 1 -#define MOBILEGL_LOG_ENABLE_ANDROID 1 - -#ifdef __ANDROID__ -#define MOBILEGL_LOG_FILE_PATH "/sdcard/MG/latest.log" -#else -#define MOBILEGL_LOG_FILE_PATH "" -#endif +#include +#include namespace MobileGL { - namespace MG_Config { - inline const String ProjectName = "MobileGL"; - inline const String CoreName = "MobileGL Core"; - inline const String CoreVendor = "MobileGL-Dev"; - inline const Version CoreVersion = { 1, 0, 0, "-Dev" }; - extern RendererInfo* RendererInfoPtr; + namespace MG_Config { + inline const String ProjectName = "MobileGL"; + inline const String CoreName = "MobileGL Core"; + inline const String CoreVendor = "MobileGL-Dev"; + inline const Version CoreVersion = {1, 0, 0, "-Dev"}; + extern RendererInfo* RendererInfoPtr; - namespace Backend { + namespace Backend { #define MOBILEGL_BACKEND MOBILEGL_BACKEND_UNKNOWN - namespace Diligent { - inline const MG_Backend::Diligent::SpecificBackendType SpecificBackend = - MG_Backend::Diligent::SpecificBackendType::Vulkan; - } - } - } -} \ No newline at end of file + namespace Diligent { + inline const MG_Backend::Diligent::SpecificBackendType SpecificBackend = + MG_Backend::Diligent::SpecificBackendType::Vulkan; + } + } // namespace Backend + } // namespace MG_Config +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/Defines.h b/MobileGL/Defines.h new file mode 100644 index 00000000..532df8dc --- /dev/null +++ b/MobileGL/Defines.h @@ -0,0 +1,41 @@ +#pragma once + +// ============== Platform-specific definitions and macros ============== // +#ifdef __ANDROID__ +#define __ANDROID_API__ 26 // force Android API level to 26 for compatibility +#endif + +#ifdef _WIN32 +#define NOMINMAX // prevent Windows.h from defining min and max macros +#endif + +// ================== MobileGL definitions and macros =================== // +#ifdef _WIN32 +#define MOBILEGL_EXPORT extern "C" __declspec(dllexport) +#else +#define MOBILEGL_EXPORT extern "C" __attribute__((visibility("default"))) +#endif + +#define MOBILEGL_API MOBILEGL_EXPORT + +#define MOBILEGL_GLX_API MOBILEGL_API +#define MOBILEGL_GL_API MOBILEGL_API +#define MOBILEGL_EGL_API MOBILEGL_API + +#define MOBILEGL_BACKEND_TYPE_UNKNOWN 0 +#define MOBILEGL_BACKEND_TYPE_DILIGENT 1 +#define MOBILEGL_BACKEND_TYPE_MRHI 2 +#define MOBILEGL_BACKEND_TYPE_DIRECT 3 + +// ====================== MobileGL configurations ======================= // +#define MOBILEGL_LOG_ACTIVE_LEVEL MOBILEGL_LOG_LEVEL_DEBUG + +#define MOBILEGL_LOG_ENABLE_CONSOLE 0 +#define MOBILEGL_LOG_ENABLE_FILE 1 +#define MOBILEGL_LOG_ENABLE_ANDROID 1 + +#ifdef __ANDROID__ +#define MOBILEGL_LOG_FILE_PATH "/sdcard/MG/latest.log" +#else +#define MOBILEGL_LOG_FILE_PATH "" +#endif \ No newline at end of file diff --git a/MobileGL/Includes.h b/MobileGL/Includes.h index 4cdab56a..ebb5afdc 100644 --- a/MobileGL/Includes.h +++ b/MobileGL/Includes.h @@ -1,137 +1,82 @@ #pragma once -#ifdef __ANDROID__ -#define __ANDROID_API__ 26 // force Android API level to 26 for compatibility -#endif +// Include significant project headers +#include "Defines.h" +#include "MG_Util/PlatformStubs.h" -#ifdef _WIN32 -#define MOBILEGL_EXPORT extern "C" __declspec(dllexport) -#else -#define MOBILEGL_EXPORT extern "C" __attribute__((visibility("default"))) -#endif - -#define MOBILEGL_API MOBILEGL_EXPORT - -#define MOBILEGL_GLX_API MOBILEGL_API -#define MOBILEGL_GL_API MOBILEGL_API -#define MOBILEGL_EGL_API MOBILEGL_API - -#define NOMINMAX // prevent Windows.h from defining min and max macros - -#include -#include -#include -#include -#include -#include -#include -#include +// Include necessary standard headers +#include #include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include +#include #include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include -#include +// Include ankerl::unordered_dense +#include + +// Include spirv_cross +#include + +// Include glm +#include +#include + +// Include OpenGL and EGL headers +#include +#include +#include +#include + +// Include glslang headers #include #include -#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#ifdef __ANDROID__ -#include -#include -#include -#include -#include +// Include headers for platform-specific functionality +#ifdef __linux__ #include -#include -#elif defined(_WIN32) +#include +#endif + +#ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #include -#else +#endif + +#ifdef __ANDROID__ +#include #include +#include +#include +#include +#include #endif -#ifndef __ANDROID__ -// Define a stub for __android_log_print if not on Android -#define ANDROID_LOG_UNKNOWN 0 -#define ANDROID_LOG_DEFAULT 1 -#define ANDROID_LOG_VERBOSE 2 -#define ANDROID_LOG_DEBUG 3 -#define ANDROID_LOG_INFO 4 -#define ANDROID_LOG_WARN 5 -#define ANDROID_LOG_ERROR 6 -#define ANDROID_LOG_FATAL 7 -#define ANDROID_LOG_SILENT 8 - -typedef int android_LogPriority; - -inline int __android_log_print(int prio, const char* tag, const char* fmt, ...) { return 0; } -#endif - -#include "MG_Util/GLExtensions.h" +// Post-includes for significant project headers #include "MG_Util/Types.h" -#include "MG_Util/Miscellany/IndexGenerator.h" -#include "MG_Util/Debug/Log.h" -#include "MG_State/GLState/ErrorState/ErrorCode.h" -#include "MG_State/GLState/ErrorState/ErrorInfo.h" -#include "MG_State/GLState/ErrorState/Error.h" - -#include "MG_Backend/Backends.h" - -#include "Config.h" - -#include "MG_Impl/GLXImpl/LookUp/LookUp.h" -#include "MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.h" - -#include "MG_State/GLState/BufferState/BufferObject.h" -#include "MG_State/GLState/BufferState/BufferState.h" -#include "MG_State/GLState/VertexArrayState/VertexArrayObject.h" -#include "MG_State/GLState/VertexArrayState/VertexArrayState.h" - -/* @INSERTION_POINT:HEADER_FILE_GLIMPL@ */ -#include "MG_Impl/GLImpl/VertexArray/Validators.h" -#include "MG_Impl/GLImpl/VertexArray/GL_VertexArray.h" -#include "MG_Impl/GLImpl/Getter/GL_Getter.h" -#include "MG_Impl/GLImpl/Buffer/GL_Buffer.h" -#include "MG_Impl/GLImpl/Buffer/Validators.h" - -#include "MG_State/GLState/Core.h" - -#include "MG_Util/Converters/MGToGL/BufferEnumConverter.h" -#include "MG_Util/Converters/MGToGL/ErrorCodeConverter.h" -#include "MG_Util/Converters/MGToGL/DataTypeConverter.h" -#include "MG_Util/Converters/MGToStr/DataTypeConverter.h" -#include "MG_Util/Converters/MGToStr/BufferEnumConverter.h" -#include "MG_Util/Converters/MGToStr/GLExtensionConverter.h" -#include "MG_Util/Converters/GLToMG/BufferEnumConverter.h" -#include "MG_Util/Converters/GLToMG/DataTypeConverter.h" -#include "MG_Util/Converters/GLToStr/GLEnumConverter.h" -#include "MG_Util/Converters/GLToGlslang/GLShaderLangConverter.h" - -#include "MG_Util/ShaderTranspiler/SpvcSession.h" -#include "MG_Util/ShaderTranspiler/ShaderCompiler.h" +#include "MG_Util/Debug/Log.h" \ No newline at end of file diff --git a/MobileGL/Init.cpp b/MobileGL/Init.cpp index 36eeaf68..64a6d8a7 100644 --- a/MobileGL/Init.cpp +++ b/MobileGL/Init.cpp @@ -1,9 +1,10 @@ #include "Includes.h" +#include namespace MobileGL { void MG_Initialize() { MG_Util::Debug::InitFile(); - MGLOG_I("MobileGL Initializing..."); + MGLOG_I("MobileGL Initializing..."); MG_Backend::Init(); glslang::InitializeProcess(); } @@ -25,12 +26,8 @@ namespace MobileGL { #endif #ifdef _WIN32 - BOOL WINAPI DllMain(HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) - { - switch (ul_reason_for_call) - { + BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: MG_Initialize(); break; @@ -42,4 +39,4 @@ namespace MobileGL { return TRUE; } #endif -} \ No newline at end of file +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Backend/Backends.h b/MobileGL/MG_Backend/Backends.h index f1284ceb..71a1f856 100644 --- a/MobileGL/MG_Backend/Backends.h +++ b/MobileGL/MG_Backend/Backends.h @@ -1,57 +1,46 @@ #pragma once -#define MOBILEGL_BACKEND_TYPE_UNKNOWN 0 -#define MOBILEGL_BACKEND_TYPE_DILIGENT 1 -#define MOBILEGL_BACKEND_TYPE_MRHI 2 -#define MOBILEGL_BACKEND_TYPE_DIRECT 3 // the previous "ShittilyDraw" +#include +#include namespace MobileGL { - namespace MG_Backend { - namespace Unknown { - const RendererInfo RendererInfoUnknown = { - "", - "", - ", ", - { - { 0, 0, 0 }, - { 0, 0, 0 }, - { }, - }, - { } - }; - } - namespace Diligent { - enum class SpecificBackendType { - Vulkan, - Metal - }; + namespace MG_Backend { + namespace Unknown { + const RendererInfo RendererInfoUnknown = {"", + "", + ", ", + { + {0, 0, 0}, + {0, 0, 0}, + {}, + }, + {}}; + } - const RendererInfo RendererInfoVulkan = { - "MobileGlued-vk", - "Diligent Engine (Vulkan)", - Nullopt, - { - { 3, 2, 0 }, - { 4, 5, 0 }, - { V_OpenGL30, V_OpenGL31, V_OpenGL32 }, - false - }, - { } - }; + namespace Diligent { + enum class SpecificBackendType { + Vulkan, + Metal + }; - const RendererInfo RendererInfoMetal = { - "MobileGlued-mtl", - "Diligent Engine (Metal)", - Nullopt, - { - { 3, 2, 0 }, - { 4, 5, 0 }, - { V_OpenGL30, V_OpenGL31, V_OpenGL32 }, - }, - { } - }; - } + const RendererInfo RendererInfoVulkan = { + "MobileGlued-vk", + "Diligent Engine (Vulkan)", + Nullopt, + {{3, 2, 0}, {4, 5, 0}, {V_OpenGL30, V_OpenGL31, V_OpenGL32}, false}, + {}}; - void Init(); - } -} \ No newline at end of file + const RendererInfo RendererInfoMetal = {"MobileGlued-mtl", + "Diligent Engine (Metal)", + Nullopt, + { + {3, 2, 0}, + {4, 5, 0}, + {V_OpenGL30, V_OpenGL31, V_OpenGL32}, + }, + {}}; + } // namespace Diligent + + void Init(); + } // namespace MG_Backend +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Backend/Init.cpp b/MobileGL/MG_Backend/Init.cpp index 157b2bb5..6ba3f884 100644 --- a/MobileGL/MG_Backend/Init.cpp +++ b/MobileGL/MG_Backend/Init.cpp @@ -1,28 +1,29 @@ -#include "../Includes.h" +#include "Backends.h" +#include namespace MobileGL { - namespace MG_Config { - RendererInfo* RendererInfoPtr = nullptr; - } + namespace MG_Config { + RendererInfo* RendererInfoPtr = nullptr; + } - namespace MG_Backend { - void Init() { - MGLOG_D("Initializing MobileGL Backend..."); + namespace MG_Backend { + void Init() { + MGLOG_D("Initializing MobileGL Backend..."); #if MOBILEGL_BACKEND == MOBILEGL_BACKEND_DILIGENT - switch (MG_Config::Backend::Diligent::SpecificBackend) { - case MG_Backend::Diligent::SpecificBackendType::Vulkan: - MG_Config::RendererInfoPtr = (RendererInfo*)&MG_Backend::Diligent::RendererInfoVulkan; - break; - case MG_Backend::Diligent::SpecificBackendType::Metal: - MG_Config::RendererInfoPtr = (RendererInfo*)&MG_Backend::Diligent::RendererInfoMetal; - break; - default: - throw RuntimeError("Unsupported renderer type"); - } + switch (MG_Config::Backend::Diligent::SpecificBackend) { + case MG_Backend::Diligent::SpecificBackendType::Vulkan: + MG_Config::RendererInfoPtr = (RendererInfo*)&MG_Backend::Diligent::RendererInfoVulkan; + break; + case MG_Backend::Diligent::SpecificBackendType::Metal: + MG_Config::RendererInfoPtr = (RendererInfo*)&MG_Backend::Diligent::RendererInfoMetal; + break; + default: + throw RuntimeError("Unsupported renderer type"); + } #else - MG_Config::RendererInfoPtr = (RendererInfo*)&RendererInfoUnknown; + MG_Config::RendererInfoPtr = (RendererInfo*)&RendererInfoUnknown; #endif - } - } -} \ No newline at end of file + } + } // namespace MG_Backend +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp b/MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp index 5c146115..303dc5c4 100644 --- a/MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp +++ b/MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp @@ -1,17 +1,18 @@ -#include "../../../Includes.h" +#include +#include "../Temporary/TemporaryEGLImpl.h" MOBILEGL_EGL_API EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window, - const EGLint* attrib_list) { + const EGLint* attrib_list) { return MobileGL::MG_Impl::EGLImpl::CreateWindowSurface(dpy, config, window, attrib_list); } MOBILEGL_EGL_API EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, - EGLint config_size, EGLint* num_config) { + EGLint config_size, EGLint* num_config) { return MobileGL::MG_Impl::EGLImpl::ChooseConfig(dpy, attrib_list, configs, config_size, num_config); } MOBILEGL_EGL_API EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, - const EGLint* attrib_list) { + const EGLint* attrib_list) { return MobileGL::MG_Impl::EGLImpl::CreateContext(dpy, config, shareCtx, attrib_list); } @@ -82,4 +83,3 @@ MOBILEGL_EGL_API EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig co MOBILEGL_EGL_API __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* name) { return MobileGL::MG_Impl::EGLImpl::GetProcAddress(name); } - diff --git a/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp b/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp index e6b189f2..34f26b53 100644 --- a/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp +++ b/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp @@ -1,22 +1,21 @@ -#include "../../../Includes.h" +#include "TemporaryEGLImpl.h" namespace MobileGL { namespace MG_Impl::EGLImpl { - // TODO: Implement complete EGL functionality + // TODO: Implement complete EGL functionality EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window, - const EGLint* attrib_list) { + const EGLint* attrib_list) { return (EGLSurface)1; } - EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, - EGLint config_size, EGLint* num_config) { + EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, + EGLint* num_config) { *num_config = 1; return EGL_TRUE; } - EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, - const EGLint* attrib_list) { + EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list) { return (EGLContext)1; } @@ -59,8 +58,21 @@ namespace MobileGL { } EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) { - if (attribute == EGL_NATIVE_VISUAL_ID) + if (attribute == EGL_NATIVE_VISUAL_ID) { +#if defined(ANDROID) *value = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM; + return EGL_TRUE; +#elif defined(__linux__) + *value = 0; + return EGL_TRUE; +#elif defined(_WIN32) + *value = 0; + return EGL_TRUE; +#else + *value = 0; + return EGL_FALSE; +#endif + } return EGL_TRUE; } @@ -95,7 +107,7 @@ namespace MobileGL { MGLOG_W("Failed to get function: %s", (const char*)name); return nullptr; } - return (__eglMustCastToProperFunctionPointerType)proc; - } - } -} \ No newline at end of file + return (__eglMustCastToProperFunctionPointerType)proc; + } + } // namespace MG_Impl::EGLImpl +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.h b/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.h index ff9dc0fb..f91d5dc7 100644 --- a/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.h +++ b/MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.h @@ -1,13 +1,13 @@ #pragma once +#include namespace MobileGL { namespace MG_Impl::EGLImpl { EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window, - const EGLint* attrib_list); - EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, - EGLint config_size, EGLint* num_config); - EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, - const EGLint* attrib_list); + const EGLint* attrib_list); + EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, + EGLint* num_config); + EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list); EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor); EGLDisplay GetDisplay(NativeDisplayType display); EGLint GetError(); @@ -25,5 +25,5 @@ namespace MobileGL { EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw); EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list); __eglMustCastToProperFunctionPointerType GetProcAddress(const char* name); - } -} \ No newline at end of file + } // namespace MG_Impl::EGLImpl +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp index 1e7293d8..9abb3c52 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp @@ -1,457 +1,497 @@ -#include "../../../Includes.h" +#include "GL_Buffer.h" +#include "Validators.h" +#include +#include +#include namespace MobileGL { - namespace MG_Impl::GLImpl { - void DeleteBuffers_State(GLsizei n, const GLuint* buffers) { - if (n < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "DeleteBuffers_State", - "n must be non-negative.")); - return; - } + namespace MG_Impl::GLImpl { + void DeleteBuffers_State(GLsizei n, const GLuint* buffers) { + if (n < 0) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", "DeleteBuffers_State", "n must be non-negative.")); + return; + } - if (!buffers) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "DeleteBuffers_State", - "Buffer names array cannot be null.")); - return; - } + if (!buffers) { + MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", "DeleteBuffers_State", + "Buffer names array cannot be null.")); + return; + } - for (SizeT i = 0; i < static_cast(n); ++i) { - Uint bufferName = buffers[i]; - if (bufferName == 0) continue; - if (!BufferImpl::ValidateBufferName(bufferName)) continue; - MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName); - } + for (SizeT i = 0; i < static_cast(n); ++i) { + Uint bufferName = buffers[i]; + if (bufferName == 0) continue; + if (!BufferImpl::ValidateBufferName(bufferName)) continue; + MG_State::pGLContext->MarkBufferObjectForDeletion(bufferName); + } + } - } - - void FlushMappedBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length) { - if (length < 0 || offset < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "FlushMappedBufferRange_State", - "Offset and length must be non-negative.")); - return; - } + void FlushMappedBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length) { + if (length < 0 || offset < 0) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", "FlushMappedBufferRange_State", + "Offset and length must be non-negative.")); + return; + } - BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); - if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; + BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); + if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; - auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); + auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); - auto bufferObject = bindingSlot.GetBoundObject(); - if (!bufferObject) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "FlushMappedBufferRange_State", - "Buffer target is bound to no buffer object.")); - return; - } + auto bufferObject = bindingSlot.GetBoundObject(); + if (!bufferObject) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "FlushMappedBufferRange_State", + "Buffer target is bound to no buffer object.")); + return; + } - if (!bufferObject->IsMapped()) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "FlushMappedBufferRange_State", - "Cannot flush a buffer object that is not mapped.")); - return; - } + if (!bufferObject->IsMapped()) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "FlushMappedBufferRange_State", + "Cannot flush a buffer object that is not mapped.")); + return; + } - if (offset + length > bufferObject->GetSize()) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "FlushMappedBufferRange_State", - "Offset and length exceed buffer size.")); - return; - } + if (offset + length > bufferObject->GetSize()) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", "FlushMappedBufferRange_State", + "Offset and length exceed buffer size.")); + return; + } - auto mappingAccess = bufferObject->GetMappingAccess(); - if(!(mappingAccess & BufferMappingAccessBit::FlushExplicit)) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "FlushMappedBufferRange_State", - "Cannot flush a buffer object that is not mapped with GL_MAP_FLUSH_EXPLICIT_BIT.")); - return; - } + auto mappingAccess = bufferObject->GetMappingAccess(); + if (!(mappingAccess & BufferMappingAccessBit::FlushExplicit)) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared( + "MG_Impl/GLImpl", "FlushMappedBufferRange_State", + "Cannot flush a buffer object that is not mapped with GL_MAP_FLUSH_EXPLICIT_BIT.")); + return; + } - bufferObject->FlushMemoryRange(static_cast(offset), static_cast(length)); - } - - GLboolean UnmapBuffer_State(GLenum target) { - BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); - if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return GL_FALSE; + bufferObject->FlushMemoryRange(static_cast(offset), static_cast(length)); + } - auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); + GLboolean UnmapBuffer_State(GLenum target) { + BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); + if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return GL_FALSE; - auto bufferObject = bindingSlot.GetBoundObject(); - if (!bufferObject) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "UnmapBuffer_State", - "Buffer target is bound to no buffer object.")); - return GL_FALSE; - } + auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); - if (!bufferObject->IsMapped()) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "UnmapBuffer_State", - "Cannot unmap a buffer object that is not mapped.")); - return GL_FALSE; - } + auto bufferObject = bindingSlot.GetBoundObject(); + if (!bufferObject) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "UnmapBuffer_State", + "Buffer target is bound to no buffer object.")); + return GL_FALSE; + } - bufferObject->ReleaseMemory(); - return GL_TRUE; - } - - void* MapBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) { - if (length < 0 || offset < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "Offset and length must be non-negative.")); - return nullptr; - } + if (!bufferObject->IsMapped()) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "UnmapBuffer_State", + "Cannot unmap a buffer object that is not mapped.")); + return GL_FALSE; + } - if (length == 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "Length must be greater than zero.")); - return nullptr; - } + bufferObject->ReleaseMemory(); + return GL_TRUE; + } - BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); - if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr; + void* MapBufferRange_State(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) { + if (length < 0 || offset < 0) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", + "Offset and length must be non-negative.")); + return nullptr; + } - auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); - auto bufferObject = bindingSlot.GetBoundObject(); - if (!bufferObject) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "Buffer target is bound to no buffer object.")); - return nullptr; - } + if (length == 0) { + MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", + "Length must be greater than zero.")); + return nullptr; + } - if (offset + length > bufferObject->GetSize()) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "Offset and length exceed buffer size.")); - return nullptr; - } + BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); + if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr; - auto accessBits = MG_Util::ConvertGLEnumToBufferMappingAccess(access); - if (!BufferImpl::ValidateBufferMappingAccess(accessBits)) return nullptr; + auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); + auto bufferObject = bindingSlot.GetBoundObject(); + if (!bufferObject) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", + "Buffer target is bound to no buffer object.")); + return nullptr; + } - if (!(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "At least one of GL_MAP_READ_BIT or GL_MAP_WRITE_BIT must be set.")); - return nullptr; - } + if (offset + length > bufferObject->GetSize()) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", + "Offset and length exceed buffer size.")); + return nullptr; + } - if (accessBits & BufferMappingAccessBit::Read) { - const auto invalidFlags = BufferMappingAccessBit::InvalidateRange | - BufferMappingAccessBit::InvalidateBuffer | - BufferMappingAccessBit::Unsynchronized; + auto accessBits = MG_Util::ConvertGLEnumToBufferMappingAccess(access); + if (!BufferImpl::ValidateBufferMappingAccess(accessBits)) return nullptr; - if (accessBits & invalidFlags) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "GL_MAP_READ_BIT cannot be combined with invalidation or unsynchronized flags.")); - return nullptr; - } - } + if (!(accessBits & (BufferMappingAccessBit::Read | BufferMappingAccessBit::Write))) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", + "At least one of GL_MAP_READ_BIT or GL_MAP_WRITE_BIT must be set.")); + return nullptr; + } - if (accessBits & BufferMappingAccessBit::FlushExplicit) { - if (!(accessBits & BufferMappingAccessBit::Write)) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "GL_MAP_FLUSH_EXPLICIT_BIT requires GL_MAP_WRITE_BIT.")); - return nullptr; - } - } + if (accessBits & BufferMappingAccessBit::Read) { + const auto invalidFlags = BufferMappingAccessBit::InvalidateRange | + BufferMappingAccessBit::InvalidateBuffer | + BufferMappingAccessBit::Unsynchronized; - const auto storageFlags = - BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent; - auto requiredFlags = accessBits & storageFlags; - if (requiredFlags) { - // TODO: check if the buffer data is created by BufferStorage and its flags after its implementation - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "Access flags require matching storage flags in buffer.")); - return nullptr; - } + if (accessBits & invalidFlags) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared( + "MG_Impl/GLImpl", "MapBufferRange_State", + "GL_MAP_READ_BIT cannot be combined with invalidation or unsynchronized flags.")); + return nullptr; + } + } - if (bufferObject->IsMapped()) { - const auto invalidateFlags = BufferMappingAccessBit::InvalidateRange | - BufferMappingAccessBit::InvalidateBuffer; + if (accessBits & BufferMappingAccessBit::FlushExplicit) { + if (!(accessBits & BufferMappingAccessBit::Write)) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", + "GL_MAP_FLUSH_EXPLICIT_BIT requires GL_MAP_WRITE_BIT.")); + return nullptr; + } + } - if (!(accessBits & invalidateFlags)) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "Cannot map a buffer object that is already mapped.")); - return nullptr; - } - } + const auto storageFlags = BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent; + auto requiredFlags = accessBits & storageFlags; + if (requiredFlags) { + // TODO: check if the buffer data is created by BufferStorage and its flags after its implementation + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", + "Access flags require matching storage flags in buffer.")); + return nullptr; + } - void* result = bufferObject->AcquireMemoryRange( - { static_cast(offset), static_cast(offset + length) }, - accessBits - ); - if (!result) { - MG_State::pGLContext->RecordError(ErrorCode::OutOfMemory, - MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", - "Failed to map buffer due to insufficient memory.")); - return nullptr; - } - return result; - } - - void* MapBuffer_State(GLenum target, GLenum access) { - bool readable = access == GL_READ_ONLY || access == GL_READ_WRITE; - bool writable = access == GL_WRITE_ONLY || access == GL_READ_WRITE; - if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && access != GL_READ_WRITE) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum, - MakeShared("MG_Impl/GLImpl", "MapBuffer_State", - "Access must be one of GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE.")); - return nullptr; - } - - BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); - if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr; - auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); - - auto bufferObject = bindingSlot.GetBoundObject(); - if (!bufferObject) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "MapBuffer_State", - "Buffer target is bound to no buffer object.")); - return nullptr; - } - - if (bufferObject->IsMapped()) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "MapBuffer_State", - "Cannot map a buffer object that is already mapped.")); - return nullptr; - } + if (bufferObject->IsMapped()) { + const auto invalidateFlags = + BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer; - void* result = bufferObject->AcquireMemory(true, readable, writable); - if (!result) { - MG_State::pGLContext->RecordError(ErrorCode::OutOfMemory, - MakeShared("MG_Impl/GLImpl", "MapBuffer_State", - "Failed to map buffer due to insufficient memory.")); - return nullptr; - } - return result; - } - - void CopyBufferSubData_State(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { - if (size < 0 || readOffset < 0 || writeOffset < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "CopyBufferSubData_State", - "Offset and size must be non-negative.")); - return; - } - - BufferTarget readBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(readTarget); - BufferTarget writeBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(writeTarget); - if (!BufferImpl::ValidateBufferTarget(readBufferTarget) || !BufferImpl::ValidateBufferTarget(writeBufferTarget)) return; - - auto& readBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(readBufferTarget); - auto& writeBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(writeBufferTarget); - auto readBufferObject = readBindingSlot.GetBoundObject(); - auto writeBufferObject = writeBindingSlot.GetBoundObject(); + if (!(accessBits & invalidateFlags)) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", + "Cannot map a buffer object that is already mapped.")); + return nullptr; + } + } - if (!readBufferObject || !writeBufferObject) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "CopyBufferSubData_State", - "One of the buffer targets is bound to no buffer object.")); - return; - } + void* result = bufferObject->AcquireMemoryRange( + {static_cast(offset), static_cast(offset + length)}, accessBits); + if (!result) { + MG_State::pGLContext->RecordError( + ErrorCode::OutOfMemory, + MakeShared("MG_Impl/GLImpl", "MapBufferRange_State", + "Failed to map buffer due to insufficient memory.")); + return nullptr; + } + return result; + } - if (readOffset + size > readBufferObject->GetSize() || writeOffset + size > writeBufferObject->GetSize()) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "CopyBufferSubData_State", - "Offset and size must be within the bounds of the buffer objects.")); - return; - } + void* MapBuffer_State(GLenum target, GLenum access) { + bool readable = access == GL_READ_ONLY || access == GL_READ_WRITE; + bool writable = access == GL_WRITE_ONLY || access == GL_READ_WRITE; + if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && access != GL_READ_WRITE) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared( + "MG_Impl/GLImpl", "MapBuffer_State", + "Access must be one of GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE.")); + return nullptr; + } - if (readBufferObject == writeBufferObject) { - if ((readOffset <= writeOffset && readOffset + size > writeOffset) || - (writeOffset <= readOffset && writeOffset + size > readOffset)) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "CopyBufferSubData_State", - "Source and destination buffers overlap in the specified ranges.")); - return; - } - } + BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); + if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return nullptr; + auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); - auto isIllegallyMapped = [](const SharedPtr& buffer) { - return buffer->IsMapped() && !(buffer->GetMappingAccess() & BufferMappingAccessBit::Persistent); - }; - if (isIllegallyMapped(readBufferObject) || isIllegallyMapped(writeBufferObject)) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "CopyBufferSubData_State", - "Cannot copy data from/to a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT.")); - return; - } + auto bufferObject = bindingSlot.GetBoundObject(); + if (!bufferObject) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "MapBuffer_State", + "Buffer target is bound to no buffer object.")); + return nullptr; + } - writeBufferObject->CopyDataFrom(readBufferObject, readOffset, writeOffset, size); - } - - void BufferSubData_State(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { - if (!data) { - MG_State::pGLContext->RecordError(ErrorCode::NoError, // somehow OpenGL does not generate an error for this - MakeShared("MG_Impl/GLImpl", "BufferSubData_State", - "Data pointer cannot be null.")); - return; - } + if (bufferObject->IsMapped()) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "MapBuffer_State", + "Cannot map a buffer object that is already mapped.")); + return nullptr; + } - if (size < 0 || offset < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "BufferSubData_State", - "Offset and size must be non-negative.")); - return; - } + void* result = bufferObject->AcquireMemory(true, readable, writable); + if (!result) { + MG_State::pGLContext->RecordError( + ErrorCode::OutOfMemory, + MakeShared("MG_Impl/GLImpl", "MapBuffer_State", + "Failed to map buffer due to insufficient memory.")); + return nullptr; + } + return result; + } - BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); - if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; - auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); + void CopyBufferSubData_State(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size) { + if (size < 0 || readOffset < 0 || writeOffset < 0) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, MakeShared("MG_Impl/GLImpl", "CopyBufferSubData_State", + "Offset and size must be non-negative.")); + return; + } - auto bufferObject = bindingSlot.GetBoundObject(); - if (!bufferObject) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "BufferSubData_State", - "Buffer target is bound to no buffer object.")); - return; - } + BufferTarget readBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(readTarget); + BufferTarget writeBufferTarget = MG_Util::ConvertGLEnumToBufferTarget(writeTarget); + if (!BufferImpl::ValidateBufferTarget(readBufferTarget) || + !BufferImpl::ValidateBufferTarget(writeBufferTarget)) + return; - SizeT bufferSize = bufferObject->GetSize(); - Range1D mappedRange = bufferObject->GetMappedRange(); - if ((offset < mappedRange.end) && (offset + size > mappedRange.start)) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "BufferSubData_State", - "Offset and size must not overlap with the mapped range of the buffer object.")); - return; - } + auto& readBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(readBufferTarget); + auto& writeBindingSlot = MG_State::pGLContext->GetBufferBindingSlot(writeBufferTarget); + auto readBufferObject = readBindingSlot.GetBoundObject(); + auto writeBufferObject = writeBindingSlot.GetBoundObject(); - auto mappingAccess = bufferObject->GetMappingAccess(); - if (bufferObject->IsMapped() && !(mappingAccess & BufferMappingAccessBit::Persistent)) { - Range1D mappedRange = bufferObject->GetMappedRange(); - if (offset + size >= mappedRange.start) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "BufferSubData_State", - "Cannot modify a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT.")); - return; - } - } + if (!readBufferObject || !writeBufferObject) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "CopyBufferSubData_State", + "One of the buffer targets is bound to no buffer object.")); + return; + } - bufferObject->UploadSubData({ (void*)data, (SizeT)size }, offset); - } - - void BufferData_State(GLenum target, GLsizeiptr size, const void* data, GLenum usage) { - if (size < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "BufferData_State", - "Size must be non-negative.")); - return; - } + if (readOffset + size > readBufferObject->GetSize() || writeOffset + size > writeBufferObject->GetSize()) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", "CopyBufferSubData_State", + "Offset and size must be within the bounds of the buffer objects.")); + return; + } - BufferUsage bufferUsage = MG_Util::ConvertGLEnumToBufferUsage(usage); - if (!BufferImpl::ValidateBufferUsage(bufferUsage)) return; + if (readBufferObject == writeBufferObject) { + if ((readOffset <= writeOffset && readOffset + size > writeOffset) || + (writeOffset <= readOffset && writeOffset + size > readOffset)) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared( + "MG_Impl/GLImpl", "CopyBufferSubData_State", + "Source and destination buffers overlap in the specified ranges.")); + return; + } + } - BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); - if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; - auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); + auto isIllegallyMapped = [](const SharedPtr& buffer) { + return buffer->IsMapped() && !(buffer->GetMappingAccess() & BufferMappingAccessBit::Persistent); + }; + if (isIllegallyMapped(readBufferObject) || isIllegallyMapped(writeBufferObject)) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "CopyBufferSubData_State", + "Cannot copy data from/to a mapped buffer object unless it was mapped " + "with GL_MAP_PERSISTENT_BIT.")); + return; + } - auto bufferObject = bindingSlot.GetBoundObject(); - if (!bufferObject) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "BufferData_State", - "Buffer target is bound to no buffer object.")); - return; - } + writeBufferObject->CopyDataFrom(readBufferObject, readOffset, writeOffset, size); + } - bufferObject->SetUsage(bufferUsage); - bufferObject->Resize(size); - if (data) { - bufferObject->UploadData({ (void*)data, (SizeT)size }, 0); - } - } - - void BindBuffer_State(GLenum target, GLuint buffer) { - if (buffer != 0 && !BufferImpl::ValidateBufferName(buffer)) return; - BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); - if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; + void BufferSubData_State(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { + if (!data) { + MG_State::pGLContext->RecordError( + ErrorCode::NoError, // somehow OpenGL does not generate an error for this + MakeShared("MG_Impl/GLImpl", "BufferSubData_State", + "Data pointer cannot be null.")); + return; + } - auto bufferObject = MG_State::pGLContext->GetBufferObject(buffer); - if (!bufferObject) { - MG_State::pGLContext->CreateBufferObject(buffer); - bufferObject = MG_State::pGLContext->GetBufferObject(buffer); - } + if (size < 0 || offset < 0) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, MakeShared("MG_Impl/GLImpl", "BufferSubData_State", + "Offset and size must be non-negative.")); + return; + } - auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); - bindingSlot.Bind(bufferObject); - } - - void GenBuffers_State(GLsizei n, GLuint* buffers) { - if (n < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "GenBuffers_State", "n must be non-negative")); - return; - } - auto bufferNames = MG_State::pGLContext->GenBufferNames(n); - Copy(bufferNames.data(), buffers, bufferNames.size()); - } + BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); + if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; + auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); - GLboolean IsBuffer_State(GLuint buffer) { - if (buffer == 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "IsBuffer_State", - "Buffer name 0 is not a valid buffer object.")); - return GL_FALSE; - } + auto bufferObject = bindingSlot.GetBoundObject(); + if (!bufferObject) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "BufferSubData_State", + "Buffer target is bound to no buffer object.")); + return; + } - if (!BufferImpl::ValidateBufferName(buffer)) return GL_FALSE; - return MG_State::pGLContext->ValidateBufferObject(buffer) ? GL_TRUE : GL_FALSE; - } + SizeT bufferSize = bufferObject->GetSize(); + Range1D mappedRange = bufferObject->GetMappedRange(); + if ((offset < mappedRange.end) && (offset + size > mappedRange.start)) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared( + "MG_Impl/GLImpl", "BufferSubData_State", + "Offset and size must not overlap with the mapped range of the buffer object.")); + return; + } - /* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */ - GLboolean IsBuffer(GLuint buffer) { - return IsBuffer_State(buffer); - } - - void DeleteBuffers(GLsizei n, const GLuint* buffers) { - DeleteBuffers_State(n, buffers); - } - - void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) { - FlushMappedBufferRange_State(target, offset, length); - } - - GLboolean UnmapBuffer(GLenum target) { - return UnmapBuffer_State(target); - } - - void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) { - return MapBufferRange_State(target, offset, length, access); - } - - void* MapBuffer(GLenum target, GLenum access) { - return MapBuffer_State(target, access); - } - - void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { - CopyBufferSubData_State(readTarget, writeTarget, readOffset, writeOffset, size); - } - - void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { - BufferSubData_State(target, offset, size, data); - } - - void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) { - BufferData_State(target, size, data, usage); - } - - void BindBuffer(GLenum target, GLuint buffer) { - BindBuffer_State(target, buffer); - } - - void GenBuffers(GLsizei n, GLuint* buffers) { - GenBuffers_State(n, buffers); - } - } -} + auto mappingAccess = bufferObject->GetMappingAccess(); + if (bufferObject->IsMapped() && !(mappingAccess & BufferMappingAccessBit::Persistent)) { + Range1D mappedRange = bufferObject->GetMappedRange(); + if (offset + size >= mappedRange.start) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared( + "MG_Impl/GLImpl", "BufferSubData_State", + "Cannot modify a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT.")); + return; + } + } + + bufferObject->UploadSubData({(void*)data, (SizeT)size}, offset); + } + + void BufferData_State(GLenum target, GLsizeiptr size, const void* data, GLenum usage) { + if (size < 0) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", "BufferData_State", "Size must be non-negative.")); + return; + } + + BufferUsage bufferUsage = MG_Util::ConvertGLEnumToBufferUsage(usage); + if (!BufferImpl::ValidateBufferUsage(bufferUsage)) return; + + BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); + if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; + auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); + + auto bufferObject = bindingSlot.GetBoundObject(); + if (!bufferObject) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl", "BufferData_State", + "Buffer target is bound to no buffer object.")); + return; + } + + bufferObject->SetUsage(bufferUsage); + bufferObject->Resize(size); + if (data) { + bufferObject->UploadData({(void*)data, (SizeT)size}, 0); + } + } + + void BindBuffer_State(GLenum target, GLuint buffer) { + if (buffer != 0 && !BufferImpl::ValidateBufferName(buffer)) return; + BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); + if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return; + + auto bufferObject = MG_State::pGLContext->GetBufferObject(buffer); + if (!bufferObject) { + MG_State::pGLContext->CreateBufferObject(buffer); + bufferObject = MG_State::pGLContext->GetBufferObject(buffer); + } + + auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); + bindingSlot.Bind(bufferObject); + } + + void GenBuffers_State(GLsizei n, GLuint* buffers) { + if (n < 0) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", "GenBuffers_State", "n must be non-negative")); + return; + } + auto bufferNames = MG_State::pGLContext->GenBufferNames(n); + Copy(bufferNames.data(), buffers, bufferNames.size()); + } + + GLboolean IsBuffer_State(GLuint buffer) { + if (buffer == 0) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", "IsBuffer_State", + "Buffer name 0 is not a valid buffer object.")); + return GL_FALSE; + } + + if (!BufferImpl::ValidateBufferName(buffer)) return GL_FALSE; + return MG_State::pGLContext->ValidateBufferObject(buffer) ? GL_TRUE : GL_FALSE; + } + + /* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */ + GLboolean IsBuffer(GLuint buffer) { + return IsBuffer_State(buffer); + } + + void DeleteBuffers(GLsizei n, const GLuint* buffers) { + DeleteBuffers_State(n, buffers); + } + + void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) { + FlushMappedBufferRange_State(target, offset, length); + } + + GLboolean UnmapBuffer(GLenum target) { + return UnmapBuffer_State(target); + } + + void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) { + return MapBufferRange_State(target, offset, length, access); + } + + void* MapBuffer(GLenum target, GLenum access) { + return MapBuffer_State(target, access); + } + + void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size) { + CopyBufferSubData_State(readTarget, writeTarget, readOffset, writeOffset, size); + } + + void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { + BufferSubData_State(target, offset, size, data); + } + + void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) { + BufferData_State(target, size, data, usage); + } + + void BindBuffer(GLenum target, GLuint buffer) { + BindBuffer_State(target, buffer); + } + + void GenBuffers(GLsizei n, GLuint* buffers) { + GenBuffers_State(n, buffers); + } + } // namespace MG_Impl::GLImpl +} // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h index a4017d31..1f3412ef 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h +++ b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.h @@ -1,18 +1,20 @@ #pragma once +#include namespace MobileGL { - namespace MG_Impl::GLImpl { - /* @INSERTION_POINT:FUNCTION_DECLARATION@ */ - GLboolean IsBuffer(GLuint buffer); - void DeleteBuffers(GLsizei n, const GLuint* buffers); - void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); - GLboolean UnmapBuffer(GLenum target); - void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); - void* MapBuffer(GLenum target, GLenum access); - void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); - void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data); - void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage); - void BindBuffer(GLenum target, GLuint buffer); - void GenBuffers(GLsizei n, GLuint* buffers); - } -} + namespace MG_Impl::GLImpl { + /* @INSERTION_POINT:FUNCTION_DECLARATION@ */ + GLboolean IsBuffer(GLuint buffer); + void DeleteBuffers(GLsizei n, const GLuint* buffers); + void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); + GLboolean UnmapBuffer(GLenum target); + void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + void* MapBuffer(GLenum target, GLenum access); + void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, + GLsizeiptr size); + void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data); + void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage); + void BindBuffer(GLenum target, GLuint buffer); + void GenBuffers(GLsizei n, GLuint* buffers); + } // namespace MG_Impl::GLImpl +} // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp b/MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp index 91e58e5c..4325e231 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp +++ b/MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp @@ -1,79 +1,84 @@ -#include "../../../Includes.h" +#include "Validators.h" +#include +#include +#include +#include +#include namespace MobileGL::MG_Impl::GLImpl { - namespace BufferImpl { - bool ValidateBufferTarget(BufferTarget target) { - if (target == BufferTarget::Unknown) { - using namespace MG_Util; - String bufferTargetStr = ConvertBufferTargetToString(target); - String glTargetStr = ConvertGLEnumToString(ConvertBufferTargetToGLEnum(target)); - MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum, - MakeShared("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("MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget", - "No vertex array object is bound.")); - return false; - } + namespace BufferImpl { + bool ValidateBufferTarget(BufferTarget target) { + if (target == BufferTarget::Unknown) { + using namespace MG_Util; + String bufferTargetStr = ConvertBufferTargetToString(target); + String glTargetStr = ConvertGLEnumToString(ConvertBufferTargetToGLEnum(target)); + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared( + "MG_Impl/GLImpl/BufferImpl", "ValidateBufferTarget", + std::format("Target {} ({}) is not valid.", bufferTargetStr, glTargetStr))); + return false; + } - return true; - } + if (target == BufferTarget::Index && MG_State::pGLContext->GetBoundVertexArray() == nullptr) { + MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl/BufferImpl", + "ValidateBufferTarget", + "No vertex array object is bound.")); + return false; + } - bool ValidateBufferName(Uint index) { - bool isValid = MG_State::pGLContext->ValidateBufferName(index); - if (isValid) - return true; - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl/BufferImpl", "ValidateBufferName", - std::format("Buffer name {} is not valid.", index))); - return false; - } + return true; + } - bool ValidateBufferUsage(BufferUsage usage) { - if (usage != BufferUsage::Unknown) { - return true; - } - using namespace MG_Util; - String bufferUsageStr = ConvertBufferUsageToString(usage); - String glUsageStr = ConvertGLEnumToString(ConvertBufferUsageToGLEnum(usage)); - MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum, - MakeShared("MG_Impl/GLImpl/BufferImpl", "ValidateBufferUsage", - std::format("Usage {} ({}) is not one of the allowable values.", - bufferUsageStr, glUsageStr))); - return false; - } + bool ValidateBufferName(Uint index) { + bool isValid = MG_State::pGLContext->ValidateBufferName(index); + if (isValid) return true; + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, + MakeShared("MG_Impl/GLImpl/BufferImpl", "ValidateBufferName", + std::format("Buffer name {} is not valid.", index))); + return false; + } - bool ValidateBufferMappingAccess(Flags accessBits) { - if (accessBits == BufferMappingAccessBit::Null) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum, - MakeShared("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess", - "Access bits cannot be null.")); - return false; - } + bool ValidateBufferUsage(BufferUsage usage) { + if (usage != BufferUsage::Unknown) { + return true; + } + using namespace MG_Util; + String bufferUsageStr = ConvertBufferUsageToString(usage); + String glUsageStr = ConvertGLEnumToString(ConvertBufferUsageToGLEnum(usage)); + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared( + "MG_Impl/GLImpl/BufferImpl", "ValidateBufferUsage", + std::format("Usage {} ({}) is not one of the allowable values.", bufferUsageStr, glUsageStr))); + return false; + } - const auto validBits = - BufferMappingAccessBit::Read | - BufferMappingAccessBit::Write | - BufferMappingAccessBit::InvalidateRange | - BufferMappingAccessBit::InvalidateBuffer | - BufferMappingAccessBit::FlushExplicit | - BufferMappingAccessBit::Unsynchronized | - BufferMappingAccessBit::Persistent | - BufferMappingAccessBit::Coherent; + bool ValidateBufferMappingAccess(Flags accessBits) { + if (accessBits == BufferMappingAccessBit::Null) { + MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum, + MakeShared("MG_Impl/GLImpl/BufferImpl", + "ValidateBufferMappingAccess", + "Access bits cannot be null.")); + return false; + } - if ((accessBits & validBits) != accessBits) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum, - MakeShared("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess", - "Access bits cannot contain invalid flags.")); - return false; - } + const auto validBits = BufferMappingAccessBit::Read | BufferMappingAccessBit::Write | + BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer | + BufferMappingAccessBit::FlushExplicit | BufferMappingAccessBit::Unsynchronized | + BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent; - return true; - } - } -} \ No newline at end of file + if ((accessBits & validBits) != accessBits) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared("MG_Impl/GLImpl/BufferImpl", "ValidateBufferMappingAccess", + "Access bits cannot contain invalid flags.")); + return false; + } + + return true; + } + } // namespace BufferImpl +} // namespace MobileGL::MG_Impl::GLImpl \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/Validators.h b/MobileGL/MG_Impl/GLImpl/Buffer/Validators.h index 25539a3c..a1cb97ca 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/Validators.h +++ b/MobileGL/MG_Impl/GLImpl/Buffer/Validators.h @@ -1,10 +1,12 @@ #pragma once +#include +#include namespace MobileGL::MG_Impl::GLImpl { - namespace BufferImpl { - bool ValidateBufferTarget(BufferTarget target); - bool ValidateBufferName(Uint index); - bool ValidateBufferUsage(BufferUsage usage); - bool ValidateBufferMappingAccess(Flags accessBits); - } -} \ No newline at end of file + namespace BufferImpl { + bool ValidateBufferTarget(BufferTarget target); + bool ValidateBufferName(Uint index); + bool ValidateBufferUsage(BufferUsage usage); + bool ValidateBufferMappingAccess(Flags accessBits); + } // namespace BufferImpl +} // namespace MobileGL::MG_Impl::GLImpl \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp b/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp index dad43f88..e929a2f6 100644 --- a/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp +++ b/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp @@ -1,4 +1,8 @@ -#include "../../../Includes.h" +#include +#include "../Buffer/GL_Buffer.h" +#include "../VertexArray/GL_VertexArray.h" +#include "../Getter/GL_Getter.h" +#include "../Program/GL_Program.h" #define DECLARE_GL_FUNCTION_STUB_HEAD(type,name,...) \ MOBILEGL_GL_API type gl##name(__VA_ARGS__) { diff --git a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp index 8ccb8fee..a964e2e4 100644 --- a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp +++ b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp @@ -1,7 +1,12 @@ -#include "../../../Includes.h" +#include "GL_Getter.h" +#include +#include +#include +#include +#include namespace MobileGL { - namespace MG_Impl::GLImpl { + namespace MG_Impl::GLImpl { /* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */ const GLubyte* GetString(GLenum name) { static String vendorString; @@ -14,40 +19,37 @@ namespace MobileGL { case GL_VENDOR: if (vendorString.empty()) { if (MG_Config::RendererInfoPtr->ExtraVendor.has_value()) { - vendorString = std::format("{}{}", - MG_Config::CoreVendor, MG_Config::RendererInfoPtr->ExtraVendor.value()); + vendorString = + std::format("{}{}", MG_Config::CoreVendor, MG_Config::RendererInfoPtr->ExtraVendor.value()); } else { - vendorString = MG_Config::CoreVendor; + vendorString = MG_Config::CoreVendor; } } return (const GLubyte*)vendorString.c_str(); case GL_VERSION: { if (versionStr.empty()) { - versionStr = std::format("{} {}, {} Backend, Version {}", - MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(), - MG_Config::ProjectName.c_str(), - MG_Config::RendererInfoPtr->BackendName.c_str(), - MG_Config::CoreVersion.toString().c_str()); + versionStr = + std::format("{} {}, {} Backend, Version {}", + MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(), + MG_Config::ProjectName.c_str(), MG_Config::RendererInfoPtr->BackendName.c_str(), + MG_Config::CoreVersion.toString().c_str()); } return (const GLubyte*)versionStr.c_str(); } - case GL_RENDERER: - { + case GL_RENDERER: { if (rendererString.empty()) { String deviceInfo; - rendererString = std::format("{} ({}) ({})", - MG_Config::RendererInfoPtr->RendererName.c_str(), - MG_Config::CoreName.c_str(), - deviceInfo); + rendererString = std::format("{} ({}) ({})", MG_Config::RendererInfoPtr->RendererName.c_str(), + MG_Config::CoreName.c_str(), deviceInfo); } return (const GLubyte*)rendererString.c_str(); } case GL_SHADING_LANGUAGE_VERSION: if (shadingLanguageVersion.empty()) { - shadingLanguageVersion = std::format("{} MobileGL", - MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.toString( - { true, false }).c_str()); + shadingLanguageVersion = std::format( + "{} MobileGL", + MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLSLVersion.toString({true, false}).c_str()); } return (const GLubyte*)shadingLanguageVersion.c_str(); case GL_EXTENSIONS: @@ -55,10 +57,10 @@ namespace MobileGL { for (auto& ext : MG_Config::RendererInfoPtr->RendererGLInfo.Extensions) { extensionsString += MG_Util::ConvertetGLExtToString(ext); extensionsString += " "; - } + } extensionsString.pop_back(); } - return (const GLubyte*)extensionsString.c_str(); + return (const GLubyte*)extensionsString.c_str(); default: return (const GLubyte*)"Unknown enum"; } @@ -88,7 +90,6 @@ namespace MobileGL { return (const GLubyte*)extStrings[index].c_str(); } - void GetIntegerv(GLenum pname, GLint* params) { MGLOG_D("glGetIntegerv, pname: %s", MG_Util::ConvertGLEnumToString(pname).c_str()); if (!params) { @@ -101,8 +102,9 @@ namespace MobileGL { case GL_CONTEXT_FLAGS: params[0] = 0; case GL_CONTEXT_PROFILE_MASK: - params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.IsCompatibilityProfile ? - GL_CONTEXT_COMPATIBILITY_PROFILE_BIT : GL_CONTEXT_CORE_PROFILE_BIT; + params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.IsCompatibilityProfile + ? GL_CONTEXT_COMPATIBILITY_PROFILE_BIT + : GL_CONTEXT_CORE_PROFILE_BIT; break; case GL_NUM_EXTENSIONS: params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.Extensions.size(); @@ -113,22 +115,21 @@ namespace MobileGL { case GL_MINOR_VERSION: params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Minor; break; - + // State // TODO - + // Others... default: - MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)", - MG_Util::ConvertGLEnumToString(pname).c_str(), pname); - // TODO: Report GL_INVALID_ENUM. + MGLOG_E("glGetIntegerv: Invalid enum %s (0x%X)", MG_Util::ConvertGLEnumToString(pname).c_str(), pname); + // TODO: Report GL_INVALID_ENUM. break; } } GLenum GetError() { - ErrorCode errorCode = MG_State::pGLContext->PopGLError().value_or(Error{ ErrorCode::NoError, nullptr }).code; + ErrorCode errorCode = MG_State::pGLContext->PopGLError().value_or(Error{ErrorCode::NoError, nullptr}).code; return MG_Util::ConvertErrorCodeToGLEnum(errorCode); } - } -} \ No newline at end of file + } // namespace MG_Impl::GLImpl +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.h b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.h index 272f8b90..c78dbf54 100644 --- a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.h +++ b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.h @@ -1,11 +1,12 @@ #pragma once +#include namespace MobileGL { - namespace MG_Impl::GLImpl { - /* @INSERTION_POINT:FUNCTION_DECLARATION@ */ - const GLubyte* GetString(GLenum name); - const GLubyte* GetStringi(GLenum name, GLuint index); - void GetIntegerv(GLenum pname, GLint* params); - GLenum GetError(); - } -} \ No newline at end of file + namespace MG_Impl::GLImpl { + /* @INSERTION_POINT:FUNCTION_DECLARATION@ */ + const GLubyte* GetString(GLenum name); + const GLubyte* GetStringi(GLenum name, GLuint index); + void GetIntegerv(GLenum pname, GLint* params); + GLenum GetError(); + } // namespace MG_Impl::GLImpl +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp index cb416259..760059e8 100644 --- a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp +++ b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp @@ -1,260 +1,363 @@ -#include "../../../Includes.h" +#include "GL_Program.h" namespace MobileGL { namespace MG_Impl::GLImpl { void AttachShader_State(GLuint program, GLuint shader) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } - void BindAttribLocation_State(GLuint program, GLuint index, const GLchar *name) { - THROW_UNIMPL_EXCEPTION + void BindAttribLocation_State(GLuint program, GLuint index, const GLchar* name) { + THROW_UNIMPL_EXCEPTION; } void CompileShader_State(GLuint shader) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } GLuint CreateProgram_State(void) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } GLuint CreateShader_State(GLenum type) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void DeleteProgram_State(GLuint program) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void DeleteShader_State(GLuint shader) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void DetachShader_State(GLuint program, GLuint shader) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } - void GetActiveAttrib_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) { - THROW_UNIMPL_EXCEPTION + void GetActiveAttrib_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, + GLenum* type, GLchar* name) { + THROW_UNIMPL_EXCEPTION; } - void GetActiveUniform_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) { - THROW_UNIMPL_EXCEPTION + void GetActiveUniform_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, + GLenum* type, GLchar* name) { + THROW_UNIMPL_EXCEPTION; } - void GetAttachedShaders_State(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) { - THROW_UNIMPL_EXCEPTION + void GetAttachedShaders_State(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) { + THROW_UNIMPL_EXCEPTION; } - GLint GetAttribLocation_State(GLuint program, const GLchar *name) { - THROW_UNIMPL_EXCEPTION + GLint GetAttribLocation_State(GLuint program, const GLchar* name) { + THROW_UNIMPL_EXCEPTION; } - void GetProgramiv_State(GLuint program, GLenum pname, GLint *params) { - THROW_UNIMPL_EXCEPTION + void GetProgramiv_State(GLuint program, GLenum pname, GLint* params) { + THROW_UNIMPL_EXCEPTION; } - void GetProgramInfoLog_State(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) { - THROW_UNIMPL_EXCEPTION + void GetProgramInfoLog_State(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { + THROW_UNIMPL_EXCEPTION; } - void GetShaderiv_State(GLuint shader, GLenum pname, GLint *params) { - THROW_UNIMPL_EXCEPTION + void GetShaderiv_State(GLuint shader, GLenum pname, GLint* params) { + THROW_UNIMPL_EXCEPTION; } - void GetShaderInfoLog_State(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) { - THROW_UNIMPL_EXCEPTION + void GetShaderInfoLog_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { + THROW_UNIMPL_EXCEPTION; } - void GetShaderSource_State(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) { - THROW_UNIMPL_EXCEPTION + void GetShaderSource_State(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) { + THROW_UNIMPL_EXCEPTION; } - GLint GetUniformLocation_State(GLuint program, const GLchar *name) { - THROW_UNIMPL_EXCEPTION + GLint GetUniformLocation_State(GLuint program, const GLchar* name) { + THROW_UNIMPL_EXCEPTION; } - void GetUniformfv_State(GLuint program, GLint location, GLfloat *params) { - THROW_UNIMPL_EXCEPTION + void GetUniformfv_State(GLuint program, GLint location, GLfloat* params) { + THROW_UNIMPL_EXCEPTION; } - void GetUniformiv_State(GLuint program, GLint location, GLint *params) { - THROW_UNIMPL_EXCEPTION + void GetUniformiv_State(GLuint program, GLint location, GLint* params) { + THROW_UNIMPL_EXCEPTION; } GLboolean IsProgram_State(GLuint program) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } GLboolean IsShader_State(GLuint shader) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void LinkProgram_State(GLuint program) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } - void ShaderSource_State(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length) { - THROW_UNIMPL_EXCEPTION + void ShaderSource_State(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) { + THROW_UNIMPL_EXCEPTION; } void UseProgram_State(GLuint program) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void Uniform1f_State(GLint location, GLfloat v0) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void Uniform2f_State(GLint location, GLfloat v0, GLfloat v1) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void Uniform3f_State(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void Uniform4f_State(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void Uniform1i_State(GLint location, GLint v0) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void Uniform2i_State(GLint location, GLint v0, GLint v1) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void Uniform3i_State(GLint location, GLint v0, GLint v1, GLint v2) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } void Uniform4i_State(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } - void Uniform1fv_State(GLint location, GLsizei count, const GLfloat *value) { - THROW_UNIMPL_EXCEPTION + void Uniform1fv_State(GLint location, GLsizei count, const GLfloat* value) { + THROW_UNIMPL_EXCEPTION; } - void Uniform2fv_State(GLint location, GLsizei count, const GLfloat *value) { - THROW_UNIMPL_EXCEPTION + void Uniform2fv_State(GLint location, GLsizei count, const GLfloat* value) { + THROW_UNIMPL_EXCEPTION; } - void Uniform3fv_State(GLint location, GLsizei count, const GLfloat *value) { - THROW_UNIMPL_EXCEPTION + void Uniform3fv_State(GLint location, GLsizei count, const GLfloat* value) { + THROW_UNIMPL_EXCEPTION; } - void Uniform4fv_State(GLint location, GLsizei count, const GLfloat *value) { - THROW_UNIMPL_EXCEPTION + void Uniform4fv_State(GLint location, GLsizei count, const GLfloat* value) { + THROW_UNIMPL_EXCEPTION; } - void Uniform1iv_State(GLint location, GLsizei count, const GLint *value) { - THROW_UNIMPL_EXCEPTION + void Uniform1iv_State(GLint location, GLsizei count, const GLint* value) { + THROW_UNIMPL_EXCEPTION; } - void Uniform2iv_State(GLint location, GLsizei count, const GLint *value) { - THROW_UNIMPL_EXCEPTION + void Uniform2iv_State(GLint location, GLsizei count, const GLint* value) { + THROW_UNIMPL_EXCEPTION; } - void Uniform3iv_State(GLint location, GLsizei count, const GLint *value) { - THROW_UNIMPL_EXCEPTION + void Uniform3iv_State(GLint location, GLsizei count, const GLint* value) { + THROW_UNIMPL_EXCEPTION; } - void Uniform4iv_State(GLint location, GLsizei count, const GLint *value) { - THROW_UNIMPL_EXCEPTION + void Uniform4iv_State(GLint location, GLsizei count, const GLint* value) { + THROW_UNIMPL_EXCEPTION; } - void UniformMatrix2fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { - THROW_UNIMPL_EXCEPTION + void UniformMatrix2fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + THROW_UNIMPL_EXCEPTION; } - void UniformMatrix3fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { - THROW_UNIMPL_EXCEPTION + void UniformMatrix3fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + THROW_UNIMPL_EXCEPTION; } - void UniformMatrix4fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { - THROW_UNIMPL_EXCEPTION + void UniformMatrix4fv_State(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + THROW_UNIMPL_EXCEPTION; } void ValidateProgram_State(GLuint program) { - THROW_UNIMPL_EXCEPTION + THROW_UNIMPL_EXCEPTION; } + void AttachShader(GLuint program, GLuint shader) { + AttachShader_State(program, shader); + } - void AttachShader(GLuint program, GLuint shader) { AttachShader_State(program, shader); } - void BindAttribLocation(GLuint program, GLuint index, const GLchar *name) { + void BindAttribLocation(GLuint program, GLuint index, const GLchar* name) { BindAttribLocation_State(program, index, name); } - void CompileShader(GLuint shader) { CompileShader_State(shader); } - GLuint CreateProgram(void) { return CreateProgram_State(); } - GLuint CreateShader(GLenum type) { return CreateShader_State(type); } - void DeleteProgram(GLuint program) { DeleteProgram_State(program); } - void DeleteShader(GLuint shader) { DeleteShader_State(shader); } - void DetachShader(GLuint program, GLuint shader) { DetachShader_State(program, shader); } - void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) { + + void CompileShader(GLuint shader) { + CompileShader_State(shader); + } + GLuint CreateProgram(void) { + return CreateProgram_State(); + } + GLuint CreateShader(GLenum type) { + return CreateShader_State(type); + } + + void DeleteProgram(GLuint program) { + DeleteProgram_State(program); + } + + void DeleteShader(GLuint shader) { + DeleteShader_State(shader); + } + + void DetachShader(GLuint program, GLuint shader) { + DetachShader_State(program, shader); + } + + void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, + GLchar* name) { GetActiveAttrib_State(program, index, bufSize, length, size, type, name); } - void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) { + + void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, + GLchar* name) { GetActiveUniform_State(program, index, bufSize, length, size, type, name); } - void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) { + + void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) { GetAttachedShaders_State(program, maxCount, count, shaders); } - GLint GetAttribLocation(GLuint program, const GLchar *name) { + GLint GetAttribLocation(GLuint program, const GLchar* name) { GetAttribLocation_State(program, name); } - void GetProgramiv(GLuint program, GLenum pname, GLint *params) { + + void GetProgramiv(GLuint program, GLenum pname, GLint* params) { GetProgramiv_State(program, pname, params); } - void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) { + + void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { GetProgramInfoLog_State(program, bufSize, length, infoLog); } - void GetShaderiv(GLuint shader, GLenum pname, GLint *params) { + + void GetShaderiv(GLuint shader, GLenum pname, GLint* params) { GetShaderiv_State(shader, pname, params); } - void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) { + + void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) { GetShaderInfoLog_State(shader, bufSize, length, infoLog); } - void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) { + + void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) { GetShaderSource_State(shader, bufSize, length, source); } - GLint GetUniformLocation(GLuint program, const GLchar *name) { + GLint GetUniformLocation(GLuint program, const GLchar* name) { GetUniformLocation_State(program, name); } - void GetUniformfv(GLuint program, GLint location, GLfloat *params) { + + void GetUniformfv(GLuint program, GLint location, GLfloat* params) { GetUniformfv_State(program, location, params); } - void GetUniformiv(GLuint program, GLint location, GLint *params) { + + void GetUniformiv(GLuint program, GLint location, GLint* params) { GetUniformiv_State(program, location, params); } - GLboolean IsProgram(GLuint program) { return IsProgram_State(program); } - GLboolean IsShader(GLuint shader) { return IsShader_State(shader); } - void LinkProgram(GLuint program) { LinkProgram_State(program); } - void ShaderSource(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length) { + GLboolean IsProgram(GLuint program) { + return IsProgram_State(program); + } + GLboolean IsShader(GLuint shader) { + return IsShader_State(shader); + } + + void LinkProgram(GLuint program) { + LinkProgram_State(program); + } + + void ShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) { ShaderSource_State(shader, count, string, length); } - void UseProgram(GLuint program) { UseProgram_State(program); } - void Uniform1f(GLint location, GLfloat v0) { Uniform1f_State(location, v0); } - void Uniform2f(GLint location, GLfloat v0, GLfloat v1) { Uniform2f_State(location, v0, v1); } - void Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) { Uniform3f_State(location, v0, v1, v2); } - void Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); - void Uniform1i(GLint location, GLint v0) { Uniform1i_State(location, v0); } - void Uniform2i(GLint location, GLint v0, GLint v1) { Uniform2i_State(location, v0, v1); } - void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) { Uniform3i_State(location, v0, v1, v2); } - void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) { Uniform4i_State(location, v0, v1, v2, v3); } - void Uniform1fv(GLint location, GLsizei count, const GLfloat *value) { Uniform1fv_State(location, count, value); } - void Uniform2fv(GLint location, GLsizei count, const GLfloat *value) { Uniform2fv_State(location, count, value); } - void Uniform3fv(GLint location, GLsizei count, const GLfloat *value) { Uniform3fv_State(location, count, value); } - void Uniform4fv(GLint location, GLsizei count, const GLfloat *value) { Uniform4fv_State(location, count, value); } - void Uniform1iv(GLint location, GLsizei count, const GLint *value) { Uniform1iv_State(location, count, value); } - void Uniform2iv(GLint location, GLsizei count, const GLint *value) { Uniform2iv_State(location, count, value); } - void Uniform3iv(GLint location, GLsizei count, const GLint *value) { Uniform3iv_State(location, count, value); } - void Uniform4iv(GLint location, GLsizei count, const GLint *value) { Uniform4iv_State(location, count, value); } - void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { UniformMatrix2fv_State(location, count, transpose, value); } - void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { UniformMatrix3fv_State(location, count, transpose, value); } - void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { UniformMatrix4fv_State(location, count, transpose, value); } - void ValidateProgram(GLuint program) { ValidateProgram_State(program); } - } -} \ No newline at end of file + + void UseProgram(GLuint program) { + UseProgram_State(program); + } + + void Uniform1f(GLint location, GLfloat v0) { + Uniform1f_State(location, v0); + } + + void Uniform2f(GLint location, GLfloat v0, GLfloat v1) { + Uniform2f_State(location, v0, v1); + } + + void Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) { + Uniform3f_State(location, v0, v1, v2); + } + + void Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { + Uniform4f_State(location, v0, v1, v2, v3); + } + + void Uniform1i(GLint location, GLint v0) { + Uniform1i_State(location, v0); + } + + void Uniform2i(GLint location, GLint v0, GLint v1) { + Uniform2i_State(location, v0, v1); + } + + void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) { + Uniform3i_State(location, v0, v1, v2); + } + + void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) { + Uniform4i_State(location, v0, v1, v2, v3); + } + + void Uniform1fv(GLint location, GLsizei count, const GLfloat* value) { + Uniform1fv_State(location, count, value); + } + + void Uniform2fv(GLint location, GLsizei count, const GLfloat* value) { + Uniform2fv_State(location, count, value); + } + + void Uniform3fv(GLint location, GLsizei count, const GLfloat* value) { + Uniform3fv_State(location, count, value); + } + + void Uniform4fv(GLint location, GLsizei count, const GLfloat* value) { + Uniform4fv_State(location, count, value); + } + + void Uniform1iv(GLint location, GLsizei count, const GLint* value) { + Uniform1iv_State(location, count, value); + } + + void Uniform2iv(GLint location, GLsizei count, const GLint* value) { + Uniform2iv_State(location, count, value); + } + + void Uniform3iv(GLint location, GLsizei count, const GLint* value) { + Uniform3iv_State(location, count, value); + } + + void Uniform4iv(GLint location, GLsizei count, const GLint* value) { + Uniform4iv_State(location, count, value); + } + + void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + UniformMatrix2fv_State(location, count, transpose, value); + } + + void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + UniformMatrix3fv_State(location, count, transpose, value); + } + + void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { + UniformMatrix4fv_State(location, count, transpose, value); + } + + void ValidateProgram(GLuint program) { + ValidateProgram_State(program); + } + } // namespace MG_Impl::GLImpl +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.h b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.h index b282d6a7..55cb8beb 100644 --- a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.h +++ b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.h @@ -1,31 +1,34 @@ #pragma once +#include namespace MobileGL { namespace MG_Impl::GLImpl { void AttachShader(GLuint program, GLuint shader); - void BindAttribLocation(GLuint program, GLuint index, const GLchar *name); + void BindAttribLocation(GLuint program, GLuint index, const GLchar* name); void CompileShader(GLuint shader); GLuint CreateProgram(void); GLuint CreateShader(GLenum type); void DeleteProgram(GLuint program); void DeleteShader(GLuint shader); void DetachShader(GLuint program, GLuint shader); - void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); - void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); - void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); - GLint GetAttribLocation(GLuint program, const GLchar *name); - void GetProgramiv(GLuint program, GLenum pname, GLint *params); - void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); - void GetShaderiv(GLuint shader, GLenum pname, GLint *params); - void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); - void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); - GLint GetUniformLocation(GLuint program, const GLchar *name); - void GetUniformfv(GLuint program, GLint location, GLfloat *params); - void GetUniformiv(GLuint program, GLint location, GLint *params); + void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, + GLchar* name); + void GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, + GLchar* name); + void GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); + GLint GetAttribLocation(GLuint program, const GLchar* name); + void GetProgramiv(GLuint program, GLenum pname, GLint* params); + void GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); + void GetShaderiv(GLuint shader, GLenum pname, GLint* params); + void GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); + void GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source); + GLint GetUniformLocation(GLuint program, const GLchar* name); + void GetUniformfv(GLuint program, GLint location, GLfloat* params); + void GetUniformiv(GLuint program, GLint location, GLint* params); GLboolean IsProgram(GLuint program); GLboolean IsShader(GLuint shader); void LinkProgram(GLuint program); - void ShaderSource(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); + void ShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); void UseProgram(GLuint program); void Uniform1f(GLint location, GLfloat v0); void Uniform2f(GLint location, GLfloat v0, GLfloat v1); @@ -35,17 +38,17 @@ namespace MobileGL { void Uniform2i(GLint location, GLint v0, GLint v1); void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2); void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); - void Uniform1fv(GLint location, GLsizei count, const GLfloat *value); - void Uniform2fv(GLint location, GLsizei count, const GLfloat *value); - void Uniform3fv(GLint location, GLsizei count, const GLfloat *value); - void Uniform4fv(GLint location, GLsizei count, const GLfloat *value); - void Uniform1iv(GLint location, GLsizei count, const GLint *value); - void Uniform2iv(GLint location, GLsizei count, const GLint *value); - void Uniform3iv(GLint location, GLsizei count, const GLint *value); - void Uniform4iv(GLint location, GLsizei count, const GLint *value); - void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); - void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); - void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void Uniform1fv(GLint location, GLsizei count, const GLfloat* value); + void Uniform2fv(GLint location, GLsizei count, const GLfloat* value); + void Uniform3fv(GLint location, GLsizei count, const GLfloat* value); + void Uniform4fv(GLint location, GLsizei count, const GLfloat* value); + void Uniform1iv(GLint location, GLsizei count, const GLint* value); + void Uniform2iv(GLint location, GLsizei count, const GLint* value); + void Uniform3iv(GLint location, GLsizei count, const GLint* value); + void Uniform4iv(GLint location, GLsizei count, const GLint* value); + void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); void ValidateProgram(GLuint program); - } -} + } // namespace MG_Impl::GLImpl +} // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp b/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp index 48c27934..188c25a1 100644 --- a/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp +++ b/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp @@ -1,15 +1,20 @@ -#include "../../../Includes.h" +#include "GL_VertexArray.h" +#include "Validators.h" +#include +#include +#include namespace MobileGL { - namespace MG_Impl::GLImpl { + namespace MG_Impl::GLImpl { void DisableVertexAttribArray_State(GLuint index) { if (!VertexArrayImpl::ValidateVertexAttributeIndex(index)) return; auto vao = MG_State::pGLContext->GetBoundVertexArray(); if (!vao) { MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "EnableVertexAttribArray_State", - "No vertex array object is bound.")); + MakeShared("MG_Impl/GLImpl", + "EnableVertexAttribArray_State", + "No vertex array object is bound.")); return; } @@ -22,8 +27,9 @@ namespace MobileGL { auto vao = MG_State::pGLContext->GetBoundVertexArray(); if (!vao) { MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "EnableVertexAttribArray_State", - "No vertex array object is bound.")); + MakeShared("MG_Impl/GLImpl", + "EnableVertexAttribArray_State", + "No vertex array object is bound.")); return; } @@ -40,17 +46,19 @@ namespace MobileGL { auto vao = MG_State::pGLContext->GetBoundVertexArray(); if (!vao) { MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "VertexAttribPointer_State", - "No vertex array object is bound.")); + MakeShared("MG_Impl/GLImpl", + "VertexAttribPointer_State", + "No vertex array object is bound.")); return; } auto& vboSlot = MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Vertex); auto vbo = vboSlot.GetBoundObject(); if (!vbo) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, MakeShared("MG_Impl/GLImpl", "VertexAttribPointer_State", - "No buffer is bound to GL_ARRAY_BUFFER.")); + "No buffer is bound to GL_ARRAY_BUFFER.")); return; } @@ -60,27 +68,30 @@ namespace MobileGL { vao->BindAttributeBuffer(index, vbo); } - // TODO: Implement GL_BGRA support - void VertexAttribPointer_State(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) { + // TODO: Implement GL_BGRA support + void VertexAttribPointer_State(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, + const void* pointer) { if (!VertexArrayImpl::ValidateVertexAttributeIndex(index)) return; - DataType dataType = MG_Util::ConvertGLEnumToDataType(type); + DataType dataType = MG_Util::ConvertGLEnumToDataType(type); if (!VertexArrayImpl::ValidateVertexAttribPointerParams(index, size, dataType, stride)) return; auto vao = MG_State::pGLContext->GetBoundVertexArray(); if (!vao) { MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, - MakeShared("MG_Impl/GLImpl", "VertexAttribPointer_State", - "No vertex array object is bound.")); + MakeShared("MG_Impl/GLImpl", + "VertexAttribPointer_State", + "No vertex array object is bound.")); return; } auto& vboSlot = MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Vertex); auto vbo = vboSlot.GetBoundObject(); if (!vbo) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, MakeShared("MG_Impl/GLImpl", "VertexAttribPointer_State", - "No buffer is bound to GL_ARRAY_BUFFER.")); + "No buffer is bound to GL_ARRAY_BUFFER.")); return; } @@ -107,9 +118,9 @@ namespace MobileGL { void DeleteVertexArrays_State(GLsizei n, const GLuint* arrays) { if (n < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "DeleteVertexArrays_State", - "n must be non-negative.")); + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, MakeShared("MG_Impl/GLImpl", "DeleteVertexArrays_State", + "n must be non-negative.")); return; } @@ -120,8 +131,7 @@ namespace MobileGL { if (!VertexArrayImpl::ValidateVertexArrayName(vao)) continue; if (MG_State::pGLContext->GetBoundVertexArray() && - MG_State::pGLContext->GetBoundVertexArray() == - MG_State::pGLContext->GetVertexArrayObject(vao)) { + MG_State::pGLContext->GetBoundVertexArray() == MG_State::pGLContext->GetVertexArrayObject(vao)) { MG_State::pGLContext->BindVertexArray(0); } @@ -131,64 +141,66 @@ namespace MobileGL { void GenVertexArrays_State(GLsizei n, GLuint* arrays) { if (n < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "GenVertexArrays_State", - "n must be non-negative.")); + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared("MG_Impl/GLImpl", "GenVertexArrays_State", "n must be non-negative.")); return; } auto vaoNames = MG_State::pGLContext->GenVertexArrayNames(n); Copy(vaoNames.data(), arrays, vaoNames.size()); } - + GLboolean IsVertexArray_State(GLuint array) { if (array == 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "IsVertexArray_State", - "Vertex array name 0 is not supported.")); + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, MakeShared("MG_Impl/GLImpl", "IsVertexArray_State", + "Vertex array name 0 is not supported.")); return GL_FALSE; } if (!VertexArrayImpl::ValidateVertexArrayName(array)) return GL_FALSE; if (!MG_State::pGLContext->ValidateVertexArrayObject(array)) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, MakeShared("MG_Impl/GLImpl", "IsVertexArray_State", - std::format("Vertex array object {} does not exist.", array))); + std::format("Vertex array object {} does not exist.", array))); return GL_FALSE; } return GL_TRUE; - } + } /* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */ GLboolean IsVertexArray(GLuint array) { return IsVertexArray_State(array); } - + void DisableVertexAttribArray(GLuint index) { - DisableVertexAttribArray_State(index); + DisableVertexAttribArray_State(index); } - + void EnableVertexAttribArray(GLuint index) { - EnableVertexAttribArray_State(index); + EnableVertexAttribArray_State(index); } - + void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer) { - VertexAttribIPointer_State(index, size, type, stride, pointer); + VertexAttribIPointer_State(index, size, type, stride, pointer); } - - void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) { - VertexAttribPointer_State(index, size, type, normalized, stride, pointer); + + void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, + const void* pointer) { + VertexAttribPointer_State(index, size, type, normalized, stride, pointer); } - + void BindVertexArray(GLuint array) { - BindVertexArray_State(array); + BindVertexArray_State(array); } - + void DeleteVertexArrays(GLsizei n, const GLuint* arrays) { - DeleteVertexArrays_State(n, arrays); + DeleteVertexArrays_State(n, arrays); } - + void GenVertexArrays(GLsizei n, GLuint* arrays) { - GenVertexArrays_State(n, arrays); + GenVertexArrays_State(n, arrays); } - } -} + } // namespace MG_Impl::GLImpl +} // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.h b/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.h index b69dea7a..9ca051c3 100644 --- a/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.h +++ b/MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.h @@ -1,15 +1,17 @@ #pragma once +#include namespace MobileGL { - namespace MG_Impl::GLImpl { + namespace MG_Impl::GLImpl { /* @INSERTION_POINT:FUNCTION_DECLARATION@ */ GLboolean IsVertexArray(GLuint array); void DisableVertexAttribArray(GLuint index); void EnableVertexAttribArray(GLuint index); void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); - void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); + void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, + const void* pointer); void BindVertexArray(GLuint array); void DeleteVertexArrays(GLsizei n, const GLuint* arrays); void GenVertexArrays(GLsizei n, GLuint* arrays); - } -} + } // namespace MG_Impl::GLImpl +} // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp b/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp index 3a6c6593..54aefb0f 100644 --- a/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp +++ b/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp @@ -1,31 +1,37 @@ -#include "../../../Includes.h" +#include "Validators.h" +#include +#include +#include +#include namespace MobileGL::MG_Impl::GLImpl { - namespace VertexArrayImpl { + namespace VertexArrayImpl { bool ValidateVertexArrayName(Uint index) { if (index == 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "ValidateVertexArrayName", - "Vertex array name 0 is not supported.")); + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, MakeShared("MG_Impl/GLImpl", "ValidateVertexArrayName", + "Vertex array name 0 is not supported.")); return false; } - + bool isValid = MG_State::pGLContext->ValidateVertexArrayName(index); - if (!isValid) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, + if (!isValid) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, MakeShared("MG_Impl/GLImpl", "ValidateVertexArrayName", - std::format("Vertex array name {} is not valid.", index))); + std::format("Vertex array name {} is not valid.", index))); return false; } - return true; + return true; } bool ValidateVertexArrayObject(Uint index) { if (!MG_State::pGLContext->ValidateVertexArrayObject(index)) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidOperation, + MG_State::pGLContext->RecordError( + ErrorCode::InvalidOperation, MakeShared("MG_Impl/GLImpl", "ValidateVertexArrayObject", - std::format("Vertex array object {} does not exist.", index))); + std::format("Vertex array object {} does not exist.", index))); return false; } return true; @@ -33,10 +39,12 @@ namespace MobileGL::MG_Impl::GLImpl { bool ValidateVertexAttributeIndex(Uint index) { if (index >= MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "ValidateVertexAttributeIndex", - std::format("Attribute index {} exceeds maximum of {}.", - index, MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS - 1))); + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared( + "MG_Impl/GLImpl", "ValidateVertexAttributeIndex", + std::format("Attribute index {} exceeds maximum of {}.", index, + MG_State::GLState::VertexArrayObject::MAX_VERTEX_ATTRIBS - 1))); return false; } return true; @@ -44,27 +52,33 @@ namespace MobileGL::MG_Impl::GLImpl { bool ValidateVertexAttribPointerParams(Uint index, SizeT size, DataType type, Int stride) { if (size < 1 || size > 4) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "ValidateVertexAttribPointerParams", + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared( + "MG_Impl/GLImpl", "ValidateVertexAttribPointerParams", std::format("Invalid size {} for attribute {}. Must be 1-4.", size, index))); return false; } if (type == DataType::Unknown) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidEnum, + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, MakeShared("MG_Impl/GLImpl", "ValidateVertexAttribPointerParams", - std::format("Invalid type {} for attribute {}.", MG_Util::ConvertDataTypeToString(type).c_str(), index))); + std::format("Invalid type {} for attribute {}.", + MG_Util::ConvertDataTypeToString(type).c_str(), index))); return false; } if (stride < 0) { - MG_State::pGLContext->RecordError(ErrorCode::InvalidValue, - MakeShared("MG_Impl/GLImpl", "ValidateVertexAttribPointerParams", + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, + MakeShared( + "MG_Impl/GLImpl", "ValidateVertexAttribPointerParams", std::format("Negative stride {} is not allowed for attribute {}.", stride, index))); return false; } return true; - } - } -} \ No newline at end of file + } + } // namespace VertexArrayImpl +} // namespace MobileGL::MG_Impl::GLImpl \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.h b/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.h index 70ede4fd..168060b1 100644 --- a/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.h +++ b/MobileGL/MG_Impl/GLImpl/VertexArray/Validators.h @@ -1,10 +1,12 @@ #pragma once +#include +#include namespace MobileGL::MG_Impl::GLImpl { - namespace VertexArrayImpl { + namespace VertexArrayImpl { bool ValidateVertexArrayName(Uint index); bool ValidateVertexArrayObject(Uint index); bool ValidateVertexAttributeIndex(Uint index); bool ValidateVertexAttribPointerParams(Uint index, SizeT size, DataType type, Int stride); - } -} \ No newline at end of file + } // namespace VertexArrayImpl +} // namespace MobileGL::MG_Impl::GLImpl \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp b/MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp index 05411a77..46f3e9a1 100644 --- a/MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp +++ b/MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp @@ -1,4 +1,5 @@ -#include "../../../Includes.h" +#include +#include "../LookUp/LookUp.h" MOBILEGL_GLX_API void* glXGetProcAddress(const char* name) { return MG_Impl::GLXImpl::GetProcAddress(name); diff --git a/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp b/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp index 8230f11f..fe02266f 100644 --- a/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp +++ b/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp @@ -1,7 +1,7 @@ -#include "../../../Includes.h" +#include "LookUp.h" namespace MG_Impl::GLXImpl { - // TODO: Implement complete glx functionality + // TODO: Implement complete GLX functionality void* GetProcAddress(const char* name) { MGLOG_D("glXGetProcAddress(\"%s\")", name); @@ -18,4 +18,4 @@ namespace MG_Impl::GLXImpl { void* GetProcAddressARB(const char* name) { return GetProcAddress(name); } -} \ No newline at end of file +} // namespace MG_Impl::GLXImpl \ No newline at end of file diff --git a/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.h b/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.h index 69979250..3ccd293f 100644 --- a/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.h +++ b/MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.h @@ -1,8 +1,9 @@ #pragma once +#include namespace MG_Impl { namespace GLXImpl { void* GetProcAddress(const char* name); void* GetProcAddressARB(const char* name); - } -} \ No newline at end of file + } // namespace GLXImpl +} // namespace MG_Impl \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/BufferState/BufferObject.cpp b/MobileGL/MG_State/GLState/BufferState/BufferObject.cpp index 0e363b73..ffb9d1e2 100644 --- a/MobileGL/MG_State/GLState/BufferState/BufferObject.cpp +++ b/MobileGL/MG_State/GLState/BufferState/BufferObject.cpp @@ -1,159 +1,155 @@ -#include "../../../Includes.h" +#include "BufferObject.h" namespace MobileGL { - namespace MG_State { - namespace GLState { - BufferObject::BufferObject() - : m_id(0), m_size(0), m_usage(BufferUsage::StaticDraw), - m_isMapped(false), m_mappingAccess(BufferMappingAccessBit::Null), - m_dirtyRange({ 0, 0 }), m_mappedRange({ 0, 0 }) { - } + namespace MG_State { + namespace GLState { + BufferObject::BufferObject() + : m_id(0), m_size(0), m_usage(BufferUsage::StaticDraw), m_isMapped(false), + m_mappingAccess(BufferMappingAccessBit::Null), m_dirtyRange({0, 0}), m_mappedRange({0, 0}) {} - void BufferObject::Resize(SizeT size) { - m_size = size; - m_data.reserve(std::bit_ceil(size)); // power-of-2 reserve - m_data.resize(size); - m_dirtyRange = { 0, 0 }; - } + void BufferObject::Resize(SizeT size) { + m_size = size; + m_data.reserve(std::bit_ceil(size)); // power-of-2 reserve + m_data.resize(size); + m_dirtyRange = {0, 0}; + } - void BufferObject::UploadData(DataPtr data, SizeT atOffset) { - assert(atOffset + data.size <= m_size); - assert(!m_isMapped); - memcpy(m_data.data() + atOffset, data.data, data.size); - m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size); - } + void BufferObject::UploadData(DataPtr data, SizeT atOffset) { + assert(atOffset + data.size <= m_size); + assert(!m_isMapped); + memcpy(m_data.data() + atOffset, data.data, data.size); + m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size); + } - void BufferObject::SetUsage(BufferUsage usage) { - m_usage = usage; - } + void BufferObject::SetUsage(BufferUsage usage) { + m_usage = usage; + } - void BufferObject::ReleaseMemory() { - if (!m_isMapped) return; + void BufferObject::ReleaseMemory() { + if (!m_isMapped) return; - if (m_mappingAccess & BufferMappingAccessBit::Write) { // if we wrote to the buffer - if (!(m_mappingAccess & BufferMappingAccessBit::FlushExplicit)) { // if we didn't flush explicitly - memcpy(m_data.data() + m_mappedRange.start, - m_stagingData.data(), - m_mappedRange.end - m_mappedRange.start); - m_dirtyRange.UnionUpdate(m_mappedRange.start, m_mappedRange.end); - } + if (m_mappingAccess & BufferMappingAccessBit::Write) { // if we wrote to the buffer + if (!(m_mappingAccess & BufferMappingAccessBit::FlushExplicit)) { // if we didn't flush explicitly + memcpy(m_data.data() + m_mappedRange.start, m_stagingData.data(), + m_mappedRange.end - m_mappedRange.start); + m_dirtyRange.UnionUpdate(m_mappedRange.start, m_mappedRange.end); + } - m_stagingData.clear(); - } + m_stagingData.clear(); + } - m_isMapped = false; - m_mappingAccess = BufferMappingAccessBit::Null; - m_mappedRange = { 0, 0 }; - m_ownsStagingData = false; - } + m_isMapped = false; + m_mappingAccess = BufferMappingAccessBit::Null; + m_mappedRange = {0, 0}; + m_ownsStagingData = false; + } - void BufferObject::FlushMemoryRange(SizeT offset, SizeT length) { - assert(m_isMapped); - assert((m_mappingAccess & BufferMappingAccessBit::FlushExplicit)); - assert((m_mappingAccess & BufferMappingAccessBit::Write)); + void BufferObject::FlushMemoryRange(SizeT offset, SizeT length) { + assert(m_isMapped); + assert((m_mappingAccess & BufferMappingAccessBit::FlushExplicit)); + assert((m_mappingAccess & BufferMappingAccessBit::Write)); - SizeT start = m_mappedRange.start + offset; - SizeT end = start + length; - assert(end <= m_mappedRange.end); + SizeT start = m_mappedRange.start + offset; + SizeT end = start + length; + assert(end <= m_mappedRange.end); - memcpy(m_data.data() + start, m_stagingData.data() + offset, length); - m_dirtyRange.UnionUpdate(start, end); - } + memcpy(m_data.data() + start, m_stagingData.data() + offset, length); + m_dirtyRange.UnionUpdate(start, end); + } - void BufferObject::UploadSubData(DataPtr data, SizeT atOffset) { - assert(!m_isMapped); - assert(atOffset + data.size <= m_size); + void BufferObject::UploadSubData(DataPtr data, SizeT atOffset) { + assert(!m_isMapped); + assert(atOffset + data.size <= m_size); - memcpy(m_data.data() + atOffset, data.data, data.size); - m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size); - } + memcpy(m_data.data() + atOffset, data.data, data.size); + m_dirtyRange.UnionUpdate(atOffset, atOffset + data.size); + } - void BufferObject::CopyDataFrom(const SharedPtr& src, SizeT srcOffset, SizeT dstOffset, SizeT size) { - assert(!m_isMapped); - assert(!src->IsMapped()); - assert(srcOffset + size <= src->GetSize()); - assert(dstOffset + size <= m_size); + void BufferObject::CopyDataFrom(const SharedPtr& src, SizeT srcOffset, SizeT dstOffset, + SizeT size) { + assert(!m_isMapped); + assert(!src->IsMapped()); + assert(srcOffset + size <= src->GetSize()); + assert(dstOffset + size <= m_size); - const Uint8* srcData = src->m_data.data() + srcOffset; - memcpy(m_data.data() + dstOffset, srcData, size); - m_dirtyRange.UnionUpdate(dstOffset, dstOffset + size); - } + const Uint8* srcData = src->m_data.data() + srcOffset; + memcpy(m_data.data() + dstOffset, srcData, size); + m_dirtyRange.UnionUpdate(dstOffset, dstOffset + size); + } - void* BufferObject::AcquireMemory(Bool markMapped, Bool read, Bool write) { - if (markMapped) { - m_isMapped = true; - auto a = BufferMappingAccessBit::Coherent | BufferMappingAccessBit::Read; - m_mappingAccess = - (read ? BufferMappingAccessBit::Read : BufferMappingAccessBit::Null) | - (write ? BufferMappingAccessBit::Write : BufferMappingAccessBit::Null); - m_mappedRange = { 0, m_size }; + void* BufferObject::AcquireMemory(Bool markMapped, Bool read, Bool write) { + if (markMapped) { + m_isMapped = true; + auto a = BufferMappingAccessBit::Coherent | BufferMappingAccessBit::Read; + m_mappingAccess = (read ? BufferMappingAccessBit::Read : BufferMappingAccessBit::Null) | + (write ? BufferMappingAccessBit::Write : BufferMappingAccessBit::Null); + m_mappedRange = {0, m_size}; - if (m_mappingAccess & BufferMappingAccessBit::Write) { - m_stagingData.resize(m_size); - m_ownsStagingData = true; + if (m_mappingAccess & BufferMappingAccessBit::Write) { + m_stagingData.resize(m_size); + m_ownsStagingData = true; - if (!(m_mappingAccess & (BufferMappingAccessBit::InvalidateRange | - BufferMappingAccessBit::InvalidateBuffer))) { - memcpy(m_stagingData.data(), m_data.data(), m_size); - } + if (!(m_mappingAccess & + (BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer))) { + memcpy(m_stagingData.data(), m_data.data(), m_size); + } - return m_stagingData.data(); - } - } + return m_stagingData.data(); + } + } - return m_data.data(); - } + return m_data.data(); + } - void* BufferObject::AcquireMemoryRange(Range1D range, Flags access) { - assert(range.end <= m_size && range.start <= range.end); - m_isMapped = true; - m_mappingAccess = access; - m_mappedRange = range; + void* BufferObject::AcquireMemoryRange(Range1D range, Flags access) { + assert(range.end <= m_size && range.start <= range.end); + m_isMapped = true; + m_mappingAccess = access; + m_mappedRange = range; - if (access & BufferMappingAccessBit::Write) { - m_stagingData.resize(range.end - range.start); - m_ownsStagingData = true; + if (access & BufferMappingAccessBit::Write) { + m_stagingData.resize(range.end - range.start); + m_ownsStagingData = true; - if (!(access & (BufferMappingAccessBit::InvalidateRange | - BufferMappingAccessBit::InvalidateBuffer))) { - memcpy(m_stagingData.data(), m_data.data() + range.start, m_stagingData.size()); - } + if (!(access & + (BufferMappingAccessBit::InvalidateRange | BufferMappingAccessBit::InvalidateBuffer))) { + memcpy(m_stagingData.data(), m_data.data() + range.start, m_stagingData.size()); + } - return m_stagingData.data(); - } - else { - m_ownsStagingData = false; - return m_data.data() + range.start; - } - } + return m_stagingData.data(); + } else { + m_ownsStagingData = false; + return m_data.data() + range.start; + } + } - void BufferObject::ClearDirty() { - m_dirtyRange = { 0, 0 }; - } + void BufferObject::ClearDirty() { + m_dirtyRange = {0, 0}; + } - SizeT BufferObject::GetSize() const { - return m_size; - } + SizeT BufferObject::GetSize() const { + return m_size; + } - BufferUsage BufferObject::GetUsage() const { - return m_usage; - } + BufferUsage BufferObject::GetUsage() const { + return m_usage; + } - Range1D BufferObject::GetDirtyRange() const { - return m_dirtyRange; - } + Range1D BufferObject::GetDirtyRange() const { + return m_dirtyRange; + } - Bool BufferObject::IsMapped() const { - return m_isMapped; - } + Bool BufferObject::IsMapped() const { + return m_isMapped; + } - Range1D BufferObject::GetMappedRange() const { - return m_isMapped ? m_mappedRange : Range1D{ 0, 0 }; - } + Range1D BufferObject::GetMappedRange() const { + return m_isMapped ? m_mappedRange : Range1D{0, 0}; + } - Flags BufferObject::GetMappingAccess() const { - return m_isMapped ? m_mappingAccess : BufferMappingAccessBit::Null; - } - } - } -} \ No newline at end of file + Flags BufferObject::GetMappingAccess() const { + return m_isMapped ? m_mappingAccess : BufferMappingAccessBit::Null; + } + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/BufferState/BufferObject.h b/MobileGL/MG_State/GLState/BufferState/BufferObject.h index bcbf3b47..20a85189 100644 --- a/MobileGL/MG_State/GLState/BufferState/BufferObject.h +++ b/MobileGL/MG_State/GLState/BufferState/BufferObject.h @@ -1,106 +1,89 @@ #pragma once -#include "MG_Util/Types.h" +#include namespace MobileGL { - enum class BufferTarget { - Vertex, - Index, - Uniform, - CopyRead, - CopyWrite, - PixelPack, - PixelUnpack, - Query, - Texture, - TransformFeedback, - AtomicCounter, - DispatchIndirect, - DrawIndirect, - ShaderStorage, + enum class BufferTarget { + Vertex, + Index, + Uniform, + CopyRead, + CopyWrite, + PixelPack, + PixelUnpack, + Query, + Texture, + TransformFeedback, + AtomicCounter, + DispatchIndirect, + DrawIndirect, + ShaderStorage, BufferTargetCount, - Unknown = -1 - }; + Unknown = -1 + }; - enum class BufferUsage { - StreamDraw, - StreamRead, - StreamCopy, - StaticDraw, - StaticRead, - StaticCopy, - DynamicDraw, - DynamicRead, - DynamicCopy, - Unknown = -1 - }; + enum class BufferUsage { + StreamDraw, + StreamRead, + StreamCopy, + StaticDraw, + StaticRead, + StaticCopy, + DynamicDraw, + DynamicRead, + DynamicCopy, + Unknown = -1 + }; - enum class BufferMappingAccessBit : Uint { - Null = 0x00, - Read = 0x01, - Write = 0x02, - InvalidateRange = 0x04, - InvalidateBuffer = 0x08, - FlushExplicit = 0x10, - Unsynchronized = 0x20, - Persistent = 0x40, - Coherent = 0x80 - }; + enum class BufferMappingAccessBit : Uint { + Null = 0x00, + Read = 0x01, + Write = 0x02, + InvalidateRange = 0x04, + InvalidateBuffer = 0x08, + FlushExplicit = 0x10, + Unsynchronized = 0x20, + Persistent = 0x40, + Coherent = 0x80 + }; - // inline Flags operator|(BufferMappingAccessBit a, const BufferMappingAccessBit b) { - // return Flags(a) | b; - // } - // - // inline BufferMappingAccessBit& operator|=(BufferMappingAccessBit& a, BufferMappingAccessBit b) { - // a = a | b; - // return a; - // } + namespace MG_State { + namespace GLState { + class BufferObject { + public: + using TargetEnum = BufferTarget; - // inline Flags operator&(const BufferMappingAccessBit a, const BufferMappingAccessBit b) { - // return Flags(a) & b; - // } + BufferObject(); - // inline bool Any(BufferMappingAccessBit a) { - // using T = std::underlying_type_t; - // return static_cast(a) != 0; - // } + void Resize(SizeT size); + void UploadData(DataPtr data, SizeT atOffset); + void SetUsage(BufferUsage usage); + void* AcquireMemory(Bool markMapped, Bool read, Bool write); + void* AcquireMemoryRange(Range1D range, Flags access); + void ReleaseMemory(); + void FlushMemoryRange(SizeT offset, SizeT length); + void UploadSubData(DataPtr data, SizeT atOffset); + void CopyDataFrom(const SharedPtr& src, SizeT srcOffset, SizeT dstOffset, SizeT size); + void ClearDirty(); - namespace MG_State { - namespace GLState { - class BufferObject { - public: - using TargetEnum = BufferTarget; - - BufferObject(); + Bool IsMapped() const; + SizeT GetSize() const; + BufferUsage GetUsage() const; + Range1D GetDirtyRange() const; + Range1D GetMappedRange() const; + Flags GetMappingAccess() const; - void Resize(SizeT size); - void UploadData(DataPtr data, SizeT atOffset); - void SetUsage(BufferUsage usage); - void* AcquireMemory(Bool markMapped, Bool read, Bool write); - void* AcquireMemoryRange(Range1D range, Flags access); - void ReleaseMemory(); - void FlushMemoryRange(SizeT offset, SizeT length); - void UploadSubData(DataPtr data, SizeT atOffset); - void CopyDataFrom(const SharedPtr& src, SizeT srcOffset, SizeT dstOffset, SizeT size); - void ClearDirty(); - - Bool IsMapped() const; - SizeT GetSize() const; - BufferUsage GetUsage() const; - Range1D GetDirtyRange() const; - Range1D GetMappedRange() const; - Flags GetMappingAccess() const; - private: - Int m_id = 0; - SizeT m_size = 0; - BufferUsage m_usage = BufferUsage::StaticDraw; - Data m_data; - Bool m_isMapped; - Flags m_mappingAccess; - Range1D m_dirtyRange; - Range1D m_mappedRange; - std::vector m_stagingData; - bool m_ownsStagingData; - }; - } - } -} + private: + Int m_id = 0; + SizeT m_size = 0; + BufferUsage m_usage = BufferUsage::StaticDraw; + Data m_data; + Bool m_isMapped; + Flags m_mappingAccess; + Range1D m_dirtyRange; + Range1D m_mappedRange; + std::vector m_stagingData; + bool m_ownsStagingData; + }; + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/BufferState/BufferState.cpp b/MobileGL/MG_State/GLState/BufferState/BufferState.cpp index 698b1006..daf23965 100644 --- a/MobileGL/MG_State/GLState/BufferState/BufferState.cpp +++ b/MobileGL/MG_State/GLState/BufferState/BufferState.cpp @@ -1,66 +1,65 @@ -#include "../../../Includes.h" +#include "BufferState.h" namespace MobileGL { - namespace MG_State { - namespace GLState { - BufferState::BufferState() - : m_indexGenerator(1024, 1) { - for (SizeT i = 0; i < m_bindingSlots.size(); ++i) { - m_bindingSlots[i] = BindingSlot(GlobalBufferTargets[i]); - } - } + namespace MG_State { + namespace GLState { + BufferState::BufferState() : m_indexGenerator(1024, 1) { + for (SizeT i = 0; i < m_bindingSlots.size(); ++i) { + m_bindingSlots[i] = BindingSlot(GlobalBufferTargets[i]); + } + } - SharedPtr BufferState::GetBufferObject(Uint index) { - auto it = m_bufferObjects.find(index); - if (it != m_bufferObjects.end()) { - return it->second; - } - return nullptr; - } + SharedPtr BufferState::GetBufferObject(Uint index) { + auto it = m_bufferObjects.find(index); + if (it != m_bufferObjects.end()) { + return it->second; + } + return nullptr; + } - Vector BufferState::GenerateNames(Uint number) { - Vector buffers(number); - m_indexGenerator.Generate(number, buffers.data()); - return buffers; - } + Vector BufferState::GenerateNames(Uint number) { + Vector buffers(number); + m_indexGenerator.Generate(number, buffers.data()); + return buffers; + } - SharedPtr BufferState::CreateBufferObject(Uint index) { - auto bufferObject = MakeShared(); - m_bufferObjects[index] = bufferObject; - return bufferObject; - } + SharedPtr BufferState::CreateBufferObject(Uint index) { + auto bufferObject = MakeShared(); + m_bufferObjects[index] = bufferObject; + return bufferObject; + } - BindingSlot& BufferState::GetBindingSlot(BufferTarget target) { - for (SizeT i = 0; i < m_bindingSlots.size(); ++i) { - if (m_bindingSlots[i].GetTarget() == target) { - return m_bindingSlots[i]; - } - } - assert(false); - } + BindingSlot& BufferState::GetBindingSlot(BufferTarget target) { + for (SizeT i = 0; i < m_bindingSlots.size(); ++i) { + if (m_bindingSlots[i].GetTarget() == target) { + return m_bindingSlots[i]; + } + } + assert(false); + } - void BufferState::MarkBufferObjectForDeletion(Uint index) { - if (m_indexGenerator.IsValid(index)) { - auto it = m_bufferObjects.find(index); - if (it != m_bufferObjects.end()) { - for (SizeT i = 0; i < m_bindingSlots.size(); ++i) { - if (m_bindingSlots[i].GetBoundObject() == it->second) { - m_bindingSlots[i].Bind(nullptr); - } - } - m_bufferObjects.erase(it); - } - m_indexGenerator.Delete(index); - } - } + void BufferState::MarkBufferObjectForDeletion(Uint index) { + if (m_indexGenerator.IsValid(index)) { + auto it = m_bufferObjects.find(index); + if (it != m_bufferObjects.end()) { + for (SizeT i = 0; i < m_bindingSlots.size(); ++i) { + if (m_bindingSlots[i].GetBoundObject() == it->second) { + m_bindingSlots[i].Bind(nullptr); + } + } + m_bufferObjects.erase(it); + } + m_indexGenerator.Delete(index); + } + } - bool BufferState::ValidateName(Uint index) const { - return m_indexGenerator.IsValid(index); - } + bool BufferState::ValidateName(Uint index) const { + return m_indexGenerator.IsValid(index); + } - bool BufferState::ValidateBufferObject(Uint index) const { - return m_bufferObjects.find(index) != m_bufferObjects.end(); - } - } - } -} + bool BufferState::ValidateBufferObject(Uint index) const { + return m_bufferObjects.find(index) != m_bufferObjects.end(); + } + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/BufferState/BufferState.h b/MobileGL/MG_State/GLState/BufferState/BufferState.h index eb0a9dd4..7938aebf 100644 --- a/MobileGL/MG_State/GLState/BufferState/BufferState.h +++ b/MobileGL/MG_State/GLState/BufferState/BufferState.h @@ -1,40 +1,34 @@ #pragma once +#include +#include "BufferObject.h" +#include namespace MobileGL { - namespace MG_State { - namespace GLState { - constexpr const auto GlobalBufferTargets = ToArray( - BufferTarget::Vertex, - BufferTarget::Uniform, - BufferTarget::CopyRead, - BufferTarget::CopyWrite, - BufferTarget::PixelPack, - BufferTarget::PixelUnpack, - BufferTarget::Query, - BufferTarget::Texture, - BufferTarget::TransformFeedback, - BufferTarget::AtomicCounter, - BufferTarget::DispatchIndirect, - BufferTarget::DrawIndirect, - BufferTarget::ShaderStorage); + namespace MG_State { + namespace GLState { + constexpr const auto GlobalBufferTargets = + ToArray(BufferTarget::Vertex, BufferTarget::Uniform, BufferTarget::CopyRead, BufferTarget::CopyWrite, + BufferTarget::PixelPack, BufferTarget::PixelUnpack, BufferTarget::Query, BufferTarget::Texture, + BufferTarget::TransformFeedback, BufferTarget::AtomicCounter, BufferTarget::DispatchIndirect, + BufferTarget::DrawIndirect, BufferTarget::ShaderStorage); - class BufferState { - public: - BufferState(); + class BufferState { + public: + BufferState(); - SharedPtr GetBufferObject(Uint index); - Vector GenerateNames(Uint number); - SharedPtr CreateBufferObject(Uint index); - BindingSlot& GetBindingSlot(BufferTarget target); - void MarkBufferObjectForDeletion(Uint index); - bool ValidateName(Uint index) const; - bool ValidateBufferObject(Uint index) const; + SharedPtr GetBufferObject(Uint index); + Vector GenerateNames(Uint number); + SharedPtr CreateBufferObject(Uint index); + BindingSlot& GetBindingSlot(BufferTarget target); + void MarkBufferObjectForDeletion(Uint index); + bool ValidateName(Uint index) const; + bool ValidateBufferObject(Uint index) const; - private: - UnorderedMap> m_bufferObjects; - IndexGenerator m_indexGenerator; - Array, GlobalBufferTargets.size()> m_bindingSlots; - }; - } - } -} \ No newline at end of file + private: + UnorderedMap> m_bufferObjects; + IndexGenerator m_indexGenerator; + Array, GlobalBufferTargets.size()> m_bindingSlots; + }; + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/Core.cpp b/MobileGL/MG_State/GLState/Core.cpp index 89d36fac..46ce47f5 100644 --- a/MobileGL/MG_State/GLState/Core.cpp +++ b/MobileGL/MG_State/GLState/Core.cpp @@ -1,4 +1,4 @@ -#include "../../Includes.h" +#include "Core.h" namespace MobileGL { namespace MG_State { @@ -36,7 +36,7 @@ namespace MobileGL { m_errorState.Clear(); } - // Buffer + // Buffer Vector GLContext::GenBufferNames(Uint number) { return m_bufferState.GenerateNames(number); } @@ -47,9 +47,9 @@ namespace MobileGL { BindingSlot& GLContext::GetBufferBindingSlot(BufferTarget target) { if (target == BufferTarget::Index) { - return m_vertexArrayState.GetBoundVertexArray()->GetIndexBufferBindingSlot(); + return m_vertexArrayState.GetBoundVertexArray()->GetIndexBufferBindingSlot(); } - + return m_bufferState.GetBindingSlot(target); } @@ -59,12 +59,11 @@ namespace MobileGL { void GLContext::MarkBufferObjectForDeletion(Uint index) { if (ValidateBufferObject(index)) { - auto bufferObject = m_bufferState.GetBufferObject(index); + auto bufferObject = m_bufferState.GetBufferObject(index); auto& vaos = m_vertexArrayState.GetAllVertexArrays(); for (SizeT i = 0; i < vaos.size(); ++i) { auto vao = vaos[i]; - if (vao == nullptr) - continue; + if (vao == nullptr) continue; if (vao->GetIndexBufferBindingSlot().GetBoundObject() == bufferObject) { vao->GetIndexBufferBindingSlot().Bind(nullptr); @@ -81,11 +80,11 @@ namespace MobileGL { } bool GLContext::ValidateBufferName(Uint index) const { - return m_bufferState.ValidateName(index); + return m_bufferState.ValidateName(index); } bool GLContext::ValidateBufferObject(Uint index) const { - return m_bufferState.ValidateBufferObject(index); + return m_bufferState.ValidateBufferObject(index); } // VertexArray @@ -120,8 +119,8 @@ namespace MobileGL { SharedPtr GLContext::GetBoundVertexArray() { return m_vertexArrayState.GetBoundVertexArray(); } - } + } // namespace GLState GLState::GLContext* pGLContext; - } -} \ No newline at end of file + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/Core.h b/MobileGL/MG_State/GLState/Core.h index f637de26..2add10ee 100644 --- a/MobileGL/MG_State/GLState/Core.h +++ b/MobileGL/MG_State/GLState/Core.h @@ -1,53 +1,58 @@ #pragma once +#include +#include "BufferState/BufferState.h" +#include "VertexArrayState/VertexArrayState.h" +#include "ErrorState/Error.h" +#include "ProgramState/ProgramState.h" namespace MobileGL { - namespace MG_State { - namespace GLState { - class GLContext { - public: - GLContext() = default; + namespace MG_State { + namespace GLState { + class GLContext { + public: + GLContext() = default; - // Error - void RecordError(ErrorCode code, SharedPtr info = nullptr); - bool HasGLError() const; - Optional PeekGLError() const; - Optional PopGLError(); - bool HasNonGLError() const; - Optional PeekNonGLError() const; - Optional PopNonGLError(); - void ClearErrors(); + // Error + void RecordError(ErrorCode code, SharedPtr info = nullptr); + bool HasGLError() const; + Optional PeekGLError() const; + Optional PopGLError(); + bool HasNonGLError() const; + Optional PeekNonGLError() const; + Optional PopNonGLError(); + void ClearErrors(); - // Buffer - Vector GenBufferNames(Uint number); - SharedPtr GetBufferObject(Uint index); - BindingSlot& GetBufferBindingSlot(BufferTarget target); - SharedPtr CreateBufferObject(Uint index); - void MarkBufferObjectForDeletion(Uint index); - bool ValidateBufferName(Uint index) const; - bool ValidateBufferObject(Uint index) const; + // Buffer + Vector GenBufferNames(Uint number); + SharedPtr GetBufferObject(Uint index); + BindingSlot& GetBufferBindingSlot(BufferTarget target); + SharedPtr CreateBufferObject(Uint index); + void MarkBufferObjectForDeletion(Uint index); + bool ValidateBufferName(Uint index) const; + bool ValidateBufferObject(Uint index) const; - // VertexArray - Vector GenVertexArrayNames(Uint number); - SharedPtr GetVertexArrayObject(Uint index); - void BindVertexArray(Uint index); - SharedPtr CreateVertexArrayObject(Uint index); - void MarkVertexArrayForDeletion(Uint index); - bool ValidateVertexArrayName(Uint index) const; - bool ValidateVertexArrayObject(Uint index) const; - SharedPtr GetBoundVertexArray(); + // VertexArray + Vector GenVertexArrayNames(Uint number); + SharedPtr GetVertexArrayObject(Uint index); + void BindVertexArray(Uint index); + SharedPtr CreateVertexArrayObject(Uint index); + void MarkVertexArrayForDeletion(Uint index); + bool ValidateVertexArrayName(Uint index) const; + bool ValidateVertexArrayObject(Uint index) const; + SharedPtr GetBoundVertexArray(); - private: - // Error - ErrorState m_errorState; + private: + // Error + ErrorState m_errorState; - // Buffer - BufferState m_bufferState; + // Buffer + BufferState m_bufferState; - // VertexArray - VertexArrayState m_vertexArrayState; - }; - } + // VertexArray + VertexArrayState m_vertexArrayState; + }; + } // namespace GLState - extern GLState::GLContext* pGLContext; - } -} \ No newline at end of file + extern GLState::GLContext* pGLContext; + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/ErrorState/Error.cpp b/MobileGL/MG_State/GLState/ErrorState/Error.cpp index 26e3538f..de381805 100644 --- a/MobileGL/MG_State/GLState/ErrorState/Error.cpp +++ b/MobileGL/MG_State/GLState/ErrorState/Error.cpp @@ -1,19 +1,19 @@ -#include "../../../Includes.h" +#include "Error.h" +#include +#include namespace MobileGL { - namespace MG_State { + namespace MG_State { namespace GLState { void ErrorState::RecordError(ErrorCode code, SharedPtr info) { if (code == ErrorCode::NoError) { - MGLOG_E("Recording Non-OpenGL error:\n%s", - info->ToString().c_str()); - m_nonGLErrors.push_back(Error{ code, info }); - } - else { - MGLOG_E("Recording OpenGL error (%s):\n%s", - MG_Util::ConvertGLEnumToString(MG_Util::ConvertErrorCodeToGLEnum(code)).c_str(), - info->ToString().c_str()); - m_errors.push_back(Error{ code, info }); + MGLOG_E("Recording Non-OpenGL error:\n%s", info->ToString().c_str()); + m_nonGLErrors.push_back(Error{code, info}); + } else { + MGLOG_E("Recording OpenGL error (%s):\n%s", + MG_Util::ConvertGLEnumToString(MG_Util::ConvertErrorCodeToGLEnum(code)).c_str(), + info->ToString().c_str()); + m_errors.push_back(Error{code, info}); } } @@ -22,15 +22,15 @@ namespace MobileGL { } Optional ErrorState::PeekNonGLError() const { - if (m_nonGLErrors.empty()) return Optional{ }; + if (m_nonGLErrors.empty()) return Optional{}; return Optional{m_nonGLErrors.front()}; } Optional ErrorState::PopNonGLError() { - if (m_nonGLErrors.empty()) return Optional{ }; + if (m_nonGLErrors.empty()) return Optional{}; auto error = Move(m_nonGLErrors.front()); m_nonGLErrors.erase(m_nonGLErrors.begin()); - return Optional{ error }; + return Optional{error}; } bool ErrorState::HasGLError() const { @@ -38,21 +38,21 @@ namespace MobileGL { } Optional ErrorState::PeekGLError() const { - if (m_errors.empty()) return Optional{ }; + if (m_errors.empty()) return Optional{}; return Optional{m_errors.front()}; } Optional ErrorState::PopGLError() { - if (m_errors.empty()) return Optional{ }; + if (m_errors.empty()) return Optional{}; auto error = Move(m_errors.front()); m_errors.erase(m_errors.begin()); - return Optional{ error }; + return Optional{error}; } void ErrorState::Clear() { m_errors.clear(); m_nonGLErrors.clear(); } - } - } -} \ No newline at end of file + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/ErrorState/Error.h b/MobileGL/MG_State/GLState/ErrorState/Error.h index d5a12229..dc7db2f9 100644 --- a/MobileGL/MG_State/GLState/ErrorState/Error.h +++ b/MobileGL/MG_State/GLState/ErrorState/Error.h @@ -1,4 +1,7 @@ #pragma once +#include +#include "ErrorCode.h" +#include "ErrorInfo.h" namespace MobileGL { struct Error { @@ -23,6 +26,6 @@ namespace MobileGL { Vector m_errors; Vector m_nonGLErrors; }; - } - } -} \ No newline at end of file + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/ErrorState/ErrorInfo.h b/MobileGL/MG_State/GLState/ErrorState/ErrorInfo.h index b2d6d524..faf245ff 100644 --- a/MobileGL/MG_State/GLState/ErrorState/ErrorInfo.h +++ b/MobileGL/MG_State/GLState/ErrorState/ErrorInfo.h @@ -1,4 +1,5 @@ #pragma once +#include namespace MobileGL { class ErrorInfo { @@ -10,9 +11,11 @@ namespace MobileGL { class GenericErrorInfo : public ErrorInfo { public: explicit GenericErrorInfo(String message) : m_message(Move(message)) {} - explicit GenericErrorInfo(String m_prefix, String message) : m_message(Move(message)), m_prefix(Move(m_prefix)) {} - explicit GenericErrorInfo(String m_prefix, String m_prefix_2, String message) : m_message(Move(message)), m_prefix(Move(m_prefix)), m_prefix_2(Move(m_prefix_2)) {} - + explicit GenericErrorInfo(String m_prefix, String message) + : m_message(Move(message)), m_prefix(Move(m_prefix)) {} + explicit GenericErrorInfo(String m_prefix, String m_prefix_2, String message) + : m_message(Move(message)), m_prefix(Move(m_prefix)), m_prefix_2(Move(m_prefix_2)) {} + String ToString() const override { StringStream ss; if (m_prefix.has_value()) { @@ -22,11 +25,12 @@ namespace MobileGL { ss << "[" << m_prefix_2.value() << "] "; } ss << m_message; - return ss.str(); + return ss.str(); } + private: String m_message; - Optional m_prefix; - Optional m_prefix_2; + Optional m_prefix; + Optional m_prefix_2; }; -} +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp index 91d4fa41..f69b8412 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp @@ -1,4 +1,5 @@ -#include "../../../Includes.h" +#include "ProgramObject.h" +#include namespace MobileGL { namespace MG_State { @@ -8,10 +9,8 @@ namespace MobileGL { } void ProgramObject::DetachShader(SharedPtr shader) { - auto count = std::erase_if(m_shaders, - [shader](const SharedPtr& s) { - return s.get() == shader.get(); - }); + auto count = std::erase_if( + m_shaders, [shader](const SharedPtr& s) { return s.get() == shader.get(); }); if (count == 0) { // FIXME: handle error here @@ -27,7 +26,7 @@ namespace MobileGL { shaders[i] = m_shaders[i]->m_shader; } - MG_Util::ShaderTranspiler::ProgramAttrib attrib { + MG_Util::ShaderTranspiler::ProgramAttrib attrib{ .shaderTypes = Move(shaderTypes), .shaders = Move(shaders), }; @@ -40,12 +39,11 @@ namespace MobileGL { m_linkStatus = false; m_infoLog = result.error().log; - const std::string e = - std::format("Shader link failed: \nerrc: {}\nmsg: {}\n", - result.error().errc, result.error().log); + const std::string e = std::format("Shader link failed: \nerrc: {}\nmsg: {}\n", result.error().errc, + result.error().log); THROW_EXCEPTION(e); } } - } - } -} \ No newline at end of file + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h index f028432c..0a8d9426 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h @@ -1,23 +1,25 @@ #pragma once -#include "MG_Util/Types.h" +#include +#include "ShaderObject.h" namespace MobileGL { - namespace MG_State { - namespace GLState { - class ProgramObject { - public: - void AttachShader(SharedPtr shader); - void DetachShader(SharedPtr shader); - void Link(); - private: - Vector> m_shaders; - // basically this contains SPIR-V in binary format - Vector> m_programBinary; - String m_infoLog; - bool m_deleteStatus = false; - bool m_linkStatus = true; - bool m_validateStatus = true; - }; - } - } -} + namespace MG_State { + namespace GLState { + class ProgramObject { + public: + void AttachShader(SharedPtr shader); + void DetachShader(SharedPtr shader); + void Link(); + + private: + Vector> m_shaders; + // basically this contains SPIR-V in binary format + Vector> m_programBinary; + String m_infoLog; + bool m_deleteStatus = false; + bool m_linkStatus = true; + bool m_validateStatus = true; + }; + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramState.cpp b/MobileGL/MG_State/GLState/ProgramState/ProgramState.cpp index 591e6023..31462afd 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramState.cpp +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramState.cpp @@ -1,4 +1,4 @@ -#include "../../../Includes.h" +#include "ProgramState.h" namespace MobileGL { namespace MG_State { @@ -12,16 +12,14 @@ namespace MobileGL { } SharedPtr ProgramState::GetProgramObject(Uint id) { - if (!CheckIndexAvail(id)) - return nullptr; // FIXME: add error reporting here + if (!CheckIndexAvail(id)) return nullptr; // FIXME: add error reporting here return m_programObjects[id]; } void ProgramState::DeleteProgram(Uint id) { - if (!CheckIndexAvail(id)) - return; // FIXME: add error reporting here + if (!CheckIndexAvail(id)) return; // FIXME: add error reporting here m_programObjects[id].reset(); } - } - } -} \ No newline at end of file + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramState.h b/MobileGL/MG_State/GLState/ProgramState/ProgramState.h index 82a2876b..5590ead5 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramState.h +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramState.h @@ -1,4 +1,7 @@ #pragma once +#include +#include +#include "ProgramObject.h" namespace MobileGL { namespace MG_State { @@ -10,10 +13,9 @@ namespace MobileGL { Uint CreateProgram(); SharedPtr GetProgramObject(Uint id); void DeleteProgram(Uint program); + private: - bool CheckIndexAvail(SizeT idx) { - return idx < m_programObjects.size(); - } + bool CheckIndexAvail(SizeT idx) { return idx < m_programObjects.size(); } void EnsureIndexAvail(SizeT idx) { if (CheckIndexAvail(idx)) return; @@ -25,6 +27,6 @@ namespace MobileGL { IndexGenerator m_indexGenerator; Vector> m_programObjects; }; - } - } -} \ No newline at end of file + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/ProgramState/ShaderObject.cpp b/MobileGL/MG_State/GLState/ProgramState/ShaderObject.cpp index 631bb263..0bf85db3 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ShaderObject.cpp +++ b/MobileGL/MG_State/GLState/ProgramState/ShaderObject.cpp @@ -1,4 +1,5 @@ -#include "../../../Includes.h" +#include "ShaderObject.h" +#include namespace MobileGL { namespace MG_State { @@ -9,11 +10,8 @@ namespace MobileGL { void ShaderObject::Compile() { using namespace MG_Util::ShaderTranspiler; - ShaderAttrib attrib { - .sourceStr = m_source, - .shaderType = GetGLShaderTypeByMGLShaderStage(m_stage), - .flags = 0 - }; + ShaderAttrib attrib{ + .sourceStr = m_source, .shaderType = GetGLShaderTypeByMGLShaderStage(m_stage), .flags = 0}; auto result = ShaderCompiler::CompileShader(attrib); if (result) { @@ -23,12 +21,11 @@ namespace MobileGL { m_compileStatus = false; m_infoLog = result.error().log; - const std::string e = - std::format("Shader compilation failed: \nerrc: {}\nmsg: {}\n", - result.error().errc, result.error().log); + const std::string e = std::format("Shader compilation failed: \nerrc: {}\nmsg: {}\n", + result.error().errc, result.error().log); THROW_EXCEPTION(e); } } - } - } -} \ No newline at end of file + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_State/GLState/ProgramState/ShaderObject.h b/MobileGL/MG_State/GLState/ProgramState/ShaderObject.h index 48ab4b14..adcad709 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ShaderObject.h +++ b/MobileGL/MG_State/GLState/ProgramState/ShaderObject.h @@ -1,5 +1,5 @@ #pragma once -#include "MG_Util/Types.h" +#include namespace MobileGL { namespace MG_State { @@ -15,27 +15,27 @@ namespace MobileGL { inline static GLenum GetGLShaderTypeByMGLShaderStage(ShaderStage stage) { switch (stage) { - case ShaderStage::Vertex: - return GL_VERTEX_SHADER; - case ShaderStage::TessControl: - return GL_TESS_CONTROL_SHADER; - case ShaderStage::TessEval: - return GL_TESS_EVALUATION_SHADER; - case ShaderStage::Geometry: - return GL_GEOMETRY_SHADER; - case ShaderStage::Fragment: - return GL_FRAGMENT_SHADER; - case ShaderStage::Compute: - return GL_COMPUTE_SHADER; - default: - assert(false); - return 0; + case ShaderStage::Vertex: + return GL_VERTEX_SHADER; + case ShaderStage::TessControl: + return GL_TESS_CONTROL_SHADER; + case ShaderStage::TessEval: + return GL_TESS_EVALUATION_SHADER; + case ShaderStage::Geometry: + return GL_GEOMETRY_SHADER; + case ShaderStage::Fragment: + return GL_FRAGMENT_SHADER; + case ShaderStage::Compute: + return GL_COMPUTE_SHADER; + default: + assert(false); + return 0; } } class ShaderObject { public: - ShaderObject(const ShaderStage stage): m_stage(stage) {} + ShaderObject(const ShaderStage stage) : m_stage(stage) {} void SetShaderSource(const std::string& source); void Compile(); @@ -47,6 +47,6 @@ namespace MobileGL { bool m_deleteStatus = false; bool m_compileStatus = false; }; - } - } -} + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.cpp b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.cpp index 0378b1db..eb4d72ba 100644 --- a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.cpp +++ b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.cpp @@ -1,4 +1,4 @@ -#include "../../../Includes.h" +#include "VertexArrayObject.h" namespace MobileGL { namespace MG_State { @@ -30,8 +30,8 @@ namespace MobileGL { return m_attributes[index].Enabled; } - void VertexArrayObject::SetAttributeFormat(Uint index, int size, DataType type, - bool normalized, int stride, SizeT offset, bool isInteger) { + void VertexArrayObject::SetAttributeFormat(Uint index, int size, DataType type, bool normalized, int stride, + SizeT offset, bool isInteger) { if (index >= MAX_VERTEX_ATTRIBS) return; if (size < 1 || size > 4) { @@ -44,17 +44,16 @@ namespace MobileGL { attr.Normalized = normalized; attr.Stride = stride; attr.Offset = offset; - attr.IsInteger = isInteger; + attr.IsInteger = isInteger; } - void VertexArrayObject::BindAttributeBuffer(Uint index, - const SharedPtr& buffer) { + void VertexArrayObject::BindAttributeBuffer(Uint index, const SharedPtr& buffer) { if (index >= MAX_VERTEX_ATTRIBS) return; m_attributes[index].Buffer = buffer; } BindingSlot& VertexArrayObject::GetIndexBufferBindingSlot() { - return m_indexBufferBindingSlot; + return m_indexBufferBindingSlot; } const VertexAttribute& VertexArrayObject::GetAttribute(Uint index) const { @@ -62,6 +61,6 @@ namespace MobileGL { if (index >= MAX_VERTEX_ATTRIBS) return emptyAttr; return m_attributes[index]; } - } - } -} + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.h b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.h index 00007550..fde415c0 100644 --- a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.h +++ b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.h @@ -1,4 +1,6 @@ #pragma once +#include +#include "../BufferState/BufferObject.h" namespace MobileGL { namespace MG_State { @@ -24,7 +26,8 @@ namespace MobileGL { void DisableAttribute(Uint index); bool IsAttributeEnabled(Uint index) const; - void SetAttributeFormat(Uint index, int size, DataType type, bool normalized, int stride, SizeT offset, bool isInteger); + void SetAttributeFormat(Uint index, int size, DataType type, bool normalized, int stride, SizeT offset, + bool isInteger); void BindAttributeBuffer(Uint index, const SharedPtr& buffer); @@ -36,6 +39,6 @@ namespace MobileGL { Array m_attributes; BindingSlot m_indexBufferBindingSlot; }; - } - } -} + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.cpp b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.cpp index 630f510e..1fbb593c 100644 --- a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.cpp +++ b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.cpp @@ -1,11 +1,9 @@ -#include "../../../Includes.h" +#include "VertexArrayState.h" namespace MobileGL { namespace MG_State { namespace GLState { - VertexArrayState::VertexArrayState() - : m_indexGenerator(1024, 1) { - } + VertexArrayState::VertexArrayState() : m_indexGenerator(1024, 1) {} SharedPtr VertexArrayState::GetVertexArrayObject(Uint index) { if (index >= m_vertexArrays.size()) @@ -71,6 +69,6 @@ namespace MobileGL { Vector>& VertexArrayState::GetAllVertexArrays() { return m_vertexArrays; } - } - } -} + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.h b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.h index 8c6cef59..9584c68b 100644 --- a/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.h +++ b/MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.h @@ -1,4 +1,7 @@ #pragma once +#include +#include "VertexArrayObject.h" +#include namespace MobileGL { namespace MG_State { @@ -22,6 +25,6 @@ namespace MobileGL { IndexGenerator m_indexGenerator; SharedPtr m_boundVertexArray; }; - } - } -} + } // namespace GLState + } // namespace MG_State +} // namespace MobileGL diff --git a/MobileGL/MG_Util/Converters/GLToGlslang/GLShaderLangConverter.cpp b/MobileGL/MG_Util/Converters/GLToGlslang/GLShaderLangConverter.cpp index 8fdd6090..34ed0563 100644 --- a/MobileGL/MG_Util/Converters/GLToGlslang/GLShaderLangConverter.cpp +++ b/MobileGL/MG_Util/Converters/GLToGlslang/GLShaderLangConverter.cpp @@ -1,24 +1,24 @@ -#include "../../../Includes.h" +#include "GLShaderLangConverter.h" namespace MobileGL { namespace MG_Util { EShLanguage ConvertGLEnumToEShLanguage(GLenum shaderType) { switch (shaderType) { - case GL_VERTEX_SHADER: - return EShLanguage::EShLangVertex; - case GL_FRAGMENT_SHADER: - return EShLanguage::EShLangFragment; - case GL_COMPUTE_SHADER: - return EShLanguage::EShLangCompute; - case GL_TESS_CONTROL_SHADER: - return EShLanguage::EShLangTessControl; - case GL_TESS_EVALUATION_SHADER: - return EShLanguage::EShLangTessEvaluation; - case GL_GEOMETRY_SHADER: - return EShLanguage::EShLangGeometry; - default: - return EShLanguage::EShLangCount; + case GL_VERTEX_SHADER: + return EShLanguage::EShLangVertex; + case GL_FRAGMENT_SHADER: + return EShLanguage::EShLangFragment; + case GL_COMPUTE_SHADER: + return EShLanguage::EShLangCompute; + case GL_TESS_CONTROL_SHADER: + return EShLanguage::EShLangTessControl; + case GL_TESS_EVALUATION_SHADER: + return EShLanguage::EShLangTessEvaluation; + case GL_GEOMETRY_SHADER: + return EShLanguage::EShLangGeometry; + default: + return EShLanguage::EShLangCount; } } - } -} \ No newline at end of file + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/GLToGlslang/GLShaderLangConverter.h b/MobileGL/MG_Util/Converters/GLToGlslang/GLShaderLangConverter.h index 078254e6..c20afeaf 100644 --- a/MobileGL/MG_Util/Converters/GLToGlslang/GLShaderLangConverter.h +++ b/MobileGL/MG_Util/Converters/GLToGlslang/GLShaderLangConverter.h @@ -1,7 +1,8 @@ #pragma once +#include namespace MobileGL { namespace MG_Util { EShLanguage ConvertGLEnumToEShLanguage(GLenum shaderType); } -} \ No newline at end of file +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.cpp b/MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.cpp index 4a21e8d8..8c213ee0 100644 --- a/MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.cpp @@ -1,54 +1,79 @@ -#include "../../../Includes.h" +#include "BufferEnumConverter.h" namespace MobileGL { - namespace MG_Util { - BufferTarget ConvertGLEnumToBufferTarget(GLenum bufferTarget) { - switch (bufferTarget) { - case GL_ARRAY_BUFFER: return BufferTarget::Vertex; - case GL_ELEMENT_ARRAY_BUFFER: return BufferTarget::Index; - case GL_UNIFORM_BUFFER: return BufferTarget::Uniform; - case GL_COPY_READ_BUFFER: return BufferTarget::CopyRead; - case GL_COPY_WRITE_BUFFER: return BufferTarget::CopyWrite; - case GL_PIXEL_PACK_BUFFER: return BufferTarget::PixelPack; - case GL_PIXEL_UNPACK_BUFFER: return BufferTarget::PixelUnpack; - case GL_QUERY_BUFFER: return BufferTarget::Query; - case GL_TEXTURE_BUFFER: return BufferTarget::Texture; - case GL_TRANSFORM_FEEDBACK_BUFFER: return BufferTarget::TransformFeedback; - case GL_ATOMIC_COUNTER_BUFFER: return BufferTarget::AtomicCounter; - case GL_DISPATCH_INDIRECT_BUFFER: return BufferTarget::DispatchIndirect; - case GL_DRAW_INDIRECT_BUFFER: return BufferTarget::DrawIndirect; - case GL_SHADER_STORAGE_BUFFER: return BufferTarget::ShaderStorage; - case GL_UNKNOWN_MGL: - default: return BufferTarget::Unknown; - } - } + namespace MG_Util { + BufferTarget ConvertGLEnumToBufferTarget(GLenum bufferTarget) { + switch (bufferTarget) { + case GL_ARRAY_BUFFER: + return BufferTarget::Vertex; + case GL_ELEMENT_ARRAY_BUFFER: + return BufferTarget::Index; + case GL_UNIFORM_BUFFER: + return BufferTarget::Uniform; + case GL_COPY_READ_BUFFER: + return BufferTarget::CopyRead; + case GL_COPY_WRITE_BUFFER: + return BufferTarget::CopyWrite; + case GL_PIXEL_PACK_BUFFER: + return BufferTarget::PixelPack; + case GL_PIXEL_UNPACK_BUFFER: + return BufferTarget::PixelUnpack; + case GL_QUERY_BUFFER: + return BufferTarget::Query; + case GL_TEXTURE_BUFFER: + return BufferTarget::Texture; + case GL_TRANSFORM_FEEDBACK_BUFFER: + return BufferTarget::TransformFeedback; + case GL_ATOMIC_COUNTER_BUFFER: + return BufferTarget::AtomicCounter; + case GL_DISPATCH_INDIRECT_BUFFER: + return BufferTarget::DispatchIndirect; + case GL_DRAW_INDIRECT_BUFFER: + return BufferTarget::DrawIndirect; + case GL_SHADER_STORAGE_BUFFER: + return BufferTarget::ShaderStorage; + case GL_UNKNOWN_MGL: + default: + return BufferTarget::Unknown; + } + } - BufferUsage ConvertGLEnumToBufferUsage(GLenum usage) { - switch (usage) { - case GL_STREAM_DRAW: return BufferUsage::StreamDraw; - case GL_STREAM_READ: return BufferUsage::StreamRead; - case GL_STREAM_COPY: return BufferUsage::StreamCopy; - case GL_STATIC_DRAW: return BufferUsage::StaticDraw; - case GL_STATIC_READ: return BufferUsage::StaticRead; - case GL_STATIC_COPY: return BufferUsage::StaticCopy; - case GL_DYNAMIC_DRAW: return BufferUsage::DynamicDraw; - case GL_DYNAMIC_READ: return BufferUsage::DynamicRead; - case GL_DYNAMIC_COPY: return BufferUsage::DynamicCopy; - default: return BufferUsage::Unknown; - } - } + BufferUsage ConvertGLEnumToBufferUsage(GLenum usage) { + switch (usage) { + case GL_STREAM_DRAW: + return BufferUsage::StreamDraw; + case GL_STREAM_READ: + return BufferUsage::StreamRead; + case GL_STREAM_COPY: + return BufferUsage::StreamCopy; + case GL_STATIC_DRAW: + return BufferUsage::StaticDraw; + case GL_STATIC_READ: + return BufferUsage::StaticRead; + case GL_STATIC_COPY: + return BufferUsage::StaticCopy; + case GL_DYNAMIC_DRAW: + return BufferUsage::DynamicDraw; + case GL_DYNAMIC_READ: + return BufferUsage::DynamicRead; + case GL_DYNAMIC_COPY: + return BufferUsage::DynamicCopy; + default: + return BufferUsage::Unknown; + } + } - Flags ConvertGLEnumToBufferMappingAccess(GLbitfield access) { - Flags result = BufferMappingAccessBit::Null; - if (access & GL_MAP_READ_BIT) result |= BufferMappingAccessBit::Read; - if (access & GL_MAP_WRITE_BIT) result |= BufferMappingAccessBit::Write; - if (access & GL_MAP_INVALIDATE_RANGE_BIT) result |= BufferMappingAccessBit::InvalidateRange; - if (access & GL_MAP_INVALIDATE_BUFFER_BIT) result |= BufferMappingAccessBit::InvalidateBuffer; - if (access & GL_MAP_FLUSH_EXPLICIT_BIT) result |= BufferMappingAccessBit::FlushExplicit; - if (access & GL_MAP_UNSYNCHRONIZED_BIT) result |= BufferMappingAccessBit::Unsynchronized; - if (access & GL_MAP_PERSISTENT_BIT) result |= BufferMappingAccessBit::Persistent; - if (access & GL_MAP_COHERENT_BIT) result |= BufferMappingAccessBit::Coherent; - return result; - } - } -} \ No newline at end of file + Flags ConvertGLEnumToBufferMappingAccess(GLbitfield access) { + Flags result = BufferMappingAccessBit::Null; + if (access & GL_MAP_READ_BIT) result |= BufferMappingAccessBit::Read; + if (access & GL_MAP_WRITE_BIT) result |= BufferMappingAccessBit::Write; + if (access & GL_MAP_INVALIDATE_RANGE_BIT) result |= BufferMappingAccessBit::InvalidateRange; + if (access & GL_MAP_INVALIDATE_BUFFER_BIT) result |= BufferMappingAccessBit::InvalidateBuffer; + if (access & GL_MAP_FLUSH_EXPLICIT_BIT) result |= BufferMappingAccessBit::FlushExplicit; + if (access & GL_MAP_UNSYNCHRONIZED_BIT) result |= BufferMappingAccessBit::Unsynchronized; + if (access & GL_MAP_PERSISTENT_BIT) result |= BufferMappingAccessBit::Persistent; + if (access & GL_MAP_COHERENT_BIT) result |= BufferMappingAccessBit::Coherent; + return result; + } + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.h b/MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.h index e6b68ad3..ffddf8a7 100644 --- a/MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.h +++ b/MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.h @@ -1,9 +1,11 @@ #pragma once +#include +#include namespace MobileGL { - namespace MG_Util { - BufferTarget ConvertGLEnumToBufferTarget(GLenum bufferTarget); - BufferUsage ConvertGLEnumToBufferUsage(GLenum usage); - Flags ConvertGLEnumToBufferMappingAccess(GLbitfield access); - } -} \ No newline at end of file + namespace MG_Util { + BufferTarget ConvertGLEnumToBufferTarget(GLenum bufferTarget); + BufferUsage ConvertGLEnumToBufferUsage(GLenum usage); + Flags ConvertGLEnumToBufferMappingAccess(GLbitfield access); + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.cpp b/MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.cpp index 5f314e0d..fcd08ce8 100644 --- a/MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.cpp +++ b/MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.cpp @@ -1,21 +1,30 @@ -#include "../../../Includes.h" +#include "DataTypeConverter.h" namespace MobileGL { - namespace MG_Util { - DataType ConvertGLEnumToDataType(GLenum type) { - switch (type) { - case GL_BYTE: return DataType::Int8; - case GL_UNSIGNED_BYTE: return DataType::Uint8; - case GL_SHORT: return DataType::Int16; - case GL_UNSIGNED_SHORT: return DataType::Uint16; - case GL_INT: return DataType::Int32; - case GL_UNSIGNED_INT: return DataType::Uint32; - case GL_HALF_FLOAT: return DataType::Float16; - case GL_FLOAT: return DataType::Float32; - case GL_DOUBLE: return DataType::Float64; - default: - return DataType::Unknown; - } - } - } -} \ No newline at end of file + namespace MG_Util { + DataType ConvertGLEnumToDataType(GLenum type) { + switch (type) { + case GL_BYTE: + return DataType::Int8; + case GL_UNSIGNED_BYTE: + return DataType::Uint8; + case GL_SHORT: + return DataType::Int16; + case GL_UNSIGNED_SHORT: + return DataType::Uint16; + case GL_INT: + return DataType::Int32; + case GL_UNSIGNED_INT: + return DataType::Uint32; + case GL_HALF_FLOAT: + return DataType::Float16; + case GL_FLOAT: + return DataType::Float32; + case GL_DOUBLE: + return DataType::Float64; + default: + return DataType::Unknown; + } + } + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.h b/MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.h index b5528d72..0f498508 100644 --- a/MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.h +++ b/MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.h @@ -1,7 +1,8 @@ #pragma once +#include namespace MobileGL { - namespace MG_Util { - DataType ConvertGLEnumToDataType(GLenum type); - } -} \ No newline at end of file + namespace MG_Util { + DataType ConvertGLEnumToDataType(GLenum type); + } +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.cpp b/MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.cpp index aba353e8..e1f44b17 100644 --- a/MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.cpp @@ -1,20 +1,21 @@ -#include "../../../Includes.h" +#include "GLEnumConverter.h" namespace MobileGL { - namespace MG_Util { + namespace MG_Util { String ConvertGLEnumToString(GLenum value) { switch (value) { -#define CASE(value) \ - case value: return #value; - //CASE(GL_VERSION_1_0) - //CASE(GL_VERSION_1_1) +#define CASE(value) \ + case value: \ + return #value; + // CASE(GL_VERSION_1_0) + // CASE(GL_VERSION_1_1) CASE(GL_DEPTH_BUFFER_BIT) CASE(GL_STENCIL_BUFFER_BIT) CASE(GL_COLOR_BUFFER_BIT) CASE(GL_FALSE) CASE(GL_TRUE) - //CASE(GL_POINTS) - //CASE(GL_LINES) + // CASE(GL_POINTS) + // CASE(GL_LINES) CASE(GL_LINE_LOOP) CASE(GL_LINE_STRIP) CASE(GL_TRIANGLES) @@ -29,8 +30,8 @@ namespace MobileGL { CASE(GL_NOTEQUAL) CASE(GL_GEQUAL) CASE(GL_ALWAYS) - //CASE(GL_ZERO) - //CASE(GL_ONE) + // CASE(GL_ZERO) + // CASE(GL_ONE) CASE(GL_SRC_COLOR) CASE(GL_ONE_MINUS_SRC_COLOR) CASE(GL_SRC_ALPHA) @@ -40,8 +41,8 @@ namespace MobileGL { CASE(GL_DST_COLOR) CASE(GL_ONE_MINUS_DST_COLOR) CASE(GL_SRC_ALPHA_SATURATE) - //CASE(GL_NONE) - //CASE(GL_FRONT_LEFT) + // CASE(GL_NONE) + // CASE(GL_FRONT_LEFT) CASE(GL_FRONT_RIGHT) CASE(GL_BACK_LEFT) CASE(GL_BACK_RIGHT) @@ -50,7 +51,7 @@ namespace MobileGL { CASE(GL_LEFT) CASE(GL_RIGHT) CASE(GL_FRONT_AND_BACK) - //CASE(GL_NO_ERROR) + // CASE(GL_NO_ERROR) CASE(GL_INVALID_ENUM) CASE(GL_INVALID_VALUE) CASE(GL_INVALID_OPERATION) @@ -182,7 +183,7 @@ namespace MobileGL { CASE(GL_DECR) CASE(GL_VENDOR) CASE(GL_RENDERER) - //CASE(GL_VERSION) + // CASE(GL_VERSION) CASE(GL_EXTENSIONS) CASE(GL_NEAREST) CASE(GL_LINEAR) @@ -212,7 +213,7 @@ namespace MobileGL { CASE(GL_RGBA12) CASE(GL_RGBA16) CASE(GL_VERTEX_ARRAY) - //CASE(GL_VERSION_1_2) + // CASE(GL_VERSION_1_2) CASE(GL_UNSIGNED_BYTE_3_3_2) CASE(GL_UNSIGNED_SHORT_4_4_4_4) CASE(GL_UNSIGNED_SHORT_5_5_5_1) @@ -244,12 +245,12 @@ namespace MobileGL { CASE(GL_TEXTURE_MAX_LOD) CASE(GL_TEXTURE_BASE_LEVEL) CASE(GL_TEXTURE_MAX_LEVEL) - //CASE(GL_SMOOTH_POINT_SIZE_RANGE) - //CASE(GL_SMOOTH_POINT_SIZE_GRANULARITY) - //CASE(GL_SMOOTH_LINE_WIDTH_RANGE) - //CASE(GL_SMOOTH_LINE_WIDTH_GRANULARITY) + // CASE(GL_SMOOTH_POINT_SIZE_RANGE) + // CASE(GL_SMOOTH_POINT_SIZE_GRANULARITY) + // CASE(GL_SMOOTH_LINE_WIDTH_RANGE) + // CASE(GL_SMOOTH_LINE_WIDTH_GRANULARITY) CASE(GL_ALIASED_LINE_WIDTH_RANGE) - //CASE(GL_VERSION_1_3) + // CASE(GL_VERSION_1_3) CASE(GL_TEXTURE0) CASE(GL_TEXTURE1) CASE(GL_TEXTURE2) @@ -309,7 +310,7 @@ namespace MobileGL { CASE(GL_NUM_COMPRESSED_TEXTURE_FORMATS) CASE(GL_COMPRESSED_TEXTURE_FORMATS) CASE(GL_CLAMP_TO_BORDER) - //CASE(GL_VERSION_1_4) + // CASE(GL_VERSION_1_4) CASE(GL_BLEND_DST_RGB) CASE(GL_BLEND_SRC_RGB) CASE(GL_BLEND_DST_ALPHA) @@ -335,7 +336,7 @@ namespace MobileGL { CASE(GL_ONE_MINUS_CONSTANT_COLOR) CASE(GL_CONSTANT_ALPHA) CASE(GL_ONE_MINUS_CONSTANT_ALPHA) - //CASE(GL_VERSION_1_5) + // CASE(GL_VERSION_1_5) CASE(GL_BUFFER_SIZE) CASE(GL_BUFFER_USAGE) CASE(GL_QUERY_COUNTER_BITS) @@ -364,7 +365,7 @@ namespace MobileGL { CASE(GL_DYNAMIC_COPY) CASE(GL_SAMPLES_PASSED) CASE(GL_SRC1_ALPHA) - //CASE(GL_VERSION_2_0) + // CASE(GL_VERSION_2_0) CASE(GL_BLEND_EQUATION_RGB) CASE(GL_VERTEX_ATTRIB_ARRAY_ENABLED) CASE(GL_VERTEX_ATTRIB_ARRAY_SIZE) @@ -445,7 +446,7 @@ namespace MobileGL { CASE(GL_STENCIL_BACK_REF) CASE(GL_STENCIL_BACK_VALUE_MASK) CASE(GL_STENCIL_BACK_WRITEMASK) - //CASE(GL_VERSION_2_1) + // CASE(GL_VERSION_2_1) CASE(GL_PIXEL_PACK_BUFFER) CASE(GL_PIXEL_UNPACK_BUFFER) CASE(GL_PIXEL_PACK_BUFFER_BINDING) @@ -456,7 +457,7 @@ namespace MobileGL { CASE(GL_SRGB8_ALPHA8) CASE(GL_COMPRESSED_SRGB) CASE(GL_COMPRESSED_SRGB_ALPHA) - //CASE(GL_VERSION_3_0) + // CASE(GL_VERSION_3_0) CASE(GL_COMPARE_REF_TO_TEXTURE) CASE(GL_CLIP_DISTANCE0) CASE(GL_CLIP_DISTANCE1) @@ -473,7 +474,7 @@ namespace MobileGL { CASE(GL_CONTEXT_FLAGS) CASE(GL_COMPRESSED_RED) CASE(GL_COMPRESSED_RG) - //CASE(GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) + // CASE(GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) CASE(GL_RGBA32F) CASE(GL_RGB32F) CASE(GL_RGBA16F) @@ -484,7 +485,7 @@ namespace MobileGL { CASE(GL_MAX_PROGRAM_TEXEL_OFFSET) CASE(GL_CLAMP_READ_COLOR) CASE(GL_FIXED_ONLY) - //CASE(GL_MAX_VARYING_COMPONENTS) + // CASE(GL_MAX_VARYING_COMPONENTS) CASE(GL_TEXTURE_1D_ARRAY) CASE(GL_PROXY_TEXTURE_1D_ARRAY) CASE(GL_TEXTURE_2D_ARRAY) @@ -584,7 +585,7 @@ namespace MobileGL { CASE(GL_TEXTURE_DEPTH_TYPE) CASE(GL_UNSIGNED_NORMALIZED) CASE(GL_FRAMEBUFFER_BINDING) - //CASE(GL_DRAW_FRAMEBUFFER_BINDING) + // CASE(GL_DRAW_FRAMEBUFFER_BINDING) CASE(GL_RENDERBUFFER_BINDING) CASE(GL_READ_FRAMEBUFFER) CASE(GL_DRAW_FRAMEBUFFER) @@ -655,9 +656,9 @@ namespace MobileGL { CASE(GL_MAX_SAMPLES) CASE(GL_FRAMEBUFFER_SRGB) CASE(GL_HALF_FLOAT) - //CASE(GL_MAP_READ_BIT) - //CASE(GL_MAP_WRITE_BIT) - //CASE(GL_MAP_INVALIDATE_RANGE_BIT) + // CASE(GL_MAP_READ_BIT) + // CASE(GL_MAP_WRITE_BIT) + // CASE(GL_MAP_INVALIDATE_RANGE_BIT) CASE(GL_MAP_INVALIDATE_BUFFER_BIT) CASE(GL_MAP_FLUSH_EXPLICIT_BIT) CASE(GL_MAP_UNSYNCHRONIZED_BIT) @@ -688,7 +689,7 @@ namespace MobileGL { CASE(GL_RG32I) CASE(GL_RG32UI) CASE(GL_VERTEX_ARRAY_BINDING) - //CASE(GL_VERSION_3_1) + // CASE(GL_VERSION_3_1) CASE(GL_SAMPLER_2D_RECT) CASE(GL_SAMPLER_2D_RECT_SHADOW) CASE(GL_SAMPLER_BUFFER) @@ -749,14 +750,14 @@ namespace MobileGL { CASE(GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER) CASE(GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER) CASE(GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER) - //CASE(GL_VERSION_3_2) - //CASE(GL_CONTEXT_CORE_PROFILE_BIT) - //CASE(GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) + // CASE(GL_VERSION_3_2) + // CASE(GL_CONTEXT_CORE_PROFILE_BIT) + // CASE(GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) CASE(GL_LINES_ADJACENCY) CASE(GL_LINE_STRIP_ADJACENCY) CASE(GL_TRIANGLES_ADJACENCY) CASE(GL_TRIANGLE_STRIP_ADJACENCY) - //CASE(GL_PROGRAM_POINT_SIZE) + // CASE(GL_PROGRAM_POINT_SIZE) CASE(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS) CASE(GL_FRAMEBUFFER_ATTACHMENT_LAYERED) CASE(GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS) @@ -791,7 +792,7 @@ namespace MobileGL { CASE(GL_TIMEOUT_EXPIRED) CASE(GL_CONDITION_SATISFIED) CASE(GL_WAIT_FAILED) - //CASE(GL_SYNC_FLUSH_COMMANDS_BIT) + // CASE(GL_SYNC_FLUSH_COMMANDS_BIT) CASE(GL_SAMPLE_POSITION) CASE(GL_SAMPLE_MASK) CASE(GL_SAMPLE_MASK_VALUE) @@ -813,7 +814,7 @@ namespace MobileGL { CASE(GL_MAX_COLOR_TEXTURE_SAMPLES) CASE(GL_MAX_DEPTH_TEXTURE_SAMPLES) CASE(GL_MAX_INTEGER_SAMPLES) - //CASE(GL_VERSION_3_3) + // CASE(GL_VERSION_3_3) CASE(GL_VERTEX_ATTRIB_ARRAY_DIVISOR) CASE(GL_SRC1_COLOR) CASE(GL_ONE_MINUS_SRC1_COLOR) @@ -830,7 +831,7 @@ namespace MobileGL { CASE(GL_TIME_ELAPSED) CASE(GL_TIMESTAMP) CASE(GL_INT_2_10_10_10_REV) - //CASE(GL_VERSION_4_0) + // CASE(GL_VERSION_4_0) CASE(GL_SAMPLE_SHADING) CASE(GL_MIN_SAMPLE_SHADING_VALUE) CASE(GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET) @@ -902,7 +903,7 @@ namespace MobileGL { CASE(GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE) CASE(GL_TRANSFORM_FEEDBACK_BINDING) CASE(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS) - //CASE(GL_VERSION_4_1) + // CASE(GL_VERSION_4_1) CASE(GL_FIXED) CASE(GL_IMPLEMENTATION_COLOR_READ_TYPE) CASE(GL_IMPLEMENTATION_COLOR_READ_FORMAT) @@ -923,11 +924,11 @@ namespace MobileGL { CASE(GL_PROGRAM_BINARY_LENGTH) CASE(GL_NUM_PROGRAM_BINARY_FORMATS) CASE(GL_PROGRAM_BINARY_FORMATS) - //CASE(GL_VERTEX_SHADER_BIT) - //CASE(GL_FRAGMENT_SHADER_BIT) - //CASE(GL_GEOMETRY_SHADER_BIT) - //CASE(GL_TESS_CONTROL_SHADER_BIT) - //CASE(GL_TESS_EVALUATION_SHADER_BIT) + // CASE(GL_VERTEX_SHADER_BIT) + // CASE(GL_FRAGMENT_SHADER_BIT) + // CASE(GL_GEOMETRY_SHADER_BIT) + // CASE(GL_TESS_CONTROL_SHADER_BIT) + // CASE(GL_TESS_EVALUATION_SHADER_BIT) CASE(GL_PROGRAM_SEPARABLE) CASE(GL_ACTIVE_PROGRAM) CASE(GL_PROGRAM_PIPELINE_BINDING) @@ -937,11 +938,11 @@ namespace MobileGL { CASE(GL_LAYER_PROVOKING_VERTEX) CASE(GL_VIEWPORT_INDEX_PROVOKING_VERTEX) CASE(GL_UNDEFINED_VERTEX) - //CASE(GL_VERSION_4_2) - //CASE(GL_COPY_READ_BUFFER_BINDING) - //CASE(GL_COPY_WRITE_BUFFER_BINDING) - //CASE(GL_TRANSFORM_FEEDBACK_ACTIVE) - //CASE(GL_TRANSFORM_FEEDBACK_PAUSED) + // CASE(GL_VERSION_4_2) + // CASE(GL_COPY_READ_BUFFER_BINDING) + // CASE(GL_COPY_WRITE_BUFFER_BINDING) + // CASE(GL_TRANSFORM_FEEDBACK_ACTIVE) + // CASE(GL_TRANSFORM_FEEDBACK_PAUSED) CASE(GL_UNPACK_COMPRESSED_BLOCK_WIDTH) CASE(GL_UNPACK_COMPRESSED_BLOCK_HEIGHT) CASE(GL_UNPACK_COMPRESSED_BLOCK_DEPTH) @@ -981,18 +982,18 @@ namespace MobileGL { CASE(GL_ACTIVE_ATOMIC_COUNTER_BUFFERS) CASE(GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX) CASE(GL_UNSIGNED_INT_ATOMIC_COUNTER) - //CASE(GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT) - //CASE(GL_ELEMENT_ARRAY_BARRIER_BIT) - //CASE(GL_UNIFORM_BARRIER_BIT) - //CASE(GL_TEXTURE_FETCH_BARRIER_BIT) - //CASE(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT) + // CASE(GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT) + // CASE(GL_ELEMENT_ARRAY_BARRIER_BIT) + // CASE(GL_UNIFORM_BARRIER_BIT) + // CASE(GL_TEXTURE_FETCH_BARRIER_BIT) + // CASE(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT) CASE(GL_COMMAND_BARRIER_BIT) CASE(GL_PIXEL_BUFFER_BARRIER_BIT) - //CASE(GL_TEXTURE_UPDATE_BARRIER_BIT) - //CASE(GL_BUFFER_UPDATE_BARRIER_BIT) - //CASE(GL_FRAMEBUFFER_BARRIER_BIT) + // CASE(GL_TEXTURE_UPDATE_BARRIER_BIT) + // CASE(GL_BUFFER_UPDATE_BARRIER_BIT) + // CASE(GL_FRAMEBUFFER_BARRIER_BIT) CASE(GL_TRANSFORM_FEEDBACK_BARRIER_BIT) - //CASE(GL_ATOMIC_COUNTER_BARRIER_BIT) + // CASE(GL_ATOMIC_COUNTER_BARRIER_BIT) CASE(GL_MAX_IMAGE_UNITS) CASE(GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS) CASE(GL_IMAGE_BINDING_NAME) @@ -1049,7 +1050,7 @@ namespace MobileGL { CASE(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT) CASE(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT) CASE(GL_TEXTURE_IMMUTABLE_FORMAT) - //CASE(GL_VERSION_4_3) + // CASE(GL_VERSION_4_3) CASE(GL_NUM_SHADING_LANGUAGE_VERSIONS) CASE(GL_VERTEX_ATTRIB_ARRAY_LONG) CASE(GL_COMPRESSED_RGB8_ETC2) @@ -1082,7 +1083,7 @@ namespace MobileGL { CASE(GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER) CASE(GL_DISPATCH_INDIRECT_BUFFER) CASE(GL_DISPATCH_INDIRECT_BUFFER_BINDING) - //CASE(GL_COMPUTE_SHADER_BIT) + // CASE(GL_COMPUTE_SHADER_BIT) CASE(GL_DEBUG_OUTPUT_SYNCHRONOUS) CASE(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH) CASE(GL_DEBUG_CALLBACK_FUNCTION) @@ -1119,7 +1120,7 @@ namespace MobileGL { CASE(GL_SAMPLER) CASE(GL_MAX_LABEL_LENGTH) CASE(GL_DEBUG_OUTPUT) - //CASE(GL_CONTEXT_FLAG_DEBUG_BIT) + // CASE(GL_CONTEXT_FLAG_DEBUG_BIT) CASE(GL_MAX_UNIFORM_LOCATIONS) CASE(GL_FRAMEBUFFER_DEFAULT_WIDTH) CASE(GL_FRAMEBUFFER_DEFAULT_HEIGHT) @@ -1290,7 +1291,7 @@ namespace MobileGL { CASE(GL_MAX_SHADER_STORAGE_BLOCK_SIZE) CASE(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT) CASE(GL_SHADER_STORAGE_BARRIER_BIT) - //CASE(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES) + // CASE(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES) CASE(GL_DEPTH_STENCIL_TEXTURE_MODE) CASE(GL_TEXTURE_BUFFER_OFFSET) CASE(GL_TEXTURE_BUFFER_SIZE) @@ -1308,15 +1309,15 @@ namespace MobileGL { CASE(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET) CASE(GL_MAX_VERTEX_ATTRIB_BINDINGS) CASE(GL_VERTEX_BINDING_BUFFER) - //CASE(GL_VERSION_4_4) + // CASE(GL_VERSION_4_4) CASE(GL_MAX_VERTEX_ATTRIB_STRIDE) CASE(GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED) - //CASE(GL_TEXTURE_BUFFER_BINDING) - //CASE(GL_MAP_PERSISTENT_BIT) - //CASE(GL_MAP_COHERENT_BIT) - //CASE(GL_DYNAMIC_STORAGE_BIT) - //CASE(GL_CLIENT_STORAGE_BIT) - //CASE(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT) + // CASE(GL_TEXTURE_BUFFER_BINDING) + // CASE(GL_MAP_PERSISTENT_BIT) + // CASE(GL_MAP_COHERENT_BIT) + // CASE(GL_DYNAMIC_STORAGE_BIT) + // CASE(GL_CLIENT_STORAGE_BIT) + // CASE(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT) CASE(GL_BUFFER_IMMUTABLE_STORAGE) CASE(GL_BUFFER_STORAGE_FLAGS) CASE(GL_CLEAR_TEXTURE) @@ -1328,7 +1329,7 @@ namespace MobileGL { CASE(GL_QUERY_BUFFER_BINDING) CASE(GL_QUERY_RESULT_NO_WAIT) CASE(GL_MIRROR_CLAMP_TO_EDGE) - //CASE(GL_VERSION_4_5) + // CASE(GL_VERSION_4_5) CASE(GL_CONTEXT_LOST) CASE(GL_NEGATIVE_ONE_TO_ONE) CASE(GL_ZERO_TO_ONE) @@ -1348,40 +1349,40 @@ namespace MobileGL { CASE(GL_RESET_NOTIFICATION_STRATEGY) CASE(GL_LOSE_CONTEXT_ON_RESET) CASE(GL_NO_RESET_NOTIFICATION) - //CASE(GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT) + // CASE(GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT) CASE(GL_CONTEXT_RELEASE_BEHAVIOR) CASE(GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH) CASE(GL_UNSIGNED_INT64_ARB) CASE(GL_SYNC_CL_EVENT_ARB) CASE(GL_SYNC_CL_EVENT_COMPLETE_ARB) CASE(GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB) - //CASE(GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB) + // CASE(GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB) CASE(GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB) - //CASE(GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB) - //CASE(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) - //CASE(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB) - //CASE(GL_DEBUG_CALLBACK_FUNCTION_ARB) - //CASE(GL_DEBUG_CALLBACK_USER_PARAM_ARB) - //CASE(GL_DEBUG_SOURCE_API_ARB) - //CASE(GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB) - //CASE(GL_DEBUG_SOURCE_SHADER_COMPILER_ARB) - //CASE(GL_DEBUG_SOURCE_THIRD_PARTY_ARB) - //CASE(GL_DEBUG_SOURCE_APPLICATION_ARB) - //CASE(GL_DEBUG_SOURCE_OTHER_ARB) - //CASE(GL_DEBUG_TYPE_ERROR_ARB) - //CASE(GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) - //CASE(GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) - //CASE(GL_DEBUG_TYPE_PORTABILITY_ARB) - //CASE(GL_DEBUG_TYPE_PERFORMANCE_ARB) - //CASE(GL_DEBUG_TYPE_OTHER_ARB) - //CASE(GL_MAX_DEBUG_MESSAGE_LENGTH_ARB) - //CASE(GL_MAX_DEBUG_LOGGED_MESSAGES_ARB) - //CASE(GL_DEBUG_LOGGED_MESSAGES_ARB) - //CASE(GL_DEBUG_SEVERITY_HIGH_ARB) - //CASE(GL_DEBUG_SEVERITY_MEDIUM_ARB) - //CASE(GL_DEBUG_SEVERITY_LOW_ARB) + // CASE(GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB) + // CASE(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) + // CASE(GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB) + // CASE(GL_DEBUG_CALLBACK_FUNCTION_ARB) + // CASE(GL_DEBUG_CALLBACK_USER_PARAM_ARB) + // CASE(GL_DEBUG_SOURCE_API_ARB) + // CASE(GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB) + // CASE(GL_DEBUG_SOURCE_SHADER_COMPILER_ARB) + // CASE(GL_DEBUG_SOURCE_THIRD_PARTY_ARB) + // CASE(GL_DEBUG_SOURCE_APPLICATION_ARB) + // CASE(GL_DEBUG_SOURCE_OTHER_ARB) + // CASE(GL_DEBUG_TYPE_ERROR_ARB) + // CASE(GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) + // CASE(GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) + // CASE(GL_DEBUG_TYPE_PORTABILITY_ARB) + // CASE(GL_DEBUG_TYPE_PERFORMANCE_ARB) + // CASE(GL_DEBUG_TYPE_OTHER_ARB) + // CASE(GL_MAX_DEBUG_MESSAGE_LENGTH_ARB) + // CASE(GL_MAX_DEBUG_LOGGED_MESSAGES_ARB) + // CASE(GL_DEBUG_LOGGED_MESSAGES_ARB) + // CASE(GL_DEBUG_SEVERITY_HIGH_ARB) + // CASE(GL_DEBUG_SEVERITY_MEDIUM_ARB) + // CASE(GL_DEBUG_SEVERITY_LOW_ARB) CASE(GL_BLEND_COLOR) - //CASE(GL_BLEND_EQUATION) + // CASE(GL_BLEND_EQUATION) CASE(GL_PARAMETER_BUFFER_ARB) CASE(GL_PARAMETER_BUFFER_BINDING_ARB) CASE(GL_SRGB_DECODE_ARB) @@ -1395,19 +1396,19 @@ namespace MobileGL { CASE(GL_COMPUTE_SHADER_INVOCATIONS_ARB) CASE(GL_CLIPPING_INPUT_PRIMITIVES_ARB) CASE(GL_CLIPPING_OUTPUT_PRIMITIVES_ARB) - //CASE(GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) - //CASE(GL_LOSE_CONTEXT_ON_RESET_ARB) - //CASE(GL_GUILTY_CONTEXT_RESET_ARB) - //CASE(GL_INNOCENT_CONTEXT_RESET_ARB) - //CASE(GL_UNKNOWN_CONTEXT_RESET_ARB) - //CASE(GL_RESET_NOTIFICATION_STRATEGY_ARB) - //CASE(GL_NO_RESET_NOTIFICATION_ARB) - //CASE(GL_SAMPLE_SHADING_ARB) - //CASE(GL_MIN_SAMPLE_SHADING_VALUE_ARB) + // CASE(GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) + // CASE(GL_LOSE_CONTEXT_ON_RESET_ARB) + // CASE(GL_GUILTY_CONTEXT_RESET_ARB) + // CASE(GL_INNOCENT_CONTEXT_RESET_ARB) + // CASE(GL_UNKNOWN_CONTEXT_RESET_ARB) + // CASE(GL_RESET_NOTIFICATION_STRATEGY_ARB) + // CASE(GL_NO_RESET_NOTIFICATION_ARB) + // CASE(GL_SAMPLE_SHADING_ARB) + // CASE(GL_MIN_SAMPLE_SHADING_VALUE_ARB) CASE(GL_SHADER_INCLUDE_ARB) CASE(GL_NAMED_STRING_LENGTH_ARB) CASE(GL_NAMED_STRING_TYPE_ARB) - //CASE(GL_SPARSE_STORAGE_BIT_ARB) + // CASE(GL_SPARSE_STORAGE_BIT_ARB) CASE(GL_SPARSE_BUFFER_PAGE_SIZE_ARB) CASE(GL_TEXTURE_SPARSE_ARB) CASE(GL_VIRTUAL_PAGE_SIZE_INDEX_ARB) @@ -1420,55 +1421,55 @@ namespace MobileGL { CASE(GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB) CASE(GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB) CASE(GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB) - //CASE(GL_COMPRESSED_RGBA_BPTC_UNORM_ARB) - //CASE(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB) - //CASE(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB) - //CASE(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB) - //CASE(GL_TEXTURE_CUBE_MAP_ARRAY_ARB) - //CASE(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB) - //CASE(GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB) - //CASE(GL_SAMPLER_CUBE_MAP_ARRAY_ARB) - //CASE(GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB) - //CASE(GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB) - //CASE(GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB) - //CASE(GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB) - //CASE(GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB) + // CASE(GL_COMPRESSED_RGBA_BPTC_UNORM_ARB) + // CASE(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB) + // CASE(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB) + // CASE(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB) + // CASE(GL_TEXTURE_CUBE_MAP_ARRAY_ARB) + // CASE(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB) + // CASE(GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB) + // CASE(GL_SAMPLER_CUBE_MAP_ARRAY_ARB) + // CASE(GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB) + // CASE(GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB) + // CASE(GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB) + // CASE(GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB) + // CASE(GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB) CASE(GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB) CASE(GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB) CASE(GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB) - //CASE(GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR) + // CASE(GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR) CASE(GL_CONTEXT_ROBUST_ACCESS) - //CASE(GL_ACCUM) + // CASE(GL_ACCUM) CASE(GL_LOAD) CASE(GL_RETURN) CASE(GL_MULT) CASE(GL_ADD) - //CASE(GL_CURRENT_BIT) - //CASE(GL_POINT_BIT) - //CASE(GL_LINE_BIT) - //CASE(GL_POLYGON_BIT) - //CASE(GL_POLYGON_STIPPLE_BIT) - //CASE(GL_PIXEL_MODE_BIT) - //CASE(GL_LIGHTING_BIT) - //CASE(GL_FOG_BIT) - //CASE(GL_ACCUM_BUFFER_BIT) - //CASE(GL_VIEWPORT_BIT) - //CASE(GL_TRANSFORM_BIT) - //CASE(GL_ENABLE_BIT) - //CASE(GL_HINT_BIT) + // CASE(GL_CURRENT_BIT) + // CASE(GL_POINT_BIT) + // CASE(GL_LINE_BIT) + // CASE(GL_POLYGON_BIT) + // CASE(GL_POLYGON_STIPPLE_BIT) + // CASE(GL_PIXEL_MODE_BIT) + // CASE(GL_LIGHTING_BIT) + // CASE(GL_FOG_BIT) + // CASE(GL_ACCUM_BUFFER_BIT) + // CASE(GL_VIEWPORT_BIT) + // CASE(GL_TRANSFORM_BIT) + // CASE(GL_ENABLE_BIT) + // CASE(GL_HINT_BIT) CASE(GL_EVAL_BIT) CASE(GL_LIST_BIT) CASE(GL_TEXTURE_BIT) CASE(GL_SCISSOR_BIT) CASE(GL_ALL_ATTRIB_BITS) - //CASE(GL_QUAD_STRIP) + // CASE(GL_QUAD_STRIP) CASE(GL_POLYGON) - //CASE(GL_CLIP_PLANE0) - //CASE(GL_CLIP_PLANE1) - //CASE(GL_CLIP_PLANE2) - //CASE(GL_CLIP_PLANE3) - //CASE(GL_CLIP_PLANE4) - //CASE(GL_CLIP_PLANE5) + // CASE(GL_CLIP_PLANE0) + // CASE(GL_CLIP_PLANE1) + // CASE(GL_CLIP_PLANE2) + // CASE(GL_CLIP_PLANE3) + // CASE(GL_CLIP_PLANE4) + // CASE(GL_CLIP_PLANE5) CASE(GL_2_BYTES) CASE(GL_3_BYTES) CASE(GL_4_BYTES) @@ -1489,7 +1490,7 @@ namespace MobileGL { CASE(GL_DRAW_PIXEL_TOKEN) CASE(GL_COPY_PIXEL_TOKEN) CASE(GL_LINE_RESET_TOKEN) - //CASE(GL_EXP) + // CASE(GL_EXP) CASE(GL_EXP2) CASE(GL_COEFF) CASE(GL_ORDER) @@ -1595,7 +1596,7 @@ namespace MobileGL { CASE(GL_DEPTH_BIAS) CASE(GL_MAX_EVAL_ORDER) CASE(GL_MAX_LIGHTS) - //CASE(GL_MAX_CLIP_PLANES) + // CASE(GL_MAX_CLIP_PLANES) CASE(GL_MAX_PIXEL_MAP_TABLE) CASE(GL_MAX_ATTRIB_STACK_DEPTH) CASE(GL_MAX_MODELVIEW_STACK_DEPTH) @@ -1644,7 +1645,7 @@ namespace MobileGL { CASE(GL_SELECTION_BUFFER_POINTER) CASE(GL_SELECTION_BUFFER_SIZE) CASE(GL_TEXTURE_BORDER) - //CASE(GL_LIGHT0) + // CASE(GL_LIGHT0) CASE(GL_LIGHT1) CASE(GL_LIGHT2) CASE(GL_LIGHT3) @@ -1679,7 +1680,7 @@ namespace MobileGL { CASE(GL_SELECT) CASE(GL_FLAT) CASE(GL_SMOOTH) - //CASE(GL_S) + // CASE(GL_S) CASE(GL_T) CASE(GL_R) CASE(GL_Q) @@ -1695,8 +1696,8 @@ namespace MobileGL { CASE(GL_OBJECT_PLANE) CASE(GL_EYE_PLANE) CASE(GL_CLAMP) - //CASE(GL_CLIENT_PIXEL_STORE_BIT) - //CASE(GL_CLIENT_VERTEX_ARRAY_BIT) + // CASE(GL_CLIENT_PIXEL_STORE_BIT) + // CASE(GL_CLIENT_VERTEX_ARRAY_BIT) CASE(GL_ALPHA4) CASE(GL_ALPHA8) CASE(GL_ALPHA12) @@ -1759,56 +1760,56 @@ namespace MobileGL { CASE(GL_T2F_N3F_V3F) CASE(GL_T2F_C4F_N3F_V3F) CASE(GL_T4F_C4F_N3F_V4F) - //CASE(GL_VERTEX_ARRAY_EXT) - //CASE(GL_NORMAL_ARRAY_EXT) - //CASE(GL_COLOR_ARRAY_EXT) - //CASE(GL_INDEX_ARRAY_EXT) - //CASE(GL_TEXTURE_COORD_ARRAY_EXT) - //CASE(GL_EDGE_FLAG_ARRAY_EXT) - //CASE(GL_VERTEX_ARRAY_SIZE_EXT) - //CASE(GL_VERTEX_ARRAY_TYPE_EXT) - //CASE(GL_VERTEX_ARRAY_STRIDE_EXT) + // CASE(GL_VERTEX_ARRAY_EXT) + // CASE(GL_NORMAL_ARRAY_EXT) + // CASE(GL_COLOR_ARRAY_EXT) + // CASE(GL_INDEX_ARRAY_EXT) + // CASE(GL_TEXTURE_COORD_ARRAY_EXT) + // CASE(GL_EDGE_FLAG_ARRAY_EXT) + // CASE(GL_VERTEX_ARRAY_SIZE_EXT) + // CASE(GL_VERTEX_ARRAY_TYPE_EXT) + // CASE(GL_VERTEX_ARRAY_STRIDE_EXT) CASE(GL_VERTEX_ARRAY_COUNT_EXT) - //CASE(GL_NORMAL_ARRAY_TYPE_EXT) - //CASE(GL_NORMAL_ARRAY_STRIDE_EXT) + // CASE(GL_NORMAL_ARRAY_TYPE_EXT) + // CASE(GL_NORMAL_ARRAY_STRIDE_EXT) CASE(GL_NORMAL_ARRAY_COUNT_EXT) - //CASE(GL_COLOR_ARRAY_SIZE_EXT) - //CASE(GL_COLOR_ARRAY_TYPE_EXT) - //CASE(GL_COLOR_ARRAY_STRIDE_EXT) + // CASE(GL_COLOR_ARRAY_SIZE_EXT) + // CASE(GL_COLOR_ARRAY_TYPE_EXT) + // CASE(GL_COLOR_ARRAY_STRIDE_EXT) CASE(GL_COLOR_ARRAY_COUNT_EXT) - //CASE(GL_INDEX_ARRAY_TYPE_EXT) - //CASE(GL_INDEX_ARRAY_STRIDE_EXT) + // CASE(GL_INDEX_ARRAY_TYPE_EXT) + // CASE(GL_INDEX_ARRAY_STRIDE_EXT) CASE(GL_INDEX_ARRAY_COUNT_EXT) - //CASE(GL_TEXTURE_COORD_ARRAY_SIZE_EXT) - //CASE(GL_TEXTURE_COORD_ARRAY_TYPE_EXT) - //CASE(GL_TEXTURE_COORD_ARRAY_STRIDE_EXT) + // CASE(GL_TEXTURE_COORD_ARRAY_SIZE_EXT) + // CASE(GL_TEXTURE_COORD_ARRAY_TYPE_EXT) + // CASE(GL_TEXTURE_COORD_ARRAY_STRIDE_EXT) CASE(GL_TEXTURE_COORD_ARRAY_COUNT_EXT) - //CASE(GL_EDGE_FLAG_ARRAY_STRIDE_EXT) + // CASE(GL_EDGE_FLAG_ARRAY_STRIDE_EXT) CASE(GL_EDGE_FLAG_ARRAY_COUNT_EXT) - //CASE(GL_VERTEX_ARRAY_POINTER_EXT) - //CASE(GL_NORMAL_ARRAY_POINTER_EXT) - //CASE(GL_COLOR_ARRAY_POINTER_EXT) - //CASE(GL_INDEX_ARRAY_POINTER_EXT) - //CASE(GL_TEXTURE_COORD_ARRAY_POINTER_EXT) - //CASE(GL_EDGE_FLAG_ARRAY_POINTER_EXT) - //CASE(GL_BGR_EXT) - //CASE(GL_BGRA_EXT) - //CASE(GL_COLOR_TABLE_FORMAT_EXT) - //CASE(GL_COLOR_TABLE_WIDTH_EXT) - //CASE(GL_COLOR_TABLE_RED_SIZE_EXT) - //CASE(GL_COLOR_TABLE_GREEN_SIZE_EXT) - //CASE(GL_COLOR_TABLE_BLUE_SIZE_EXT) - //CASE(GL_COLOR_TABLE_ALPHA_SIZE_EXT) - //CASE(GL_COLOR_TABLE_LUMINANCE_SIZE_EXT) - //CASE(GL_COLOR_TABLE_INTENSITY_SIZE_EXT) + // CASE(GL_VERTEX_ARRAY_POINTER_EXT) + // CASE(GL_NORMAL_ARRAY_POINTER_EXT) + // CASE(GL_COLOR_ARRAY_POINTER_EXT) + // CASE(GL_INDEX_ARRAY_POINTER_EXT) + // CASE(GL_TEXTURE_COORD_ARRAY_POINTER_EXT) + // CASE(GL_EDGE_FLAG_ARRAY_POINTER_EXT) + // CASE(GL_BGR_EXT) + // CASE(GL_BGRA_EXT) + // CASE(GL_COLOR_TABLE_FORMAT_EXT) + // CASE(GL_COLOR_TABLE_WIDTH_EXT) + // CASE(GL_COLOR_TABLE_RED_SIZE_EXT) + // CASE(GL_COLOR_TABLE_GREEN_SIZE_EXT) + // CASE(GL_COLOR_TABLE_BLUE_SIZE_EXT) + // CASE(GL_COLOR_TABLE_ALPHA_SIZE_EXT) + // CASE(GL_COLOR_TABLE_LUMINANCE_SIZE_EXT) + // CASE(GL_COLOR_TABLE_INTENSITY_SIZE_EXT) CASE(GL_COLOR_INDEX1_EXT) CASE(GL_COLOR_INDEX2_EXT) CASE(GL_COLOR_INDEX4_EXT) CASE(GL_COLOR_INDEX8_EXT) CASE(GL_COLOR_INDEX12_EXT) CASE(GL_COLOR_INDEX16_EXT) - //CASE(GL_MAX_ELEMENTS_VERTICES_WIN) - //CASE(GL_MAX_ELEMENTS_INDICES_WIN) + // CASE(GL_MAX_ELEMENTS_VERTICES_WIN) + // CASE(GL_MAX_ELEMENTS_INDICES_WIN) CASE(GL_PHONG_WIN) CASE(GL_PHONG_HINT_WIN) CASE(GL_FOG_SPECULAR_TEXTURE_WIN) @@ -1817,6 +1818,6 @@ namespace MobileGL { return std::format("0x%x", value); } #undef CASE - } - } -} \ No newline at end of file + } + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.h b/MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.h index 9d34f090..b982d2dd 100644 --- a/MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.h +++ b/MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.h @@ -1,7 +1,8 @@ #pragma once +#include namespace MobileGL { - namespace MG_Util { - String ConvertGLEnumToString(GLenum value); - } -} \ No newline at end of file + namespace MG_Util { + String ConvertGLEnumToString(GLenum value); + } +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.cpp b/MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.cpp index 060673a6..3bb187bf 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.cpp @@ -1,54 +1,79 @@ -#include "../../../Includes.h" +#include "BufferEnumConverter.h" namespace MobileGL { - namespace MG_Util { - GLenum ConvertBufferTargetToGLEnum(BufferTarget bufferTarget) { - switch (bufferTarget) { - case BufferTarget::Vertex: return GL_ARRAY_BUFFER; - case BufferTarget::Index: return GL_ELEMENT_ARRAY_BUFFER; - case BufferTarget::Uniform: return GL_UNIFORM_BUFFER; - case BufferTarget::CopyRead: return GL_COPY_READ_BUFFER; - case BufferTarget::CopyWrite: return GL_COPY_WRITE_BUFFER; - case BufferTarget::PixelPack: return GL_PIXEL_PACK_BUFFER; - case BufferTarget::PixelUnpack: return GL_PIXEL_UNPACK_BUFFER; - case BufferTarget::Query: return GL_QUERY_BUFFER; - case BufferTarget::Texture: return GL_TEXTURE_BUFFER; - case BufferTarget::TransformFeedback: return GL_TRANSFORM_FEEDBACK_BUFFER; - case BufferTarget::AtomicCounter: return GL_ATOMIC_COUNTER_BUFFER; - case BufferTarget::DispatchIndirect: return GL_DISPATCH_INDIRECT_BUFFER; - case BufferTarget::DrawIndirect: return GL_DRAW_INDIRECT_BUFFER; - case BufferTarget::ShaderStorage: return GL_SHADER_STORAGE_BUFFER; - case BufferTarget::Unknown: - default: return GL_UNKNOWN_MGL; - } - } + namespace MG_Util { + GLenum ConvertBufferTargetToGLEnum(BufferTarget bufferTarget) { + switch (bufferTarget) { + case BufferTarget::Vertex: + return GL_ARRAY_BUFFER; + case BufferTarget::Index: + return GL_ELEMENT_ARRAY_BUFFER; + case BufferTarget::Uniform: + return GL_UNIFORM_BUFFER; + case BufferTarget::CopyRead: + return GL_COPY_READ_BUFFER; + case BufferTarget::CopyWrite: + return GL_COPY_WRITE_BUFFER; + case BufferTarget::PixelPack: + return GL_PIXEL_PACK_BUFFER; + case BufferTarget::PixelUnpack: + return GL_PIXEL_UNPACK_BUFFER; + case BufferTarget::Query: + return GL_QUERY_BUFFER; + case BufferTarget::Texture: + return GL_TEXTURE_BUFFER; + case BufferTarget::TransformFeedback: + return GL_TRANSFORM_FEEDBACK_BUFFER; + case BufferTarget::AtomicCounter: + return GL_ATOMIC_COUNTER_BUFFER; + case BufferTarget::DispatchIndirect: + return GL_DISPATCH_INDIRECT_BUFFER; + case BufferTarget::DrawIndirect: + return GL_DRAW_INDIRECT_BUFFER; + case BufferTarget::ShaderStorage: + return GL_SHADER_STORAGE_BUFFER; + case BufferTarget::Unknown: + default: + return GL_UNKNOWN_MGL; + } + } - GLenum ConvertBufferUsageToGLEnum(BufferUsage usage) { - switch (usage) { - case BufferUsage::StreamDraw: return GL_STREAM_DRAW; - case BufferUsage::StreamRead: return GL_STREAM_READ; - case BufferUsage::StreamCopy: return GL_STREAM_COPY; - case BufferUsage::StaticDraw: return GL_STATIC_DRAW; - case BufferUsage::StaticRead: return GL_STATIC_READ; - case BufferUsage::StaticCopy: return GL_STATIC_COPY; - case BufferUsage::DynamicDraw: return GL_DYNAMIC_DRAW; - case BufferUsage::DynamicRead: return GL_DYNAMIC_READ; - case BufferUsage::DynamicCopy: return GL_DYNAMIC_COPY; - default: return GL_UNKNOWN_MGL; - } - } + GLenum ConvertBufferUsageToGLEnum(BufferUsage usage) { + switch (usage) { + case BufferUsage::StreamDraw: + return GL_STREAM_DRAW; + case BufferUsage::StreamRead: + return GL_STREAM_READ; + case BufferUsage::StreamCopy: + return GL_STREAM_COPY; + case BufferUsage::StaticDraw: + return GL_STATIC_DRAW; + case BufferUsage::StaticRead: + return GL_STATIC_READ; + case BufferUsage::StaticCopy: + return GL_STATIC_COPY; + case BufferUsage::DynamicDraw: + return GL_DYNAMIC_DRAW; + case BufferUsage::DynamicRead: + return GL_DYNAMIC_READ; + case BufferUsage::DynamicCopy: + return GL_DYNAMIC_COPY; + default: + return GL_UNKNOWN_MGL; + } + } - GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access) { - GLbitfield result = 0; - if (access & BufferMappingAccessBit::Read) result |= GL_MAP_READ_BIT; - if (access & BufferMappingAccessBit::Write) result |= GL_MAP_WRITE_BIT; - if (access & BufferMappingAccessBit::InvalidateRange) result |= GL_MAP_INVALIDATE_RANGE_BIT; - if (access & BufferMappingAccessBit::InvalidateBuffer) result |= GL_MAP_INVALIDATE_BUFFER_BIT; - if (access & BufferMappingAccessBit::FlushExplicit) result |= GL_MAP_FLUSH_EXPLICIT_BIT; - if (access & BufferMappingAccessBit::Unsynchronized) result |= GL_MAP_UNSYNCHRONIZED_BIT; - if (access & BufferMappingAccessBit::Persistent) result |= GL_MAP_PERSISTENT_BIT; - if (access & BufferMappingAccessBit::Coherent) result |= GL_MAP_COHERENT_BIT; - return result; - } - } -} \ No newline at end of file + GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access) { + GLbitfield result = 0; + if (access & BufferMappingAccessBit::Read) result |= GL_MAP_READ_BIT; + if (access & BufferMappingAccessBit::Write) result |= GL_MAP_WRITE_BIT; + if (access & BufferMappingAccessBit::InvalidateRange) result |= GL_MAP_INVALIDATE_RANGE_BIT; + if (access & BufferMappingAccessBit::InvalidateBuffer) result |= GL_MAP_INVALIDATE_BUFFER_BIT; + if (access & BufferMappingAccessBit::FlushExplicit) result |= GL_MAP_FLUSH_EXPLICIT_BIT; + if (access & BufferMappingAccessBit::Unsynchronized) result |= GL_MAP_UNSYNCHRONIZED_BIT; + if (access & BufferMappingAccessBit::Persistent) result |= GL_MAP_PERSISTENT_BIT; + if (access & BufferMappingAccessBit::Coherent) result |= GL_MAP_COHERENT_BIT; + return result; + } + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.h b/MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.h index 949de48b..1384fc4d 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.h +++ b/MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.h @@ -1,9 +1,11 @@ #pragma once +#include +#include namespace MobileGL { - namespace MG_Util { - GLenum ConvertBufferTargetToGLEnum(BufferTarget bufferTarget); - GLenum ConvertBufferUsageToGLEnum(BufferUsage usage); - GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access); - } -} \ No newline at end of file + namespace MG_Util { + GLenum ConvertBufferTargetToGLEnum(BufferTarget bufferTarget); + GLenum ConvertBufferUsageToGLEnum(BufferUsage usage); + GLbitfield ConvertBufferMappingAccessToGLEnum(BufferMappingAccessBit access); + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.cpp b/MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.cpp index 62b11020..6da34441 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.cpp @@ -1,21 +1,30 @@ -#include "../../../Includes.h" +#include "DataTypeConverter.h" namespace MobileGL { - namespace MG_Util { - GLenum ConvertDataTypeToGLEnum(DataType type) { - switch (type) { - case DataType::Int8: return GL_BYTE; - case DataType::Uint8: return GL_UNSIGNED_BYTE; - case DataType::Int16: return GL_SHORT; - case DataType::Uint16: return GL_UNSIGNED_SHORT; - case DataType::Int32: return GL_INT; - case DataType::Uint32: return GL_UNSIGNED_INT; - case DataType::Float16: return GL_HALF_FLOAT; - case DataType::Float32: return GL_FLOAT; - case DataType::Float64: return GL_DOUBLE; - default: - return GL_UNKNOWN_MGL; - } - } - } -} \ No newline at end of file + namespace MG_Util { + GLenum ConvertDataTypeToGLEnum(DataType type) { + switch (type) { + case DataType::Int8: + return GL_BYTE; + case DataType::Uint8: + return GL_UNSIGNED_BYTE; + case DataType::Int16: + return GL_SHORT; + case DataType::Uint16: + return GL_UNSIGNED_SHORT; + case DataType::Int32: + return GL_INT; + case DataType::Uint32: + return GL_UNSIGNED_INT; + case DataType::Float16: + return GL_HALF_FLOAT; + case DataType::Float32: + return GL_FLOAT; + case DataType::Float64: + return GL_DOUBLE; + default: + return GL_UNKNOWN_MGL; + } + } + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.h b/MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.h index 1fd93600..de2c05be 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.h +++ b/MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.h @@ -1,7 +1,8 @@ #pragma once +#include namespace MobileGL { - namespace MG_Util { - GLenum ConvertDataTypeToGLEnum(DataType type); - } -} \ No newline at end of file + namespace MG_Util { + GLenum ConvertDataTypeToGLEnum(DataType type); + } +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.cpp b/MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.cpp index 19cfed3d..c4ac9d93 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.cpp @@ -1,28 +1,28 @@ -#include "../../../Includes.h" +#include "ErrorCodeConverter.h" namespace MobileGL { - namespace MG_Util { - GLenum ConvertErrorCodeToGLEnum(ErrorCode code) { - switch (code) { - case ErrorCode::NoError: - return GL_NO_ERROR; - case ErrorCode::InvalidEnum: - return GL_INVALID_ENUM; - case ErrorCode::InvalidValue: - return GL_INVALID_VALUE; - case ErrorCode::InvalidOperation: - return GL_INVALID_OPERATION; - case ErrorCode::InvalidFramebufferOperation: - return GL_INVALID_FRAMEBUFFER_OPERATION; - case ErrorCode::OutOfMemory: - return GL_OUT_OF_MEMORY; - case ErrorCode::StackUnderflow: - return GL_STACK_UNDERFLOW; - case ErrorCode::StackOverflow: - return GL_STACK_OVERFLOW; - default: - return GL_NO_ERROR; - } - } - } -} \ No newline at end of file + namespace MG_Util { + GLenum ConvertErrorCodeToGLEnum(ErrorCode code) { + switch (code) { + case ErrorCode::NoError: + return GL_NO_ERROR; + case ErrorCode::InvalidEnum: + return GL_INVALID_ENUM; + case ErrorCode::InvalidValue: + return GL_INVALID_VALUE; + case ErrorCode::InvalidOperation: + return GL_INVALID_OPERATION; + case ErrorCode::InvalidFramebufferOperation: + return GL_INVALID_FRAMEBUFFER_OPERATION; + case ErrorCode::OutOfMemory: + return GL_OUT_OF_MEMORY; + case ErrorCode::StackUnderflow: + return GL_STACK_UNDERFLOW; + case ErrorCode::StackOverflow: + return GL_STACK_OVERFLOW; + default: + return GL_NO_ERROR; + } + } + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.h b/MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.h index 59aee290..aa30f034 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.h +++ b/MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.h @@ -1,7 +1,9 @@ #pragma once +#include +#include namespace MobileGL { - namespace MG_Util { - GLenum ConvertErrorCodeToGLEnum(ErrorCode code); - } -} \ No newline at end of file + namespace MG_Util { + GLenum ConvertErrorCodeToGLEnum(ErrorCode code); + } +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.cpp b/MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.cpp index f9833df2..da5ea280 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.cpp @@ -1,57 +1,82 @@ -#include "../../../Includes.h" +#include "BufferEnumConverter.h" namespace MobileGL { - namespace MG_Util { - String ConvertBufferTargetToString(BufferTarget bufferTarget) { - switch (bufferTarget) { - case BufferTarget::Vertex: return "Vertex"; - case BufferTarget::Index: return "Index"; - case BufferTarget::Uniform: return "Uniform"; - case BufferTarget::CopyRead: return "CopyRead"; - case BufferTarget::CopyWrite: return "CopyWrite"; - case BufferTarget::PixelPack: return "PixelPack"; - case BufferTarget::PixelUnpack: return "PixelUnpack"; - case BufferTarget::Query: return "Query"; - case BufferTarget::Texture: return "Texture"; - case BufferTarget::TransformFeedback: return "TransformFeedback"; - case BufferTarget::AtomicCounter: return "AtomicCounter"; - case BufferTarget::DispatchIndirect: return "DispatchIndirect"; - case BufferTarget::DrawIndirect: return "DrawIndirect"; - case BufferTarget::ShaderStorage: return "ShaderStorage"; - case BufferTarget::Unknown: - default: return "Unknown"; - } - } + namespace MG_Util { + String ConvertBufferTargetToString(BufferTarget bufferTarget) { + switch (bufferTarget) { + case BufferTarget::Vertex: + return "Vertex"; + case BufferTarget::Index: + return "Index"; + case BufferTarget::Uniform: + return "Uniform"; + case BufferTarget::CopyRead: + return "CopyRead"; + case BufferTarget::CopyWrite: + return "CopyWrite"; + case BufferTarget::PixelPack: + return "PixelPack"; + case BufferTarget::PixelUnpack: + return "PixelUnpack"; + case BufferTarget::Query: + return "Query"; + case BufferTarget::Texture: + return "Texture"; + case BufferTarget::TransformFeedback: + return "TransformFeedback"; + case BufferTarget::AtomicCounter: + return "AtomicCounter"; + case BufferTarget::DispatchIndirect: + return "DispatchIndirect"; + case BufferTarget::DrawIndirect: + return "DrawIndirect"; + case BufferTarget::ShaderStorage: + return "ShaderStorage"; + case BufferTarget::Unknown: + default: + return "Unknown"; + } + } - String ConvertBufferUsageToString(BufferUsage usage) { - switch (usage) { - case BufferUsage::StreamDraw: return "StreamDraw"; - case BufferUsage::StreamRead: return "StreamRead"; - case BufferUsage::StreamCopy: return "StreamCopy"; - case BufferUsage::StaticDraw: return "StaticDraw"; - case BufferUsage::StaticRead: return "StaticRead"; - case BufferUsage::StaticCopy: return "StaticCopy"; - case BufferUsage::DynamicDraw: return "DynamicDraw"; - case BufferUsage::DynamicRead: return "DynamicRead"; - case BufferUsage::DynamicCopy: return "DynamicCopy"; - default: return "Unknown"; - } - } + String ConvertBufferUsageToString(BufferUsage usage) { + switch (usage) { + case BufferUsage::StreamDraw: + return "StreamDraw"; + case BufferUsage::StreamRead: + return "StreamRead"; + case BufferUsage::StreamCopy: + return "StreamCopy"; + case BufferUsage::StaticDraw: + return "StaticDraw"; + case BufferUsage::StaticRead: + return "StaticRead"; + case BufferUsage::StaticCopy: + return "StaticCopy"; + case BufferUsage::DynamicDraw: + return "DynamicDraw"; + case BufferUsage::DynamicRead: + return "DynamicRead"; + case BufferUsage::DynamicCopy: + return "DynamicCopy"; + default: + return "Unknown"; + } + } - String ConvertBufferMappingAccessToString(Flags access) { - String result = "["; - if (access & BufferMappingAccessBit::Read) result += "Read, "; - if (access & BufferMappingAccessBit::Write) result += "Write, "; - if (access & BufferMappingAccessBit::InvalidateRange) result += "InvalidateRange, "; - if (access & BufferMappingAccessBit::InvalidateBuffer) result += "InvalidateBuffer, "; - if (access & BufferMappingAccessBit::FlushExplicit) result += "FlushExplicit, "; - if (access & BufferMappingAccessBit::Unsynchronized) result += "Unsynchronized, "; - if (access & BufferMappingAccessBit::Persistent) result += "Persistent, "; - if (access & BufferMappingAccessBit::Coherent) result += "Coherent, "; - result.pop_back(); - result.pop_back(); - result += "]"; - return result.empty() ? "[]" : result; - } - } -} \ No newline at end of file + String ConvertBufferMappingAccessToString(Flags access) { + String result = "["; + if (access & BufferMappingAccessBit::Read) result += "Read, "; + if (access & BufferMappingAccessBit::Write) result += "Write, "; + if (access & BufferMappingAccessBit::InvalidateRange) result += "InvalidateRange, "; + if (access & BufferMappingAccessBit::InvalidateBuffer) result += "InvalidateBuffer, "; + if (access & BufferMappingAccessBit::FlushExplicit) result += "FlushExplicit, "; + if (access & BufferMappingAccessBit::Unsynchronized) result += "Unsynchronized, "; + if (access & BufferMappingAccessBit::Persistent) result += "Persistent, "; + if (access & BufferMappingAccessBit::Coherent) result += "Coherent, "; + result.pop_back(); + result.pop_back(); + result += "]"; + return result.empty() ? "[]" : result; + } + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.h b/MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.h index c14d4b1d..8eec6630 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.h +++ b/MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.h @@ -1,9 +1,11 @@ #pragma once +#include +#include namespace MobileGL { - namespace MG_Util { - String ConvertBufferTargetToString(BufferTarget bufferTarget); - String ConvertBufferUsageToString(BufferUsage usage); - String ConvertBufferMappingAccessToString(Flags access); - } -} \ No newline at end of file + namespace MG_Util { + String ConvertBufferTargetToString(BufferTarget bufferTarget); + String ConvertBufferUsageToString(BufferUsage usage); + String ConvertBufferMappingAccessToString(Flags access); + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.cpp b/MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.cpp index 120908b9..8da9b607 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.cpp @@ -1,22 +1,33 @@ -#include "../../../Includes.h" +#include "DataTypeConverter.h" namespace MobileGL { - namespace MG_Util { - String ConvertDataTypeToString(DataType type) { - switch (type) { - case DataType::Int8: return "Int8"; - case DataType::Uint8: return "Uint8"; - case DataType::Int16: return "Int16"; - case DataType::Uint16: return "Uint16"; - case DataType::Int32: return "Int32"; - case DataType::Uint32: return "Uint32"; - case DataType::Float16: return "Float16"; - case DataType::Float32: return "Float32"; - case DataType::Float64: return "Float64"; - case DataType::Fixed32: return "Fixed32"; - case DataType::Unknown: - default: return "Unknown"; - } - } - } -} \ No newline at end of file + namespace MG_Util { + String ConvertDataTypeToString(DataType type) { + switch (type) { + case DataType::Int8: + return "Int8"; + case DataType::Uint8: + return "Uint8"; + case DataType::Int16: + return "Int16"; + case DataType::Uint16: + return "Uint16"; + case DataType::Int32: + return "Int32"; + case DataType::Uint32: + return "Uint32"; + case DataType::Float16: + return "Float16"; + case DataType::Float32: + return "Float32"; + case DataType::Float64: + return "Float64"; + case DataType::Fixed32: + return "Fixed32"; + case DataType::Unknown: + default: + return "Unknown"; + } + } + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.h b/MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.h index c720dab3..9d1f64e9 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.h +++ b/MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.h @@ -1,7 +1,8 @@ #pragma once +#include namespace MobileGL { - namespace MG_Util { - String ConvertDataTypeToString(DataType type); - } -} \ No newline at end of file + namespace MG_Util { + String ConvertDataTypeToString(DataType type); + } +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.cpp b/MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.cpp index 8c30ab5c..d2f9d664 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.cpp @@ -1,775 +1,778 @@ -#include "../../../Includes.h" +#include "GLExtensionConverter.h" namespace MobileGL { - namespace MG_Util { - String ConvertetGLExtToString(GLExtension extension) { - String str; - switch (extension) { -#define CASE(value) \ - case value: { str = #value; break; } - CASE(V_OpenGL10) - CASE(V_OpenGL11) - CASE(V_OpenGL12) - CASE(V_OpenGL13) - CASE(V_OpenGL14) - CASE(V_OpenGL15) - CASE(V_OpenGL20) - CASE(V_OpenGL21) - CASE(V_OpenGL30) - CASE(V_OpenGL31) - CASE(V_OpenGL32) - CASE(V_OpenGL33) - CASE(V_OpenGL40) - CASE(V_OpenGL41) - CASE(V_OpenGL42) - CASE(V_OpenGL43) - CASE(V_OpenGL44) - CASE(V_OpenGL45) - CASE(V_OpenGL46) - CASE(E_GL_EXT_shader_samples_identical) - CASE(E_GL_ARB_multitexture) - CASE(E_GLX_ARB_get_proc_address) - CASE(E_GL_ARB_transpose_matrix) - CASE(E_WGL_ARB_buffer_region) - CASE(E_GL_ARB_multisample) - CASE(E_GLX_ARB_multisample) - CASE(E_WGL_ARB_multisample) - CASE(E_GL_ARB_texture_env_add) - CASE(E_GL_ARB_texture_cube_map) - CASE(E_WGL_ARB_extensions_string) - CASE(E_WGL_ARB_pixel_format) - CASE(E_WGL_ARB_make_current_read) - CASE(E_WGL_ARB_pbuffer) - CASE(E_GL_ARB_texture_compression) - CASE(E_GL_ARB_texture_border_clamp) - CASE(E_GL_ARB_point_parameters) - CASE(E_GL_ARB_vertex_blend) - CASE(E_GL_ARB_matrix_palette) - CASE(E_GL_ARB_texture_env_combine) - CASE(E_GL_ARB_texture_env_crossbar) - CASE(E_GL_ARB_texture_env_dot3) - CASE(E_WGL_ARB_render_texture) - CASE(E_GL_ARB_texture_mirrored_repeat) - CASE(E_GL_ARB_depth_texture) - CASE(E_GL_ARB_shadow) - CASE(E_GL_ARB_shadow_ambient) - CASE(E_GL_ARB_window_pos) - CASE(E_GL_ARB_vertex_program) - CASE(E_GL_ARB_fragment_program) - CASE(E_GL_ARB_vertex_buffer_object) - CASE(E_GLX_ARB_vertex_buffer_object) - CASE(E_GL_ARB_occlusion_query) - CASE(E_GL_ARB_shader_objects) - CASE(E_GL_ARB_vertex_shader) - CASE(E_GL_ARB_fragment_shader) - CASE(E_GL_ARB_shading_language_100) - CASE(E_GL_ARB_texture_non_power_of_two) - CASE(E_GL_ARB_point_sprite) - CASE(E_GL_ARB_fragment_program_shadow) - CASE(E_GL_ARB_draw_buffers) - CASE(E_GL_ARB_texture_rectangle) - CASE(E_GL_ARB_color_buffer_float) - CASE(E_GLX_ARB_fbconfig_float) - CASE(E_WGL_ARB_pixel_format_float) - CASE(E_GL_ARB_half_float_pixel) - CASE(E_GL_ARB_texture_float) - CASE(E_GL_ARB_pixel_buffer_object) - CASE(E_GL_ARB_depth_buffer_float) - CASE(E_GL_ARB_draw_instanced) - CASE(E_GL_ARB_framebuffer_object) - CASE(E_GL_ARB_framebuffer_sRGB) - CASE(E_GLX_ARB_framebuffer_sRGB) - CASE(E_WGL_ARB_framebuffer_sRGB) - CASE(E_GL_ARB_geometry_shader4) - CASE(E_GL_ARB_half_float_vertex) - CASE(E_GL_ARB_instanced_arrays) - CASE(E_GL_ARB_map_buffer_range) - CASE(E_GL_ARB_texture_buffer_object) - CASE(E_GL_ARB_texture_compression_rgtc) - CASE(E_GL_ARB_texture_rg) - CASE(E_GL_ARB_vertex_array_object) - CASE(E_WGL_ARB_create_context) - CASE(E_GLX_ARB_create_context) - CASE(E_GL_ARB_uniform_buffer_object) - CASE(E_GL_ARB_compatibility) - CASE(E_GL_ARB_copy_buffer) - CASE(E_GL_ARB_shader_texture_lod) - CASE(E_GL_ARB_depth_clamp) - CASE(E_GL_ARB_draw_elements_base_vertex) - CASE(E_GL_ARB_fragment_coord_conventions) - CASE(E_GL_ARB_provoking_vertex) - CASE(E_GL_ARB_seamless_cube_map) - CASE(E_GL_ARB_sync) - CASE(E_GL_ARB_texture_multisample) - CASE(E_GL_ARB_vertex_array_bgra) - CASE(E_GL_ARB_draw_buffers_blend) - CASE(E_GL_ARB_sample_shading) - CASE(E_GL_ARB_texture_cube_map_array) - CASE(E_GL_ARB_texture_gather) - CASE(E_GL_ARB_texture_query_lod) - CASE(E_WGL_ARB_create_context_profile) - CASE(E_GLX_ARB_create_context_profile) - CASE(E_GL_ARB_shading_language_include) - CASE(E_GL_ARB_texture_compression_bptc) - CASE(E_GL_ARB_blend_func_extended) - CASE(E_GL_ARB_explicit_attrib_location) - CASE(E_GL_ARB_occlusion_query2) - CASE(E_GL_ARB_sampler_objects) - CASE(E_GL_ARB_shader_bit_encoding) - CASE(E_GL_ARB_texture_rgb10_a2ui) - CASE(E_GL_ARB_texture_swizzle) - CASE(E_GL_ARB_timer_query) - CASE(E_GL_ARB_vertex_type_2_10_10_10_rev) - CASE(E_GL_ARB_draw_indirect) - CASE(E_GL_ARB_gpu_shader5) - CASE(E_GL_ARB_gpu_shader_fp64) - CASE(E_GL_ARB_shader_subroutine) - CASE(E_GL_ARB_tessellation_shader) - CASE(E_GL_ARB_texture_buffer_object_rgb32) - CASE(E_GL_ARB_transform_feedback2) - CASE(E_GL_ARB_transform_feedback3) - CASE(E_GL_ARB_ES2_compatibility) - CASE(E_GL_ARB_get_program_binary) - CASE(E_GL_ARB_separate_shader_objects) - CASE(E_GL_ARB_shader_precision) - CASE(E_GL_ARB_vertex_attrib_64bit) - CASE(E_GL_ARB_viewport_array) - CASE(E_GLX_ARB_create_context_robustness) - CASE(E_WGL_ARB_create_context_robustness) - CASE(E_GL_ARB_cl_event) - CASE(E_GL_ARB_debug_output) - CASE(E_GL_ARB_robustness) - CASE(E_GL_ARB_shader_stencil_export) - CASE(E_GL_ARB_base_instance) - CASE(E_GL_ARB_shading_language_420pack) - CASE(E_GL_ARB_transform_feedback_instanced) - CASE(E_GL_ARB_compressed_texture_pixel_storage) - CASE(E_GL_ARB_conservative_depth) - CASE(E_GL_ARB_internalformat_query) - CASE(E_GL_ARB_map_buffer_alignment) - CASE(E_GL_ARB_shader_atomic_counters) - CASE(E_GL_ARB_shader_image_load_store) - CASE(E_GL_ARB_shading_language_packing) - CASE(E_GL_ARB_texture_storage) - CASE(E_GL_KHR_texture_compression_astc_hdr) - CASE(E_GL_KHR_texture_compression_astc_ldr) - CASE(E_GL_KHR_debug) - CASE(E_GL_ARB_arrays_of_arrays) - CASE(E_GL_ARB_clear_buffer_object) - CASE(E_GL_ARB_compute_shader) - CASE(E_GL_ARB_copy_image) - CASE(E_GL_ARB_texture_view) - CASE(E_GL_ARB_vertex_attrib_binding) - CASE(E_GL_ARB_robustness_isolation) - CASE(E_GL_ARB_robustness_share_group_isolation) - CASE(E_GL_ARB_ES3_compatibility) - CASE(E_GL_ARB_explicit_uniform_location) - CASE(E_GL_ARB_fragment_layer_viewport) - CASE(E_GL_ARB_framebuffer_no_attachments) - CASE(E_GL_ARB_internalformat_query2) - CASE(E_GL_ARB_invalidate_subdata) - CASE(E_GL_ARB_multi_draw_indirect) - CASE(E_GL_ARB_program_interface_query) - CASE(E_GL_ARB_robust_buffer_access_behavior) - CASE(E_GL_ARB_shader_image_size) - CASE(E_GL_ARB_shader_storage_buffer_object) - CASE(E_GL_ARB_stencil_texturing) - CASE(E_GL_ARB_texture_buffer_range) - CASE(E_GL_ARB_texture_query_levels) - CASE(E_GL_ARB_texture_storage_multisample) - CASE(E_GLX_ARB_robustness_application_isolation) - CASE(E_GLX_ARB_robustness_share_group_isolation) - CASE(E_WGL_ARB_robustness_application_isolation) - CASE(E_WGL_ARB_robustness_share_group_isolation) - CASE(E_GL_ARB_buffer_storage) - CASE(E_GL_ARB_clear_texture) - CASE(E_GL_ARB_enhanced_layouts) - CASE(E_GL_ARB_multi_bind) - CASE(E_GL_ARB_query_buffer_object) - CASE(E_GL_ARB_texture_mirror_clamp_to_edge) - CASE(E_GL_ARB_texture_stencil8) - CASE(E_GL_ARB_vertex_type_10f_11f_11f_rev) - CASE(E_GL_ARB_bindless_texture) - CASE(E_GL_ARB_compute_variable_group_size) - CASE(E_GL_ARB_indirect_parameters) - CASE(E_GL_ARB_seamless_cubemap_per_texture) - CASE(E_GL_ARB_shader_draw_parameters) - CASE(E_GL_ARB_shader_group_vote) - CASE(E_GL_ARB_sparse_texture) - CASE(E_GL_ARB_ES3_1_compatibility) - CASE(E_GL_ARB_clip_control) - CASE(E_GL_ARB_conditional_render_inverted) - CASE(E_GL_ARB_cull_distance) - CASE(E_GL_ARB_derivative_control) - CASE(E_GL_ARB_direct_state_access) - CASE(E_GL_ARB_get_texture_sub_image) - CASE(E_GL_ARB_shader_texture_image_samples) - CASE(E_GL_ARB_texture_barrier) - CASE(E_GL_KHR_context_flush_control) - CASE(E_GLX_ARB_context_flush_control) - CASE(E_WGL_ARB_context_flush_control) - CASE(E_GL_KHR_robust_buffer_access_behavior) - CASE(E_GL_KHR_robustness) - CASE(E_GL_ARB_pipeline_statistics_query) - CASE(E_GL_ARB_sparse_buffer) - CASE(E_GL_ARB_transform_feedback_overflow_query) - CASE(E_GL_KHR_blend_equation_advanced) - CASE(E_GL_KHR_blend_equation_advanced_coherent) - CASE(E_GL_KHR_no_error) - CASE(E_GL_ARB_ES3_2_compatibility) - CASE(E_GL_ARB_fragment_shader_interlock) - CASE(E_GL_ARB_gpu_shader_int64) - CASE(E_GL_ARB_parallel_shader_compile) - CASE(E_GL_ARB_post_depth_coverage) - CASE(E_GL_ARB_sample_locations) - CASE(E_GL_ARB_shader_atomic_counter_ops) - CASE(E_GL_ARB_shader_ballot) - CASE(E_GL_ARB_shader_clock) - CASE(E_GL_ARB_shader_viewport_layer_array) - CASE(E_GL_ARB_sparse_texture2) - CASE(E_GL_ARB_sparse_texture_clamp) - CASE(E_GL_ARB_texture_filter_minmax) - CASE(E_GL_KHR_texture_compression_astc_sliced_3d) - CASE(E_GL_ARB_gl_spirv) - CASE(E_GLX_ARB_create_context_no_error) - CASE(E_WGL_ARB_create_context_no_error) - CASE(E_GL_KHR_parallel_shader_compile) - CASE(E_GL_ARB_polygon_offset_clamp) - CASE(E_GL_ARB_spirv_extensions) - CASE(E_GL_ARB_texture_filter_anisotropic) - CASE(E_GL_KHR_shader_subgroup) - CASE(E_GL_EXT_abgr) - CASE(E_GL_EXT_blend_color) - CASE(E_GL_EXT_polygon_offset) - CASE(E_GL_EXT_texture) - CASE(E_GL_EXT_texture3D) - CASE(E_GL_SGIS_texture_filter4) - CASE(E_GL_EXT_subtexture) - CASE(E_GL_EXT_copy_texture) - CASE(E_GL_EXT_histogram) - CASE(E_GL_EXT_convolution) - CASE(E_GL_SGI_color_matrix) - CASE(E_GL_SGI_color_table) - CASE(E_GL_SGIS_pixel_texture) - CASE(E_GL_SGIS_texture4D) - CASE(E_GL_SGI_texture_color_table) - CASE(E_GL_EXT_cmyka) - CASE(E_GL_EXT_texture_object) - CASE(E_GL_SGIS_detail_texture) - CASE(E_GL_SGIS_sharpen_texture) - CASE(E_GL_EXT_packed_pixels) - CASE(E_GL_SGIS_texture_lod) - CASE(E_GL_SGIS_multisample) - CASE(E_GLX_SGIS_multisample) - CASE(E_GL_EXT_rescale_normal) - CASE(E_GLX_EXT_visual_info) - CASE(E_GL_EXT_vertex_array) - CASE(E_GL_EXT_misc_attribute) - CASE(E_GL_SGIS_generate_mipmap) - CASE(E_GL_SGIX_clipmap) - CASE(E_GL_SGIX_shadow) - CASE(E_GL_SGIS_texture_edge_clamp) - CASE(E_GL_SGIS_texture_border_clamp) - CASE(E_GL_EXT_blend_minmax) - CASE(E_GL_EXT_blend_subtract) - CASE(E_GL_EXT_blend_logic_op) - CASE(E_GLX_SGI_swap_control) - CASE(E_GLX_SGI_video_sync) - CASE(E_GLX_SGI_make_current_read) - CASE(E_GLX_SGIX_video_source) - CASE(E_GLX_EXT_visual_rating) - CASE(E_GL_SGIX_interlace) - CASE(E_GLX_EXT_import_context) - CASE(E_GLX_SGIX_fbconfig) - CASE(E_GLX_SGIX_pbuffer) - CASE(E_GL_SGIS_texture_select) - CASE(E_GL_SGIX_sprite) - CASE(E_GL_SGIX_texture_multi_buffer) - CASE(E_GL_EXT_point_parameters) - CASE(E_GL_SGIX_instruments) - CASE(E_GL_SGIX_texture_scale_bias) - CASE(E_GL_SGIX_framezoom) - CASE(E_GL_SGIX_tag_sample_buffer) - CASE(E_GL_SGIX_reference_plane) - CASE(E_GL_SGIX_flush_raster) - CASE(E_GLX_SGI_cushion) - CASE(E_GL_SGIX_depth_texture) - CASE(E_GL_SGIS_fog_function) - CASE(E_GL_SGIX_fog_offset) - CASE(E_GL_HP_image_transform) - CASE(E_GL_HP_convolution_border_modes) - CASE(E_GL_SGIX_texture_add_env) - CASE(E_GL_EXT_color_subtable) - CASE(E_GLU_EXT_object_space_tess) - CASE(E_GL_PGI_vertex_hints) - CASE(E_GL_PGI_misc_hints) - CASE(E_GL_EXT_paletted_texture) - CASE(E_GL_EXT_clip_volume_hint) - CASE(E_GL_SGIX_list_priority) - CASE(E_GL_SGIX_ir_instrument1) - CASE(E_GLX_SGIX_video_resize) - CASE(E_GL_SGIX_texture_lod_bias) - CASE(E_GLU_SGI_filter4_parameters) - CASE(E_GLX_SGIX_dm_buffer) - CASE(E_GL_SGIX_shadow_ambient) - CASE(E_GLX_SGIX_swap_group) - CASE(E_GLX_SGIX_swap_barrier) - CASE(E_GL_EXT_index_texture) - CASE(E_GL_EXT_index_material) - CASE(E_GL_EXT_index_func) - CASE(E_GL_EXT_index_array_formats) - CASE(E_GL_EXT_compiled_vertex_array) - CASE(E_GL_EXT_cull_vertex) - CASE(E_GLU_EXT_nurbs_tessellator) - CASE(E_GL_SGIX_ycrcb) - CASE(E_GL_EXT_fragment_lighting) - CASE(E_GL_IBM_rasterpos_clip) - CASE(E_GL_HP_texture_lighting) - CASE(E_GL_EXT_draw_range_elements) - CASE(E_GL_WIN_phong_shading) - CASE(E_GL_WIN_specular_fog) - CASE(E_GLX_SGIS_color_range) - CASE(E_GL_SGIS_color_range) - CASE(E_GL_EXT_light_texture) - CASE(E_GL_SGIX_blend_alpha_minmax) - CASE(E_GL_EXT_scene_marker) - CASE(E_GLX_EXT_scene_marker) - CASE(E_GL_SGIX_pixel_texture_bits) - CASE(E_GL_EXT_bgra) - CASE(E_GL_SGIX_async) - CASE(E_GL_SGIX_async_pixel) - CASE(E_GL_SGIX_async_histogram) - CASE(E_GL_INTEL_texture_scissor) - CASE(E_GL_INTEL_parallel_arrays) - CASE(E_GL_HP_occlusion_test) - CASE(E_GL_EXT_pixel_transform) - CASE(E_GL_EXT_pixel_transform_color_table) - CASE(E_GL_EXT_shared_texture_palette) - CASE(E_GLX_SGIS_blended_overlay) - CASE(E_GL_EXT_separate_specular_color) - CASE(E_GL_EXT_secondary_color) - CASE(E_GL_EXT_texture_env) - CASE(E_GL_EXT_texture_perturb_normal) - CASE(E_GL_EXT_multi_draw_arrays) - CASE(E_GL_SUN_multi_draw_arrays) - CASE(E_GL_EXT_fog_coord) - CASE(E_GL_REND_screen_coordinates) - CASE(E_GL_EXT_coordinate_frame) - CASE(E_GL_EXT_texture_env_combine) - CASE(E_GL_APPLE_specular_vector) - CASE(E_GL_APPLE_transform_hint) - CASE(E_GL_SUNX_constant_data) - CASE(E_GL_SUN_global_alpha) - CASE(E_GL_SUN_triangle_list) - CASE(E_GL_SUN_vertex) - CASE(E_WGL_EXT_display_color_table) - CASE(E_WGL_EXT_extensions_string) - CASE(E_WGL_EXT_make_current_read) - CASE(E_WGL_EXT_pixel_format) - CASE(E_WGL_EXT_pbuffer) - CASE(E_WGL_EXT_swap_control) - CASE(E_GL_EXT_blend_func_separate) - CASE(E_GL_INGR_color_clamp) - CASE(E_GL_INGR_interlace_read) - CASE(E_GL_EXT_stencil_wrap) - CASE(E_WGL_EXT_depth_float) - CASE(E_GL_EXT_422_pixels) - CASE(E_GL_NV_texgen_reflection) - CASE(E_GL_SGIX_texture_range) - CASE(E_GL_SUN_convolution_border_modes) - CASE(E_GLX_SUN_get_transparent_index) - CASE(E_GLX_SGIX_video_resize_float) - CASE(E_GL_EXT_texture_env_add) - CASE(E_GL_EXT_texture_lod_bias) - CASE(E_GL_EXT_texture_filter_anisotropic) - CASE(E_GL_EXT_vertex_weighting) - CASE(E_GL_NV_light_max_exponent) - CASE(E_GL_NV_vertex_array_range) - CASE(E_GL_NV_register_combiners) - CASE(E_GL_NV_fog_distance) - CASE(E_GL_NV_texgen_emboss) - CASE(E_GL_NV_blend_square) - CASE(E_GL_NV_texture_env_combine4) - CASE(E_GL_MESA_resize_buffers) - CASE(E_GL_MESA_window_pos) - CASE(E_GL_EXT_texture_compression_s3tc) - CASE(E_GL_IBM_cull_vertex) - CASE(E_GL_IBM_multimode_draw_arrays) - CASE(E_GL_IBM_vertex_array_lists) - CASE(E_GL_3DFX_texture_compression_FXT1) - CASE(E_GL_3DFX_multisample) - CASE(E_GL_3DFX_tbuffer) - CASE(E_WGL_EXT_multisample) - CASE(E_GL_EXT_multisample) - CASE(E_GL_SGIX_vertex_preclip) - CASE(E_GL_SGIX_vertex_preclip_hint) - CASE(E_GL_SGIX_convolution_accuracy) - CASE(E_GL_SGIX_resample) - CASE(E_GL_SGIS_point_line_texgen) - CASE(E_GL_SGIS_texture_color_mask) - CASE(E_GLX_MESA_copy_sub_buffer) - CASE(E_GLX_MESA_pixmap_colormap) - CASE(E_GLX_MESA_release_buffers) - CASE(E_GLX_MESA_set_3dfx_mode) - CASE(E_GL_EXT_texture_env_dot3) - CASE(E_GL_ATI_texture_mirror_once) - CASE(E_GL_NV_fence) - CASE(E_GL_IBM_static_data) - CASE(E_GL_IBM_texture_mirrored_repeat) - CASE(E_GL_NV_evaluators) - CASE(E_GL_NV_packed_depth_stencil) - CASE(E_GL_NV_register_combiners2) - CASE(E_GL_NV_texture_compression_vtc) - CASE(E_GL_NV_texture_rectangle) - CASE(E_GL_NV_texture_shader) - CASE(E_GL_NV_texture_shader2) - CASE(E_GL_NV_vertex_array_range2) - CASE(E_GL_NV_vertex_program) - CASE(E_GLX_SGIX_visual_select_group) - CASE(E_GL_SGIX_texture_coordinate_clamp) - CASE(E_GLX_OML_swap_method) - CASE(E_GLX_OML_sync_control) - CASE(E_GL_OML_interlace) - CASE(E_GL_OML_subsample) - CASE(E_GL_OML_resample) - CASE(E_WGL_OML_sync_control) - CASE(E_GL_NV_copy_depth_to_color) - CASE(E_GL_ATI_envmap_bumpmap) - CASE(E_GL_ATI_fragment_shader) - CASE(E_GL_ATI_pn_triangles) - CASE(E_GL_ATI_vertex_array_object) - CASE(E_GL_EXT_vertex_shader) - CASE(E_GL_ATI_vertex_streams) - CASE(E_WGL_I3D_digital_video_control) - CASE(E_WGL_I3D_gamma) - CASE(E_WGL_I3D_genlock) - CASE(E_WGL_I3D_image_buffer) - CASE(E_WGL_I3D_swap_frame_lock) - CASE(E_WGL_I3D_swap_frame_usage) - CASE(E_GL_ATI_element_array) - CASE(E_GL_SUN_mesh_array) - CASE(E_GL_SUN_slice_accum) - CASE(E_GL_NV_multisample_filter_hint) - CASE(E_GL_NV_depth_clamp) - CASE(E_GL_NV_occlusion_query) - CASE(E_GL_NV_point_sprite) - CASE(E_WGL_NV_render_depth_texture) - CASE(E_WGL_NV_render_texture_rectangle) - CASE(E_GL_NV_texture_shader3) - CASE(E_GL_NV_vertex_program1_1) - CASE(E_GL_EXT_shadow_funcs) - CASE(E_GL_EXT_stencil_two_side) - CASE(E_GL_ATI_text_fragment_shader) - CASE(E_GL_APPLE_client_storage) - CASE(E_GL_APPLE_element_array) - CASE(E_GL_APPLE_fence) - CASE(E_GL_APPLE_vertex_array_object) - CASE(E_GL_APPLE_vertex_array_range) - CASE(E_GL_APPLE_ycbcr_422) - CASE(E_GL_S3_s3tc) - CASE(E_GL_ATI_draw_buffers) - CASE(E_WGL_ATI_pixel_format_float) - CASE(E_GL_ATI_texture_env_combine3) - CASE(E_GL_ATI_texture_float) - CASE(E_GL_NV_float_buffer) - CASE(E_WGL_NV_float_buffer) - CASE(E_GL_NV_fragment_program) - CASE(E_GL_NV_half_float) - CASE(E_GL_NV_pixel_data_range) - CASE(E_GL_NV_primitive_restart) - CASE(E_GL_NV_texture_expand_normal) - CASE(E_GL_NV_vertex_program2) - CASE(E_GL_ATI_map_object_buffer) - CASE(E_GL_ATI_separate_stencil) - CASE(E_GL_ATI_vertex_attrib_array_object) - CASE(E_GL_OES_byte_coordinates) - CASE(E_GL_OES_fixed_point) - CASE(E_GL_OES_single_precision) - CASE(E_GL_OES_compressed_paletted_texture) - CASE(E_GL_OES_read_format) - CASE(E_GL_OES_query_matrix) - CASE(E_GL_EXT_depth_bounds_test) - CASE(E_GL_EXT_texture_mirror_clamp) - CASE(E_GL_EXT_blend_equation_separate) - CASE(E_GL_MESA_pack_invert) - CASE(E_GL_MESA_ycbcr_texture) - CASE(E_GL_EXT_pixel_buffer_object) - CASE(E_GL_NV_fragment_program_option) - CASE(E_GL_NV_fragment_program2) - CASE(E_GL_NV_vertex_program2_option) - CASE(E_GL_NV_vertex_program3) - CASE(E_GLX_SGIX_hyperpipe) - CASE(E_GLX_MESA_agp_offset) - CASE(E_GL_EXT_texture_compression_dxt1) - CASE(E_GL_EXT_framebuffer_object) - CASE(E_GL_GREMEDY_string_marker) - CASE(E_GL_EXT_packed_depth_stencil) - CASE(E_WGL_3DL_stereo_control) - CASE(E_GL_EXT_stencil_clear_tag) - CASE(E_GL_EXT_texture_sRGB) - CASE(E_GL_EXT_framebuffer_blit) - CASE(E_GL_EXT_framebuffer_multisample) - CASE(E_GL_MESAX_texture_stack) - CASE(E_GL_EXT_timer_query) - CASE(E_GL_EXT_gpu_program_parameters) - CASE(E_GL_APPLE_flush_buffer_range) - CASE(E_GL_NV_gpu_program4) - CASE(E_GL_NV_geometry_program4) - CASE(E_GL_EXT_geometry_shader4) - CASE(E_GL_NV_vertex_program4) - CASE(E_GL_EXT_gpu_shader4) - CASE(E_GL_EXT_draw_instanced) - CASE(E_GL_EXT_packed_float) - CASE(E_GLX_EXT_fbconfig_packed_float) - CASE(E_WGL_EXT_pixel_format_packed_float) - CASE(E_GL_EXT_texture_array) - CASE(E_GL_EXT_texture_buffer_object) - CASE(E_GL_EXT_texture_compression_latc) - CASE(E_GL_EXT_texture_compression_rgtc) - CASE(E_GL_EXT_texture_shared_exponent) - CASE(E_GL_NV_depth_buffer_float) - CASE(E_GL_NV_fragment_program4) - CASE(E_GL_NV_framebuffer_multisample_coverage) - CASE(E_GL_EXT_framebuffer_sRGB) - CASE(E_GLX_EXT_framebuffer_sRGB) - CASE(E_WGL_EXT_framebuffer_sRGB) - CASE(E_GL_NV_geometry_shader4) - CASE(E_GL_NV_parameter_buffer_object) - CASE(E_GL_EXT_draw_buffers2) - CASE(E_GL_NV_transform_feedback) - CASE(E_GL_EXT_bindable_uniform) - CASE(E_GL_EXT_texture_integer) - CASE(E_GLX_EXT_texture_from_pixmap) - CASE(E_GL_GREMEDY_frame_terminator) - CASE(E_GL_NV_conditional_render) - CASE(E_GL_NV_present_video) - CASE(E_GLX_NV_present_video) - CASE(E_WGL_NV_present_video) - CASE(E_GLX_NV_video_out) - CASE(E_WGL_NV_video_output) - CASE(E_GLX_NV_swap_group) - CASE(E_WGL_NV_swap_group) - CASE(E_GL_EXT_transform_feedback) - CASE(E_GL_EXT_direct_state_access) - CASE(E_GL_EXT_vertex_array_bgra) - CASE(E_WGL_NV_gpu_affinity) - CASE(E_GL_EXT_texture_swizzle) - CASE(E_GL_NV_explicit_multisample) - CASE(E_GL_NV_transform_feedback2) - CASE(E_GL_ATI_meminfo) - CASE(E_GL_AMD_performance_monitor) - CASE(E_WGL_AMD_gpu_association) - CASE(E_GL_AMD_texture_texture4) - CASE(E_GL_AMD_vertex_shader_tessellator) - CASE(E_GL_EXT_provoking_vertex) - CASE(E_GL_EXT_texture_snorm) - CASE(E_GL_AMD_draw_buffers_blend) - CASE(E_GL_APPLE_texture_range) - CASE(E_GL_APPLE_float_pixels) - CASE(E_GL_APPLE_vertex_program_evaluators) - CASE(E_GL_APPLE_aux_depth_stencil) - CASE(E_GL_APPLE_object_purgeable) - CASE(E_GL_APPLE_row_bytes) - CASE(E_GL_APPLE_rgb_422) - CASE(E_GL_NV_video_capture) - CASE(E_GLX_NV_video_capture) - CASE(E_WGL_NV_video_capture) - CASE(E_GL_EXT_swap_control) - CASE(E_GL_NV_copy_image) - CASE(E_GLX_NV_copy_image) - CASE(E_WGL_NV_copy_image) - CASE(E_GL_EXT_separate_shader_objects) - CASE(E_GL_NV_parameter_buffer_object2) - CASE(E_GL_NV_shader_buffer_load) - CASE(E_GL_NV_vertex_buffer_unified_memory) - CASE(E_GL_NV_texture_barrier) - CASE(E_GL_AMD_shader_stencil_export) - CASE(E_GL_AMD_seamless_cubemap_per_texture) - CASE(E_GLX_INTEL_swap_event) - CASE(E_GL_AMD_conservative_depth) - CASE(E_GL_EXT_shader_image_load_store) - CASE(E_GL_EXT_vertex_attrib_64bit) - CASE(E_GL_NV_gpu_program5) - CASE(E_GL_NV_gpu_shader5) - CASE(E_GL_NV_shader_buffer_store) - CASE(E_GL_NV_tessellation_program5) - CASE(E_GL_NV_vertex_attrib_integer_64bit) - CASE(E_GL_NV_multisample_coverage) - CASE(E_GL_AMD_name_gen_delete) - CASE(E_GL_AMD_debug_output) - CASE(E_GL_NV_vdpau_interop) - CASE(E_GL_AMD_transform_feedback3_lines_triangles) - CASE(E_GLX_AMD_gpu_association) - CASE(E_GLX_EXT_create_context_es2_profile) - CASE(E_GLX_EXT_create_context_es_profile) - CASE(E_WGL_EXT_create_context_es2_profile) - CASE(E_WGL_EXT_create_context_es_profile) - CASE(E_GL_AMD_depth_clamp_separate) - CASE(E_GL_EXT_texture_sRGB_decode) - CASE(E_GL_NV_texture_multisample) - CASE(E_GL_AMD_blend_minmax_factor) - CASE(E_GL_AMD_sample_positions) - CASE(E_GL_EXT_x11_sync_object) - CASE(E_WGL_NV_DX_interop) - CASE(E_GL_AMD_multi_draw_indirect) - CASE(E_GL_EXT_framebuffer_multisample_blit_scaled) - CASE(E_GL_NV_path_rendering) - CASE(E_GL_AMD_pinned_memory) - CASE(E_WGL_NV_DX_interop2) - CASE(E_GL_AMD_stencil_operation_extended) - CASE(E_GLX_EXT_swap_control_tear) - CASE(E_WGL_EXT_swap_control_tear) - CASE(E_GL_AMD_vertex_shader_viewport_index) - CASE(E_GL_AMD_vertex_shader_layer) - CASE(E_GL_NV_bindless_texture) - CASE(E_GL_NV_shader_atomic_float) - CASE(E_GL_AMD_query_buffer_object) - CASE(E_GL_NV_compute_program5) - CASE(E_GL_NV_shader_storage_buffer_object) - CASE(E_GL_NV_shader_atomic_counters) - CASE(E_GL_NV_deep_texture3D) - CASE(E_GL_NVX_conditional_render) - CASE(E_GL_AMD_sparse_texture) - CASE(E_GLX_EXT_buffer_age) - CASE(E_GL_AMD_shader_trinary_minmax) - CASE(E_GL_INTEL_map_texture) - CASE(E_GL_NV_draw_texture) - CASE(E_GL_AMD_interleaved_elements) - CASE(E_GL_NV_bindless_multi_draw_indirect) - CASE(E_GL_NV_blend_equation_advanced) - CASE(E_GL_NV_blend_equation_advanced_coherent) - CASE(E_GL_NV_gpu_program5_mem_extended) - CASE(E_GL_AMD_shader_atomic_counter_ops) - CASE(E_WGL_NV_delay_before_swap) - CASE(E_GL_EXT_shader_integer_mix) - CASE(E_GL_NVX_gpu_memory_info) - CASE(E_GL_EXT_debug_label) - CASE(E_GL_EXT_debug_marker) - CASE(E_GL_INTEL_fragment_shader_ordering) - CASE(E_GL_AMD_occlusion_query_event) - CASE(E_GL_INTEL_performance_query) - CASE(E_GL_AMD_shader_stencil_value_export) - CASE(E_GLX_NV_delay_before_swap) - CASE(E_GLX_MESA_query_renderer) - CASE(E_GL_NV_shader_thread_group) - CASE(E_GL_NV_shader_thread_shuffle) - CASE(E_GL_EXT_shader_image_load_formatted) - CASE(E_GL_AMD_transform_feedback4) - CASE(E_GL_AMD_gpu_shader_int64) - CASE(E_GLX_EXT_stereo_tree) - CASE(E_GL_AMD_gcn_shader) - CASE(E_GL_AMD_framebuffer_sample_positions) - CASE(E_GL_NV_shader_atomic_int64) - CASE(E_GL_NV_bindless_multi_draw_indirect_count) - CASE(E_GLX_NV_copy_buffer) - CASE(E_GL_NV_uniform_buffer_unified_memory) - CASE(E_GL_EXT_polygon_offset_clamp) - CASE(E_GL_EXT_post_depth_coverage) - CASE(E_GL_EXT_raster_multisample) - CASE(E_GL_EXT_sparse_texture2) - CASE(E_GL_EXT_texture_filter_minmax) - CASE(E_GL_NV_conservative_raster) - CASE(E_GL_NV_fill_rectangle) - CASE(E_GL_NV_fragment_coverage_to_color) - CASE(E_GL_NV_fragment_shader_interlock) - CASE(E_GL_NV_framebuffer_mixed_samples) - CASE(E_GL_NV_geometry_shader_passthrough) - CASE(E_GL_NV_path_rendering_shared_edge) - CASE(E_GL_NV_sample_locations) - CASE(E_GL_NV_sample_mask_override_coverage) - CASE(E_GL_NV_shader_atomic_fp16_vector) - CASE(E_GL_NV_internalformat_sample_query) - CASE(E_GL_NV_viewport_array2) - CASE(E_GL_NV_command_list) - CASE(E_GL_OVR_multiview) - CASE(E_GL_OVR_multiview2) - CASE(E_GL_NV_conservative_raster_dilate) - CASE(E_GL_INTEL_framebuffer_CMAA) - CASE(E_GLX_EXT_libglvnd) - CASE(E_GL_NV_viewport_swizzle) - CASE(E_GL_NV_robustness_video_memory_purge) - CASE(E_GL_AMD_shader_explicit_vertex_parameter) - CASE(E_GL_NV_clip_space_w_scaling) - CASE(E_GL_NV_conservative_raster_pre_snap_triangles) - CASE(E_GL_NV_shader_atomic_float64) - CASE(E_GL_NV_stereo_view_rendering) - CASE(E_GL_EXT_window_rectangles) - CASE(E_GL_INTEL_conservative_rasterization) - CASE(E_GL_NVX_blend_equation_advanced_multi_draw_buffers) - CASE(E_GL_NVX_linked_gpu_multicast) - CASE(E_GL_NV_gpu_multicast) - CASE(E_GL_MESA_shader_integer_functions) - CASE(E_GL_AMD_gpu_shader_half_float) - CASE(E_GL_AMD_shader_ballot) - CASE(E_WGL_EXT_colorspace) - CASE(E_GL_SGIX_pixel_texture) - CASE(E_GL_NV_alpha_to_coverage_dither_control) - CASE(E_GL_NV_draw_vulkan_image) - CASE(E_GL_AMD_texture_gather_bias_lod) - CASE(E_GL_EXT_memory_object) - CASE(E_GL_EXT_semaphore) - CASE(E_GL_EXT_memory_object_fd) - CASE(E_GL_EXT_semaphore_fd) - CASE(E_GL_EXT_memory_object_win32) - CASE(E_GL_EXT_semaphore_win32) - CASE(E_GL_EXT_win32_keyed_mutex) - CASE(E_GL_AMD_gpu_shader_int16) - CASE(E_GL_EXT_external_buffer) - CASE(E_GL_NV_texture_rectangle_compressed) - CASE(E_GL_NV_blend_minmax_factor) - CASE(E_GL_NV_query_resource) - CASE(E_GL_NV_query_resource_tag) - CASE(E_GL_AMD_shader_image_load_store_lod) - CASE(E_GLX_MESA_swap_control) - CASE(E_GL_MESA_tile_raster_order) - CASE(E_GL_MESA_program_binary_formats) - CASE(E_GL_NV_conservative_raster_pre_snap) - CASE(E_GL_NV_conservative_raster_underestimation) - CASE(E_GL_AMD_gpu_shader_half_float_fetch) - CASE(E_GL_EXT_shader_framebuffer_fetch) - CASE(E_GL_EXT_shader_framebuffer_fetch_non_coherent) - CASE(E_GL_INTEL_blackhole_render) - CASE(E_GL_EXT_EGL_image_storage) - CASE(E_GL_AMD_framebuffer_multisample_advanced) - CASE(E_GL_NV_memory_attachment) - CASE(E_GL_NV_compute_shader_derivatives) - CASE(E_GL_NV_fragment_shader_barycentric) - CASE(E_GL_NV_mesh_shader) - CASE(E_GL_NV_representative_fragment_test) - CASE(E_GL_NV_scissor_exclusive) - CASE(E_GL_NV_shader_texture_footprint) - CASE(E_GL_NV_shading_rate_image) - CASE(E_WGL_ATI_render_texture_rectangle) - CASE(E_GL_NV_vdpau_interop2) - CASE(E_GL_EXT_texture_sRGB_R8) - CASE(E_GLX_EXT_context_priority) - CASE(E_GL_EXT_multiview_timer_query) - CASE(E_GL_EXT_multiview_texture_multisample) - CASE(E_GL_EXT_multiview_tessellation_geometry_shader) - CASE(E_GL_EXT_texture_shadow_lod) - CASE(E_GL_MESA_framebuffer_flip_y) - CASE(E_GL_NVX_progress_fence) - CASE(E_WGL_NV_multigpu_context) - CASE(E_GL_NVX_gpu_multicast2) - CASE(E_GL_NV_shader_subgroup_partitioned) - CASE(E_GLX_NV_multigpu_context) - CASE(E_GL_EXT_EGL_sync) - CASE(E_GL_INTEL_shader_integer_functions2) - CASE(E_GL_MESA_framebuffer_flip_x) - CASE(E_GL_MESA_framebuffer_swap_xy) - CASE(E_GL_NV_memory_object_sparse) - CASE(E_GL_NV_timeline_semaphore) - CASE(E_GLX_EXT_get_drawable_type) - CASE(E_GLX_EXT_no_config_context) - CASE(E_GL_NV_primitive_shading_rate) - CASE(E_GL_EXT_texture_sRGB_RG8) - CASE(E_GL_EXT_texture_storage) - CASE(E_GL_EXT_framebuffer_blit_layers) - CASE(E_GL_NV_uniform_buffer_std430_layout) - CASE(E_GL_MESA_texture_const_bandwidth) - } - str.erase(0, 2); - return str; - } - } -} \ No newline at end of file + namespace MG_Util { + String ConvertetGLExtToString(GLExtension extension) { + String str; + switch (extension) { +#define CASE(value) \ + case value: { \ + str = #value; \ + break; \ + } + CASE(V_OpenGL10) + CASE(V_OpenGL11) + CASE(V_OpenGL12) + CASE(V_OpenGL13) + CASE(V_OpenGL14) + CASE(V_OpenGL15) + CASE(V_OpenGL20) + CASE(V_OpenGL21) + CASE(V_OpenGL30) + CASE(V_OpenGL31) + CASE(V_OpenGL32) + CASE(V_OpenGL33) + CASE(V_OpenGL40) + CASE(V_OpenGL41) + CASE(V_OpenGL42) + CASE(V_OpenGL43) + CASE(V_OpenGL44) + CASE(V_OpenGL45) + CASE(V_OpenGL46) + CASE(E_GL_EXT_shader_samples_identical) + CASE(E_GL_ARB_multitexture) + CASE(E_GLX_ARB_get_proc_address) + CASE(E_GL_ARB_transpose_matrix) + CASE(E_WGL_ARB_buffer_region) + CASE(E_GL_ARB_multisample) + CASE(E_GLX_ARB_multisample) + CASE(E_WGL_ARB_multisample) + CASE(E_GL_ARB_texture_env_add) + CASE(E_GL_ARB_texture_cube_map) + CASE(E_WGL_ARB_extensions_string) + CASE(E_WGL_ARB_pixel_format) + CASE(E_WGL_ARB_make_current_read) + CASE(E_WGL_ARB_pbuffer) + CASE(E_GL_ARB_texture_compression) + CASE(E_GL_ARB_texture_border_clamp) + CASE(E_GL_ARB_point_parameters) + CASE(E_GL_ARB_vertex_blend) + CASE(E_GL_ARB_matrix_palette) + CASE(E_GL_ARB_texture_env_combine) + CASE(E_GL_ARB_texture_env_crossbar) + CASE(E_GL_ARB_texture_env_dot3) + CASE(E_WGL_ARB_render_texture) + CASE(E_GL_ARB_texture_mirrored_repeat) + CASE(E_GL_ARB_depth_texture) + CASE(E_GL_ARB_shadow) + CASE(E_GL_ARB_shadow_ambient) + CASE(E_GL_ARB_window_pos) + CASE(E_GL_ARB_vertex_program) + CASE(E_GL_ARB_fragment_program) + CASE(E_GL_ARB_vertex_buffer_object) + CASE(E_GLX_ARB_vertex_buffer_object) + CASE(E_GL_ARB_occlusion_query) + CASE(E_GL_ARB_shader_objects) + CASE(E_GL_ARB_vertex_shader) + CASE(E_GL_ARB_fragment_shader) + CASE(E_GL_ARB_shading_language_100) + CASE(E_GL_ARB_texture_non_power_of_two) + CASE(E_GL_ARB_point_sprite) + CASE(E_GL_ARB_fragment_program_shadow) + CASE(E_GL_ARB_draw_buffers) + CASE(E_GL_ARB_texture_rectangle) + CASE(E_GL_ARB_color_buffer_float) + CASE(E_GLX_ARB_fbconfig_float) + CASE(E_WGL_ARB_pixel_format_float) + CASE(E_GL_ARB_half_float_pixel) + CASE(E_GL_ARB_texture_float) + CASE(E_GL_ARB_pixel_buffer_object) + CASE(E_GL_ARB_depth_buffer_float) + CASE(E_GL_ARB_draw_instanced) + CASE(E_GL_ARB_framebuffer_object) + CASE(E_GL_ARB_framebuffer_sRGB) + CASE(E_GLX_ARB_framebuffer_sRGB) + CASE(E_WGL_ARB_framebuffer_sRGB) + CASE(E_GL_ARB_geometry_shader4) + CASE(E_GL_ARB_half_float_vertex) + CASE(E_GL_ARB_instanced_arrays) + CASE(E_GL_ARB_map_buffer_range) + CASE(E_GL_ARB_texture_buffer_object) + CASE(E_GL_ARB_texture_compression_rgtc) + CASE(E_GL_ARB_texture_rg) + CASE(E_GL_ARB_vertex_array_object) + CASE(E_WGL_ARB_create_context) + CASE(E_GLX_ARB_create_context) + CASE(E_GL_ARB_uniform_buffer_object) + CASE(E_GL_ARB_compatibility) + CASE(E_GL_ARB_copy_buffer) + CASE(E_GL_ARB_shader_texture_lod) + CASE(E_GL_ARB_depth_clamp) + CASE(E_GL_ARB_draw_elements_base_vertex) + CASE(E_GL_ARB_fragment_coord_conventions) + CASE(E_GL_ARB_provoking_vertex) + CASE(E_GL_ARB_seamless_cube_map) + CASE(E_GL_ARB_sync) + CASE(E_GL_ARB_texture_multisample) + CASE(E_GL_ARB_vertex_array_bgra) + CASE(E_GL_ARB_draw_buffers_blend) + CASE(E_GL_ARB_sample_shading) + CASE(E_GL_ARB_texture_cube_map_array) + CASE(E_GL_ARB_texture_gather) + CASE(E_GL_ARB_texture_query_lod) + CASE(E_WGL_ARB_create_context_profile) + CASE(E_GLX_ARB_create_context_profile) + CASE(E_GL_ARB_shading_language_include) + CASE(E_GL_ARB_texture_compression_bptc) + CASE(E_GL_ARB_blend_func_extended) + CASE(E_GL_ARB_explicit_attrib_location) + CASE(E_GL_ARB_occlusion_query2) + CASE(E_GL_ARB_sampler_objects) + CASE(E_GL_ARB_shader_bit_encoding) + CASE(E_GL_ARB_texture_rgb10_a2ui) + CASE(E_GL_ARB_texture_swizzle) + CASE(E_GL_ARB_timer_query) + CASE(E_GL_ARB_vertex_type_2_10_10_10_rev) + CASE(E_GL_ARB_draw_indirect) + CASE(E_GL_ARB_gpu_shader5) + CASE(E_GL_ARB_gpu_shader_fp64) + CASE(E_GL_ARB_shader_subroutine) + CASE(E_GL_ARB_tessellation_shader) + CASE(E_GL_ARB_texture_buffer_object_rgb32) + CASE(E_GL_ARB_transform_feedback2) + CASE(E_GL_ARB_transform_feedback3) + CASE(E_GL_ARB_ES2_compatibility) + CASE(E_GL_ARB_get_program_binary) + CASE(E_GL_ARB_separate_shader_objects) + CASE(E_GL_ARB_shader_precision) + CASE(E_GL_ARB_vertex_attrib_64bit) + CASE(E_GL_ARB_viewport_array) + CASE(E_GLX_ARB_create_context_robustness) + CASE(E_WGL_ARB_create_context_robustness) + CASE(E_GL_ARB_cl_event) + CASE(E_GL_ARB_debug_output) + CASE(E_GL_ARB_robustness) + CASE(E_GL_ARB_shader_stencil_export) + CASE(E_GL_ARB_base_instance) + CASE(E_GL_ARB_shading_language_420pack) + CASE(E_GL_ARB_transform_feedback_instanced) + CASE(E_GL_ARB_compressed_texture_pixel_storage) + CASE(E_GL_ARB_conservative_depth) + CASE(E_GL_ARB_internalformat_query) + CASE(E_GL_ARB_map_buffer_alignment) + CASE(E_GL_ARB_shader_atomic_counters) + CASE(E_GL_ARB_shader_image_load_store) + CASE(E_GL_ARB_shading_language_packing) + CASE(E_GL_ARB_texture_storage) + CASE(E_GL_KHR_texture_compression_astc_hdr) + CASE(E_GL_KHR_texture_compression_astc_ldr) + CASE(E_GL_KHR_debug) + CASE(E_GL_ARB_arrays_of_arrays) + CASE(E_GL_ARB_clear_buffer_object) + CASE(E_GL_ARB_compute_shader) + CASE(E_GL_ARB_copy_image) + CASE(E_GL_ARB_texture_view) + CASE(E_GL_ARB_vertex_attrib_binding) + CASE(E_GL_ARB_robustness_isolation) + CASE(E_GL_ARB_robustness_share_group_isolation) + CASE(E_GL_ARB_ES3_compatibility) + CASE(E_GL_ARB_explicit_uniform_location) + CASE(E_GL_ARB_fragment_layer_viewport) + CASE(E_GL_ARB_framebuffer_no_attachments) + CASE(E_GL_ARB_internalformat_query2) + CASE(E_GL_ARB_invalidate_subdata) + CASE(E_GL_ARB_multi_draw_indirect) + CASE(E_GL_ARB_program_interface_query) + CASE(E_GL_ARB_robust_buffer_access_behavior) + CASE(E_GL_ARB_shader_image_size) + CASE(E_GL_ARB_shader_storage_buffer_object) + CASE(E_GL_ARB_stencil_texturing) + CASE(E_GL_ARB_texture_buffer_range) + CASE(E_GL_ARB_texture_query_levels) + CASE(E_GL_ARB_texture_storage_multisample) + CASE(E_GLX_ARB_robustness_application_isolation) + CASE(E_GLX_ARB_robustness_share_group_isolation) + CASE(E_WGL_ARB_robustness_application_isolation) + CASE(E_WGL_ARB_robustness_share_group_isolation) + CASE(E_GL_ARB_buffer_storage) + CASE(E_GL_ARB_clear_texture) + CASE(E_GL_ARB_enhanced_layouts) + CASE(E_GL_ARB_multi_bind) + CASE(E_GL_ARB_query_buffer_object) + CASE(E_GL_ARB_texture_mirror_clamp_to_edge) + CASE(E_GL_ARB_texture_stencil8) + CASE(E_GL_ARB_vertex_type_10f_11f_11f_rev) + CASE(E_GL_ARB_bindless_texture) + CASE(E_GL_ARB_compute_variable_group_size) + CASE(E_GL_ARB_indirect_parameters) + CASE(E_GL_ARB_seamless_cubemap_per_texture) + CASE(E_GL_ARB_shader_draw_parameters) + CASE(E_GL_ARB_shader_group_vote) + CASE(E_GL_ARB_sparse_texture) + CASE(E_GL_ARB_ES3_1_compatibility) + CASE(E_GL_ARB_clip_control) + CASE(E_GL_ARB_conditional_render_inverted) + CASE(E_GL_ARB_cull_distance) + CASE(E_GL_ARB_derivative_control) + CASE(E_GL_ARB_direct_state_access) + CASE(E_GL_ARB_get_texture_sub_image) + CASE(E_GL_ARB_shader_texture_image_samples) + CASE(E_GL_ARB_texture_barrier) + CASE(E_GL_KHR_context_flush_control) + CASE(E_GLX_ARB_context_flush_control) + CASE(E_WGL_ARB_context_flush_control) + CASE(E_GL_KHR_robust_buffer_access_behavior) + CASE(E_GL_KHR_robustness) + CASE(E_GL_ARB_pipeline_statistics_query) + CASE(E_GL_ARB_sparse_buffer) + CASE(E_GL_ARB_transform_feedback_overflow_query) + CASE(E_GL_KHR_blend_equation_advanced) + CASE(E_GL_KHR_blend_equation_advanced_coherent) + CASE(E_GL_KHR_no_error) + CASE(E_GL_ARB_ES3_2_compatibility) + CASE(E_GL_ARB_fragment_shader_interlock) + CASE(E_GL_ARB_gpu_shader_int64) + CASE(E_GL_ARB_parallel_shader_compile) + CASE(E_GL_ARB_post_depth_coverage) + CASE(E_GL_ARB_sample_locations) + CASE(E_GL_ARB_shader_atomic_counter_ops) + CASE(E_GL_ARB_shader_ballot) + CASE(E_GL_ARB_shader_clock) + CASE(E_GL_ARB_shader_viewport_layer_array) + CASE(E_GL_ARB_sparse_texture2) + CASE(E_GL_ARB_sparse_texture_clamp) + CASE(E_GL_ARB_texture_filter_minmax) + CASE(E_GL_KHR_texture_compression_astc_sliced_3d) + CASE(E_GL_ARB_gl_spirv) + CASE(E_GLX_ARB_create_context_no_error) + CASE(E_WGL_ARB_create_context_no_error) + CASE(E_GL_KHR_parallel_shader_compile) + CASE(E_GL_ARB_polygon_offset_clamp) + CASE(E_GL_ARB_spirv_extensions) + CASE(E_GL_ARB_texture_filter_anisotropic) + CASE(E_GL_KHR_shader_subgroup) + CASE(E_GL_EXT_abgr) + CASE(E_GL_EXT_blend_color) + CASE(E_GL_EXT_polygon_offset) + CASE(E_GL_EXT_texture) + CASE(E_GL_EXT_texture3D) + CASE(E_GL_SGIS_texture_filter4) + CASE(E_GL_EXT_subtexture) + CASE(E_GL_EXT_copy_texture) + CASE(E_GL_EXT_histogram) + CASE(E_GL_EXT_convolution) + CASE(E_GL_SGI_color_matrix) + CASE(E_GL_SGI_color_table) + CASE(E_GL_SGIS_pixel_texture) + CASE(E_GL_SGIS_texture4D) + CASE(E_GL_SGI_texture_color_table) + CASE(E_GL_EXT_cmyka) + CASE(E_GL_EXT_texture_object) + CASE(E_GL_SGIS_detail_texture) + CASE(E_GL_SGIS_sharpen_texture) + CASE(E_GL_EXT_packed_pixels) + CASE(E_GL_SGIS_texture_lod) + CASE(E_GL_SGIS_multisample) + CASE(E_GLX_SGIS_multisample) + CASE(E_GL_EXT_rescale_normal) + CASE(E_GLX_EXT_visual_info) + CASE(E_GL_EXT_vertex_array) + CASE(E_GL_EXT_misc_attribute) + CASE(E_GL_SGIS_generate_mipmap) + CASE(E_GL_SGIX_clipmap) + CASE(E_GL_SGIX_shadow) + CASE(E_GL_SGIS_texture_edge_clamp) + CASE(E_GL_SGIS_texture_border_clamp) + CASE(E_GL_EXT_blend_minmax) + CASE(E_GL_EXT_blend_subtract) + CASE(E_GL_EXT_blend_logic_op) + CASE(E_GLX_SGI_swap_control) + CASE(E_GLX_SGI_video_sync) + CASE(E_GLX_SGI_make_current_read) + CASE(E_GLX_SGIX_video_source) + CASE(E_GLX_EXT_visual_rating) + CASE(E_GL_SGIX_interlace) + CASE(E_GLX_EXT_import_context) + CASE(E_GLX_SGIX_fbconfig) + CASE(E_GLX_SGIX_pbuffer) + CASE(E_GL_SGIS_texture_select) + CASE(E_GL_SGIX_sprite) + CASE(E_GL_SGIX_texture_multi_buffer) + CASE(E_GL_EXT_point_parameters) + CASE(E_GL_SGIX_instruments) + CASE(E_GL_SGIX_texture_scale_bias) + CASE(E_GL_SGIX_framezoom) + CASE(E_GL_SGIX_tag_sample_buffer) + CASE(E_GL_SGIX_reference_plane) + CASE(E_GL_SGIX_flush_raster) + CASE(E_GLX_SGI_cushion) + CASE(E_GL_SGIX_depth_texture) + CASE(E_GL_SGIS_fog_function) + CASE(E_GL_SGIX_fog_offset) + CASE(E_GL_HP_image_transform) + CASE(E_GL_HP_convolution_border_modes) + CASE(E_GL_SGIX_texture_add_env) + CASE(E_GL_EXT_color_subtable) + CASE(E_GLU_EXT_object_space_tess) + CASE(E_GL_PGI_vertex_hints) + CASE(E_GL_PGI_misc_hints) + CASE(E_GL_EXT_paletted_texture) + CASE(E_GL_EXT_clip_volume_hint) + CASE(E_GL_SGIX_list_priority) + CASE(E_GL_SGIX_ir_instrument1) + CASE(E_GLX_SGIX_video_resize) + CASE(E_GL_SGIX_texture_lod_bias) + CASE(E_GLU_SGI_filter4_parameters) + CASE(E_GLX_SGIX_dm_buffer) + CASE(E_GL_SGIX_shadow_ambient) + CASE(E_GLX_SGIX_swap_group) + CASE(E_GLX_SGIX_swap_barrier) + CASE(E_GL_EXT_index_texture) + CASE(E_GL_EXT_index_material) + CASE(E_GL_EXT_index_func) + CASE(E_GL_EXT_index_array_formats) + CASE(E_GL_EXT_compiled_vertex_array) + CASE(E_GL_EXT_cull_vertex) + CASE(E_GLU_EXT_nurbs_tessellator) + CASE(E_GL_SGIX_ycrcb) + CASE(E_GL_EXT_fragment_lighting) + CASE(E_GL_IBM_rasterpos_clip) + CASE(E_GL_HP_texture_lighting) + CASE(E_GL_EXT_draw_range_elements) + CASE(E_GL_WIN_phong_shading) + CASE(E_GL_WIN_specular_fog) + CASE(E_GLX_SGIS_color_range) + CASE(E_GL_SGIS_color_range) + CASE(E_GL_EXT_light_texture) + CASE(E_GL_SGIX_blend_alpha_minmax) + CASE(E_GL_EXT_scene_marker) + CASE(E_GLX_EXT_scene_marker) + CASE(E_GL_SGIX_pixel_texture_bits) + CASE(E_GL_EXT_bgra) + CASE(E_GL_SGIX_async) + CASE(E_GL_SGIX_async_pixel) + CASE(E_GL_SGIX_async_histogram) + CASE(E_GL_INTEL_texture_scissor) + CASE(E_GL_INTEL_parallel_arrays) + CASE(E_GL_HP_occlusion_test) + CASE(E_GL_EXT_pixel_transform) + CASE(E_GL_EXT_pixel_transform_color_table) + CASE(E_GL_EXT_shared_texture_palette) + CASE(E_GLX_SGIS_blended_overlay) + CASE(E_GL_EXT_separate_specular_color) + CASE(E_GL_EXT_secondary_color) + CASE(E_GL_EXT_texture_env) + CASE(E_GL_EXT_texture_perturb_normal) + CASE(E_GL_EXT_multi_draw_arrays) + CASE(E_GL_SUN_multi_draw_arrays) + CASE(E_GL_EXT_fog_coord) + CASE(E_GL_REND_screen_coordinates) + CASE(E_GL_EXT_coordinate_frame) + CASE(E_GL_EXT_texture_env_combine) + CASE(E_GL_APPLE_specular_vector) + CASE(E_GL_APPLE_transform_hint) + CASE(E_GL_SUNX_constant_data) + CASE(E_GL_SUN_global_alpha) + CASE(E_GL_SUN_triangle_list) + CASE(E_GL_SUN_vertex) + CASE(E_WGL_EXT_display_color_table) + CASE(E_WGL_EXT_extensions_string) + CASE(E_WGL_EXT_make_current_read) + CASE(E_WGL_EXT_pixel_format) + CASE(E_WGL_EXT_pbuffer) + CASE(E_WGL_EXT_swap_control) + CASE(E_GL_EXT_blend_func_separate) + CASE(E_GL_INGR_color_clamp) + CASE(E_GL_INGR_interlace_read) + CASE(E_GL_EXT_stencil_wrap) + CASE(E_WGL_EXT_depth_float) + CASE(E_GL_EXT_422_pixels) + CASE(E_GL_NV_texgen_reflection) + CASE(E_GL_SGIX_texture_range) + CASE(E_GL_SUN_convolution_border_modes) + CASE(E_GLX_SUN_get_transparent_index) + CASE(E_GLX_SGIX_video_resize_float) + CASE(E_GL_EXT_texture_env_add) + CASE(E_GL_EXT_texture_lod_bias) + CASE(E_GL_EXT_texture_filter_anisotropic) + CASE(E_GL_EXT_vertex_weighting) + CASE(E_GL_NV_light_max_exponent) + CASE(E_GL_NV_vertex_array_range) + CASE(E_GL_NV_register_combiners) + CASE(E_GL_NV_fog_distance) + CASE(E_GL_NV_texgen_emboss) + CASE(E_GL_NV_blend_square) + CASE(E_GL_NV_texture_env_combine4) + CASE(E_GL_MESA_resize_buffers) + CASE(E_GL_MESA_window_pos) + CASE(E_GL_EXT_texture_compression_s3tc) + CASE(E_GL_IBM_cull_vertex) + CASE(E_GL_IBM_multimode_draw_arrays) + CASE(E_GL_IBM_vertex_array_lists) + CASE(E_GL_3DFX_texture_compression_FXT1) + CASE(E_GL_3DFX_multisample) + CASE(E_GL_3DFX_tbuffer) + CASE(E_WGL_EXT_multisample) + CASE(E_GL_EXT_multisample) + CASE(E_GL_SGIX_vertex_preclip) + CASE(E_GL_SGIX_vertex_preclip_hint) + CASE(E_GL_SGIX_convolution_accuracy) + CASE(E_GL_SGIX_resample) + CASE(E_GL_SGIS_point_line_texgen) + CASE(E_GL_SGIS_texture_color_mask) + CASE(E_GLX_MESA_copy_sub_buffer) + CASE(E_GLX_MESA_pixmap_colormap) + CASE(E_GLX_MESA_release_buffers) + CASE(E_GLX_MESA_set_3dfx_mode) + CASE(E_GL_EXT_texture_env_dot3) + CASE(E_GL_ATI_texture_mirror_once) + CASE(E_GL_NV_fence) + CASE(E_GL_IBM_static_data) + CASE(E_GL_IBM_texture_mirrored_repeat) + CASE(E_GL_NV_evaluators) + CASE(E_GL_NV_packed_depth_stencil) + CASE(E_GL_NV_register_combiners2) + CASE(E_GL_NV_texture_compression_vtc) + CASE(E_GL_NV_texture_rectangle) + CASE(E_GL_NV_texture_shader) + CASE(E_GL_NV_texture_shader2) + CASE(E_GL_NV_vertex_array_range2) + CASE(E_GL_NV_vertex_program) + CASE(E_GLX_SGIX_visual_select_group) + CASE(E_GL_SGIX_texture_coordinate_clamp) + CASE(E_GLX_OML_swap_method) + CASE(E_GLX_OML_sync_control) + CASE(E_GL_OML_interlace) + CASE(E_GL_OML_subsample) + CASE(E_GL_OML_resample) + CASE(E_WGL_OML_sync_control) + CASE(E_GL_NV_copy_depth_to_color) + CASE(E_GL_ATI_envmap_bumpmap) + CASE(E_GL_ATI_fragment_shader) + CASE(E_GL_ATI_pn_triangles) + CASE(E_GL_ATI_vertex_array_object) + CASE(E_GL_EXT_vertex_shader) + CASE(E_GL_ATI_vertex_streams) + CASE(E_WGL_I3D_digital_video_control) + CASE(E_WGL_I3D_gamma) + CASE(E_WGL_I3D_genlock) + CASE(E_WGL_I3D_image_buffer) + CASE(E_WGL_I3D_swap_frame_lock) + CASE(E_WGL_I3D_swap_frame_usage) + CASE(E_GL_ATI_element_array) + CASE(E_GL_SUN_mesh_array) + CASE(E_GL_SUN_slice_accum) + CASE(E_GL_NV_multisample_filter_hint) + CASE(E_GL_NV_depth_clamp) + CASE(E_GL_NV_occlusion_query) + CASE(E_GL_NV_point_sprite) + CASE(E_WGL_NV_render_depth_texture) + CASE(E_WGL_NV_render_texture_rectangle) + CASE(E_GL_NV_texture_shader3) + CASE(E_GL_NV_vertex_program1_1) + CASE(E_GL_EXT_shadow_funcs) + CASE(E_GL_EXT_stencil_two_side) + CASE(E_GL_ATI_text_fragment_shader) + CASE(E_GL_APPLE_client_storage) + CASE(E_GL_APPLE_element_array) + CASE(E_GL_APPLE_fence) + CASE(E_GL_APPLE_vertex_array_object) + CASE(E_GL_APPLE_vertex_array_range) + CASE(E_GL_APPLE_ycbcr_422) + CASE(E_GL_S3_s3tc) + CASE(E_GL_ATI_draw_buffers) + CASE(E_WGL_ATI_pixel_format_float) + CASE(E_GL_ATI_texture_env_combine3) + CASE(E_GL_ATI_texture_float) + CASE(E_GL_NV_float_buffer) + CASE(E_WGL_NV_float_buffer) + CASE(E_GL_NV_fragment_program) + CASE(E_GL_NV_half_float) + CASE(E_GL_NV_pixel_data_range) + CASE(E_GL_NV_primitive_restart) + CASE(E_GL_NV_texture_expand_normal) + CASE(E_GL_NV_vertex_program2) + CASE(E_GL_ATI_map_object_buffer) + CASE(E_GL_ATI_separate_stencil) + CASE(E_GL_ATI_vertex_attrib_array_object) + CASE(E_GL_OES_byte_coordinates) + CASE(E_GL_OES_fixed_point) + CASE(E_GL_OES_single_precision) + CASE(E_GL_OES_compressed_paletted_texture) + CASE(E_GL_OES_read_format) + CASE(E_GL_OES_query_matrix) + CASE(E_GL_EXT_depth_bounds_test) + CASE(E_GL_EXT_texture_mirror_clamp) + CASE(E_GL_EXT_blend_equation_separate) + CASE(E_GL_MESA_pack_invert) + CASE(E_GL_MESA_ycbcr_texture) + CASE(E_GL_EXT_pixel_buffer_object) + CASE(E_GL_NV_fragment_program_option) + CASE(E_GL_NV_fragment_program2) + CASE(E_GL_NV_vertex_program2_option) + CASE(E_GL_NV_vertex_program3) + CASE(E_GLX_SGIX_hyperpipe) + CASE(E_GLX_MESA_agp_offset) + CASE(E_GL_EXT_texture_compression_dxt1) + CASE(E_GL_EXT_framebuffer_object) + CASE(E_GL_GREMEDY_string_marker) + CASE(E_GL_EXT_packed_depth_stencil) + CASE(E_WGL_3DL_stereo_control) + CASE(E_GL_EXT_stencil_clear_tag) + CASE(E_GL_EXT_texture_sRGB) + CASE(E_GL_EXT_framebuffer_blit) + CASE(E_GL_EXT_framebuffer_multisample) + CASE(E_GL_MESAX_texture_stack) + CASE(E_GL_EXT_timer_query) + CASE(E_GL_EXT_gpu_program_parameters) + CASE(E_GL_APPLE_flush_buffer_range) + CASE(E_GL_NV_gpu_program4) + CASE(E_GL_NV_geometry_program4) + CASE(E_GL_EXT_geometry_shader4) + CASE(E_GL_NV_vertex_program4) + CASE(E_GL_EXT_gpu_shader4) + CASE(E_GL_EXT_draw_instanced) + CASE(E_GL_EXT_packed_float) + CASE(E_GLX_EXT_fbconfig_packed_float) + CASE(E_WGL_EXT_pixel_format_packed_float) + CASE(E_GL_EXT_texture_array) + CASE(E_GL_EXT_texture_buffer_object) + CASE(E_GL_EXT_texture_compression_latc) + CASE(E_GL_EXT_texture_compression_rgtc) + CASE(E_GL_EXT_texture_shared_exponent) + CASE(E_GL_NV_depth_buffer_float) + CASE(E_GL_NV_fragment_program4) + CASE(E_GL_NV_framebuffer_multisample_coverage) + CASE(E_GL_EXT_framebuffer_sRGB) + CASE(E_GLX_EXT_framebuffer_sRGB) + CASE(E_WGL_EXT_framebuffer_sRGB) + CASE(E_GL_NV_geometry_shader4) + CASE(E_GL_NV_parameter_buffer_object) + CASE(E_GL_EXT_draw_buffers2) + CASE(E_GL_NV_transform_feedback) + CASE(E_GL_EXT_bindable_uniform) + CASE(E_GL_EXT_texture_integer) + CASE(E_GLX_EXT_texture_from_pixmap) + CASE(E_GL_GREMEDY_frame_terminator) + CASE(E_GL_NV_conditional_render) + CASE(E_GL_NV_present_video) + CASE(E_GLX_NV_present_video) + CASE(E_WGL_NV_present_video) + CASE(E_GLX_NV_video_out) + CASE(E_WGL_NV_video_output) + CASE(E_GLX_NV_swap_group) + CASE(E_WGL_NV_swap_group) + CASE(E_GL_EXT_transform_feedback) + CASE(E_GL_EXT_direct_state_access) + CASE(E_GL_EXT_vertex_array_bgra) + CASE(E_WGL_NV_gpu_affinity) + CASE(E_GL_EXT_texture_swizzle) + CASE(E_GL_NV_explicit_multisample) + CASE(E_GL_NV_transform_feedback2) + CASE(E_GL_ATI_meminfo) + CASE(E_GL_AMD_performance_monitor) + CASE(E_WGL_AMD_gpu_association) + CASE(E_GL_AMD_texture_texture4) + CASE(E_GL_AMD_vertex_shader_tessellator) + CASE(E_GL_EXT_provoking_vertex) + CASE(E_GL_EXT_texture_snorm) + CASE(E_GL_AMD_draw_buffers_blend) + CASE(E_GL_APPLE_texture_range) + CASE(E_GL_APPLE_float_pixels) + CASE(E_GL_APPLE_vertex_program_evaluators) + CASE(E_GL_APPLE_aux_depth_stencil) + CASE(E_GL_APPLE_object_purgeable) + CASE(E_GL_APPLE_row_bytes) + CASE(E_GL_APPLE_rgb_422) + CASE(E_GL_NV_video_capture) + CASE(E_GLX_NV_video_capture) + CASE(E_WGL_NV_video_capture) + CASE(E_GL_EXT_swap_control) + CASE(E_GL_NV_copy_image) + CASE(E_GLX_NV_copy_image) + CASE(E_WGL_NV_copy_image) + CASE(E_GL_EXT_separate_shader_objects) + CASE(E_GL_NV_parameter_buffer_object2) + CASE(E_GL_NV_shader_buffer_load) + CASE(E_GL_NV_vertex_buffer_unified_memory) + CASE(E_GL_NV_texture_barrier) + CASE(E_GL_AMD_shader_stencil_export) + CASE(E_GL_AMD_seamless_cubemap_per_texture) + CASE(E_GLX_INTEL_swap_event) + CASE(E_GL_AMD_conservative_depth) + CASE(E_GL_EXT_shader_image_load_store) + CASE(E_GL_EXT_vertex_attrib_64bit) + CASE(E_GL_NV_gpu_program5) + CASE(E_GL_NV_gpu_shader5) + CASE(E_GL_NV_shader_buffer_store) + CASE(E_GL_NV_tessellation_program5) + CASE(E_GL_NV_vertex_attrib_integer_64bit) + CASE(E_GL_NV_multisample_coverage) + CASE(E_GL_AMD_name_gen_delete) + CASE(E_GL_AMD_debug_output) + CASE(E_GL_NV_vdpau_interop) + CASE(E_GL_AMD_transform_feedback3_lines_triangles) + CASE(E_GLX_AMD_gpu_association) + CASE(E_GLX_EXT_create_context_es2_profile) + CASE(E_GLX_EXT_create_context_es_profile) + CASE(E_WGL_EXT_create_context_es2_profile) + CASE(E_WGL_EXT_create_context_es_profile) + CASE(E_GL_AMD_depth_clamp_separate) + CASE(E_GL_EXT_texture_sRGB_decode) + CASE(E_GL_NV_texture_multisample) + CASE(E_GL_AMD_blend_minmax_factor) + CASE(E_GL_AMD_sample_positions) + CASE(E_GL_EXT_x11_sync_object) + CASE(E_WGL_NV_DX_interop) + CASE(E_GL_AMD_multi_draw_indirect) + CASE(E_GL_EXT_framebuffer_multisample_blit_scaled) + CASE(E_GL_NV_path_rendering) + CASE(E_GL_AMD_pinned_memory) + CASE(E_WGL_NV_DX_interop2) + CASE(E_GL_AMD_stencil_operation_extended) + CASE(E_GLX_EXT_swap_control_tear) + CASE(E_WGL_EXT_swap_control_tear) + CASE(E_GL_AMD_vertex_shader_viewport_index) + CASE(E_GL_AMD_vertex_shader_layer) + CASE(E_GL_NV_bindless_texture) + CASE(E_GL_NV_shader_atomic_float) + CASE(E_GL_AMD_query_buffer_object) + CASE(E_GL_NV_compute_program5) + CASE(E_GL_NV_shader_storage_buffer_object) + CASE(E_GL_NV_shader_atomic_counters) + CASE(E_GL_NV_deep_texture3D) + CASE(E_GL_NVX_conditional_render) + CASE(E_GL_AMD_sparse_texture) + CASE(E_GLX_EXT_buffer_age) + CASE(E_GL_AMD_shader_trinary_minmax) + CASE(E_GL_INTEL_map_texture) + CASE(E_GL_NV_draw_texture) + CASE(E_GL_AMD_interleaved_elements) + CASE(E_GL_NV_bindless_multi_draw_indirect) + CASE(E_GL_NV_blend_equation_advanced) + CASE(E_GL_NV_blend_equation_advanced_coherent) + CASE(E_GL_NV_gpu_program5_mem_extended) + CASE(E_GL_AMD_shader_atomic_counter_ops) + CASE(E_WGL_NV_delay_before_swap) + CASE(E_GL_EXT_shader_integer_mix) + CASE(E_GL_NVX_gpu_memory_info) + CASE(E_GL_EXT_debug_label) + CASE(E_GL_EXT_debug_marker) + CASE(E_GL_INTEL_fragment_shader_ordering) + CASE(E_GL_AMD_occlusion_query_event) + CASE(E_GL_INTEL_performance_query) + CASE(E_GL_AMD_shader_stencil_value_export) + CASE(E_GLX_NV_delay_before_swap) + CASE(E_GLX_MESA_query_renderer) + CASE(E_GL_NV_shader_thread_group) + CASE(E_GL_NV_shader_thread_shuffle) + CASE(E_GL_EXT_shader_image_load_formatted) + CASE(E_GL_AMD_transform_feedback4) + CASE(E_GL_AMD_gpu_shader_int64) + CASE(E_GLX_EXT_stereo_tree) + CASE(E_GL_AMD_gcn_shader) + CASE(E_GL_AMD_framebuffer_sample_positions) + CASE(E_GL_NV_shader_atomic_int64) + CASE(E_GL_NV_bindless_multi_draw_indirect_count) + CASE(E_GLX_NV_copy_buffer) + CASE(E_GL_NV_uniform_buffer_unified_memory) + CASE(E_GL_EXT_polygon_offset_clamp) + CASE(E_GL_EXT_post_depth_coverage) + CASE(E_GL_EXT_raster_multisample) + CASE(E_GL_EXT_sparse_texture2) + CASE(E_GL_EXT_texture_filter_minmax) + CASE(E_GL_NV_conservative_raster) + CASE(E_GL_NV_fill_rectangle) + CASE(E_GL_NV_fragment_coverage_to_color) + CASE(E_GL_NV_fragment_shader_interlock) + CASE(E_GL_NV_framebuffer_mixed_samples) + CASE(E_GL_NV_geometry_shader_passthrough) + CASE(E_GL_NV_path_rendering_shared_edge) + CASE(E_GL_NV_sample_locations) + CASE(E_GL_NV_sample_mask_override_coverage) + CASE(E_GL_NV_shader_atomic_fp16_vector) + CASE(E_GL_NV_internalformat_sample_query) + CASE(E_GL_NV_viewport_array2) + CASE(E_GL_NV_command_list) + CASE(E_GL_OVR_multiview) + CASE(E_GL_OVR_multiview2) + CASE(E_GL_NV_conservative_raster_dilate) + CASE(E_GL_INTEL_framebuffer_CMAA) + CASE(E_GLX_EXT_libglvnd) + CASE(E_GL_NV_viewport_swizzle) + CASE(E_GL_NV_robustness_video_memory_purge) + CASE(E_GL_AMD_shader_explicit_vertex_parameter) + CASE(E_GL_NV_clip_space_w_scaling) + CASE(E_GL_NV_conservative_raster_pre_snap_triangles) + CASE(E_GL_NV_shader_atomic_float64) + CASE(E_GL_NV_stereo_view_rendering) + CASE(E_GL_EXT_window_rectangles) + CASE(E_GL_INTEL_conservative_rasterization) + CASE(E_GL_NVX_blend_equation_advanced_multi_draw_buffers) + CASE(E_GL_NVX_linked_gpu_multicast) + CASE(E_GL_NV_gpu_multicast) + CASE(E_GL_MESA_shader_integer_functions) + CASE(E_GL_AMD_gpu_shader_half_float) + CASE(E_GL_AMD_shader_ballot) + CASE(E_WGL_EXT_colorspace) + CASE(E_GL_SGIX_pixel_texture) + CASE(E_GL_NV_alpha_to_coverage_dither_control) + CASE(E_GL_NV_draw_vulkan_image) + CASE(E_GL_AMD_texture_gather_bias_lod) + CASE(E_GL_EXT_memory_object) + CASE(E_GL_EXT_semaphore) + CASE(E_GL_EXT_memory_object_fd) + CASE(E_GL_EXT_semaphore_fd) + CASE(E_GL_EXT_memory_object_win32) + CASE(E_GL_EXT_semaphore_win32) + CASE(E_GL_EXT_win32_keyed_mutex) + CASE(E_GL_AMD_gpu_shader_int16) + CASE(E_GL_EXT_external_buffer) + CASE(E_GL_NV_texture_rectangle_compressed) + CASE(E_GL_NV_blend_minmax_factor) + CASE(E_GL_NV_query_resource) + CASE(E_GL_NV_query_resource_tag) + CASE(E_GL_AMD_shader_image_load_store_lod) + CASE(E_GLX_MESA_swap_control) + CASE(E_GL_MESA_tile_raster_order) + CASE(E_GL_MESA_program_binary_formats) + CASE(E_GL_NV_conservative_raster_pre_snap) + CASE(E_GL_NV_conservative_raster_underestimation) + CASE(E_GL_AMD_gpu_shader_half_float_fetch) + CASE(E_GL_EXT_shader_framebuffer_fetch) + CASE(E_GL_EXT_shader_framebuffer_fetch_non_coherent) + CASE(E_GL_INTEL_blackhole_render) + CASE(E_GL_EXT_EGL_image_storage) + CASE(E_GL_AMD_framebuffer_multisample_advanced) + CASE(E_GL_NV_memory_attachment) + CASE(E_GL_NV_compute_shader_derivatives) + CASE(E_GL_NV_fragment_shader_barycentric) + CASE(E_GL_NV_mesh_shader) + CASE(E_GL_NV_representative_fragment_test) + CASE(E_GL_NV_scissor_exclusive) + CASE(E_GL_NV_shader_texture_footprint) + CASE(E_GL_NV_shading_rate_image) + CASE(E_WGL_ATI_render_texture_rectangle) + CASE(E_GL_NV_vdpau_interop2) + CASE(E_GL_EXT_texture_sRGB_R8) + CASE(E_GLX_EXT_context_priority) + CASE(E_GL_EXT_multiview_timer_query) + CASE(E_GL_EXT_multiview_texture_multisample) + CASE(E_GL_EXT_multiview_tessellation_geometry_shader) + CASE(E_GL_EXT_texture_shadow_lod) + CASE(E_GL_MESA_framebuffer_flip_y) + CASE(E_GL_NVX_progress_fence) + CASE(E_WGL_NV_multigpu_context) + CASE(E_GL_NVX_gpu_multicast2) + CASE(E_GL_NV_shader_subgroup_partitioned) + CASE(E_GLX_NV_multigpu_context) + CASE(E_GL_EXT_EGL_sync) + CASE(E_GL_INTEL_shader_integer_functions2) + CASE(E_GL_MESA_framebuffer_flip_x) + CASE(E_GL_MESA_framebuffer_swap_xy) + CASE(E_GL_NV_memory_object_sparse) + CASE(E_GL_NV_timeline_semaphore) + CASE(E_GLX_EXT_get_drawable_type) + CASE(E_GLX_EXT_no_config_context) + CASE(E_GL_NV_primitive_shading_rate) + CASE(E_GL_EXT_texture_sRGB_RG8) + CASE(E_GL_EXT_texture_storage) + CASE(E_GL_EXT_framebuffer_blit_layers) + CASE(E_GL_NV_uniform_buffer_std430_layout) + CASE(E_GL_MESA_texture_const_bandwidth) + } + str.erase(0, 2); + return str; + } + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.h b/MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.h index 8b0a7ce5..e313ab44 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.h +++ b/MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.h @@ -1,7 +1,8 @@ #pragma once +#include namespace MobileGL { - namespace MG_Util { - String ConvertetGLExtToString(GLExtension extension); - } -} \ No newline at end of file + namespace MG_Util { + String ConvertetGLExtToString(GLExtension extension); + } +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/Debug/Log.h b/MobileGL/MG_Util/Debug/Log.h index 7b379f69..f08f449c 100644 --- a/MobileGL/MG_Util/Debug/Log.h +++ b/MobileGL/MG_Util/Debug/Log.h @@ -1,56 +1,62 @@ #pragma once +#include #define MOBILEGL_LOG_LEVEL_DEBUG 0 -#define MOBILEGL_LOG_LEVEL_WARN 1 +#define MOBILEGL_LOG_LEVEL_WARN 1 #define MOBILEGL_LOG_LEVEL_ERROR 2 -#define MOBILEGL_LOG_LEVEL_INFO 3 +#define MOBILEGL_LOG_LEVEL_INFO 3 #define MOBILEGL_LOG_LEVEL_FATAL 4 -#define MOBILEGL_LOG_INTERNAL(levelTag, androidLogLevel, fmt, ...) \ - do { \ - MobileGL::MG_Util::Debug::Log(levelTag, androidLogLevel, fmt, ##__VA_ARGS__); \ - } while(0) +#define MOBILEGL_LOG_INTERNAL(levelTag, androidLogLevel, fmt, ...) \ + do { \ + MobileGL::MG_Util::Debug::Log(levelTag, androidLogLevel, fmt, ##__VA_ARGS__); \ + } while (0) #if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_DEBUG -# define MGLOG_D(fmt, ...) MOBILEGL_LOG_INTERNAL("DEBUG", ANDROID_LOG_DEBUG, fmt, ##__VA_ARGS__) +#define MGLOG_D(fmt, ...) MOBILEGL_LOG_INTERNAL("DEBUG", ANDROID_LOG_DEBUG, fmt, ##__VA_ARGS__) #else -# define MGLOG_D(fmt, ...) { } +#define MGLOG_D(fmt, ...) \ + {} #endif #if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_INFO -# define MGLOG_I(fmt, ...) MOBILEGL_LOG_INTERNAL("INFO", ANDROID_LOG_INFO, fmt, ##__VA_ARGS__) +#define MGLOG_I(fmt, ...) MOBILEGL_LOG_INTERNAL("INFO", ANDROID_LOG_INFO, fmt, ##__VA_ARGS__) #else -# define MGLOG_I(fmt, ...) { } +#define MGLOG_I(fmt, ...) \ + {} #endif #if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_WARN -# define MGLOG_W(fmt, ...) MOBILEGL_LOG_INTERNAL("WARN", ANDROID_LOG_WARN, fmt, ##__VA_ARGS__) +#define MGLOG_W(fmt, ...) MOBILEGL_LOG_INTERNAL("WARN", ANDROID_LOG_WARN, fmt, ##__VA_ARGS__) #else -# define MGLOG_W(fmt, ...) { } +#define MGLOG_W(fmt, ...) \ + {} #endif #if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_ERROR -# define MGLOG_E(fmt, ...) MOBILEGL_LOG_INTERNAL("ERROR", ANDROID_LOG_ERROR, fmt, ##__VA_ARGS__) +#define MGLOG_E(fmt, ...) MOBILEGL_LOG_INTERNAL("ERROR", ANDROID_LOG_ERROR, fmt, ##__VA_ARGS__) #else -# define MGLOG_E(fmt, ...) { } +#define MGLOG_E(fmt, ...) \ + {} #endif #if MOBILEGL_LOG_ACTIVE_LEVEL <= MOBILEGL_LOG_LEVEL_FATAL -# define MGLOG_F(fmt, ...) MOBILEGL_LOG_INTERNAL("FATAL", ANDROID_LOG_FATAL, fmt, ##__VA_ARGS__) +#define MGLOG_F(fmt, ...) MOBILEGL_LOG_INTERNAL("FATAL", ANDROID_LOG_FATAL, fmt, ##__VA_ARGS__) #else -# define MGLOG_F(fmt, ...) { } +#define MGLOG_F(fmt, ...) \ + {} #endif namespace MobileGL { namespace MG_Util { namespace Debug { - void Log(const char* levelTag, android_LogPriority androidLogLevel, const char* fmt, ...); + void Log(const char* levelTag, android_LogPriority androidLogLevel, const char* fmt, ...); void InitFile(); void WriteToFile(const char* msg); std::string GetCurrentTime(); constexpr char* GetOSName(); - std::string GetThreadName(); + std::string GetThreadName(); void Close(); - } - } -} + } // namespace Debug + } // namespace MG_Util +} // namespace MobileGL diff --git a/MobileGL/MG_Util/GLExtensions.h b/MobileGL/MG_Util/GLExtensions.h index 9b766a37..87fb02e4 100644 --- a/MobileGL/MG_Util/GLExtensions.h +++ b/MobileGL/MG_Util/GLExtensions.h @@ -763,4 +763,4 @@ namespace MobileGL { E_GL_NV_uniform_buffer_std430_layout , E_GL_MESA_texture_const_bandwidth }; -} \ No newline at end of file +} diff --git a/MobileGL/MG_Util/Miscellany/IndexGenerator.h b/MobileGL/MG_Util/Miscellany/IndexGenerator.h index 0f7aa19e..0e7fddfa 100644 --- a/MobileGL/MG_Util/Miscellany/IndexGenerator.h +++ b/MobileGL/MG_Util/Miscellany/IndexGenerator.h @@ -1,39 +1,38 @@ #pragma once +#include namespace MobileGL { template class IndexGenerator { public: - explicit IndexGenerator(size_t initial_capacity = 1024, IndexType first_index = 0) - : next_index_(first_index) - { - const size_t words_needed = (initial_capacity + 63) / 64; + explicit IndexGenerator(SizeT initial_capacity = 1024, IndexType first_index = 0) : next_index_(first_index) { + const SizeT words_needed = (initial_capacity + 63) / 64; is_valid_.resize(words_needed, ~0ull); freed_indices_.reserve(initial_capacity); } - void Generate(size_t n, IndexType* indices) { + void Generate(SizeT n, IndexType* indices) { if (n == 0) return; - size_t from_freed = std::min(n, freed_indices_.size()); + SizeT from_freed = std::min(n, freed_indices_.size()); if (from_freed > 0) { std::copy_n(freed_indices_.end() - from_freed, from_freed, indices); freed_indices_.resize(freed_indices_.size() - from_freed); - for (size_t i = 0; i < from_freed; ++i) { + for (SizeT i = 0; i < from_freed; ++i) { SetValid(indices[i], true); } } - size_t need_new = n - from_freed; + SizeT need_new = n - from_freed; if (need_new > 0) { - size_t required_index = next_index_ + need_new; - size_t required_words = (required_index + 63) / 64; + SizeT required_index = next_index_ + need_new; + SizeT required_words = (required_index + 63) / 64; if (required_words > is_valid_.size()) { is_valid_.resize(required_words, ~0ull); } - for (size_t i = 0; i < need_new; ++i) { + for (SizeT i = 0; i < need_new; ++i) { indices[from_freed + i] = next_index_++; } } @@ -48,25 +47,24 @@ namespace MobileGL { } bool IsValid(IndexType index) const { - size_t word = index >> 6; - size_t bit = index & 0x3F; + SizeT word = index >> 6; + SizeT bit = index & 0x3F; return word < is_valid_.size() && (is_valid_[word] & (1ull << bit)); } - size_t FreeListSize() const { return freed_indices_.size(); } - size_t ActiveCount() const { return next_index_ - freed_indices_.size(); } + SizeT FreeListSize() const { return freed_indices_.size(); } + SizeT ActiveCount() const { return next_index_ - freed_indices_.size(); } private: inline void SetValid(IndexType index, bool valid) { - size_t word = index >> 6; + SizeT word = index >> 6; uint64_t mask = 1ull << (index & 0x3F); if (word >= is_valid_.size()) return; if (valid) { is_valid_[word] |= mask; - } - else { + } else { is_valid_[word] &= ~mask; } } @@ -82,4 +80,4 @@ namespace MobileGL { std::vector freed_indices_; std::vector is_valid_; }; -} \ No newline at end of file +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/PlatformStubs.h b/MobileGL/MG_Util/PlatformStubs.h new file mode 100644 index 00000000..2dcaf63e --- /dev/null +++ b/MobileGL/MG_Util/PlatformStubs.h @@ -0,0 +1,23 @@ +#pragma once + +// Stubs for non-Android platforms +#ifndef __ANDROID__ + +// Stubs for Android logging functions +#define ANDROID_LOG_UNKNOWN 0 +#define ANDROID_LOG_DEFAULT 1 +#define ANDROID_LOG_VERBOSE 2 +#define ANDROID_LOG_DEBUG 3 +#define ANDROID_LOG_INFO 4 +#define ANDROID_LOG_WARN 5 +#define ANDROID_LOG_ERROR 6 +#define ANDROID_LOG_FATAL 7 +#define ANDROID_LOG_SILENT 8 + +typedef int android_LogPriority; + +inline int __android_log_print(int prio, const char* tag, const char* fmt, ...) { + return 0; +} + +#endif \ No newline at end of file diff --git a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp index d1116600..d9f8e370 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp +++ b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp @@ -1,113 +1,114 @@ -#include "../../Includes.h" +#include "ShaderCompiler.h" +#include +#include namespace MobileGL { namespace MG_Util { namespace ShaderTranspiler { - TBuiltInResource& GetTBuiltInResourceInstance() - { + TBuiltInResource& GetTBuiltInResourceInstance() { static TBuiltInResource Resources{}; - Resources.maxLights = 32; - Resources.maxClipPlanes = 6; - Resources.maxTextureUnits = 32; - Resources.maxTextureCoords = 32; - Resources.maxVertexAttribs = 64; - Resources.maxVertexUniformComponents = 4096; - Resources.maxVaryingFloats = 64; - Resources.maxVertexTextureImageUnits = 32; - Resources.maxCombinedTextureImageUnits = 80; - Resources.maxTextureImageUnits = 32; - Resources.maxFragmentUniformComponents = 4096; - Resources.maxDrawBuffers = 32; - Resources.maxVertexUniformVectors = 128; - Resources.maxVaryingVectors = 8; - Resources.maxFragmentUniformVectors = 16; - Resources.maxVertexOutputVectors = 16; - Resources.maxFragmentInputVectors = 15; - Resources.minProgramTexelOffset = -8; - Resources.maxProgramTexelOffset = 7; - Resources.maxClipDistances = 8; - Resources.maxComputeWorkGroupCountX = 65535; - Resources.maxComputeWorkGroupCountY = 65535; - Resources.maxComputeWorkGroupCountZ = 65535; - Resources.maxComputeWorkGroupSizeX = 1024; - Resources.maxComputeWorkGroupSizeY = 1024; - Resources.maxComputeWorkGroupSizeZ = 64; - Resources.maxComputeUniformComponents = 1024; - Resources.maxComputeTextureImageUnits = 16; - Resources.maxComputeImageUniforms = 8; - Resources.maxComputeAtomicCounters = 8; - Resources.maxComputeAtomicCounterBuffers = 1; - Resources.maxVaryingComponents = 60; - Resources.maxVertexOutputComponents = 64; - Resources.maxGeometryInputComponents = 64; - Resources.maxGeometryOutputComponents = 128; - Resources.maxFragmentInputComponents = 128; - Resources.maxImageUnits = 8; - Resources.maxCombinedImageUnitsAndFragmentOutputs = 8; - Resources.maxCombinedShaderOutputResources = 8; - Resources.maxImageSamples = 0; - Resources.maxVertexImageUniforms = 0; - Resources.maxTessControlImageUniforms = 0; - Resources.maxTessEvaluationImageUniforms = 0; - Resources.maxGeometryImageUniforms = 0; - Resources.maxFragmentImageUniforms = 8; - Resources.maxCombinedImageUniforms = 8; - Resources.maxGeometryTextureImageUnits = 16; - Resources.maxGeometryOutputVertices = 256; - Resources.maxGeometryTotalOutputComponents = 1024; - Resources.maxGeometryUniformComponents = 1024; - Resources.maxGeometryVaryingComponents = 64; - Resources.maxTessControlInputComponents = 128; - Resources.maxTessControlOutputComponents = 128; - Resources.maxTessControlTextureImageUnits = 16; - Resources.maxTessControlUniformComponents = 1024; - Resources.maxTessControlTotalOutputComponents = 4096; - Resources.maxTessEvaluationInputComponents = 128; - Resources.maxTessEvaluationOutputComponents = 128; - Resources.maxTessEvaluationTextureImageUnits = 16; - Resources.maxTessEvaluationUniformComponents = 1024; - Resources.maxTessPatchComponents = 120; - Resources.maxPatchVertices = 32; - Resources.maxTessGenLevel = 64; - Resources.maxViewports = 16; - Resources.maxVertexAtomicCounters = 0; - Resources.maxTessControlAtomicCounters = 0; - Resources.maxTessEvaluationAtomicCounters = 0; - Resources.maxGeometryAtomicCounters = 0; - Resources.maxFragmentAtomicCounters = 8; - Resources.maxCombinedAtomicCounters = 8; - Resources.maxAtomicCounterBindings = 1; - Resources.maxVertexAtomicCounterBuffers = 0; - Resources.maxTessControlAtomicCounterBuffers = 0; - Resources.maxTessEvaluationAtomicCounterBuffers = 0; - Resources.maxGeometryAtomicCounterBuffers = 0; - Resources.maxFragmentAtomicCounterBuffers = 1; - Resources.maxCombinedAtomicCounterBuffers = 1; - Resources.maxAtomicCounterBufferSize = 16384; - Resources.maxTransformFeedbackBuffers = 4; + Resources.maxLights = 32; + Resources.maxClipPlanes = 6; + Resources.maxTextureUnits = 32; + Resources.maxTextureCoords = 32; + Resources.maxVertexAttribs = 64; + Resources.maxVertexUniformComponents = 4096; + Resources.maxVaryingFloats = 64; + Resources.maxVertexTextureImageUnits = 32; + Resources.maxCombinedTextureImageUnits = 80; + Resources.maxTextureImageUnits = 32; + Resources.maxFragmentUniformComponents = 4096; + Resources.maxDrawBuffers = 32; + Resources.maxVertexUniformVectors = 128; + Resources.maxVaryingVectors = 8; + Resources.maxFragmentUniformVectors = 16; + Resources.maxVertexOutputVectors = 16; + Resources.maxFragmentInputVectors = 15; + Resources.minProgramTexelOffset = -8; + Resources.maxProgramTexelOffset = 7; + Resources.maxClipDistances = 8; + Resources.maxComputeWorkGroupCountX = 65535; + Resources.maxComputeWorkGroupCountY = 65535; + Resources.maxComputeWorkGroupCountZ = 65535; + Resources.maxComputeWorkGroupSizeX = 1024; + Resources.maxComputeWorkGroupSizeY = 1024; + Resources.maxComputeWorkGroupSizeZ = 64; + Resources.maxComputeUniformComponents = 1024; + Resources.maxComputeTextureImageUnits = 16; + Resources.maxComputeImageUniforms = 8; + Resources.maxComputeAtomicCounters = 8; + Resources.maxComputeAtomicCounterBuffers = 1; + Resources.maxVaryingComponents = 60; + Resources.maxVertexOutputComponents = 64; + Resources.maxGeometryInputComponents = 64; + Resources.maxGeometryOutputComponents = 128; + Resources.maxFragmentInputComponents = 128; + Resources.maxImageUnits = 8; + Resources.maxCombinedImageUnitsAndFragmentOutputs = 8; + Resources.maxCombinedShaderOutputResources = 8; + Resources.maxImageSamples = 0; + Resources.maxVertexImageUniforms = 0; + Resources.maxTessControlImageUniforms = 0; + Resources.maxTessEvaluationImageUniforms = 0; + Resources.maxGeometryImageUniforms = 0; + Resources.maxFragmentImageUniforms = 8; + Resources.maxCombinedImageUniforms = 8; + Resources.maxGeometryTextureImageUnits = 16; + Resources.maxGeometryOutputVertices = 256; + Resources.maxGeometryTotalOutputComponents = 1024; + Resources.maxGeometryUniformComponents = 1024; + Resources.maxGeometryVaryingComponents = 64; + Resources.maxTessControlInputComponents = 128; + Resources.maxTessControlOutputComponents = 128; + Resources.maxTessControlTextureImageUnits = 16; + Resources.maxTessControlUniformComponents = 1024; + Resources.maxTessControlTotalOutputComponents = 4096; + Resources.maxTessEvaluationInputComponents = 128; + Resources.maxTessEvaluationOutputComponents = 128; + Resources.maxTessEvaluationTextureImageUnits = 16; + Resources.maxTessEvaluationUniformComponents = 1024; + Resources.maxTessPatchComponents = 120; + Resources.maxPatchVertices = 32; + Resources.maxTessGenLevel = 64; + Resources.maxViewports = 16; + Resources.maxVertexAtomicCounters = 0; + Resources.maxTessControlAtomicCounters = 0; + Resources.maxTessEvaluationAtomicCounters = 0; + Resources.maxGeometryAtomicCounters = 0; + Resources.maxFragmentAtomicCounters = 8; + Resources.maxCombinedAtomicCounters = 8; + Resources.maxAtomicCounterBindings = 1; + Resources.maxVertexAtomicCounterBuffers = 0; + Resources.maxTessControlAtomicCounterBuffers = 0; + Resources.maxTessEvaluationAtomicCounterBuffers = 0; + Resources.maxGeometryAtomicCounterBuffers = 0; + Resources.maxFragmentAtomicCounterBuffers = 1; + Resources.maxCombinedAtomicCounterBuffers = 1; + Resources.maxAtomicCounterBufferSize = 16384; + Resources.maxTransformFeedbackBuffers = 4; Resources.maxTransformFeedbackInterleavedComponents = 64; - Resources.maxCullDistances = 8; - Resources.maxCombinedClipAndCullDistances = 8; - Resources.maxSamples = 4; - Resources.maxMeshOutputVerticesNV = 256; - Resources.maxMeshOutputPrimitivesNV = 512; - Resources.maxMeshWorkGroupSizeX_NV = 32; - Resources.maxMeshWorkGroupSizeY_NV = 1; - Resources.maxMeshWorkGroupSizeZ_NV = 1; - Resources.maxTaskWorkGroupSizeX_NV = 32; - Resources.maxTaskWorkGroupSizeY_NV = 1; - Resources.maxTaskWorkGroupSizeZ_NV = 1; - Resources.maxMeshViewCountNV = 4; + Resources.maxCullDistances = 8; + Resources.maxCombinedClipAndCullDistances = 8; + Resources.maxSamples = 4; + Resources.maxMeshOutputVerticesNV = 256; + Resources.maxMeshOutputPrimitivesNV = 512; + Resources.maxMeshWorkGroupSizeX_NV = 32; + Resources.maxMeshWorkGroupSizeY_NV = 1; + Resources.maxMeshWorkGroupSizeZ_NV = 1; + Resources.maxTaskWorkGroupSizeX_NV = 32; + Resources.maxTaskWorkGroupSizeY_NV = 1; + Resources.maxTaskWorkGroupSizeZ_NV = 1; + Resources.maxMeshViewCountNV = 4; - Resources.limits.nonInductiveForLoops = true; - Resources.limits.whileLoops = true; - Resources.limits.doWhileLoops = true; - Resources.limits.generalUniformIndexing = true; + Resources.limits.nonInductiveForLoops = true; + Resources.limits.whileLoops = true; + Resources.limits.doWhileLoops = true; + Resources.limits.generalUniformIndexing = true; Resources.limits.generalAttributeMatrixVectorIndexing = true; - Resources.limits.generalVaryingIndexing = true; - Resources.limits.generalSamplerIndexing = true; - Resources.limits.generalVariableIndexing = true; - Resources.limits.generalConstantMatrixVectorIndexing = true; + Resources.limits.generalVaryingIndexing = true; + Resources.limits.generalSamplerIndexing = true; + Resources.limits.generalVariableIndexing = true; + Resources.limits.generalConstantMatrixVectorIndexing = true; return Resources; } @@ -119,8 +120,7 @@ namespace MobileGL { auto lang = GetEShLanguageByShaderType(shaderType); if (lang == EShLanguage::EShLangCount) { ResultInfo r; - r.log += "Error: [Preprocess] Unsupported shader type: " + - ConvertGLEnumToString(shaderType); + r.log += "Error: [Preprocess] Unsupported shader type: " + ConvertGLEnumToString(shaderType); r.errc = -1; return std::unexpected(r); } @@ -128,7 +128,7 @@ namespace MobileGL { SharedPtr res; auto& tshader = res; tshader = MakeShared(lang); - const char* src[] = { sourceStr.data() }; + const char* src[] = {sourceStr.data()}; tshader->setStrings(src, 1); tshader->setInvertY(true); tshader->setEnvInput(glslang::EShSourceGlsl, lang, glslang::EShClientVulkan, 450); @@ -136,14 +136,15 @@ namespace MobileGL { tshader->setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_5); tshader->setAutoMapLocations(true); tshader->setAutoMapBindings(true); - tshader->setEnvInputVulkanRulesRelaxed(); // using EXT_vulkan_glsl_relaxed for gl_VertexID and gl_InstanceID? + tshader->setEnvInputVulkanRulesRelaxed(); // using EXT_vulkan_glsl_relaxed for gl_VertexID and + // gl_InstanceID? tshader->setGlobalUniformBlockName(GLOBAL_UBO_NAME); if (!tshader->parse(&GetTBuiltInResourceInstance(), 150, ECoreProfile, - /*forceDefaultVersionAndProfile: */false, - /*forwardCompatible: */true, EShMsgDefault)) { + /*forceDefaultVersionAndProfile: */ false, + /*forwardCompatible: */ true, EShMsgDefault)) { ResultInfo r; - r.log += "Error: [glslang] Cannot compile " + ConvertGLEnumToString(shaderType) + ":\n" - + std::string(tshader->getInfoLog()); + r.log += "Error: [glslang] Cannot compile " + ConvertGLEnumToString(shaderType) + ":\n" + + std::string(tshader->getInfoLog()); r.errc = -2; return std::unexpected(r); } @@ -204,7 +205,7 @@ namespace MobileGL { session.SetOptions(options); - const char *result = nullptr; + const char* result = nullptr; session.Compile(&result); if (!result) { @@ -219,6 +220,6 @@ namespace MobileGL { return glsl; } - } - } -} + } // namespace ShaderTranspiler + } // namespace MG_Util +} // namespace MobileGL diff --git a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.h b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.h index 56bde616..0fadb5de 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.h +++ b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.h @@ -1,14 +1,16 @@ #pragma once +#include +#include "SpvcSession.h" namespace MobileGL { -namespace MG_Util { -namespace ShaderTranspiler { - class ShaderCompiler { - public: - static Result> CompileShader(const ShaderAttrib& attrib); - static Result>> LinkProgram(const ProgramAttrib& attrib); - static Result DecompileShader(SpvcSession& session); - }; -} -} -} + namespace MG_Util { + namespace ShaderTranspiler { + class ShaderCompiler { + public: + static Result> CompileShader(const ShaderAttrib& attrib); + static Result>> LinkProgram(const ProgramAttrib& attrib); + static Result DecompileShader(SpvcSession& session); + }; + } // namespace ShaderTranspiler + } // namespace MG_Util +} // namespace MobileGL diff --git a/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp b/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp index b229bcb3..adcfca11 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp +++ b/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp @@ -1,111 +1,113 @@ -#include "../../Includes.h" +#include "SpvcSession.h" namespace MobileGL { -namespace MG_Util { -namespace ShaderTranspiler { - SpvcSession::SpvcSession(const Vector& spirv) { - const SpvId *p_spirv = spirv.data(); - size_t word_count = spirv.size(); + namespace MG_Util { + namespace ShaderTranspiler { + SpvcSession::SpvcSession(const Vector& spirv) { + const SpvId* p_spirv = spirv.data(); + size_t word_count = spirv.size(); - spvc_context_create(&context); - spvc_context_parse_spirv(context, p_spirv, word_count, &ir); - spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP, &compiler); - spvc_compiler_create_shader_resources(compiler, &resources); - } - - SpvcSession::SpvcSession(SpvcSession&& that) { - std::swap(this->context, that.context); - std::swap(this->compiler, that.compiler); - std::swap(this->ir, that.ir); - std::swap(this->compiler_options, that.compiler_options); - std::swap(this->resources, that.resources); - } - - SpvcSession& SpvcSession::operator=(SpvcSession&& that) { - std::swap(this->context, that.context); - std::swap(this->compiler, that.compiler); - std::swap(this->ir, that.ir); - std::swap(this->compiler_options, that.compiler_options); - std::swap(this->resources, that.resources); - return *this; - } - - spvc_result SpvcSession::CreateOptions(spvc_compiler_options *options) { - return spvc_compiler_create_compiler_options(compiler, options); - } - - spvc_result SpvcSession::SetOptions(spvc_compiler_options options) { - compiler_options = options; - return spvc_compiler_install_compiler_options(compiler, options); - } - - Vector SpvcSession::GetShaderInterface(spvc_resource_type resource_type) const { - const spvc_reflected_resource *list = nullptr; - size_t count = 0; - spvc_resources_get_resource_list_for_type(resources, resource_type, &list, &count); - - Vector variables; - for (size_t i = 0; i < count; ++i) { - if (spvc_compiler_has_decoration(compiler, list[i].id, SpvDecorationBuiltIn)) { - continue; + spvc_context_create(&context); + spvc_context_parse_spirv(context, p_spirv, word_count, &ir); + spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP, + &compiler); + spvc_compiler_create_shader_resources(compiler, &resources); } - InterfaceVariable var; - var.name = list[i].name; - var.location = spvc_compiler_get_decoration(compiler, list[i].id, SpvDecorationLocation); - variables.push_back(var); - } - std::sort(variables.begin(), variables.end()); - return variables; - } - - spvc_result SpvcSession::Compile(const char** result) { - SPVC_CHK_INIT - SPVC_CHK_RESULT(spvc_compiler_compile(compiler, result)); - SPVC_CHK_RESULT(ParseMetaData()); - SPVC_CHK_RETURN - } - - spvc_result SpvcSession::ParseMetaData() { - SPVC_CHK_INIT - - metadata = SpvcMetadata(); - - const spvc_reflected_resource *list = nullptr; - size_t count = 0; - - SPVC_CHK_RESULT( - spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_UNIFORM_BUFFER, &list, &count); - ) - for (size_t i = 0; i < count; ++i) { - if (spvc_compiler_has_decoration(compiler, list[i].id, SpvDecorationBuiltIn)) { - continue; + SpvcSession::SpvcSession(SpvcSession&& that) { + std::swap(this->context, that.context); + std::swap(this->compiler, that.compiler); + std::swap(this->ir, that.ir); + std::swap(this->compiler_options, that.compiler_options); + std::swap(this->resources, that.resources); } - if (strcmp(list[i].name, GLOBAL_UBO_NAME) == 0) { - spvc_type type = spvc_compiler_get_type_handle(compiler, list[i].base_type_id); - size_t num_members = spvc_type_get_num_member_types(type); - for (size_t j = 0; j < num_members; ++j) { - const char *memberName = spvc_compiler_get_member_name(compiler, list[i].base_type_id, j); + SpvcSession& SpvcSession::operator=(SpvcSession&& that) { + std::swap(this->context, that.context); + std::swap(this->compiler, that.compiler); + std::swap(this->ir, that.ir); + std::swap(this->compiler_options, that.compiler_options); + std::swap(this->resources, that.resources); + return *this; + } - unsigned memberOffset = 0; - SPVC_CHK_RESULT(spvc_compiler_type_struct_member_offset(compiler, type, j, &memberOffset);) - metadata.plainUniformOffsetsInUBO[memberName] = memberOffset; + spvc_result SpvcSession::CreateOptions(spvc_compiler_options* options) { + return spvc_compiler_create_compiler_options(compiler, options); + } + + spvc_result SpvcSession::SetOptions(spvc_compiler_options options) { + compiler_options = options; + return spvc_compiler_install_compiler_options(compiler, options); + } + + Vector SpvcSession::GetShaderInterface(spvc_resource_type resource_type) const { + const spvc_reflected_resource* list = nullptr; + size_t count = 0; + spvc_resources_get_resource_list_for_type(resources, resource_type, &list, &count); + + Vector variables; + for (size_t i = 0; i < count; ++i) { + if (spvc_compiler_has_decoration(compiler, list[i].id, SpvDecorationBuiltIn)) { + continue; + } + + InterfaceVariable var; + var.name = list[i].name; + var.location = spvc_compiler_get_decoration(compiler, list[i].id, SpvDecorationLocation); + variables.push_back(var); } + std::sort(variables.begin(), variables.end()); + return variables; } - } - SPVC_CHK_RETURN - } - const SpvcMetadata& SpvcSession::GetMetadata() const { - return metadata; - } + spvc_result SpvcSession::Compile(const char** result) { + SPVC_CHK_INIT + SPVC_CHK_RESULT(spvc_compiler_compile(compiler, result)); + SPVC_CHK_RESULT(ParseMetaData()); + SPVC_CHK_RETURN + } - const char* SpvcSession::GetLastErrorString() const { - return spvc_context_get_last_error_string(context); - } + spvc_result SpvcSession::ParseMetaData() { + SPVC_CHK_INIT - SpvcSession::~SpvcSession() { spvc_context_destroy(context); } -} -} -} + metadata = SpvcMetadata(); + + const spvc_reflected_resource* list = nullptr; + size_t count = 0; + + SPVC_CHK_RESULT(spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_UNIFORM_BUFFER, + &list, &count);) + for (size_t i = 0; i < count; ++i) { + if (spvc_compiler_has_decoration(compiler, list[i].id, SpvDecorationBuiltIn)) { + continue; + } + + if (strcmp(list[i].name, GLOBAL_UBO_NAME) == 0) { + spvc_type type = spvc_compiler_get_type_handle(compiler, list[i].base_type_id); + size_t num_members = spvc_type_get_num_member_types(type); + for (size_t j = 0; j < num_members; ++j) { + const char* memberName = spvc_compiler_get_member_name(compiler, list[i].base_type_id, j); + + unsigned memberOffset = 0; + SPVC_CHK_RESULT(spvc_compiler_type_struct_member_offset(compiler, type, j, &memberOffset);) + metadata.plainUniformOffsetsInUBO[memberName] = memberOffset; + } + } + } + SPVC_CHK_RETURN + } + + const SpvcMetadata& SpvcSession::GetMetadata() const { + return metadata; + } + + const char* SpvcSession::GetLastErrorString() const { + return spvc_context_get_last_error_string(context); + } + + SpvcSession::~SpvcSession() { + spvc_context_destroy(context); + } + } // namespace ShaderTranspiler + } // namespace MG_Util +} // namespace MobileGL diff --git a/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.h b/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.h index 2d3a3f1f..6c1442bd 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.h +++ b/MobileGL/MG_Util/ShaderTranspiler/SpvcSession.h @@ -1,69 +1,59 @@ -// -// Created by Swung0x48 on 2025/8/7. -// - -#ifndef SPVCSESSION_H -#define SPVCSESSION_H - #pragma once +#include +#include "Types.h" -#define SPVC_CHK_INIT \ - auto __r = SPVC_SUCCESS; +#define SPVC_CHK_INIT auto __r = SPVC_SUCCESS; -#define SPVC_CHK_RESULT(res) \ - __r = res; \ - if (__r != SPVC_SUCCESS) { \ - return __r; \ +#define SPVC_CHK_RESULT(res) \ + __r = res; \ + if (__r != SPVC_SUCCESS) { \ + return __r; \ } -#define SPVC_CHK_RETURN \ - return __r; +#define SPVC_CHK_RETURN return __r; namespace MobileGL { -namespace MG_Util { -namespace ShaderTranspiler { - struct SpvcMetadata { - UnorderedMap plainUniformOffsetsInUBO; - }; + namespace MG_Util { + namespace ShaderTranspiler { + struct SpvcMetadata { + UnorderedMap plainUniformOffsetsInUBO; + }; - class SpvcSession { - public: - SpvcSession() {} + class SpvcSession { + public: + SpvcSession() {} - explicit SpvcSession(const Vector& spirv); + explicit SpvcSession(const Vector& spirv); - SpvcSession(SpvcSession&) = delete; + SpvcSession(SpvcSession&) = delete; - SpvcSession(SpvcSession&& that); + SpvcSession(SpvcSession&& that); - ~SpvcSession(); + ~SpvcSession(); - SpvcSession& operator=(SpvcSession& session) = delete; + SpvcSession& operator=(SpvcSession& session) = delete; - SpvcSession& operator=(SpvcSession&& that); + SpvcSession& operator=(SpvcSession&& that); - spvc_result CreateOptions(spvc_compiler_options *options); - spvc_result SetOptions(spvc_compiler_options options); - Vector GetShaderInterface(spvc_resource_type resource_type) const; - spvc_result Compile(const char** result); - const SpvcMetadata& GetMetadata() const; - const char* GetLastErrorString() const; + spvc_result CreateOptions(spvc_compiler_options* options); + spvc_result SetOptions(spvc_compiler_options options); + Vector GetShaderInterface(spvc_resource_type resource_type) const; + spvc_result Compile(const char** result); + const SpvcMetadata& GetMetadata() const; + const char* GetLastErrorString() const; - private: - // Should be called once, and only once, for every SPIR-V binary - spvc_result ParseMetaData(); + private: + // Should be called once, and only once, for every SPIR-V binary + spvc_result ParseMetaData(); - spvc_context context = nullptr; - spvc_parsed_ir ir = nullptr; - spvc_compiler compiler = nullptr; - spvc_compiler_options compiler_options = nullptr; - spvc_resources resources = nullptr; + spvc_context context = nullptr; + spvc_parsed_ir ir = nullptr; + spvc_compiler compiler = nullptr; + spvc_compiler_options compiler_options = nullptr; + spvc_resources resources = nullptr; - SpvcMetadata metadata; - }; -} -} -} - - -#endif //SPVCSESSION_H + SpvcMetadata metadata; + }; + } // namespace ShaderTranspiler + } // namespace MG_Util +} // namespace MobileGL \ No newline at end of file diff --git a/MobileGL/MG_Util/ShaderTranspiler/Types.h b/MobileGL/MG_Util/ShaderTranspiler/Types.h index acb37236..98258eff 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/Types.h +++ b/MobileGL/MG_Util/ShaderTranspiler/Types.h @@ -1,5 +1,5 @@ #pragma once -#include "MG_Util/Debug/Log.h" +#include namespace MobileGL { namespace MG_Util { @@ -10,7 +10,6 @@ namespace MobileGL { enum class ShaderCompileBits : Uint { EmitDiscardAsDemote = 1 << 0, - }; struct ShaderAttrib { @@ -36,9 +35,7 @@ namespace MobileGL { std::string name; uint32_t location; - bool operator<(const InterfaceVariable& other) const { - return location < other.location; - } + bool operator<(const InterfaceVariable& other) const { return location < other.location; } bool operator==(const InterfaceVariable& other) const { return location == other.location && name == other.name; @@ -55,8 +52,8 @@ namespace MobileGL { // // spvc_context_create(&context); // spvc_context_parse_spirv(context, p_spirv, word_count, &ir); - // spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP, &compiler); - // spvc_compiler_create_shader_resources(compiler, &resources); + // spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP, + // &compiler); spvc_compiler_create_shader_resources(compiler, &resources); // } // // SpvcSession(SpvcSession&) = delete; @@ -110,7 +107,8 @@ namespace MobileGL { // size_t num_members = spvc_type_get_num_member_types(type); // printf("uniform %s {\n", var.name.c_str()); // for (size_t j = 0; j < num_members; ++j) { - // const char *memberName = spvc_compiler_get_member_name(compiler, list[i].base_type_id, j); + // const char *memberName = spvc_compiler_get_member_name(compiler, + // list[i].base_type_id, j); // // auto memberTypeId = spvc_type_get_member_type(type, j); // // auto memberType = spvc_compiler_get_type_handle(compiler, memberTypeId); // @@ -144,22 +142,22 @@ namespace MobileGL { inline static EShLanguage GetEShLanguageByShaderType(GLenum shaderType) { switch (shaderType) { - case GL_VERTEX_SHADER: - return EShLanguage::EShLangVertex; - case GL_FRAGMENT_SHADER: - return EShLanguage::EShLangFragment; - case GL_COMPUTE_SHADER: - return EShLanguage::EShLangCompute; - case GL_TESS_CONTROL_SHADER: - return EShLanguage::EShLangTessControl; - case GL_TESS_EVALUATION_SHADER: - return EShLanguage::EShLangTessEvaluation; - case GL_GEOMETRY_SHADER: - return EShLanguage::EShLangGeometry; - default: - return EShLanguage::EShLangCount; + case GL_VERTEX_SHADER: + return EShLanguage::EShLangVertex; + case GL_FRAGMENT_SHADER: + return EShLanguage::EShLangFragment; + case GL_COMPUTE_SHADER: + return EShLanguage::EShLangCompute; + case GL_TESS_CONTROL_SHADER: + return EShLanguage::EShLangTessControl; + case GL_TESS_EVALUATION_SHADER: + return EShLanguage::EShLangTessEvaluation; + case GL_GEOMETRY_SHADER: + return EShLanguage::EShLangGeometry; + default: + return EShLanguage::EShLangCount; } } - } - } -} + } // namespace ShaderTranspiler + } // namespace MG_Util +} // namespace MobileGL diff --git a/MobileGL/MG_Util/Types.h b/MobileGL/MG_Util/Types.h index c10e5a0c..94dbf9df 100644 --- a/MobileGL/MG_Util/Types.h +++ b/MobileGL/MG_Util/Types.h @@ -1,271 +1,239 @@ #pragma once +#include +#include "GLExtensions.h" + #define GL_UNKNOWN_MGL 0 -#define THROW_EXCEPTION(msg) \ - throw std::runtime_error(msg); +#define THROW_EXCEPTION(msg) throw std::runtime_error(msg) -#define THROW_UNIMPL_EXCEPTION \ - THROW_EXCEPTION("Unimplemented function called!") +#define THROW_UNIMPL_EXCEPTION THROW_EXCEPTION("Unimplemented function called!") namespace MobileGL { - using String = std::string; - using StringStream = std::stringstream; - using Int8 = int8_t; - using Uint8 = uint8_t; - using Int16 = int16_t; - using Uint16 = uint16_t; - using Int32 = int32_t; - using Uint32 = uint32_t; - using Int = Int32; - using Uint = Uint32; - using Int64 = int64_t; - using Uint64 = uint64_t; - using Bool = bool; - using Float = float; - using Double = double; - using StringView = std::string_view; - template - using Vector = std::vector; - template - using Pair = std::pair; - template - using SharedPtr = std::shared_ptr; - template - using UniquePtr = std::unique_ptr; - template - inline SharedPtr MakeShared(Args&&... args) { - return std::make_shared(std::forward(args)...); - } - template - inline UniquePtr MakeUnique(Args&&... args) { - return std::make_unique(std::forward(args)...); - } - using SizeT = std::size_t; - template - using Array = std::array; - template - using UnorderedMap = std::unordered_map; - template - inline constexpr std::remove_reference_t&& Move(T&& t) noexcept { - return static_cast&&>(t); - } - template - inline constexpr void Copy(const T* src, T* dest, SizeT count) { - std::copy(src, src + count, dest); - } - template - constexpr auto ToArray(Ts&&... elems) { - using E = std::common_type_t; - return std::array{ { std::forward(elems)... } }; - } - class RuntimeError : public std::runtime_error { - public: - using std::runtime_error::runtime_error; - }; - template - using Optional = std::optional; - using NulloptT = std::nullopt_t; - const NulloptT Nullopt = std::nullopt; + using String = std::string; + using StringStream = std::stringstream; + using Int8 = int8_t; + using Uint8 = uint8_t; + using Int16 = int16_t; + using Uint16 = uint16_t; + using Int32 = int32_t; + using Uint32 = uint32_t; + using Int = Int32; + using Uint = Uint32; + using Int64 = int64_t; + using Uint64 = uint64_t; + using Bool = bool; + using Float = float; + using Double = double; + using StringView = std::string_view; + template + using Vector = std::vector; + template + using Pair = std::pair; + template + using SharedPtr = std::shared_ptr; + template + using UniquePtr = std::unique_ptr; + template + inline SharedPtr MakeShared(Args&&... args) { + return std::make_shared(std::forward(args)...); + } + template + inline UniquePtr MakeUnique(Args&&... args) { + return std::make_unique(std::forward(args)...); + } + using SizeT = std::size_t; + template + using Array = std::array; + template + using UnorderedMap = std::unordered_map; + template + inline constexpr std::remove_reference_t&& Move(T&& t) noexcept { + return static_cast&&>(t); + } + template + inline constexpr void Copy(const T* src, T* dest, SizeT count) { + std::copy(src, src + count, dest); + } + template + constexpr auto ToArray(Ts&&... elems) { + using E = std::common_type_t; + return std::array{{std::forward(elems)...}}; + } + class RuntimeError : public std::runtime_error { + public: + using std::runtime_error::runtime_error; + }; + template + using Optional = std::optional; + using NulloptT = std::nullopt_t; + const NulloptT Nullopt = std::nullopt; using std::format; - using Data = Vector; - struct DataPtr { - void* data; - SizeT size; - }; + using Data = Vector; + struct DataPtr { + void* data; + SizeT size; + }; - enum class DataType { - Int8, - Uint8, - Int16, - Uint16, - Int32, - Uint32, - Float16, - Float32, - Float64, - Fixed32, - Unknown = -1 - }; + enum class DataType { + Int8, + Uint8, + Int16, + Uint16, + Int32, + Uint32, + Float16, + Float32, + Float64, + Fixed32, + Unknown = -1 + }; - // represents a range of [start, end) - struct Range1D { - SizeT start = 0; - SizeT end = 0; + // represents a range of [start, end) + struct Range1D { + SizeT start = 0; + SizeT end = 0; - void Update(SizeT newStart, SizeT newEnd) { - assert(newStart <= newEnd); - start = newStart; - end = newEnd; - } + void Update(SizeT newStart, SizeT newEnd) { + assert(newStart <= newEnd); + start = newStart; + end = newEnd; + } - void UnionUpdate(SizeT newStart, SizeT newEnd) { - assert(newStart <= newEnd); - if (start == end) { - Update(newStart, newEnd); - return; - } - start = std::min(start, newStart); - end = std::max(end, newEnd); - } + void UnionUpdate(SizeT newStart, SizeT newEnd) { + assert(newStart <= newEnd); + if (start == end) { + Update(newStart, newEnd); + return; + } + start = std::min(start, newStart); + end = std::max(end, newEnd); + } - void IntersectionUpdate(SizeT newStart, SizeT newEnd) { - assert(newStart <= newEnd); - start = std::max(start, newStart); - end = std::min(end, newEnd); - assert(start <= end); - } - }; + void IntersectionUpdate(SizeT newStart, SizeT newEnd) { + assert(newStart <= newEnd); + start = std::max(start, newStart); + end = std::min(end, newEnd); + assert(start <= end); + } + }; - template - class BindingSlot { - public: - using TargetEnum = typename ObjectType::TargetEnum; + template + class BindingSlot { + public: + using TargetEnum = typename ObjectType::TargetEnum; - BindingSlot(): m_target((TargetEnum)0), m_boundObject(nullptr) {} + BindingSlot() : m_target((TargetEnum)0), m_boundObject(nullptr) {} - explicit BindingSlot(TargetEnum target) - : m_target(target), m_boundObject(nullptr) { - } + explicit BindingSlot(TargetEnum target) : m_target(target), m_boundObject(nullptr) {} - void Bind(SharedPtr object) { - m_boundObject = object; - } + void Bind(SharedPtr object) { m_boundObject = object; } - SharedPtr GetBoundObject() const { - return m_boundObject; - } + SharedPtr GetBoundObject() const { return m_boundObject; } - TargetEnum GetTarget() const { - return m_target; - } + TargetEnum GetTarget() const { return m_target; } - private: - TargetEnum m_target; - SharedPtr m_boundObject; - }; + private: + TargetEnum m_target; + SharedPtr m_boundObject; + }; - struct Version { - Int Major; - Int Minor; - Int Patch; - Optional Suffix; + struct Version { + Int Major; + Int Minor; + Int Patch; + Optional Suffix; - String toString(Pair dots = { true, true }, Bool useSuffix = true) const { - StringStream result; - result << Major << (dots.first ? "." : "") << Minor << (dots.second ? "." : "") << Patch << - (useSuffix && Suffix.has_value() ? *Suffix : ""); - return result.str(); - } - }; + String toString(Pair dots = {true, true}, Bool useSuffix = true) const { + StringStream result; + result << Major << (dots.first ? "." : "") << Minor << (dots.second ? "." : "") << Patch + << (useSuffix && Suffix.has_value() ? *Suffix : ""); + return result.str(); + } + }; - struct BackendCap { + struct BackendCap {}; - }; + struct GLInfo { + Version TargetGLVersion; + Version TargetGLSLVersion; + Vector Extensions; + Bool IsCompatibilityProfile; + }; - struct GLInfo { - Version TargetGLVersion; - Version TargetGLSLVersion; - Vector Extensions; - Bool IsCompatibilityProfile; - }; + struct RendererInfo { + String RendererName; + String BackendName; + Optional ExtraVendor; + GLInfo RendererGLInfo; + BackendCap BackendCapability; + }; - struct RendererInfo { - String RendererName; - String BackendName; - Optional ExtraVendor; - GLInfo RendererGLInfo; - BackendCap BackendCapability; - }; + template , std::underlying_type_t>> + class Flags { + public: + Flags() = default; - template , std::underlying_type_t> - > - class Flags { - public: - Flags() = default; + Flags(Bit b) : flags(static_cast(b)) {} - Flags(Bit b): flags(static_cast(b)) {} + Flags(typename Underlying::type b) : flags(b) {} - Flags(typename Underlying::type b): flags(b) {} + // Flags - Bit + Flags operator|(const Bit b) const { return Flags(flags | static_cast(b)); } - // Flags - Bit - Flags operator|(const Bit b) const { - return Flags(flags | static_cast(b)); - } + Flags operator&(const Bit b) const { return Flags(flags & static_cast(b)); } - Flags operator&(const Bit b) const { - return Flags(flags & static_cast(b)); - } + Flags& operator|=(const Bit b) { + flags |= static_cast(b); + return *this; + } - Flags& operator|=(const Bit b) { - flags |= static_cast(b); - return *this; - } + Flags& operator&=(const Bit b) { + flags &= static_cast(b); + return *this; + } - Flags& operator&=(const Bit b) { - flags &= static_cast(b); - return *this; - } + bool operator==(const Bit b) const { return flags == static_cast(b); } - bool operator==(const Bit b) const { - return flags == static_cast(b); - } + bool operator!=(const Bit b) const { return !(*this == b); } - bool operator!=(const Bit b) const { - return !(*this == b); - } + // Flags - Flags + Flags operator|(const Flags b) const { return Flags(flags | b.flags); } - // Flags - Flags - Flags operator|(const Flags b) const { - return Flags(flags | b.flags); - } + Flags operator&(const Flags b) const { return Flags(flags & b.flags); } - Flags operator&(const Flags b) const { - return Flags(flags & b.flags); - } + Flags& operator|=(Flags b) { + flags |= b.flags; + return *this; + } - Flags& operator|=(Flags b) { - flags |= b.flags; - return *this; - } + Flags& operator&=(Flags b) { + flags &= b.flags; + return *this; + } - Flags& operator&=(Flags b) { - flags &= b.flags; - return *this; - } + bool operator==(const Flags b) const { return flags == b.flags; } - bool operator==(const Flags b) const { - return flags == b.flags; - } + bool operator!=(const Flags b) const { return !(*this == b); } - bool operator!=(const Flags b) const { - return !(*this == b); - } + operator bool() const { return Any(); } - operator bool() const { - return Any(); - } + private: + bool Any() const { return static_cast(flags) != 0; } - private: - bool Any() const { - return static_cast(flags) != 0; - } + typename Underlying::type flags = 0; + }; - typename Underlying::type flags = 0; - }; + template >> + Flags operator|(const Bit lhs, const Bit rhs) { + return Flags(lhs) | rhs; + } - template>> - Flags operator|(const Bit lhs, const Bit rhs) { - return Flags(lhs) | rhs; - } - - template>> - Flags operator&(const Bit lhs, const Bit rhs) { - return Flags(lhs) & rhs; - } -} - -#include "../MG_Util/ShaderTranspiler/Types.h" + template >> + Flags operator&(const Bit lhs, const Bit rhs) { + return Flags(lhs) & rhs; + } +} // namespace MobileGL \ No newline at end of file