diff --git a/scripts/build.bat b/scripts/build.bat new file mode 100644 index 0000000..f9f6074 --- /dev/null +++ b/scripts/build.bat @@ -0,0 +1,19 @@ +@echo off +REM This script expects to be run from the parent directory +REM ex. scripts/build.bat + +IF not exist build/ ( + echo This script needs to be run from the directory above build/ + goto END +) + + +IF "%~1" == "r" ( +cmake --build build/ --target ALL_BUILD --config Release +xcopy /y test_data build\Release\test_data\ +) ELSE ( +cmake --build build/ --target ALL_BUILD --config Debug +xcopy /y test_data build\Debug\test_data\ +) + +:END \ No newline at end of file diff --git a/scripts/clean.bat b/scripts/clean.bat new file mode 100644 index 0000000..9a786e4 --- /dev/null +++ b/scripts/clean.bat @@ -0,0 +1,13 @@ + +@echo off + +IF not exist build/ ( + echo This script needs to be run from the directory above build/ + goto END +) + +echo Removing the build directory +del /s /q build +rd /s /q build + +:END \ No newline at end of file diff --git a/scripts/cmconfig.bat b/scripts/cmconfig.bat index 0c5d7e7..8901304 100644 --- a/scripts/cmconfig.bat +++ b/scripts/cmconfig.bat @@ -3,4 +3,4 @@ REM This script expects to be run from the parent directory REM ex. scripts/cmconfig.bat @echo on -cmake -DGLFW_BUILD_DOCS=OFF -B build/ -S . \ No newline at end of file +cmake -DGLFW_BUILD_DOCS=OFF -B build/ -S . -G "Visual Studio 16 2019" -A x64 \ No newline at end of file diff --git a/src/core/Version.cpp b/src/core/Version.cpp new file mode 100644 index 0000000..1391b91 --- /dev/null +++ b/src/core/Version.cpp @@ -0,0 +1,79 @@ +/****************************************************************************** +* File - Version.cpp +* Author - Joey Pollack +* Date - 2020/03/06 (y/m/d) +* Mod Date - 2021/08/31 (y/m/d) +* Description - Defines the current version of the engine and provides +* methods to work with the Version struct. Using Semantic +* Versioning https://semver.org/ +* +******************************************************************************/ + +#include "Version.h" +#include +#include + +namespace lunarium +{ + Version Version::GetVersion() + { + return { Lunarium_VERSION_MAJOR, Lunarium_VERSION_MINOR, Lunarium_VERSION_PATCH }; + } + + OpRes Version::StringToVersion(const char * str, Version & v) + { + std::string part = ""; + const char* pos = str; + + // Major version + while (*pos != '.') + { + if (*pos == 0) + { + return OpRes::Fail("StringToVersion -- str was malformed"); + } + + part += *pos; + pos++; + } + + v.Major = atoi(part.c_str()); + + + // Minor version + part = ""; + pos++; + while (*pos != '.') + { + if (*pos == 0) + { + return OpRes::Fail("StringToVersion -- str was malformed"); + } + + part += *pos; + pos++; + } + + v.Minor = atoi(part.c_str()); + + // Patch version + part = ""; + pos++; + while (*pos != 0) + { + part += *pos; + pos++; + } + + v.Patch = atoi(part.c_str()); + + return OpRes::OK(); + } + + std::string Version::ToString() + { + std::ostringstream oss; + oss << Major << "." << Minor << "." << Patch; + return oss.str(); + } +} \ No newline at end of file diff --git a/src/core/Version.h b/src/core/Version.h new file mode 100644 index 0000000..e11a821 --- /dev/null +++ b/src/core/Version.h @@ -0,0 +1,34 @@ +/****************************************************************************** +* File - Version.h +* Author - Joey Pollack +* Date - 2020/03/06 (y/m/d) +* Mod Date - 2021/08/31 (y/m/d) +* Description - Defines the current version of the engine and provides +* methods to work with the Version struct. Using Semantic +* Versioning https://semver.org/ +* +******************************************************************************/ + +#ifndef _VERSION_H_ +#define _VERSION_H_ + +#include + +#include + +namespace lunarium +{ + struct Version + { + int Major; + int Minor; + int Patch; + + static Version GetVersion(); + static OpRes StringToVersion(const char* str, Version& v); + std::string ToString(); + }; + +} + +#endif // _VERSION_H_ \ No newline at end of file diff --git a/src/core/core.cpp b/src/core/core.cpp index 682ae06..ca58fe9 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -38,8 +38,23 @@ namespace lunarium mpInstance = nullptr; } + void core::Initialize(const char* args, std::vector& listeners) + { + mpLog = Logger::GetInstance(); + + for (unsigned i = 0; i < listeners.size(); i++) + { + mpLog->AddListener(listeners[i]); + } + } + bool core::IsInit() const { return mbIsInit; } + + const State& core::GetState() const + { + return mState; + } } \ No newline at end of file diff --git a/src/core/core.h b/src/core/core.h index 1287069..b05b55b 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -10,6 +10,7 @@ #define CORE_H_ #include "state.h" +#include namespace lunarium { @@ -19,14 +20,16 @@ namespace lunarium static core& GetInstance(); static void Shutdown(); - void Initialize(const char* args); + void Initialize(const char* args, std::vector& listeners); bool IsInit() const; + const State& GetState() const; private: // DATA static core* mpInstance; bool mbIsInit; State mState; + Logger* mpLog; private: // HIDDEN METHODS diff --git a/src/test_main.cpp b/src/test_main.cpp index 75670b9..fbd17cd 100644 --- a/src/test_main.cpp +++ b/src/test_main.cpp @@ -17,6 +17,7 @@ extern "C" #include } +//#include // the following can also be but it results in // an intellisense error @@ -24,6 +25,11 @@ extern "C" int main(int argc, char** argv) { + // char pBuf[256]; + // size_t len = sizeof(pBuf); + // int bytes = GetModuleFileNameA(NULL, pBuf, len); + // std::cout < -namespace Lunarium +namespace lunarium { class HighResTimer diff --git a/src/utils/Logger.cpp b/src/utils/Logger.cpp index f757ad8..76ece25 100644 --- a/src/utils/Logger.cpp +++ b/src/utils/Logger.cpp @@ -16,7 +16,7 @@ #include #include -namespace Lunarium +namespace lunarium { //namespace LogLevel //{ diff --git a/src/utils/Logger.h b/src/utils/Logger.h index 1acde22..fd7ffd6 100644 --- a/src/utils/Logger.h +++ b/src/utils/Logger.h @@ -24,7 +24,7 @@ // Conflict with a region flag in wingdi.h #undef ERROR -namespace Lunarium +namespace lunarium { namespace LogLevel {