Skip to content

Commit

Permalink
Rework configuration header and move it outside the Base directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamyCecil committed Feb 15, 2024
1 parent 693a3d1 commit 230eed6
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 139 deletions.
128 changes: 0 additions & 128 deletions Sources/Engine/Base/Config.h

This file was deleted.

4 changes: 2 additions & 2 deletions Sources/Engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

// [Cecil] Configuration of specific platform macros
#include <Engine/Base/Config.h>
// [Cecil] Serious Engine configuration for a specific platform
#include <Engine/SE_Config.h>

// set this to 1 to enable checks whether somethig is deleted while iterating some array/container
#define CHECKARRAYLOCKING 0
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Engine.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@
<ClInclude Include="Base\ByteSwap.h" />
<ClInclude Include="Base\Changeable.h" />
<ClInclude Include="Base\ChangeableRT.h" />
<ClInclude Include="Base\Config.h" />
<ClInclude Include="Base\Console.h" />
<ClInclude Include="Base\Console_internal.h" />
<ClInclude Include="Base\CRC.h" />
Expand Down Expand Up @@ -714,6 +713,7 @@
<ClInclude Include="OS\OS.h" />
<ClInclude Include="OS\PlatformSpecific.h" />
<ClInclude Include="OS\PlatformTypes.h" />
<ClInclude Include="SE_Config.h" />
<ClInclude Include="Sound\al_functions.h" />
<ClInclude Include="Sound\DSound.h" />
<ClInclude Include="Sound\eax.h" />
Expand Down
6 changes: 3 additions & 3 deletions Sources/Engine/Engine.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,6 @@
<ClInclude Include="Sound\ov_functions.h">
<Filter>Header Files\Sound Headers</Filter>
</ClInclude>
<ClInclude Include="Base\Config.h">
<Filter>Header Files\Base Headers</Filter>
</ClInclude>
<ClInclude Include="Base\ByteSwap.h">
<Filter>Header Files\Base Headers</Filter>
</ClInclude>
Expand Down Expand Up @@ -1356,6 +1353,9 @@
<ClInclude Include="Sound\SoundAPI.h">
<Filter>Header Files\Sound Headers</Filter>
</ClInclude>
<ClInclude Include="SE_Config.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="Base\CTString.inl">
Expand Down
4 changes: 2 additions & 2 deletions Sources/Engine/Graphics/Gfx_OpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static void FailFunction_t(const char *strName) {
}

// [Cecil] Wrappers for non-existent GLEW methods
#if SE1_GLEW && SE1_USE_GLEW
#if SE1_GLEW >= 2

static HINSTANCE _hiForWGL;

