diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..01689820 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +indent_style = tab \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2833f627..8ca61327 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,15 @@ -/bin/ +# Binaries +**/bin/ +!vendor/premake/bin/ bin-int/ -.vs/ # StarEngine files *.log - - -*.user -*.vcxproj -*.filters -*.sln *imgui.ini -/Sandbox/imgui.ini -/StarEngine/vendor/*/bin -Sandbox/StarEngineProfile*.json -/StarEngine/vendor/GLAD/bin** + +# Visual Studio files and folder +.vs/ +**.sln +**.vcxproj +**.vcxproj.filters +**.vcxproj.user \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 14661ba8..139635c2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,13 +1,13 @@ [submodule "StarEngine/vendor/GLFW"] path = StarEngine/vendor/GLFW - url = https://github.com/starbounded-dev/glfw + url = ../../starbounded-dev/glfw.git [submodule "StarEngine/vendor/spdlog"] path = StarEngine/vendor/spdlog - url = https://github.com/gabime/spdlog + url = ../../gabime/spdlog.git [submodule "StarEngine/vendor/imgui"] path = StarEngine/vendor/imgui - url = https://github.com/starbounded-dev/imgui + url = ../../starbounded-dev/imgui.git branch = docking [submodule "StarEngine/vendor/glm"] path = StarEngine/vendor/glm - url = https://github.com/g-truc/glm \ No newline at end of file + url = ../../g-truc/glm.git \ No newline at end of file diff --git a/Sandbox/premake5.lua b/Sandbox/premake5.lua new file mode 100644 index 00000000..e39df8f1 --- /dev/null +++ b/Sandbox/premake5.lua @@ -0,0 +1,49 @@ +project "Sandbox" + kind "ConsoleApp" + language "C++" + cppdialect "C++17" + staticruntime "on" + + targetdir ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}") + objdir ("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}") + + files + { + "src/**.h", + "src/**.cpp" + } + + includedirs + { + "%{wks.location}/StarEngine/vendor/spdlog/include", + "%{wks.location}/StarEngine/src", + "%{wks.location}/StarEngine/vendor", + "%{IncludeDir.glm}", + "%{IncludeDir.entt}" + } + + links + { + "StarEngine" + } + + filter "system:windows" + systemversion "latest" + + filter "configurations:Debug" + defines "SE_DEBUG" + runtime "Debug" + symbols "on" + + filter "configurations:Release" + defines "SE_RELEASE" + runtime "Release" + optimize "on" + + filter "configurations:Dist" + defines "SE_DIST" + runtime "Release" + optimize "on" + + filter "action:vs2022" + buildoptions { "/utf-8" } \ No newline at end of file diff --git a/StarEditor/premake5.lua b/StarEditor/premake5.lua new file mode 100644 index 00000000..0bea68fa --- /dev/null +++ b/StarEditor/premake5.lua @@ -0,0 +1,49 @@ +project "StarEditor" + kind "ConsoleApp" + language "C++" + cppdialect "C++17" + staticruntime "on" + + targetdir ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}") + objdir ("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}") + + files + { + "src/**.h", + "src/**.cpp" + } + + includedirs + { + "%{wks.location}/StarEngine/vendor/spdlog/include", + "%{wks.location}/StarEngine/src", + "%{wks.location}/StarEngine/vendor", + "%{IncludeDir.glm}", + "%{IncludeDir.entt}" + } + + links + { + "StarEngine" + } + + filter "system:windows" + systemversion "latest" + + filter "configurations:Debug" + defines "SE_DEBUG" + runtime "Debug" + symbols "on" + + filter "configurations:Release" + defines "SE_RELEASE" + runtime "Release" + optimize "on" + + filter "configurations:Dist" + defines "SE_DIST" + runtime "Release" + optimize "on" + + filter "action:vs2022" + buildoptions { "/utf-8" } \ No newline at end of file diff --git a/StarEditor/src/EditorLayer.cpp b/StarEditor/src/EditorLayer.cpp index 30b94d57..97e77189 100644 --- a/StarEditor/src/EditorLayer.cpp +++ b/StarEditor/src/EditorLayer.cpp @@ -58,13 +58,13 @@ namespace StarEngine { auto& transform = GetComponent().Transform; float speed = 5.0f; - if (Input::IsKeyPressed(SE_KEY_A)) + if (Input::IsKeyPressed(Key::A)) transform[3][0] -= speed * ts; - if (Input::IsKeyPressed(SE_KEY_D)) + if (Input::IsKeyPressed(Key::D)) transform[3][0] += speed * ts; - if (Input::IsKeyPressed(SE_KEY_W)) + if (Input::IsKeyPressed(Key::W)) transform[3][1] += speed * ts; - if (Input::IsKeyPressed(SE_KEY_S)) + if (Input::IsKeyPressed(Key::S)) transform[3][1] -= speed * ts; } }; @@ -228,7 +228,7 @@ namespace StarEngine { m_ViewportSize = { viewportPanelSize.x, viewportPanelSize.y }; - uint32_t textureID = m_Framebuffer->GetColorAttachmentRendererID(); + uint64_t textureID = m_Framebuffer->GetColorAttachmentRendererID(); ImGui::Image(textureID, ImVec2{ m_ViewportSize.x, m_ViewportSize.y }, ImVec2{0,1}, ImVec2{1,0}); ImGui::End(); diff --git a/StarEngine/premake5.lua b/StarEngine/premake5.lua new file mode 100644 index 00000000..c027306e --- /dev/null +++ b/StarEngine/premake5.lua @@ -0,0 +1,76 @@ +project "StarEngine" + kind "StaticLib" + language "C++" + cppdialect "C++17" + staticruntime "on" + + targetdir ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}") + objdir ("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}") + + pchheader "sepch.h" + pchsource "src/sepch.cpp" + + files + { + "src/**.h", + "src/**.cpp", + "vendor/stb_image/**.h", + "vendor/stb_image/**.cpp", + "vendor/glm/glm/**.hpp", + "vendor/glm/glm/**.inl" + } + + defines + { + "_CRT_SECURE_NO_WARNINGS", + "GLFW_INCLUDE_NONE" + } + + includedirs + { + "src", + "vendor/spdlog/include", + "%{IncludeDir.GLFW}", + "%{IncludeDir.GLAD}", + "%{IncludeDir.imgui}", + "%{IncludeDir.glm}", + "%{IncludeDir.stb_image}", + "%{IncludeDir.entt}" + + + } + + links + { + "GLFW", + "GLAD", + "imgui", + "opengl32.lib", + "dwmapi.lib" + } + + filter "system:windows" + systemversion "latest" + + defines + { + + } + + filter "configurations:Debug" + defines "SE_DEBUG" + runtime "Debug" + symbols "on" + + filter "configurations:Release" + defines "SE_RELEASE" + runtime "Release" + optimize "on" + + filter "configurations:Dist" + defines "SE_DIST" + runtime "Release" + optimize "on" + + filter "action:vs2022" + buildoptions { "/utf-8" } \ No newline at end of file diff --git a/StarEngine/src/Platform/OpenGL/OpenGLContext.cpp b/StarEngine/src/Platform/OpenGL/OpenGLContext.cpp index 830155c1..c020f326 100644 --- a/StarEngine/src/Platform/OpenGL/OpenGLContext.cpp +++ b/StarEngine/src/Platform/OpenGL/OpenGLContext.cpp @@ -25,13 +25,7 @@ namespace StarEngine { SE_CORE_INFO(" Renderer: {0}", (const char*)glGetString(GL_RENDERER)); SE_CORE_INFO(" Version: {0}", (const char*)glGetString(GL_VERSION)); - #ifdef SS_ENABLE_ASSERTS - int versionMajor; - int versionMinor; - glGetIntegerv(GL_MAJOR_VERSION, &versionMajor); - glGetIntegerv(GL_MINOR_VERSION, &versionMinor); - SE_CORE_ASSERT(versionMajor > 4 || (versionMajor == 4 && versionMinor >= 5), "StarStudio requires at least OpenGL version 4.5!"); - #endif + SE_CORE_ASSERT(GLVersion.major > 4 || (GLVersion.major == 4 && GLVersion.minor >= 5), "Hazel requires at least OpenGL version 4.5!"); } void OpenGLContext::SwapBuffers() diff --git a/StarEngine/src/Platform/OpenGL/OpenGLShader.cpp b/StarEngine/src/Platform/OpenGL/OpenGLShader.cpp index 82910170..a55f9be8 100644 --- a/StarEngine/src/Platform/OpenGL/OpenGLShader.cpp +++ b/StarEngine/src/Platform/OpenGL/OpenGLShader.cpp @@ -57,7 +57,7 @@ namespace StarEngine { SE_PROFILE_FUNCTION(); std::string result; - std::ifstream in(filepath, std::ios::in | std::ios::binary); + std::ifstream in(filepath, std::ios::in | std::ios::binary); // ifstream closes itself due to RAII if (in) { in.seekg(0, std::ios::end); @@ -67,7 +67,6 @@ namespace StarEngine { result.resize(size); in.seekg(0, std::ios::beg); in.read(&result[0], size); - in.close(); } else { diff --git a/StarEngine/src/Platform/OpenGL/OpenGLVertexArray.cpp b/StarEngine/src/Platform/OpenGL/OpenGLVertexArray.cpp index 46a3bdc7..d1a2dcb3 100644 --- a/StarEngine/src/Platform/OpenGL/OpenGLVertexArray.cpp +++ b/StarEngine/src/Platform/OpenGL/OpenGLVertexArray.cpp @@ -95,7 +95,7 @@ namespace StarEngine { ShaderDataTypeToOpenGLBaseType(element.Type), element.Normalized ? GL_TRUE : GL_FALSE, layout.GetStride(), - (const void*)(sizeof(float) * count * i)); + (const void*)(element.Offset + sizeof(float) * count * i)); glVertexAttribDivisor(m_VertexBufferIndex, 1); m_VertexBufferIndex++; } diff --git a/StarEngine/src/Platform/Windows/WindowsInput.cpp b/StarEngine/src/Platform/Windows/WindowsInput.cpp index f95cf281..cfafc9b6 100644 --- a/StarEngine/src/Platform/Windows/WindowsInput.cpp +++ b/StarEngine/src/Platform/Windows/WindowsInput.cpp @@ -6,23 +6,23 @@ namespace StarEngine { - bool Input::IsKeyPressed(KeyCode key) + bool Input::IsKeyPressed(const KeyCode key) { auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); auto state = glfwGetKey(window, static_cast(key)); return state == GLFW_PRESS || state == GLFW_REPEAT; } - bool Input::IsMouseButtonPressed(MouseCode button) + bool Input::IsMouseButtonPressed(const MouseCode button) { auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); auto state = glfwGetMouseButton(window, static_cast(button)); return state == GLFW_PRESS; } - std::pair Input::GetMousePosition() + glm::vec2 Input::GetMousePosition() { - auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); + auto* window = static_cast(Application::Get().GetWindow().GetNativeWindow()); double xpos, ypos; glfwGetCursorPos(window, &xpos, &ypos); @@ -31,13 +31,11 @@ namespace StarEngine { float Input::GetMouseX() { - auto [x, y] = GetMousePosition(); - return x; + return GetMousePosition().x; } float Input::GetMouseY() { - auto [x, y] = GetMousePosition(); - return y; + return GetMousePosition().y; } } \ No newline at end of file diff --git a/StarEngine/src/Platform/Windows/WindowsWindow.cpp b/StarEngine/src/Platform/Windows/WindowsWindow.cpp index 839b550c..13d7d401 100644 --- a/StarEngine/src/Platform/Windows/WindowsWindow.cpp +++ b/StarEngine/src/Platform/Windows/WindowsWindow.cpp @@ -96,19 +96,19 @@ namespace StarEngine { { case GLFW_PRESS: { - KeyPressedEvent event(static_cast(key), 0); + KeyPressedEvent event(key, 0); data.EventCallback(event); break; } case GLFW_RELEASE: { - KeyReleasedEvent event(static_cast(key)); + KeyReleasedEvent event(key); data.EventCallback(event); break; } case GLFW_REPEAT: { - KeyPressedEvent event(static_cast(key), 1); + KeyPressedEvent event(key, 1); data.EventCallback(event); break; } @@ -119,7 +119,7 @@ namespace StarEngine { { WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window); - KeyTypedEvent event(static_cast(keycode)); + KeyTypedEvent event(keycode); data.EventCallback(event); }); @@ -131,13 +131,13 @@ namespace StarEngine { { case GLFW_PRESS: { - MouseButtonPressedEvent event(static_cast(button)); + MouseButtonPressedEvent event(button); data.EventCallback(event); break; } case GLFW_RELEASE: { - MouseButtonReleasedEvent event(static_cast(button)); + MouseButtonReleasedEvent event(button); data.EventCallback(event); break; } diff --git a/StarEngine/src/StarEngine/Core/Base.h b/StarEngine/src/StarEngine/Core/Base.h index b40fd5f5..07130c17 100644 --- a/StarEngine/src/StarEngine/Core/Base.h +++ b/StarEngine/src/StarEngine/Core/Base.h @@ -2,46 +2,7 @@ #include -// Platform detection using predefined macros -#ifdef _WIN32 - /* Windows x64/x86 */ -#ifdef _WIN64 - /* Windows x64 */ -#define SE_PLATFORM_WINDOWS -#else - /* Windows x86 */ -#error "x86 Builds are not supported!" -#endif -#elif defined(__APPLE__) || defined(__MACH__) -#include -/* TARGET_OS_MAC exists on all the platforms - * so we must check all of them (in this order) - * to ensure that we're running on MAC - * and not some other Apple platform */ -#if TARGET_IPHONE_SIMULATOR == 1 -#error "IOS simulator is not supported!" -#elif TARGET_OS_IPHONE == 1 -#define SE_PLATFORM_IOS -#error "IOS is not supported!" -#elif TARGET_OS_MAC == 1 -#define SE_PLATFORM_MACOS -#error "MacOS is not supported!" -#else -#error "Unknown Apple platform!" -#endif - /* We also have to check __ANDROID__ before __linux__ - * since android is based on the linux kernel - * it has __linux__ defined */ -#elif defined(__ANDROID__) -#define SE_PLATFORM_ANDROID -#error "Android is not supported!" -#elif defined(__linux__) -#define SE_PLATFORM_LINUX -#error "Linux is not supported!" -#else - /* Unknown compiler/platform */ -#error "Unknown platform!" -#endif // End of platform detection +#include "StarEngine/Core/PlatformDetection.h" #ifdef SE_DEBUG diff --git a/StarEngine/src/StarEngine/Core/Input.h b/StarEngine/src/StarEngine/Core/Input.h index f7512b17..8c0ad793 100644 --- a/StarEngine/src/StarEngine/Core/Input.h +++ b/StarEngine/src/StarEngine/Core/Input.h @@ -1,6 +1,7 @@ #pragma once -#include "StarEngine/Core/Base.h" +#include + #include "StarEngine/Core/KeyCodes.h" #include "StarEngine/Core/MouseCodes.h" @@ -12,7 +13,7 @@ namespace StarEngine { static bool IsKeyPressed(KeyCode key); static bool IsMouseButtonPressed(MouseCode button); - static std::pair GetMousePosition(); + static glm::vec2 GetMousePosition(); static float GetMouseX(); static float GetMouseY(); diff --git a/StarEngine/src/StarEngine/Core/KeyCodes.h b/StarEngine/src/StarEngine/Core/KeyCodes.h index 371bf5d7..b5154541 100644 --- a/StarEngine/src/StarEngine/Core/KeyCodes.h +++ b/StarEngine/src/StarEngine/Core/KeyCodes.h @@ -2,271 +2,143 @@ namespace StarEngine { - typedef enum class KeyCode : uint16_t - { - // From glfw3.h - Space = 32, - Apostrophe = 39, /* ' */ - Comma = 44, /* , */ - Minus = 45, /* - */ - Period = 46, /* . */ - Slash = 47, /* / */ + using KeyCode = uint16_t; - D0 = 48, /* 0 */ - D1 = 49, /* 1 */ - D2 = 50, /* 2 */ - D3 = 51, /* 3 */ - D4 = 52, /* 4 */ - D5 = 53, /* 5 */ - D6 = 54, /* 6 */ - D7 = 55, /* 7 */ - D8 = 56, /* 8 */ - D9 = 57, /* 9 */ + namespace Key + { + enum : KeyCode + { + // From glfw3.h + Space = 32, + Apostrophe = 39, /* ' */ + Comma = 44, /* , */ + Minus = 45, /* - */ + Period = 46, /* . */ + Slash = 47, /* / */ - Semicolon = 59, /* ; */ - Equal = 61, /* = */ + D0 = 48, /* 0 */ + D1 = 49, /* 1 */ + D2 = 50, /* 2 */ + D3 = 51, /* 3 */ + D4 = 52, /* 4 */ + D5 = 53, /* 5 */ + D6 = 54, /* 6 */ + D7 = 55, /* 7 */ + D8 = 56, /* 8 */ + D9 = 57, /* 9 */ - A = 65, - B = 66, - C = 67, - D = 68, - E = 69, - F = 70, - G = 71, - H = 72, - I = 73, - J = 74, - K = 75, - L = 76, - M = 77, - N = 78, - O = 79, - P = 80, - Q = 81, - R = 82, - S = 83, - T = 84, - U = 85, - V = 86, - W = 87, - X = 88, - Y = 89, - Z = 90, + Semicolon = 59, /* ; */ + Equal = 61, /* = */ - LeftBracket = 91, /* [ */ - Backslash = 92, /* \ */ - RightBracket = 93, /* ] */ - GraveAccent = 96, /* ` */ + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, - World1 = 161, /* non-US #1 */ - World2 = 162, /* non-US #2 */ + LeftBracket = 91, /* [ */ + Backslash = 92, /* \ */ + RightBracket = 93, /* ] */ + GraveAccent = 96, /* ` */ - /* Function keys */ - Escape = 256, - Enter = 257, - Tab = 258, - Backspace = 259, - Insert = 260, - Delete = 261, - Right = 262, - Left = 263, - Down = 264, - Up = 265, - PageUp = 266, - PageDown = 267, - Home = 268, - End = 269, - CapsLock = 280, - ScrollLock = 281, - NumLock = 282, - PrintScreen = 283, - Pause = 284, - F1 = 290, - F2 = 291, - F3 = 292, - F4 = 293, - F5 = 294, - F6 = 295, - F7 = 296, - F8 = 297, - F9 = 298, - F10 = 299, - F11 = 300, - F12 = 301, - F13 = 302, - F14 = 303, - F15 = 304, - F16 = 305, - F17 = 306, - F18 = 307, - F19 = 308, - F20 = 309, - F21 = 310, - F22 = 311, - F23 = 312, - F24 = 313, - F25 = 314, + World1 = 161, /* non-US #1 */ + World2 = 162, /* non-US #2 */ - /* Keypad */ - KP0 = 320, - KP1 = 321, - KP2 = 322, - KP3 = 323, - KP4 = 324, - KP5 = 325, - KP6 = 326, - KP7 = 327, - KP8 = 328, - KP9 = 329, - KPDecimal = 330, - KPDivide = 331, - KPMultiply = 332, - KPSubtract = 333, - KPAdd = 334, - KPEnter = 335, - KPEqual = 336, + /* Function keys */ + Escape = 256, + Enter = 257, + Tab = 258, + Backspace = 259, + Insert = 260, + Delete = 261, + Right = 262, + Left = 263, + Down = 264, + Up = 265, + PageUp = 266, + PageDown = 267, + Home = 268, + End = 269, + CapsLock = 280, + ScrollLock = 281, + NumLock = 282, + PrintScreen = 283, + Pause = 284, + F1 = 290, + F2 = 291, + F3 = 292, + F4 = 293, + F5 = 294, + F6 = 295, + F7 = 296, + F8 = 297, + F9 = 298, + F10 = 299, + F11 = 300, + F12 = 301, + F13 = 302, + F14 = 303, + F15 = 304, + F16 = 305, + F17 = 306, + F18 = 307, + F19 = 308, + F20 = 309, + F21 = 310, + F22 = 311, + F23 = 312, + F24 = 313, + F25 = 314, - LeftShift = 340, - LeftControl = 341, - LeftAlt = 342, - LeftSuper = 343, - RightShift = 344, - RightControl = 345, - RightAlt = 346, - RightSuper = 347, - Menu = 348 - } Key; + /* Keypad */ + KP0 = 320, + KP1 = 321, + KP2 = 322, + KP3 = 323, + KP4 = 324, + KP5 = 325, + KP6 = 326, + KP7 = 327, + KP8 = 328, + KP9 = 329, + KPDecimal = 330, + KPDivide = 331, + KPMultiply = 332, + KPSubtract = 333, + KPAdd = 334, + KPEnter = 335, + KPEqual = 336, - inline std::ostream& operator<<(std::ostream& os, KeyCode keyCode) - { - os << static_cast(keyCode); - return os; + LeftShift = 340, + LeftControl = 341, + LeftAlt = 342, + LeftSuper = 343, + RightShift = 344, + RightControl = 345, + RightAlt = 346, + RightSuper = 347, + Menu = 348 + }; } -} - -// From glfw3.h -#define SE_KEY_SPACE ::StarEngine::Key::Space -#define SE_KEY_APOSTROPHE ::StarEngine::Key::Apostrophe /* ' */ -#define SE_KEY_COMMA ::StarEngine::Key::Comma /* , */ -#define SE_KEY_MINUS ::StarEngine::Key::Minus /* - */ -#define SE_KEY_PERIOD ::StarEngine::Key::Period /* . */ -#define SE_KEY_SLASH ::StarEngine::Key::Slash /* / */ -#define SE_KEY_0 ::StarEngine::Key::D0 -#define SE_KEY_1 ::StarEngine::Key::D1 -#define SE_KEY_2 ::StarEngine::Key::D2 -#define SE_KEY_3 ::StarEngine::Key::D3 -#define SE_KEY_4 ::StarEngine::Key::D4 -#define SE_KEY_5 ::StarEngine::Key::D5 -#define SE_KEY_6 ::StarEngine::Key::D6 -#define SE_KEY_7 ::StarEngine::Key::D7 -#define SE_KEY_8 ::StarEngine::Key::D8 -#define SE_KEY_9 ::StarEngine::Key::D9 -#define SE_KEY_SEMICOLON ::StarEngine::Key::Semicolon /* ; */ -#define SE_KEY_EQUAL ::StarEngine::Key::Equal /* = */ -#define SE_KEY_A ::StarEngine::Key::A -#define SE_KEY_B ::StarEngine::Key::B -#define SE_KEY_C ::StarEngine::Key::C -#define SE_KEY_D ::StarEngine::Key::D -#define SE_KEY_E ::StarEngine::Key::E -#define SE_KEY_F ::StarEngine::Key::F -#define SE_KEY_G ::StarEngine::Key::G -#define SE_KEY_H ::StarEngine::Key::H -#define SE_KEY_I ::StarEngine::Key::I -#define SE_KEY_J ::StarEngine::Key::J -#define SE_KEY_K ::StarEngine::Key::K -#define SE_KEY_L ::StarEngine::Key::L -#define SE_KEY_M ::StarEngine::Key::M -#define SE_KEY_N ::StarEngine::Key::N -#define SE_KEY_O ::StarEngine::Key::O -#define SE_KEY_P ::StarEngine::Key::P -#define SE_KEY_Q ::StarEngine::Key::Q -#define SE_KEY_R ::StarEngine::Key::R -#define SE_KEY_S ::StarEngine::Key::S -#define SE_KEY_T ::StarEngine::Key::T -#define SE_KEY_U ::StarEngine::Key::U -#define SE_KEY_V ::StarEngine::Key::V -#define SE_KEY_W ::StarEngine::Key::W -#define SE_KEY_X ::StarEngine::Key::X -#define SE_KEY_Y ::StarEngine::Key::Y -#define SE_KEY_Z ::StarEngine::Key::Z -#define SE_KEY_LEFT_BRACKET ::StarEngine::Key::LeftBracket /* [ */ -#define SE_KEY_BACKSLASH ::StarEngine::Key::Backslash /* \ */ -#define SE_KEY_RIGHT_BRACKET ::StarEngine::Key::RightBracket /* ] */ -#define SE_KEY_GRAVE_ACCENT ::StarEngine::Key::GraveAccent /* ` */ -#define SE_KEY_WORLD_1 ::StarEngine::Key::World1 /* non-US #1 */ -#define SE_KEY_WORLD_2 ::StarEngine::Key::World2 /* non-US #2 */ - -/* Function keys */ -#define SE_KEY_ESCAPE ::StarEngine::Key::Escape -#define SE_KEY_ENTER ::StarEngine::Key::Enter -#define SE_KEY_TAB ::StarEngine::Key::Tab -#define SE_KEY_BACKSPACE ::StarEngine::Key::Backspace -#define SE_KEY_INSERT ::StarEngine::Key::Insert -#define SE_KEY_DELETE ::StarEngine::Key::Delete -#define SE_KEY_RIGHT ::StarEngine::Key::Right -#define SE_KEY_LEFT ::StarEngine::Key::Left -#define SE_KEY_DOWN ::StarEngine::Key::Down -#define SE_KEY_UP ::StarEngine::Key::Up -#define SE_KEY_PAGE_UP ::StarEngine::Key::PageUp -#define SE_KEY_PAGE_DOWN ::StarEngine::Key::PageDown -#define SE_KEY_HOME ::StarEngine::Key::Home -#define SE_KEY_END ::StarEngine::Key::End -#define SE_KEY_CAPS_LOCK ::StarEngine::Key::CapsLock -#define SE_KEY_SCROLL_LOCK ::StarEngine::Key::ScrollLock -#define SE_KEY_NUM_LOCK ::StarEngine::Key::NumLock -#define SE_KEY_PRINT_SCREEN ::StarEngine::Key::PrintScreen -#define SE_KEY_PAUSE ::StarEngine::Key::Pause -#define SE_KEY_F1 ::StarEngine::Key::F1 -#define SE_KEY_F2 ::StarEngine::Key::F2 -#define SE_KEY_F3 ::StarEngine::Key::F3 -#define SE_KEY_F4 ::StarEngine::Key::F4 -#define SE_KEY_F5 ::StarEngine::Key::F5 -#define SE_KEY_F6 ::StarEngine::Key::F6 -#define SE_KEY_F7 ::StarEngine::Key::F7 -#define SE_KEY_F8 ::StarEngine::Key::F8 -#define SE_KEY_F9 ::StarEngine::Key::F9 -#define SE_KEY_F10 ::StarEngine::Key::F10 -#define SE_KEY_F11 ::StarEngine::Key::F11 -#define SE_KEY_F12 ::StarEngine::Key::F12 -#define SE_KEY_F13 ::StarEngine::Key::F13 -#define SE_KEY_F14 ::StarEngine::Key::F14 -#define SE_KEY_F15 ::StarEngine::Key::F15 -#define SE_KEY_F16 ::StarEngine::Key::F16 -#define SE_KEY_F17 ::StarEngine::Key::F17 -#define SE_KEY_F18 ::StarEngine::Key::F18 -#define SE_KEY_F19 ::StarEngine::Key::F19 -#define SE_KEY_F20 ::StarEngine::Key::F20 -#define SE_KEY_F21 ::StarEngine::Key::F21 -#define SE_KEY_F22 ::StarEngine::Key::F22 -#define SE_KEY_F23 ::StarEngine::Key::F23 -#define SE_KEY_F24 ::StarEngine::Key::F24 -#define SE_KEY_F25 ::StarEngine::Key::F25 - -/* Keypad */ -#define SE_KEY_KP_0 ::StarEngine::Key::KP0 -#define SE_KEY_KP_1 ::StarEngine::Key::KP1 -#define SE_KEY_KP_2 ::StarEngine::Key::KP2 -#define SE_KEY_KP_3 ::StarEngine::Key::KP3 -#define SE_KEY_KP_4 ::StarEngine::Key::KP4 -#define SE_KEY_KP_5 ::StarEngine::Key::KP5 -#define SE_KEY_KP_6 ::StarEngine::Key::KP6 -#define SE_KEY_KP_7 ::StarEngine::Key::KP7 -#define SE_KEY_KP_8 ::StarEngine::Key::KP8 -#define SE_KEY_KP_9 ::StarEngine::Key::KP9 -#define SE_KEY_KP_DECIMAL ::StarEngine::Key::KPDecimal -#define SE_KEY_KP_DIVIDE ::StarEngine::Key::KPDivide -#define SE_KEY_KP_MULTIPLY ::StarEngine::Key::KPMultiply -#define SE_KEY_KP_SUBTRACT ::StarEngine::Key::KPSubtract -#define SE_KEY_KP_ADD ::StarEngine::Key::KPAdd -#define SE_KEY_KP_ENTER ::StarEngine::Key::KPEnter -#define SE_KEY_KP_EQUAL ::StarEngine::Key::KPEqual - -#define SE_KEY_LEFT_SHIFT ::StarEngine::Key::LeftShift -#define SE_KEY_LEFT_CONTROL ::StarEngine::Key::LeftControl -#define SE_KEY_LEFT_ALT ::StarEngine::Key::LeftAlt -#define SE_KEY_LEFT_SUPER ::StarEngine::Key::LeftSuper -#define SE_KEY_RIGHT_SHIFT ::StarEngine::Key::RightShift -#define SE_KEY_RIGHT_CONTROL ::StarEngine::Key::RightControl -#define SE_KEY_RIGHT_ALT ::StarEngine::Key::RightAlt -#define SE_KEY_RIGHT_SUPER ::StarEngine::Key::RightSuper -#define SE_KEY_MENU ::StarEngine::Key::Menu \ No newline at end of file +} \ No newline at end of file diff --git a/StarEngine/src/StarEngine/Core/MouseCodes.h b/StarEngine/src/StarEngine/Core/MouseCodes.h index 0fe15465..bca7cba1 100644 --- a/StarEngine/src/StarEngine/Core/MouseCodes.h +++ b/StarEngine/src/StarEngine/Core/MouseCodes.h @@ -2,40 +2,26 @@ namespace StarEngine { - typedef enum class MouseCode : uint16_t - { - // From glfw3.h - Button0 = 0, - Button1 = 1, - Button2 = 2, - Button3 = 3, - Button4 = 4, - Button5 = 5, - Button6 = 6, - Button7 = 7, - - ButtonLast = Button7, - ButtonLeft = Button0, - ButtonRight = Button1, - ButtonMiddle = Button2 - } Mouse; + using MouseCode = uint16_t; - inline std::ostream& operator<<(std::ostream& os, MouseCode mouseCode) + namespace Mouse { - os << static_cast(mouseCode); - return os; - } -} + enum : MouseCode + { + // From glfw3.h + Button0 = 0, + Button1 = 1, + Button2 = 2, + Button3 = 3, + Button4 = 4, + Button5 = 5, + Button6 = 6, + Button7 = 7, -#define SE_MOUSE_BUTTON_0 ::StarEngine::Mouse::Button0 -#define SE_MOUSE_BUTTON_1 ::StarEngine::Mouse::Button1 -#define SE_MOUSE_BUTTON_2 ::StarEngine::Mouse::Button2 -#define SE_MOUSE_BUTTON_3 ::StarEngine::Mouse::Button3 -#define SE_MOUSE_BUTTON_4 ::StarEngine::Mouse::Button4 -#define SE_MOUSE_BUTTON_5 ::StarEngine::Mouse::Button5 -#define SE_MOUSE_BUTTON_6 ::StarEngine::Mouse::Button6 -#define SE_MOUSE_BUTTON_7 ::StarEngine::Mouse::Button7 -#define SE_MOUSE_BUTTON_LAST ::StarEngine::Mouse::ButtonLast -#define SE_MOUSE_BUTTON_LEFT ::StarEngine::Mouse::ButtonLeft -#define SE_MOUSE_BUTTON_RIGHT ::StarEngine::Mouse::ButtonRight -#define SE_MOUSE_BUTTON_MIDDLE ::StarEngine::Mouse::ButtonMiddle \ No newline at end of file + ButtonLast = Button7, + ButtonLeft = Button0, + ButtonRight = Button1, + ButtonMiddle = Button2 + }; + } +} \ No newline at end of file diff --git a/StarEngine/src/StarEngine/Core/PlatformDetection.h b/StarEngine/src/StarEngine/Core/PlatformDetection.h new file mode 100644 index 00000000..9f52bb75 --- /dev/null +++ b/StarEngine/src/StarEngine/Core/PlatformDetection.h @@ -0,0 +1,40 @@ +// Platform detection using predefined macros +#ifdef _WIN32 + /* Windows x64/x86 */ +#ifdef _WIN64 + /* Windows x64 */ +#define SE_PLATFORM_WINDOWS +#else + /* Windows x86 */ +#error "x86 Builds are not supported!" +#endif +#elif defined(__APPLE__) || defined(__MACH__) +#include +/* TARGET_OS_MAC exists on all the platforms + * so we must check all of them (in this order) + * to ensure that we're running on MAC + * and not some other Apple platform */ +#if TARGET_IPHONE_SIMULATOR == 1 +#error "IOS simulator is not supported!" +#elif TARGET_OS_IPHONE == 1 +#define SE_PLATFORM_IOS +#error "IOS is not supported!" +#elif TARGET_OS_MAC == 1 +#define SE_PLATFORM_MACOS +#error "MacOS is not supported!" +#else +#error "Unknown Apple platform!" +#endif + /* We also have to check __ANDROID__ before __linux__ + * since android is based on the linux kernel + * it has __linux__ defined */ +#elif defined(__ANDROID__) +#define SE_PLATFORM_ANDROID +#error "Android is not supported!" +#elif defined(__linux__) +#define SE_PLATFORM_LINUX +#error "Linux is not supported!" +#else + /* Unknown compiler/platform */ +#error "Unknown platform!" +#endif // End of platform detection \ No newline at end of file diff --git a/StarEngine/src/StarEngine/Core/Window.h b/StarEngine/src/StarEngine/Core/Window.h index e5bd670d..af47735d 100644 --- a/StarEngine/src/StarEngine/Core/Window.h +++ b/StarEngine/src/StarEngine/Core/Window.h @@ -1,6 +1,6 @@ #pragma once -#include "sepch.h" +#include #include "StarEngine/Core/Base.h" #include "StarEngine/Events/Event.h" diff --git a/StarEngine/src/StarEngine/Debug/Instrumentor.h b/StarEngine/src/StarEngine/Debug/Instrumentor.h index 82bbdfe0..ad9d8e72 100644 --- a/StarEngine/src/StarEngine/Debug/Instrumentor.h +++ b/StarEngine/src/StarEngine/Debug/Instrumentor.h @@ -7,6 +7,11 @@ #include #include +#include +#include + +#include "StarEngine/Core/Log.h" + namespace StarEngine { using FloatingPointMicroseconds = std::chrono::duration; diff --git a/StarEngine/src/StarEngine/Events/Event.h b/StarEngine/src/StarEngine/Events/Event.h index 8ff88a2e..d2ecbe7a 100644 --- a/StarEngine/src/StarEngine/Events/Event.h +++ b/StarEngine/src/StarEngine/Events/Event.h @@ -1,6 +1,8 @@ #pragma once -#include "sepch.h" +#include + +#include "StarEngine/Debug/Instrumentor.h" #include "StarEngine/Core/Base.h" namespace StarEngine { diff --git a/StarEngine/src/StarEngine/Events/KeyEvent.h b/StarEngine/src/StarEngine/Events/KeyEvent.h index f791a7ae..bc61249d 100644 --- a/StarEngine/src/StarEngine/Events/KeyEvent.h +++ b/StarEngine/src/StarEngine/Events/KeyEvent.h @@ -1,7 +1,7 @@ #pragma once #include "StarEngine/Events/Event.h" -#include "StarEngine/Core/Input.h" +#include "StarEngine/Core/KeyCodes.h" namespace StarEngine { @@ -12,7 +12,7 @@ namespace StarEngine { EVENT_CLASS_CATEGORY(EventCategoryKeyboard | EventCategoryInput) protected: - KeyEvent(KeyCode keycode) + KeyEvent(const KeyCode keycode) : m_KeyCode(keycode) { } @@ -22,11 +22,11 @@ namespace StarEngine { class KeyPressedEvent : public KeyEvent { public: - KeyPressedEvent(KeyCode keycode, int repeatCount) + KeyPressedEvent(const KeyCode keycode, const uint16_t repeatCount) : KeyEvent(keycode), m_RepeatCount(repeatCount) { } - int GetRepeatCount() const { return m_RepeatCount; } + uint16_t GetRepeatCount() const { return m_RepeatCount; } std::string ToString() const override { @@ -37,13 +37,13 @@ namespace StarEngine { EVENT_CLASS_TYPE(KeyPressed) private: - int m_RepeatCount; + uint16_t m_RepeatCount; }; class KeyReleasedEvent : public KeyEvent { public: - KeyReleasedEvent(KeyCode keycode) + KeyReleasedEvent(const KeyCode keycode) : KeyEvent(keycode) { } @@ -60,7 +60,7 @@ namespace StarEngine { class KeyTypedEvent : public KeyEvent { public: - KeyTypedEvent(KeyCode keycode) + KeyTypedEvent(const KeyCode keycode) : KeyEvent(keycode) { } diff --git a/StarEngine/src/StarEngine/Events/MouseEvent.h b/StarEngine/src/StarEngine/Events/MouseEvent.h index 760f7eb4..f500c5de 100644 --- a/StarEngine/src/StarEngine/Events/MouseEvent.h +++ b/StarEngine/src/StarEngine/Events/MouseEvent.h @@ -1,14 +1,14 @@ #pragma once #include "StarEngine/Events/Event.h" -#include "StarEngine/Core/Input.h" +#include "StarEngine/Core/MouseCodes.h" namespace StarEngine { class MouseMovedEvent : public Event { public: - MouseMovedEvent(float x, float y) + MouseMovedEvent(const float x, const float y) : m_MouseX(x), m_MouseY(y) { } @@ -31,7 +31,7 @@ namespace StarEngine { class MouseScrolledEvent : public Event { public: - MouseScrolledEvent(float xOffset, float yOffset) + MouseScrolledEvent(const float xOffset, const float yOffset) : m_XOffset(xOffset), m_YOffset(yOffset) { } @@ -58,7 +58,7 @@ namespace StarEngine { EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput) protected: - MouseButtonEvent(MouseCode button) + MouseButtonEvent(const MouseCode button) : m_Button(button) { } @@ -68,7 +68,7 @@ namespace StarEngine { class MouseButtonPressedEvent : public MouseButtonEvent { public: - MouseButtonPressedEvent(MouseCode button) + MouseButtonPressedEvent(const MouseCode button) : MouseButtonEvent(button) { } @@ -85,7 +85,7 @@ namespace StarEngine { class MouseButtonReleasedEvent : public MouseButtonEvent { public: - MouseButtonReleasedEvent(MouseCode button) + MouseButtonReleasedEvent(const MouseCode button) : MouseButtonEvent(button) { } diff --git a/StarEngine/src/StarEngine/Renderer/Framebuffer.h b/StarEngine/src/StarEngine/Renderer/Framebuffer.h index 47c930b4..c871a3d9 100644 --- a/StarEngine/src/StarEngine/Renderer/Framebuffer.h +++ b/StarEngine/src/StarEngine/Renderer/Framebuffer.h @@ -6,7 +6,7 @@ namespace StarEngine { struct FramebufferSpecification { - uint32_t Width, Height; + uint32_t Width = 0, Height = 0; uint32_t Samples = 1; bool SwapChainTarget = false; }; diff --git a/StarEngine/src/StarEngine/Renderer/OrthographicCameraController.cpp b/StarEngine/src/StarEngine/Renderer/OrthographicCameraController.cpp index 5bf0337b..058ce2eb 100644 --- a/StarEngine/src/StarEngine/Renderer/OrthographicCameraController.cpp +++ b/StarEngine/src/StarEngine/Renderer/OrthographicCameraController.cpp @@ -15,23 +15,23 @@ namespace StarEngine { { SE_PROFILE_FUNCTION(); - if (Input::IsKeyPressed(SE_KEY_A)) + if (Input::IsKeyPressed(Key::A)) { m_CameraPosition.x -= cos(glm::radians(m_CameraRotation)) * m_CameraTranslationSpeed * ts; m_CameraPosition.y -= sin(glm::radians(m_CameraRotation)) * m_CameraTranslationSpeed * ts; } - else if (Input::IsKeyPressed(SE_KEY_D)) + else if (Input::IsKeyPressed(Key::D)) { m_CameraPosition.x += cos(glm::radians(m_CameraRotation)) * m_CameraTranslationSpeed * ts; m_CameraPosition.y += sin(glm::radians(m_CameraRotation)) * m_CameraTranslationSpeed * ts; } - if (Input::IsKeyPressed(SE_KEY_W)) + if (Input::IsKeyPressed(Key::W)) { m_CameraPosition.x += -sin(glm::radians(m_CameraRotation)) * m_CameraTranslationSpeed * ts; m_CameraPosition.y += cos(glm::radians(m_CameraRotation)) * m_CameraTranslationSpeed * ts; } - else if (Input::IsKeyPressed(SE_KEY_S)) + else if (Input::IsKeyPressed(Key::S)) { m_CameraPosition.x -= -sin(glm::radians(m_CameraRotation)) * m_CameraTranslationSpeed * ts; m_CameraPosition.y -= cos(glm::radians(m_CameraRotation)) * m_CameraTranslationSpeed * ts; @@ -39,10 +39,10 @@ namespace StarEngine { if (m_Rotation) { - if (Input::IsKeyPressed(SE_KEY_Q)) + if (Input::IsKeyPressed(Key::Q)) m_CameraRotation += m_CameraRotationSpeed * ts; - if (Input::IsKeyPressed(SE_KEY_E)) + if (Input::IsKeyPressed(Key::E)) m_CameraRotation -= m_CameraRotationSpeed * ts; m_Camera.SetRotation(m_CameraRotation); diff --git a/StarEngine/src/StarEngine/Renderer/Renderer2D.cpp b/StarEngine/src/StarEngine/Renderer/Renderer2D.cpp index a3025182..7e0b1cfe 100644 --- a/StarEngine/src/StarEngine/Renderer/Renderer2D.cpp +++ b/StarEngine/src/StarEngine/Renderer/Renderer2D.cpp @@ -94,7 +94,7 @@ namespace StarEngine { s_Data.TextureShader->Bind(); s_Data.TextureShader->SetIntArray("u_Textures", samplers, s_Data.MaxTextureSlots); - // Set all texture slots to 0 + // Set first texture slot to 0 s_Data.TextureSlots[0] = s_Data.WhiteTexture; s_Data.QuadVertexPositions[0] = { -0.5f, -0.5f, 0.0f, 1.0f }; @@ -198,7 +198,7 @@ namespace StarEngine { glm::mat4 transform = glm::translate(glm::mat4(1.0f), position) * glm::scale(glm::mat4(1.0f), { size.x, size.y, 1.0f }); - DrawQuad(transform, texture, tilingFactor); + DrawQuad(transform, texture, tilingFactor, tintColor); } void Renderer2D::DrawQuad(const glm::mat4& transform, const glm::vec4& color) @@ -242,7 +242,7 @@ namespace StarEngine { float textureIndex = 0.0f; for (uint32_t i = 1; i < s_Data.TextureSlotIndex; i++) { - if (*s_Data.TextureSlots[i].get() == *texture.get()) + if (*s_Data.TextureSlots[i] == *texture) { textureIndex = (float)i; break; diff --git a/StarEngine/src/sepch.h b/StarEngine/src/sepch.h index 921cacc3..4a8bf2d2 100644 --- a/StarEngine/src/sepch.h +++ b/StarEngine/src/sepch.h @@ -1,5 +1,14 @@ #pragma once +#include "StarEngine/Core/PlatformDetection.h" + +#ifdef SE_PLATFORM_WINDOWS +#ifndef NOMINMAX +// See github.com/skypjack/entt/wiki/Frequently-Asked-Questions#warning-c4003-the-min-the-max-and-the-macro +#define NOMINMAX +#endif +#endif + #include #include #include @@ -13,6 +22,8 @@ #include #include +#include "StarEngine/Core/Base.h" + #include "StarEngine/Core/Log.h" #include "StarEngine/Debug/Instrumentor.h" diff --git a/StarEngine/vendor/imgui b/StarEngine/vendor/imgui index 4d836308..ac746a15 160000 --- a/StarEngine/vendor/imgui +++ b/StarEngine/vendor/imgui @@ -1 +1 @@ -Subproject commit 4d83630870a3b2344b03ebcf3f8353a56f9dae0c +Subproject commit ac746a15195548e6b4fae09e06048896e41bcd8d diff --git a/premake5.lua b/premake5.lua index fd04f492..e85e8fb1 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,3 +1,5 @@ +include "./vendor/premake/premake_customization/solution_items.lua" + workspace "StarEngine" architecture "x86_64" startproject "StarEditor" @@ -9,6 +11,11 @@ workspace "StarEngine" "Dist" } + solution_items + { + ".editorconfig" + } + flags { "MultiProcessorCompile" @@ -16,191 +23,23 @@ workspace "StarEngine" outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}" +-- Include directories relative to root folder (solution directory) IncludeDir = {} -IncludeDir["GLFW"] = "StarEngine/vendor/GLFW/include" -IncludeDir["GLAD"] = "StarEngine/vendor/GLAD/include" -IncludeDir["imgui"] = "StarEngine/vendor/imgui" -IncludeDir["glm"] = "StarEngine/vendor/glm" -IncludeDir["stb_image"] = "StarEngine/vendor/stb_image" -IncludeDir["entt"] = "StarEngine/vendor/entt/include" +IncludeDir["GLFW"] = "%{wks.location}/StarEngine/vendor/GLFW/include" +IncludeDir["GLAD"] = "%{wks.location}/StarEngine/vendor/GLAD/include" +IncludeDir["imgui"] = "%{wks.location}/StarEngine/vendor/imgui" +IncludeDir["glm"] = "%{wks.location}/StarEngine/vendor/glm" +IncludeDir["stb_image"] = "%{wks.location}/StarEngine/vendor/stb_image" +IncludeDir["entt"] = "%{wks.location}/StarEngine/vendor/entt/include" group "Dependencies" + include "vendor/premake" include "StarEngine/vendor/GLFW" include "StarEngine/vendor/GLAD" include "StarEngine/vendor/imgui" group "" -project "StarEngine" - location "StarEngine" - kind "StaticLib" - language "C++" - cppdialect "C++17" - staticruntime "on" - - targetdir ("bin/" .. outputdir .. "/%{prj.name}") - objdir ("bin-int/" .. outputdir .. "/%{prj.name}") - - pchheader "sepch.h" - pchsource "StarEngine/src/sepch.cpp" - - files - { - "%{prj.name}/src/**.h", - "%{prj.name}/src/**.cpp", - "%{prj.name}/vendor/stb_image/**.h", - "%{prj.name}/vendor/stb_image/**.cpp", - "%{prj.name}/vendor/glm/glm/**.hpp", - "%{prj.name}/vendor/glm/glm/**.inl" - } - - defines - { - "_CRT_SECURE_NO_WARNINGS", - "GLFW_INCLUDE_NONE" - } - - includedirs - { - "%{prj.name}/src", - "%{prj.name}/vendor/spdlog/include", - "%{IncludeDir.GLFW}", - "%{IncludeDir.GLAD}", - "%{IncludeDir.imgui}", - "%{IncludeDir.glm}", - "%{IncludeDir.stb_image}", - "%{IncludeDir.entt}" - - - } - - links - { - "GLFW", - "GLAD", - "imgui", - "opengl32.lib", - "dwmapi.lib" - } - - filter "system:windows" - systemversion "latest" - - defines - { - - } - - filter "configurations:Debug" - defines "SE_DEBUG" - runtime "Debug" - symbols "on" - - filter "configurations:Release" - defines "SE_RELEASE" - runtime "Release" - optimize "on" - - filter "configurations:Dist" - defines "SE_DIST" - runtime "Release" - optimize "on" - - filter "action:vs2022" - buildoptions { "/utf-8" } - -project "Sandbox" - location "Sandbox" - kind "ConsoleApp" - language "C++" - cppdialect "C++17" - staticruntime "on" - - targetdir ("bin/" .. outputdir .. "/%{prj.name}") - objdir ("bin-int/" .. outputdir .. "/%{prj.name}") - - files - { - "%{prj.name}/src/**.h", - "%{prj.name}/src/**.cpp" - } - - includedirs - { - "StarEngine/vendor/spdlog/include", - "StarEngine/src", - "StarEngine/vendor", - "%{IncludeDir.glm}", - "%{IncludeDir.entt}" - } - - links - { - "StarEngine" - } - - filter "configurations:Debug" - defines "SE_DEBUG" - runtime "Debug" - symbols "on" - - filter "configurations:Release" - defines "SE_RELEASE" - runtime "Release" - optimize "on" - - filter "configurations:Dist" - defines "SE_DIST" - runtime "Release" - optimize "on" - - filter "action:vs2022" - buildoptions { "/utf-8" } - -project "StarEditor" - location "StarEditor" - kind "ConsoleApp" - language "C++" - cppdialect "C++17" - staticruntime "on" - - targetdir ("bin/" .. outputdir .. "/%{prj.name}") - objdir ("bin-int/" .. outputdir .. "/%{prj.name}") - - files - { - "%{prj.name}/src/**.h", - "%{prj.name}/src/**.cpp" - } - - includedirs - { - "StarEngine/vendor/spdlog/include", - "StarEngine/src", - "StarEngine/vendor", - "%{IncludeDir.glm}", - "%{IncludeDir.entt}" - } - - links - { - "StarEngine" - } - - filter "configurations:Debug" - defines "SE_DEBUG" - runtime "Debug" - symbols "on" - - filter "configurations:Release" - defines "SE_RELEASE" - runtime "Release" - optimize "on" - - filter "configurations:Dist" - defines "SE_DIST" - runtime "Release" - optimize "on" - - filter "action:vs2022" - buildoptions { "/utf-8" } \ No newline at end of file +include "StarEngine" +include "Sandbox" +include "StarEditor" \ No newline at end of file diff --git a/scripts/Win-GenProjects.bat b/scripts/Win-GenProjects.bat index a35f15e6..f7299e16 100644 --- a/scripts/Win-GenProjects.bat +++ b/scripts/Win-GenProjects.bat @@ -1,4 +1,4 @@ pushd ..\ -call vendor\bin\premake\premake5.exe vs2022 +call vendor\premake\bin\premake5.exe vs2022 popd PAUSE \ No newline at end of file diff --git a/vendor/bin/premake/LICENSE.txt b/vendor/premake/bin/LICENSE.txt similarity index 100% rename from vendor/bin/premake/LICENSE.txt rename to vendor/premake/bin/LICENSE.txt diff --git a/vendor/bin/premake/premake5.exe b/vendor/premake/bin/premake5.exe similarity index 100% rename from vendor/bin/premake/premake5.exe rename to vendor/premake/bin/premake5.exe diff --git a/vendor/premake/premake5.lua b/vendor/premake/premake5.lua new file mode 100644 index 00000000..0ed657eb --- /dev/null +++ b/vendor/premake/premake5.lua @@ -0,0 +1,16 @@ +project "Premake" + kind "Utility" + + targetdir ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}") + objdir ("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}") + + files + { + "%{wks.location}/**premake5.lua" + } + + postbuildmessage "Regenerating project files with Premake5!" + postbuildcommands + { + "%{prj.location}bin/premake5 %{_ACTION} --file=\"%{wks.location}premake5.lua\"" + } \ No newline at end of file diff --git a/vendor/premake/premake_customization/solution_items.lua b/vendor/premake/premake_customization/solution_items.lua new file mode 100644 index 00000000..9f6e17fe --- /dev/null +++ b/vendor/premake/premake_customization/solution_items.lua @@ -0,0 +1,24 @@ +-- Implement the solution_items command for solution-scope files +require('vstudio') + +premake.api.register { + name = "solution_items", + scope = "workspace", + kind = "list:string", +} + +premake.override(premake.vstudio.sln2005, "projects", function(base, wks) + if wks.solution_items and #wks.solution_items > 0 then + local solution_folder_GUID = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}" -- See https://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs + premake.push("Project(\"" .. solution_folder_GUID .. "\") = \"Solution Items\", \"Solution Items\", \"{" .. os.uuid("Solution Items:" .. wks.name) .. "}\"") + premake.push("ProjectSection(SolutionItems) = preProject") + + for _, path in ipairs(wks.solution_items) do + premake.w(path .. " = " .. path) + end + + premake.pop("EndProjectSection") + premake.pop("EndProject") + end + base(wks) +end) \ No newline at end of file