Skip to content

Commit

Permalink
[Misc] Use '#if'-directive instead of '#ifdef' for LLGL_BUILD_STATIC_…
Browse files Browse the repository at this point in the history
…LIB.
  • Loading branch information
LukasBanana committed Sep 29, 2024
1 parent 648c75f commit ed12b28
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.
6 changes: 3 additions & 3 deletions examples/Cpp/Fonts/Example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define FONT_COURIER_NEW_16 ( 0 )
#define FONT_LUCIDA_CONSOLE_32 ( 1 )

#ifdef LLGL_OS_IOS
#if defined LLGL_OS_IOS || defined LLGL_OS_ANDROID
# define SELECTED_FONT ( FONT_LUCIDA_CONSOLE_32 )
# define FONTS_TEXT_MARGIN ( 25 )
# define FONTS_PARAGRAPH_MARGIN ( 140 )
Expand All @@ -38,7 +38,7 @@ class Example_Fonts : public ExampleBase
LLGL::ResourceHeap* resourceHeap = nullptr;

// Constant buffer structure
struct Settings
struct alignas(16) Settings
{
Gs::Matrix4f wvpMatrix;
float glyphTextureInvSize[2];
Expand All @@ -47,7 +47,7 @@ class Example_Fonts : public ExampleBase
settings;

// Vertex for a font glyph
struct Vertex
struct alignas(4) Vertex
{
std::int16_t position[2];
std::int16_t texCoord[2];
Expand Down
6 changes: 4 additions & 2 deletions sources/Renderer/RenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@ RenderSystemPtr RenderSystem::Load(const RenderSystemDescriptor& renderSystemDes

#endif

#ifdef LLGL_BUILD_STATIC_LIB
#if LLGL_BUILD_STATIC_LIB

/* Allocate render system */
RenderSystemPtr renderSystem{ StaticModules::AllocRenderSystem(renderSystemDesc) };
if (renderSystem == nullptr)
return ReportException(report, "failed to allocate render system from module: %s", renderSystemDesc.moduleName.c_str());

if (renderSystemDesc.debugger != nullptr)
{
#ifdef LLGL_ENABLE_DEBUG_LAYER
#if LLGL_ENABLE_DEBUG_LAYER

/* Create debug layer render system */
renderSystem = RenderSystemPtr{ new DbgRenderSystem{ std::move(renderSystem), renderSystemDesc.debugger } };
Expand Down
2 changes: 1 addition & 1 deletion sources/Renderer/RenderSystemModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ RenderSystemPtr RenderSystemModule::AllocRenderSystem(const RenderSystemDescript
return ReportException(outReport, "failed to load 'LLGL_RenderSystem_Alloc' procedure from module: %s", filename_.c_str());

auto* renderSystem = reinterpret_cast<RenderSystem*>(allocProc_(&renderSystemDesc, static_cast<int>(sizeof(renderSystemDesc))));
if (!renderSystem)
if (renderSystem == nullptr)
return ReportException(outReport, "failed to allocate render system from module: %s", filename_.c_str());

/* Check if errors where reported and the render system is unusable */
Expand Down
82 changes: 41 additions & 41 deletions sources/Renderer/StaticModuleInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt).
*/

#ifdef LLGL_BUILD_STATIC_LIB
#if LLGL_BUILD_STATIC_LIB


#include "StaticModuleInterface.h"
Expand All @@ -27,35 +27,35 @@ class RenderSystem;
extern RenderSystem* AllocRenderSystem(const LLGL::RenderSystemDescriptor*); \
}

#ifdef LLGL_BUILD_RENDERER_NULL
#if LLGL_BUILD_RENDERER_NULL
LLGL_DECLARE_STATIC_MODULE_INTERFACE(Null);
#endif

#ifdef LLGL_BUILD_RENDERER_OPENGL
#if LLGL_BUILD_RENDERER_OPENGL
LLGL_DECLARE_STATIC_MODULE_INTERFACE(OpenGL);
#endif

#ifdef LLGL_BUILD_RENDERER_OPENGLES3
#if LLGL_BUILD_RENDERER_OPENGLES3
LLGL_DECLARE_STATIC_MODULE_INTERFACE(OpenGLES3);
#endif

#ifdef LLGL_BUILD_RENDERER_WEBGL
#if LLGL_BUILD_RENDERER_WEBGL
LLGL_DECLARE_STATIC_MODULE_INTERFACE(WebGL);
#endif

#ifdef LLGL_BUILD_RENDERER_VULKAN
#if LLGL_BUILD_RENDERER_VULKAN
LLGL_DECLARE_STATIC_MODULE_INTERFACE(Vulkan);
#endif

#ifdef LLGL_BUILD_RENDERER_METAL
#if LLGL_BUILD_RENDERER_METAL
LLGL_DECLARE_STATIC_MODULE_INTERFACE(Metal);
#endif

#ifdef LLGL_BUILD_RENDERER_DIRECT3D11
#if LLGL_BUILD_RENDERER_DIRECT3D11
LLGL_DECLARE_STATIC_MODULE_INTERFACE(Direct3D11);
#endif

#ifdef LLGL_BUILD_RENDERER_DIRECT3D12
#if LLGL_BUILD_RENDERER_DIRECT3D12
LLGL_DECLARE_STATIC_MODULE_INTERFACE(Direct3D12);
#endif

Expand All @@ -68,28 +68,28 @@ std::vector<std::string> GetStaticModules()
{
return
{
#ifdef LLGL_BUILD_RENDERER_NULL
#if LLGL_BUILD_RENDERER_NULL
ModuleNull::GetModuleName(),
#endif
#ifdef LLGL_BUILD_RENDERER_OPENGL
#if LLGL_BUILD_RENDERER_OPENGL
ModuleOpenGL::GetModuleName(),
#endif
#ifdef LLGL_BUILD_RENDERER_OPENGLES3
#if LLGL_BUILD_RENDERER_OPENGLES3
ModuleOpenGLES3::GetModuleName(),
#endif
#ifdef LLGL_BUILD_RENDERER_WEBGL
#if LLGL_BUILD_RENDERER_WEBGL
ModuleWebGL::GetModuleName(),
#endif
#ifdef LLGL_BUILD_RENDERER_VULKAN
#if LLGL_BUILD_RENDERER_VULKAN
ModuleVulkan::GetModuleName(),
#endif
#ifdef LLGL_BUILD_RENDERER_METAL
#if LLGL_BUILD_RENDERER_METAL
ModuleMetal::GetModuleName(),
#endif
#ifdef LLGL_BUILD_RENDERER_DIRECT3D11
#if LLGL_BUILD_RENDERER_DIRECT3D11
ModuleDirect3D11::GetModuleName(),
#endif
#ifdef LLGL_BUILD_RENDERER_DIRECT3D12
#if LLGL_BUILD_RENDERER_DIRECT3D12
ModuleDirect3D12::GetModuleName(),
#endif
};
Expand All @@ -101,35 +101,35 @@ const char* GetRendererName(const std::string& moduleName)
if (moduleName == MODULE::GetModuleName()) \
return MODULE::GetRendererName()

#ifdef LLGL_BUILD_RENDERER_NULL
#if LLGL_BUILD_RENDERER_NULL
LLGL_GET_RENDERER_NAME(ModuleNull);
#endif

#ifdef LLGL_BUILD_RENDERER_OPENGL
#if LLGL_BUILD_RENDERER_OPENGL
LLGL_GET_RENDERER_NAME(ModuleOpenGL);
#endif

#ifdef LLGL_BUILD_RENDERER_OPENGLES3
#if LLGL_BUILD_RENDERER_OPENGLES3
LLGL_GET_RENDERER_NAME(ModuleOpenGLES3);
#endif

#ifdef LLGL_BUILD_RENDERER_WEBGL
#if LLGL_BUILD_RENDERER_WEBGL
LLGL_GET_RENDERER_NAME(ModuleWebGL);
#endif

#ifdef LLGL_BUILD_RENDERER_VULKAN
#if LLGL_BUILD_RENDERER_VULKAN
LLGL_GET_RENDERER_NAME(ModuleVulkan);
#endif

#ifdef LLGL_BUILD_RENDERER_METAL
#if LLGL_BUILD_RENDERER_METAL
LLGL_GET_RENDERER_NAME(ModuleMetal);
#endif

#ifdef LLGL_BUILD_RENDERER_DIRECT3D11
#if LLGL_BUILD_RENDERER_DIRECT3D11
LLGL_GET_RENDERER_NAME(ModuleDirect3D11);
#endif

#ifdef LLGL_BUILD_RENDERER_DIRECT3D12
#if LLGL_BUILD_RENDERER_DIRECT3D12
LLGL_GET_RENDERER_NAME(ModuleDirect3D12);
#endif

Expand All @@ -144,35 +144,35 @@ int GetRendererID(const std::string& moduleName)
if (moduleName == MODULE::GetModuleName()) \
return MODULE::GetRendererID()

#ifdef LLGL_BUILD_RENDERER_NULL
#if LLGL_BUILD_RENDERER_NULL
LLGL_GET_RENDERER_ID(ModuleNull);
#endif

#ifdef LLGL_BUILD_RENDERER_OPENGL
#if LLGL_BUILD_RENDERER_OPENGL
LLGL_GET_RENDERER_ID(ModuleOpenGL);
#endif

#ifdef LLGL_BUILD_RENDERER_OPENGLES3
#if LLGL_BUILD_RENDERER_OPENGLES3
LLGL_GET_RENDERER_ID(ModuleOpenGLES3);
#endif

#ifdef LLGL_BUILD_RENDERER_WEBGL
#if LLGL_BUILD_RENDERER_WEBGL
LLGL_GET_RENDERER_ID(ModuleWebGL);
#endif

#ifdef LLGL_BUILD_RENDERER_VULKAN
#if LLGL_BUILD_RENDERER_VULKAN
LLGL_GET_RENDERER_ID(ModuleVulkan);
#endif

#ifdef LLGL_BUILD_RENDERER_METAL
#if LLGL_BUILD_RENDERER_METAL
LLGL_GET_RENDERER_ID(ModuleMetal);
#endif

#ifdef LLGL_BUILD_RENDERER_DIRECT3D11
#if LLGL_BUILD_RENDERER_DIRECT3D11
LLGL_GET_RENDERER_ID(ModuleDirect3D11);
#endif

#ifdef LLGL_BUILD_RENDERER_DIRECT3D12
#if LLGL_BUILD_RENDERER_DIRECT3D12
LLGL_GET_RENDERER_ID(ModuleDirect3D12);
#endif

Expand All @@ -187,35 +187,35 @@ RenderSystem* AllocRenderSystem(const RenderSystemDescriptor& renderSystemDesc)
if (renderSystemDesc.moduleName == MODULE::GetModuleName()) \
return MODULE::AllocRenderSystem(&renderSystemDesc)

#ifdef LLGL_BUILD_RENDERER_NULL
#if LLGL_BUILD_RENDERER_NULL
LLGL_ALLOC_RENDER_SYSTEM(ModuleNull);
#endif

#ifdef LLGL_BUILD_RENDERER_OPENGL
#if LLGL_BUILD_RENDERER_OPENGL
LLGL_ALLOC_RENDER_SYSTEM(ModuleOpenGL);
#endif

#ifdef LLGL_BUILD_RENDERER_OPENGLES3
#if LLGL_BUILD_RENDERER_OPENGLES3
LLGL_ALLOC_RENDER_SYSTEM(ModuleOpenGLES3);
#endif

#ifdef LLGL_BUILD_RENDERER_WEBGL
#if LLGL_BUILD_RENDERER_WEBGL
LLGL_ALLOC_RENDER_SYSTEM(ModuleWebGL);
#endif

#ifdef LLGL_BUILD_RENDERER_VULKAN
#if LLGL_BUILD_RENDERER_VULKAN
LLGL_ALLOC_RENDER_SYSTEM(ModuleVulkan);
#endif

#ifdef LLGL_BUILD_RENDERER_METAL
#if LLGL_BUILD_RENDERER_METAL
LLGL_ALLOC_RENDER_SYSTEM(ModuleMetal);
#endif

#ifdef LLGL_BUILD_RENDERER_DIRECT3D11
#if LLGL_BUILD_RENDERER_DIRECT3D11
LLGL_ALLOC_RENDER_SYSTEM(ModuleDirect3D11);
#endif

#ifdef LLGL_BUILD_RENDERER_DIRECT3D12
#if LLGL_BUILD_RENDERER_DIRECT3D12
LLGL_ALLOC_RENDER_SYSTEM(ModuleDirect3D12);
#endif

Expand Down

0 comments on commit ed12b28

Please sign in to comment.