diff --git a/.gitignore b/.gitignore index 259148f..bcb2e7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,6 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app +bin/ +bin-int/ +*.sln +*.vcxproj +*.vcxproj.filters +!/vendor/** \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c933331 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "FluxEngine/vendor/spdlog"] + path = FluxEngine/vendor/spdlog + url = https://github.com/gabime/spdlog diff --git a/FluxEngine/src/Flux.h b/FluxEngine/src/Flux.h new file mode 100644 index 0000000..63b57d5 --- /dev/null +++ b/FluxEngine/src/Flux.h @@ -0,0 +1,6 @@ +#pragma once + +#include "Flux/Application.h" +#include "Flux/Log.h" + +#include "Flux/EntryPoint.h" \ No newline at end of file diff --git a/FluxEngine/src/Flux/Application.cpp b/FluxEngine/src/Flux/Application.cpp new file mode 100644 index 0000000..dc977d1 --- /dev/null +++ b/FluxEngine/src/Flux/Application.cpp @@ -0,0 +1,19 @@ +#include "Application.h" + +#include "Log.h" + +namespace Flux { + + Application::Application() + { + } + + Application::~Application() + { + } + void Application::Run() + { + FLUX_CORE_TRACE("FLUX Engine Running!"); + while (true); + } +} diff --git a/FluxEngine/src/Flux/Application.h b/FluxEngine/src/Flux/Application.h new file mode 100644 index 0000000..6e81643 --- /dev/null +++ b/FluxEngine/src/Flux/Application.h @@ -0,0 +1,18 @@ +#pragma once + +#include "Core.h" + +namespace Flux { + class FLUX_API Application + { + public: + Application(); + virtual ~Application(); + + void Run(); + }; + + Application* CreateApplication(); +} + + diff --git a/FluxEngine/src/Flux/Core.h b/FluxEngine/src/Flux/Core.h new file mode 100644 index 0000000..bec8b5b --- /dev/null +++ b/FluxEngine/src/Flux/Core.h @@ -0,0 +1,11 @@ +#pragma once + +#ifdef FLUX_PLATFORM_WINDOWS + #ifdef FLUX_BUILD_DLL + #define FLUX_API __declspec(dllexport) + #else + #define FLUX_API __declspec(dllimport) + #endif +#else + #error Flux only supports windows! +#endif \ No newline at end of file diff --git a/FluxEngine/src/Flux/EntryPoint.h b/FluxEngine/src/Flux/EntryPoint.h new file mode 100644 index 0000000..425bed1 --- /dev/null +++ b/FluxEngine/src/Flux/EntryPoint.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Log.h" + +#ifdef FLUX_PLATFORM_WINDOWS + +extern Flux::Application* Flux::CreateApplication(); + +int main(int argc, char** argv) +{ + Flux::Log::Init(); + + FLUX_CORE_WARN("Logging Initialized!"); + int a = 5; + FLUX_INFO("Hello! {0}", a); + + auto app = Flux::CreateApplication(); + app->Run(); + delete app; +} +#endif \ No newline at end of file diff --git a/FluxEngine/src/Flux/Log.cpp b/FluxEngine/src/Flux/Log.cpp new file mode 100644 index 0000000..33c9c28 --- /dev/null +++ b/FluxEngine/src/Flux/Log.cpp @@ -0,0 +1,19 @@ +#include "Log.h" + +#include "spdlog/sinks/stdout_color_sinks.h" + +namespace Flux +{ + std::shared_ptr Log::s_CoreLogger; + std::shared_ptr Log::s_ClientLogger; + + void Log::Init() + { + spdlog::set_pattern("%^[%T] %n: %v%$"); + s_CoreLogger = spdlog::stdout_color_mt("FLUX"); + s_CoreLogger->set_level(spdlog::level::trace); + + s_ClientLogger = spdlog::stdout_color_mt("APP"); + s_ClientLogger->set_level(spdlog::level::trace); + } +} diff --git a/FluxEngine/src/Flux/Log.h b/FluxEngine/src/Flux/Log.h new file mode 100644 index 0000000..70e24b6 --- /dev/null +++ b/FluxEngine/src/Flux/Log.h @@ -0,0 +1,36 @@ +#pragma once + +#include + + +#include "Core.h" +#include "spdlog/spdlog.h" + +namespace Flux +{ + class FLUX_API Log + { + public: + static void Init(); + inline static std::shared_ptr& GetCoreLogger() { return s_CoreLogger; } + inline static std::shared_ptr& GetClientLogger() { return s_ClientLogger; } + private: + static std::shared_ptr s_CoreLogger; + static std::shared_ptr s_ClientLogger; + }; + +} + +// Core log macros +#define FLUX_CORE_TRACE(...) ::Flux::Log::GetCoreLogger()->trace(__VA_ARGS__) +#define FLUX_CORE_INFO(...) ::Flux::Log::GetCoreLogger()->info(__VA_ARGS__) +#define FLUX_CORE_WARN(...) ::Flux::Log::GetCoreLogger()->warn(__VA_ARGS__) +#define FLUX_CORE_ERROR(...) ::Flux::Log::GetCoreLogger()->error(__VA_ARGS__) +#define FLUX_CORE_FATAL(...) ::Flux::Log::GetCoreLogger()->fatal(__VA_ARGS__) + +// Client log macros +#define FLUX_TRACE(...) ::Flux::Log::GetCoreLogger()->trace(__VA_ARGS__) +#define FLUX_INFO(...) ::Flux::Log::GetCoreLogger()->info(__VA_ARGS__) +#define FLUX_WARN(...) ::Flux::Log::GetCoreLogger()->warn(__VA_ARGS__) +#define FLUX_ERROR(...) ::Flux::Log::GetCoreLogger()->error(__VA_ARGS__) +#define FLUX_FATAL(...) ::Flux::Log::GetCoreLogger()->fatal(__VA_ARGS__) diff --git a/GenerateProjects.bat b/GenerateProjects.bat new file mode 100644 index 0000000..12bf84e --- /dev/null +++ b/GenerateProjects.bat @@ -0,0 +1,2 @@ +call .\vendor\bin\premake\premake5.exe vs2022 +PAUSE \ No newline at end of file diff --git a/Sandbox/src/SandboxApp.cpp b/Sandbox/src/SandboxApp.cpp new file mode 100644 index 0000000..c668a04 --- /dev/null +++ b/Sandbox/src/SandboxApp.cpp @@ -0,0 +1,19 @@ +#include + +class Sandbox : public Flux::Application +{ +public: + Sandbox() + { + + } + ~Sandbox() + { + + } +}; + +Flux::Application* Flux::CreateApplication() +{ + return new Sandbox(); +} \ No newline at end of file diff --git a/premake5.lua b/premake5.lua new file mode 100644 index 0000000..079eeda --- /dev/null +++ b/premake5.lua @@ -0,0 +1,98 @@ +workspace "FluxEngine" + architecture "x64" + startproject "Sandbox" + + configurations { "Debug", "Release", "Dist" } + +outputdir = "%{cfg.buildcfg}-%{cfg.system}" + +project "FluxEngine" + location "FluxEngine" + kind "SharedLib" + language "C++" + + targetdir ("bin/" .. outputdir .. "/%{prj.name}") + objdir ("bin-int/" .. outputdir .. "/%{prj.name}") + + files + { + "%{prj.name}/src/**.h", + "%{prj.name}/src/**.cpp", + } + + includedirs + { + "%{prj.name}/vendor/spdlog/include", + } + + filter "system:windows" + cppdialect "C++20" + staticruntime "on" + systemversion "latest" + defines + { + "FLUX_PLATFORM_WINDOWS", + "FLUX_BUILD_DLL" + } + + postbuildcommands + { + ("{COPY} %{cfg.buildtarget.relpath} ../bin/".. outputdir .. "/Sandbox") + } + filter "configurations:Debug" + defines "FLUX_DEBUG" + symbols "On" + + filter "configurations:Release" + defines "FLUX_RELEASE" + optimize "On" + + filter "configurations:Dist" + defines "FLUX_DIST" + optimize "On" + +project "Sandbox" + location "Sandbox" + kind "ConsoleApp" + language "C++" + + targetdir ("bin/" .. outputdir .. "/%{prj.name}") + objdir ("bin-int/" .. outputdir .. "/%{prj.name}") + + files + { + "%{prj.name}/src/**.h", + "%{prj.name}/src/**.cpp", + } + + includedirs + { + "FluxEngine/vendor/spdlog/include", + "FluxEngine/src" + } + + links + { + "FluxEngine" + } + + filter "system:windows" + cppdialect "C++20" + staticruntime "on" + systemversion "latest" + defines + { + "FLUX_PLATFORM_WINDOWS" + } + + filter "configurations:Debug" + defines "FLUX_DEBUG" + symbols "On" + + filter "configurations:Release" + defines "FLUX_RELEASE" + optimize "On" + + filter "configurations:Dist" + defines "FLUX_DIST" + optimize "On" \ No newline at end of file diff --git a/vendor/bin/premake/LICENSE.txt b/vendor/bin/premake/LICENSE.txt new file mode 100644 index 0000000..63962d7 --- /dev/null +++ b/vendor/bin/premake/LICENSE.txt @@ -0,0 +1,27 @@ +Copyright (c) 2003-2022 Jason Perkins and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of Premake nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/bin/premake/premake5.exe b/vendor/bin/premake/premake5.exe new file mode 100644 index 0000000..1a637aa Binary files /dev/null and b/vendor/bin/premake/premake5.exe differ