Expand Down Expand Up @@ -195,7 +195,7 @@ static void OGL_SetFunctionPointers_t(HINSTANCE hiOGL)
{
const char *strName;
// get gl function pointers
#if SE1_GLEW && SE1_USE_GLEW
#if SE1_GLEW >= 2
_hiForWGL = hiOGL;

#define DLLFUNCTION(dll, output, name, inputs, params, required) \
Expand Down
6 changes: 3 additions & 3 deletions Sources/Engine/Light/LayerMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static ULONG *_pulLayer;

// [Cecil] Separate methods to avoid code duplication
static __forceinline void PrepareColorMMX(__m64 &mm7, const ULONG ulLightRGB) {
#if SE1_MMXINTOPT
#if SE1_USE_MMXINT
__m64 tmp_mm0;

mm7.m64_u64 = 0;
Expand Down Expand Up @@ -303,7 +303,7 @@ static __forceinline void MixPixelMMX(ULONG &ulPixel, const SLONG slIntensity, c
// Mix underlaying pixels with the calculated one
__m64 tmp_mm6;

#if SE1_MMXINTOPT
#if SE1_USE_MMXINT
tmp_mm6.m64_u64 = 0;
tmp_mm6 = _mm_cvtsi32_si64(slIntensity);
tmp_mm6 = _mm_unpacklo_pi16(tmp_mm6, tmp_mm6); // punpcklwd
Expand All @@ -328,7 +328,7 @@ static __forceinline void MixPixelMMX(ULONG &ulPixel, const SLONG slIntensity, c
// Add light pixel to underlying pixel
__m64 tmp_mm5;

#if SE1_MMXINTOPT
#if SE1_USE_MMXINT
// [Cecil] Old compilers don't like inline braces
const __m64 mmZero = { 0L };

Expand Down
116 changes: 116 additions & 0 deletions Sources/Engine/SE_Config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/* Copyright (c) 2023-2024 Dreamy Cecil
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */

// [Cecil] This header determines used platform and operating system and defines useful macro switches
#ifndef SE_INCL_PLATFORM_CONFIG_H
#define SE_INCL_PLATFORM_CONFIG_H

// *****************************************************************
// SYSTEM AND ARCHITECTURE TYPES ----- CAN BE EXPANDED WITH NEW ONES
// *****************************************************************

// Processor architectures (SE1_PLATFORM)
#define PLATFORM_X86 0
#define PLATFORM_X64 1

// Operating systems (SE1_SYSTEM)
#define OS_WINDOWS 0
#define OS_UNIX 1

// ********************************************************************
// AUTOMATIC DETECTION OF THE CURRENT BUILD SYSTEM AND OPERATING SYSTEM
// ********************************************************************

#if defined(__x86_64__) || defined(_M_X64)
#define SE1_PLATFORM PLATFORM_X64
#elif defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
#define SE1_PLATFORM PLATFORM_X86
#else
#error Architecture unsupported!
#endif

#if defined(_MSC_VER) || defined(_WIN32) || defined(_WIN64)
#define SE1_SYSTEM OS_WINDOWS
#elif defined(__GNUC__) || defined(__linux__)
#define SE1_SYSTEM OS_UNIX
#else
#error Operating system unsupported!
#endif

// Automatic switches for convenience

#define SE1_32BIT (SE1_PLATFORM == PLATFORM_X86) // Is building under 32-bit platform?
#define SE1_64BIT (SE1_PLATFORM == PLATFORM_X64) // Is building under 64-bit platform?

#define SE1_WIN (SE1_SYSTEM == OS_WINDOWS) // Is building under Windows OS?
#define SE1_UNIX (SE1_SYSTEM == OS_UNIX) // Is building under Unix OS?

// Automatic compiler switches

#if defined(_MSC_VER) && _MSC_VER < 1800
#define SE1_INCOMPLETE_CPP11 1 // Using a compiler with incomplete/no support of C++11
#else
#define SE1_INCOMPLETE_CPP11 0 // Using a compiler with complete support of C++11
#endif

#if defined(_MSC_VER) && _MSC_VER < 1600
#define SE1_OLD_COMPILER 1 // Using an old compiler from Visual C++ 6.0
#else
#define SE1_OLD_COMPILER 0 // Using some new compiler
#endif

// **************************************************************************
// FEATURE SWITCHES ----- CAN BE TOGGLED OR REDEFINED FOR BUILD CUSTOMIZATION
// **************************************************************************

#ifndef SE1_ASMOPT
#define SE1_ASMOPT 1 // Allow use of inline assembly code (0 - No; 1 - Yes)
#endif
#ifndef SE1_DITHERBITMAP
#define SE1_DITHERBITMAP 1 // Enable texture dithering (0 - Disabled; 1 - Enabled)
#endif
#ifndef SE1_MMXINTOPT
#define SE1_MMXINTOPT 1 // Use MMX intrinsics for light calculations (0 - No; 1 - Yes)
#endif
#ifndef SE1_TRUFORM
#define SE1_TRUFORM 0 // Truform support (0 - Disabled; 1 - Enabled)
#endif
#ifndef SE1_GLEW
#define SE1_GLEW 0 // GLEW support (0 - None; 1 - Available; 2 - Replace manual hooking of OpenGL in the engine)
#endif
#ifndef SE1_SDL
#define SE1_SDL 0 // SDL support (0 - None; 1 - Available)
#endif
#ifndef SE1_USE_SDL
#define SE1_USE_SDL 0 // Prefer SDL over Windows API (0 - No; 1 - Yes)
#endif

// Automatic overrides for non-Windows platforms

#if !SE1_WIN
#undef SE1_SDL
#undef SE1_USE_SDL

#define SE1_SDL 1 // SDL should always be available
#define SE1_USE_SDL 1 // SDL should always be preferred over Windows API
#endif

// Automatic switches for convenience

#define SE1_PREFER_SDL (SE1_SDL && SE1_USE_SDL) // Prefer SDL over Windows API?
#define SE1_USE_ASM (SE1_WIN && SE1_32BIT && SE1_ASMOPT) // Prioritize inline assembly under a traditional platform?
#define SE1_USE_MMXINT (!SE1_WIN || (SE1_32BIT && SE1_MMXINTOPT)) // Prioritize MMX intrinsic functions?

#endif // include-once check

0 comments on commit 230eed6

Please sign in to comment.