From 0090b94af9be167cf5c399d8091c58e78bff41fd Mon Sep 17 00:00:00 2001 From: lovely_santa Date: Sun, 23 Aug 2020 01:26:01 +0200 Subject: [PATCH] Community maintenance (#320) See PR for details --- .editorconfig | 8 + .github/ISSUE_TEMPLATE/config.yml | 5 + ...ate.md => other-issues--blank-template.md} | 2 +- .gitignore | 4 +- .gitmodules | 8 +- Hazel/premake5.lua | 69 ++++ Hazel/src/Hazel/Core/Base.h | 41 +- Hazel/src/Hazel/Core/Input.h | 5 +- Hazel/src/Hazel/Core/KeyCodes.h | 388 ++++++------------ Hazel/src/Hazel/Core/MouseCodes.h | 54 +-- Hazel/src/Hazel/Core/PlatformDetection.h | 40 ++ Hazel/src/Hazel/Core/Window.h | 2 +- Hazel/src/Hazel/Debug/Instrumentor.h | 4 + Hazel/src/Hazel/Events/Event.h | 3 +- Hazel/src/Hazel/Events/KeyEvent.h | 14 +- Hazel/src/Hazel/Events/MouseEvent.h | 14 +- Hazel/src/Hazel/Renderer/Framebuffer.h | 2 +- .../Renderer/OrthographicCameraController.cpp | 12 +- Hazel/src/Hazel/Renderer/Renderer2D.cpp | 6 +- Hazel/src/Platform/OpenGL/OpenGLContext.cpp | 9 +- Hazel/src/Platform/OpenGL/OpenGLShader.cpp | 5 +- .../src/Platform/OpenGL/OpenGLVertexArray.cpp | 2 +- Hazel/src/Platform/Windows/WindowsInput.cpp | 18 +- Hazel/src/Platform/Windows/WindowsWindow.cpp | 12 +- Hazel/src/hzpch.h | 13 +- Hazelnut/premake5.lua | 46 +++ Hazelnut/src/EditorLayer.cpp | 12 +- Sandbox/premake5.lua | 46 +++ premake5.lua | 191 +-------- scripts/Win-GenProjects.bat | 4 +- .../{bin/premake => premake/bin}/LICENSE.txt | 0 .../{bin/premake => premake/bin}/premake5.exe | Bin vendor/premake/premake5.lua | 16 + .../premake_customization/solution_items.lua | 24 ++ 34 files changed, 502 insertions(+), 577 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/ISSUE_TEMPLATE/config.yml rename .github/ISSUE_TEMPLATE/{issue--blank-template.md => other-issues--blank-template.md} (94%) create mode 100644 Hazel/premake5.lua create mode 100644 Hazel/src/Hazel/Core/PlatformDetection.h create mode 100644 Hazelnut/premake5.lua create mode 100644 Sandbox/premake5.lua rename vendor/{bin/premake => premake/bin}/LICENSE.txt (100%) rename vendor/{bin/premake => premake/bin}/premake5.exe (100%) create mode 100644 vendor/premake/premake5.lua create mode 100644 vendor/premake/premake_customization/solution_items.lua diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..ebc5bf6f6 --- /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 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..42b264dcb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Hazel Community Support (Discord) + url: https://thecherno.com/discord + about: Please ask Hazel related questions in the game-engine-series thread. diff --git a/.github/ISSUE_TEMPLATE/issue--blank-template.md b/.github/ISSUE_TEMPLATE/other-issues--blank-template.md similarity index 94% rename from .github/ISSUE_TEMPLATE/issue--blank-template.md rename to .github/ISSUE_TEMPLATE/other-issues--blank-template.md index d3cfda3bc..862e6c147 100644 --- a/.github/ISSUE_TEMPLATE/issue--blank-template.md +++ b/.github/ISSUE_TEMPLATE/other-issues--blank-template.md @@ -1,5 +1,5 @@ --- -name: 'Issue: Blank template' +name: 'Other issues: Blank template' about: For issues that are not a bug report or feature request --- diff --git a/.gitignore b/.gitignore index 2fd8b7d72..22040749f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Binaries **/bin/ -!vendor/bin/premake/ +!vendor/premake/bin/ bin-int/ # Hazel files @@ -11,4 +11,4 @@ bin-int/ **.sln **.vcxproj **.vcxproj.filters -**.vcxproj.user \ No newline at end of file +**.vcxproj.user diff --git a/.gitmodules b/.gitmodules index 121a579bc..df4d1b1c6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,16 +1,16 @@ [submodule "Hazel/vendor/spdlog"] path = Hazel/vendor/spdlog - url = https://github.com/gabime/spdlog + url = ../../gabime/spdlog.git branch = v1.x [submodule "Hazel/vendor/GLFW"] path = Hazel/vendor/GLFW - url = https://github.com/TheCherno/glfw + url = ../../TheCherno/glfw.git branch = master [submodule "Hazel/vendor/imgui"] path = Hazel/vendor/imgui - url = https://github.com/TheCherno/imgui + url = ../../TheCherno/imgui.git branch = docking [submodule "Hazel/vendor/glm"] path = Hazel/vendor/glm - url = https://github.com/g-truc/glm + url = ../../g-truc/glm.git branch = master diff --git a/Hazel/premake5.lua b/Hazel/premake5.lua new file mode 100644 index 000000000..5820a4ef5 --- /dev/null +++ b/Hazel/premake5.lua @@ -0,0 +1,69 @@ +project "Hazel" + 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 "hzpch.h" + pchsource "src/hzpch.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" + } + + filter "system:windows" + systemversion "latest" + + defines + { + } + + filter "configurations:Debug" + defines "HZ_DEBUG" + runtime "Debug" + symbols "on" + + filter "configurations:Release" + defines "HZ_RELEASE" + runtime "Release" + optimize "on" + + filter "configurations:Dist" + defines "HZ_DIST" + runtime "Release" + optimize "on" diff --git a/Hazel/src/Hazel/Core/Base.h b/Hazel/src/Hazel/Core/Base.h index 419505ed4..f553fdfc4 100644 --- a/Hazel/src/Hazel/Core/Base.h +++ b/Hazel/src/Hazel/Core/Base.h @@ -2,46 +2,7 @@ #include -// Platform detection using predefined macros -#ifdef _WIN32 - /* Windows x64/x86 */ - #ifdef _WIN64 - /* Windows x64 */ - #define HZ_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 HZ_PLATFORM_IOS - #error "IOS is not supported!" - #elif TARGET_OS_MAC == 1 - #define HZ_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 HZ_PLATFORM_ANDROID - #error "Android is not supported!" -#elif defined(__linux__) - #define HZ_PLATFORM_LINUX - #error "Linux is not supported!" -#else - /* Unknown compiler/platform */ - #error "Unknown platform!" -#endif // End of platform detection +#include "Hazel/Core/PlatformDetection.h" #ifdef HZ_DEBUG #if defined(HZ_PLATFORM_WINDOWS) diff --git a/Hazel/src/Hazel/Core/Input.h b/Hazel/src/Hazel/Core/Input.h index 935973094..c4b303309 100644 --- a/Hazel/src/Hazel/Core/Input.h +++ b/Hazel/src/Hazel/Core/Input.h @@ -1,6 +1,7 @@ #pragma once -#include "Hazel/Core/Base.h" +#include + #include "Hazel/Core/KeyCodes.h" #include "Hazel/Core/MouseCodes.h" @@ -12,7 +13,7 @@ namespace Hazel { 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/Hazel/src/Hazel/Core/KeyCodes.h b/Hazel/src/Hazel/Core/KeyCodes.h index 55966f382..eb0e169c9 100644 --- a/Hazel/src/Hazel/Core/KeyCodes.h +++ b/Hazel/src/Hazel/Core/KeyCodes.h @@ -2,271 +2,143 @@ namespace Hazel { - typedef enum class KeyCode : uint16_t + using KeyCode = uint16_t; + + namespace Key { - // From glfw3.h - Space = 32, - Apostrophe = 39, /* ' */ - Comma = 44, /* , */ - Minus = 45, /* - */ - Period = 46, /* . */ - Slash = 47, /* / */ + enum : KeyCode + { + // From glfw3.h + Space = 32, + Apostrophe = 39, /* ' */ + Comma = 44, /* , */ + Minus = 45, /* - */ + Period = 46, /* . */ + Slash = 47, /* / */ - 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 */ + 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 */ - Semicolon = 59, /* ; */ - Equal = 61, /* = */ + Semicolon = 59, /* ; */ + Equal = 61, /* = */ - 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, + 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, - LeftBracket = 91, /* [ */ - Backslash = 92, /* \ */ - RightBracket = 93, /* ] */ - GraveAccent = 96, /* ` */ + LeftBracket = 91, /* [ */ + Backslash = 92, /* \ */ + RightBracket = 93, /* ] */ + GraveAccent = 96, /* ` */ - World1 = 161, /* non-US #1 */ - World2 = 162, /* non-US #2 */ + World1 = 161, /* non-US #1 */ + World2 = 162, /* non-US #2 */ - /* 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, + /* 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, - /* 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, + /* 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, - LeftShift = 340, - LeftControl = 341, - LeftAlt = 342, - LeftSuper = 343, - RightShift = 344, - RightControl = 345, - RightAlt = 346, - RightSuper = 347, - Menu = 348 - } Key; - - 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 HZ_KEY_SPACE ::Hazel::Key::Space -#define HZ_KEY_APOSTROPHE ::Hazel::Key::Apostrophe /* ' */ -#define HZ_KEY_COMMA ::Hazel::Key::Comma /* , */ -#define HZ_KEY_MINUS ::Hazel::Key::Minus /* - */ -#define HZ_KEY_PERIOD ::Hazel::Key::Period /* . */ -#define HZ_KEY_SLASH ::Hazel::Key::Slash /* / */ -#define HZ_KEY_0 ::Hazel::Key::D0 -#define HZ_KEY_1 ::Hazel::Key::D1 -#define HZ_KEY_2 ::Hazel::Key::D2 -#define HZ_KEY_3 ::Hazel::Key::D3 -#define HZ_KEY_4 ::Hazel::Key::D4 -#define HZ_KEY_5 ::Hazel::Key::D5 -#define HZ_KEY_6 ::Hazel::Key::D6 -#define HZ_KEY_7 ::Hazel::Key::D7 -#define HZ_KEY_8 ::Hazel::Key::D8 -#define HZ_KEY_9 ::Hazel::Key::D9 -#define HZ_KEY_SEMICOLON ::Hazel::Key::Semicolon /* ; */ -#define HZ_KEY_EQUAL ::Hazel::Key::Equal /* = */ -#define HZ_KEY_A ::Hazel::Key::A -#define HZ_KEY_B ::Hazel::Key::B -#define HZ_KEY_C ::Hazel::Key::C -#define HZ_KEY_D ::Hazel::Key::D -#define HZ_KEY_E ::Hazel::Key::E -#define HZ_KEY_F ::Hazel::Key::F -#define HZ_KEY_G ::Hazel::Key::G -#define HZ_KEY_H ::Hazel::Key::H -#define HZ_KEY_I ::Hazel::Key::I -#define HZ_KEY_J ::Hazel::Key::J -#define HZ_KEY_K ::Hazel::Key::K -#define HZ_KEY_L ::Hazel::Key::L -#define HZ_KEY_M ::Hazel::Key::M -#define HZ_KEY_N ::Hazel::Key::N -#define HZ_KEY_O ::Hazel::Key::O -#define HZ_KEY_P ::Hazel::Key::P -#define HZ_KEY_Q ::Hazel::Key::Q -#define HZ_KEY_R ::Hazel::Key::R -#define HZ_KEY_S ::Hazel::Key::S -#define HZ_KEY_T ::Hazel::Key::T -#define HZ_KEY_U ::Hazel::Key::U -#define HZ_KEY_V ::Hazel::Key::V -#define HZ_KEY_W ::Hazel::Key::W -#define HZ_KEY_X ::Hazel::Key::X -#define HZ_KEY_Y ::Hazel::Key::Y -#define HZ_KEY_Z ::Hazel::Key::Z -#define HZ_KEY_LEFT_BRACKET ::Hazel::Key::LeftBracket /* [ */ -#define HZ_KEY_BACKSLASH ::Hazel::Key::Backslash /* \ */ -#define HZ_KEY_RIGHT_BRACKET ::Hazel::Key::RightBracket /* ] */ -#define HZ_KEY_GRAVE_ACCENT ::Hazel::Key::GraveAccent /* ` */ -#define HZ_KEY_WORLD_1 ::Hazel::Key::World1 /* non-US #1 */ -#define HZ_KEY_WORLD_2 ::Hazel::Key::World2 /* non-US #2 */ - -/* Function keys */ -#define HZ_KEY_ESCAPE ::Hazel::Key::Escape -#define HZ_KEY_ENTER ::Hazel::Key::Enter -#define HZ_KEY_TAB ::Hazel::Key::Tab -#define HZ_KEY_BACKSPACE ::Hazel::Key::Backspace -#define HZ_KEY_INSERT ::Hazel::Key::Insert -#define HZ_KEY_DELETE ::Hazel::Key::Delete -#define HZ_KEY_RIGHT ::Hazel::Key::Right -#define HZ_KEY_LEFT ::Hazel::Key::Left -#define HZ_KEY_DOWN ::Hazel::Key::Down -#define HZ_KEY_UP ::Hazel::Key::Up -#define HZ_KEY_PAGE_UP ::Hazel::Key::PageUp -#define HZ_KEY_PAGE_DOWN ::Hazel::Key::PageDown -#define HZ_KEY_HOME ::Hazel::Key::Home -#define HZ_KEY_END ::Hazel::Key::End -#define HZ_KEY_CAPS_LOCK ::Hazel::Key::CapsLock -#define HZ_KEY_SCROLL_LOCK ::Hazel::Key::ScrollLock -#define HZ_KEY_NUM_LOCK ::Hazel::Key::NumLock -#define HZ_KEY_PRINT_SCREEN ::Hazel::Key::PrintScreen -#define HZ_KEY_PAUSE ::Hazel::Key::Pause -#define HZ_KEY_F1 ::Hazel::Key::F1 -#define HZ_KEY_F2 ::Hazel::Key::F2 -#define HZ_KEY_F3 ::Hazel::Key::F3 -#define HZ_KEY_F4 ::Hazel::Key::F4 -#define HZ_KEY_F5 ::Hazel::Key::F5 -#define HZ_KEY_F6 ::Hazel::Key::F6 -#define HZ_KEY_F7 ::Hazel::Key::F7 -#define HZ_KEY_F8 ::Hazel::Key::F8 -#define HZ_KEY_F9 ::Hazel::Key::F9 -#define HZ_KEY_F10 ::Hazel::Key::F10 -#define HZ_KEY_F11 ::Hazel::Key::F11 -#define HZ_KEY_F12 ::Hazel::Key::F12 -#define HZ_KEY_F13 ::Hazel::Key::F13 -#define HZ_KEY_F14 ::Hazel::Key::F14 -#define HZ_KEY_F15 ::Hazel::Key::F15 -#define HZ_KEY_F16 ::Hazel::Key::F16 -#define HZ_KEY_F17 ::Hazel::Key::F17 -#define HZ_KEY_F18 ::Hazel::Key::F18 -#define HZ_KEY_F19 ::Hazel::Key::F19 -#define HZ_KEY_F20 ::Hazel::Key::F20 -#define HZ_KEY_F21 ::Hazel::Key::F21 -#define HZ_KEY_F22 ::Hazel::Key::F22 -#define HZ_KEY_F23 ::Hazel::Key::F23 -#define HZ_KEY_F24 ::Hazel::Key::F24 -#define HZ_KEY_F25 ::Hazel::Key::F25 - -/* Keypad */ -#define HZ_KEY_KP_0 ::Hazel::Key::KP0 -#define HZ_KEY_KP_1 ::Hazel::Key::KP1 -#define HZ_KEY_KP_2 ::Hazel::Key::KP2 -#define HZ_KEY_KP_3 ::Hazel::Key::KP3 -#define HZ_KEY_KP_4 ::Hazel::Key::KP4 -#define HZ_KEY_KP_5 ::Hazel::Key::KP5 -#define HZ_KEY_KP_6 ::Hazel::Key::KP6 -#define HZ_KEY_KP_7 ::Hazel::Key::KP7 -#define HZ_KEY_KP_8 ::Hazel::Key::KP8 -#define HZ_KEY_KP_9 ::Hazel::Key::KP9 -#define HZ_KEY_KP_DECIMAL ::Hazel::Key::KPDecimal -#define HZ_KEY_KP_DIVIDE ::Hazel::Key::KPDivide -#define HZ_KEY_KP_MULTIPLY ::Hazel::Key::KPMultiply -#define HZ_KEY_KP_SUBTRACT ::Hazel::Key::KPSubtract -#define HZ_KEY_KP_ADD ::Hazel::Key::KPAdd -#define HZ_KEY_KP_ENTER ::Hazel::Key::KPEnter -#define HZ_KEY_KP_EQUAL ::Hazel::Key::KPEqual - -#define HZ_KEY_LEFT_SHIFT ::Hazel::Key::LeftShift -#define HZ_KEY_LEFT_CONTROL ::Hazel::Key::LeftControl -#define HZ_KEY_LEFT_ALT ::Hazel::Key::LeftAlt -#define HZ_KEY_LEFT_SUPER ::Hazel::Key::LeftSuper -#define HZ_KEY_RIGHT_SHIFT ::Hazel::Key::RightShift -#define HZ_KEY_RIGHT_CONTROL ::Hazel::Key::RightControl -#define HZ_KEY_RIGHT_ALT ::Hazel::Key::RightAlt -#define HZ_KEY_RIGHT_SUPER ::Hazel::Key::RightSuper -#define HZ_KEY_MENU ::Hazel::Key::Menu +} \ No newline at end of file diff --git a/Hazel/src/Hazel/Core/MouseCodes.h b/Hazel/src/Hazel/Core/MouseCodes.h index 00b74cc4c..e151d038b 100644 --- a/Hazel/src/Hazel/Core/MouseCodes.h +++ b/Hazel/src/Hazel/Core/MouseCodes.h @@ -2,40 +2,26 @@ namespace Hazel { - 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, + using MouseCode = uint16_t; - ButtonLast = Button7, - ButtonLeft = Button0, - ButtonRight = Button1, - ButtonMiddle = Button2 - } Mouse; - - 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 HZ_MOUSE_BUTTON_0 ::Hazel::Mouse::Button0 -#define HZ_MOUSE_BUTTON_1 ::Hazel::Mouse::Button1 -#define HZ_MOUSE_BUTTON_2 ::Hazel::Mouse::Button2 -#define HZ_MOUSE_BUTTON_3 ::Hazel::Mouse::Button3 -#define HZ_MOUSE_BUTTON_4 ::Hazel::Mouse::Button4 -#define HZ_MOUSE_BUTTON_5 ::Hazel::Mouse::Button5 -#define HZ_MOUSE_BUTTON_6 ::Hazel::Mouse::Button6 -#define HZ_MOUSE_BUTTON_7 ::Hazel::Mouse::Button7 -#define HZ_MOUSE_BUTTON_LAST ::Hazel::Mouse::ButtonLast -#define HZ_MOUSE_BUTTON_LEFT ::Hazel::Mouse::ButtonLeft -#define HZ_MOUSE_BUTTON_RIGHT ::Hazel::Mouse::ButtonRight -#define HZ_MOUSE_BUTTON_MIDDLE ::Hazel::Mouse::ButtonMiddle + ButtonLast = Button7, + ButtonLeft = Button0, + ButtonRight = Button1, + ButtonMiddle = Button2 + }; + } +} \ No newline at end of file diff --git a/Hazel/src/Hazel/Core/PlatformDetection.h b/Hazel/src/Hazel/Core/PlatformDetection.h new file mode 100644 index 000000000..de346e2ea --- /dev/null +++ b/Hazel/src/Hazel/Core/PlatformDetection.h @@ -0,0 +1,40 @@ +// Platform detection using predefined macros +#ifdef _WIN32 + /* Windows x64/x86 */ + #ifdef _WIN64 + /* Windows x64 */ + #define HZ_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 HZ_PLATFORM_IOS + #error "IOS is not supported!" + #elif TARGET_OS_MAC == 1 + #define HZ_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 HZ_PLATFORM_ANDROID + #error "Android is not supported!" +#elif defined(__linux__) + #define HZ_PLATFORM_LINUX + #error "Linux is not supported!" +#else + /* Unknown compiler/platform */ + #error "Unknown platform!" +#endif // End of platform detection diff --git a/Hazel/src/Hazel/Core/Window.h b/Hazel/src/Hazel/Core/Window.h index 7424081ee..7874f5390 100644 --- a/Hazel/src/Hazel/Core/Window.h +++ b/Hazel/src/Hazel/Core/Window.h @@ -1,6 +1,6 @@ #pragma once -#include "hzpch.h" +#include #include "Hazel/Core/Base.h" #include "Hazel/Events/Event.h" diff --git a/Hazel/src/Hazel/Debug/Instrumentor.h b/Hazel/src/Hazel/Debug/Instrumentor.h index 397fadc18..12e564857 100644 --- a/Hazel/src/Hazel/Debug/Instrumentor.h +++ b/Hazel/src/Hazel/Debug/Instrumentor.h @@ -6,6 +6,10 @@ #include #include #include +#include +#include + +#include "Hazel/Core/Log.h" namespace Hazel { diff --git a/Hazel/src/Hazel/Events/Event.h b/Hazel/src/Hazel/Events/Event.h index b3eabb4fd..4ff7082ea 100644 --- a/Hazel/src/Hazel/Events/Event.h +++ b/Hazel/src/Hazel/Events/Event.h @@ -1,6 +1,7 @@ #pragma once -#include "hzpch.h" +#include +#include "Hazel/Debug/Instrumentor.h" #include "Hazel/Core/Base.h" namespace Hazel { diff --git a/Hazel/src/Hazel/Events/KeyEvent.h b/Hazel/src/Hazel/Events/KeyEvent.h index 068950b3c..9fc9bb565 100644 --- a/Hazel/src/Hazel/Events/KeyEvent.h +++ b/Hazel/src/Hazel/Events/KeyEvent.h @@ -1,7 +1,7 @@ #pragma once #include "Hazel/Events/Event.h" -#include "Hazel/Core/Input.h" +#include "Hazel/Core/KeyCodes.h" namespace Hazel { @@ -12,7 +12,7 @@ namespace Hazel { EVENT_CLASS_CATEGORY(EventCategoryKeyboard | EventCategoryInput) protected: - KeyEvent(KeyCode keycode) + KeyEvent(const KeyCode keycode) : m_KeyCode(keycode) {} KeyCode m_KeyCode; @@ -21,10 +21,10 @@ namespace Hazel { 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 { @@ -35,13 +35,13 @@ namespace Hazel { 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) {} std::string ToString() const override @@ -57,7 +57,7 @@ namespace Hazel { class KeyTypedEvent : public KeyEvent { public: - KeyTypedEvent(KeyCode keycode) + KeyTypedEvent(const KeyCode keycode) : KeyEvent(keycode) {} std::string ToString() const override diff --git a/Hazel/src/Hazel/Events/MouseEvent.h b/Hazel/src/Hazel/Events/MouseEvent.h index 020200f3e..1a9caf4f8 100644 --- a/Hazel/src/Hazel/Events/MouseEvent.h +++ b/Hazel/src/Hazel/Events/MouseEvent.h @@ -1,14 +1,14 @@ #pragma once #include "Hazel/Events/Event.h" -#include "Hazel/Core/Input.h" +#include "Hazel/Core/MouseCodes.h" namespace Hazel { class MouseMovedEvent : public Event { public: - MouseMovedEvent(float x, float y) + MouseMovedEvent(const float x, const float y) : m_MouseX(x), m_MouseY(y) {} float GetX() const { return m_MouseX; } @@ -30,7 +30,7 @@ namespace Hazel { class MouseScrolledEvent : public Event { public: - MouseScrolledEvent(float xOffset, float yOffset) + MouseScrolledEvent(const float xOffset, const float yOffset) : m_XOffset(xOffset), m_YOffset(yOffset) {} float GetXOffset() const { return m_XOffset; } @@ -52,11 +52,11 @@ namespace Hazel { class MouseButtonEvent : public Event { public: - inline MouseCode GetMouseButton() const { return m_Button; } + MouseCode GetMouseButton() const { return m_Button; } EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput) protected: - MouseButtonEvent(MouseCode button) + MouseButtonEvent(const MouseCode button) : m_Button(button) {} MouseCode m_Button; @@ -65,7 +65,7 @@ namespace Hazel { class MouseButtonPressedEvent : public MouseButtonEvent { public: - MouseButtonPressedEvent(MouseCode button) + MouseButtonPressedEvent(const MouseCode button) : MouseButtonEvent(button) {} std::string ToString() const override @@ -81,7 +81,7 @@ namespace Hazel { class MouseButtonReleasedEvent : public MouseButtonEvent { public: - MouseButtonReleasedEvent(MouseCode button) + MouseButtonReleasedEvent(const MouseCode button) : MouseButtonEvent(button) {} std::string ToString() const override diff --git a/Hazel/src/Hazel/Renderer/Framebuffer.h b/Hazel/src/Hazel/Renderer/Framebuffer.h index 3f6e7ac4e..72cbd5bbf 100644 --- a/Hazel/src/Hazel/Renderer/Framebuffer.h +++ b/Hazel/src/Hazel/Renderer/Framebuffer.h @@ -6,7 +6,7 @@ namespace Hazel { struct FramebufferSpecification { - uint32_t Width, Height; + uint32_t Width = 0, Height = 0; // FramebufferFormat Format = uint32_t Samples = 1; diff --git a/Hazel/src/Hazel/Renderer/OrthographicCameraController.cpp b/Hazel/src/Hazel/Renderer/OrthographicCameraController.cpp index 172f62595..a18d8a92c 100644 --- a/Hazel/src/Hazel/Renderer/OrthographicCameraController.cpp +++ b/Hazel/src/Hazel/Renderer/OrthographicCameraController.cpp @@ -15,23 +15,23 @@ namespace Hazel { { HZ_PROFILE_FUNCTION(); - if (Input::IsKeyPressed(HZ_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(HZ_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(HZ_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(HZ_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,9 +39,9 @@ namespace Hazel { if (m_Rotation) { - if (Input::IsKeyPressed(HZ_KEY_Q)) + if (Input::IsKeyPressed(Key::Q)) m_CameraRotation += m_CameraRotationSpeed * ts; - if (Input::IsKeyPressed(HZ_KEY_E)) + if (Input::IsKeyPressed(Key::E)) m_CameraRotation -= m_CameraRotationSpeed * ts; if (m_CameraRotation > 180.0f) diff --git a/Hazel/src/Hazel/Renderer/Renderer2D.cpp b/Hazel/src/Hazel/Renderer/Renderer2D.cpp index e2e4276e2..12670194a 100644 --- a/Hazel/src/Hazel/Renderer/Renderer2D.cpp +++ b/Hazel/src/Hazel/Renderer/Renderer2D.cpp @@ -94,7 +94,7 @@ namespace Hazel { 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 Hazel { 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) @@ -241,7 +241,7 @@ namespace Hazel { 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/Hazel/src/Platform/OpenGL/OpenGLContext.cpp b/Hazel/src/Platform/OpenGL/OpenGLContext.cpp index 772f2a1fb..0f0522775 100644 --- a/Hazel/src/Platform/OpenGL/OpenGLContext.cpp +++ b/Hazel/src/Platform/OpenGL/OpenGLContext.cpp @@ -25,14 +25,7 @@ namespace Hazel { HZ_CORE_INFO(" Renderer: {0}", glGetString(GL_RENDERER)); HZ_CORE_INFO(" Version: {0}", glGetString(GL_VERSION)); - #ifdef HZ_ENABLE_ASSERTS - int versionMajor; - int versionMinor; - glGetIntegerv(GL_MAJOR_VERSION, &versionMajor); - glGetIntegerv(GL_MINOR_VERSION, &versionMinor); - - HZ_CORE_ASSERT(versionMajor > 4 || (versionMajor == 4 && versionMinor >= 5), "Hazel requires at least OpenGL version 4.5!"); - #endif + HZ_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/Hazel/src/Platform/OpenGL/OpenGLShader.cpp b/Hazel/src/Platform/OpenGL/OpenGLShader.cpp index ffa463ab6..f6cd26613 100644 --- a/Hazel/src/Platform/OpenGL/OpenGLShader.cpp +++ b/Hazel/src/Platform/OpenGL/OpenGLShader.cpp @@ -58,7 +58,7 @@ namespace Hazel { HZ_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); @@ -68,7 +68,6 @@ namespace Hazel { result.resize(size); in.seekg(0, std::ios::beg); in.read(&result[0], size); - in.close(); } else { @@ -288,4 +287,4 @@ namespace Hazel { glUniformMatrix4fv(location, 1, GL_FALSE, glm::value_ptr(matrix)); } -} \ No newline at end of file +} diff --git a/Hazel/src/Platform/OpenGL/OpenGLVertexArray.cpp b/Hazel/src/Platform/OpenGL/OpenGLVertexArray.cpp index 7602b3f50..4bf79496d 100644 --- a/Hazel/src/Platform/OpenGL/OpenGLVertexArray.cpp +++ b/Hazel/src/Platform/OpenGL/OpenGLVertexArray.cpp @@ -100,7 +100,7 @@ namespace Hazel { 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/Hazel/src/Platform/Windows/WindowsInput.cpp b/Hazel/src/Platform/Windows/WindowsInput.cpp index 1dbf81656..f18f8e972 100644 --- a/Hazel/src/Platform/Windows/WindowsInput.cpp +++ b/Hazel/src/Platform/Windows/WindowsInput.cpp @@ -6,23 +6,23 @@ namespace Hazel { - bool Input::IsKeyPressed(KeyCode key) + bool Input::IsKeyPressed(const KeyCode key) { - auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); + 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* 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,14 +31,12 @@ namespace Hazel { 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/Hazel/src/Platform/Windows/WindowsWindow.cpp b/Hazel/src/Platform/Windows/WindowsWindow.cpp index 7e8028283..be7684efb 100644 --- a/Hazel/src/Platform/Windows/WindowsWindow.cpp +++ b/Hazel/src/Platform/Windows/WindowsWindow.cpp @@ -94,19 +94,19 @@ namespace Hazel { { 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; } @@ -117,7 +117,7 @@ namespace Hazel { { WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window); - KeyTypedEvent event(static_cast(keycode)); + KeyTypedEvent event(keycode); data.EventCallback(event); }); @@ -129,13 +129,13 @@ namespace Hazel { { 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/Hazel/src/hzpch.h b/Hazel/src/hzpch.h index ded0b0002..2cd7542fe 100644 --- a/Hazel/src/hzpch.h +++ b/Hazel/src/hzpch.h @@ -1,5 +1,14 @@ #pragma once +#include "Hazel/Core/PlatformDetection.h" + +#ifdef HZ_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,10 +22,12 @@ #include #include +#include "Hazel/Core/Base.h" + #include "Hazel/Core/Log.h" #include "Hazel/Debug/Instrumentor.h" #ifdef HZ_PLATFORM_WINDOWS #include -#endif \ No newline at end of file +#endif diff --git a/Hazelnut/premake5.lua b/Hazelnut/premake5.lua new file mode 100644 index 000000000..5ab74377c --- /dev/null +++ b/Hazelnut/premake5.lua @@ -0,0 +1,46 @@ +project "Hazelnut" + 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}/Hazel/vendor/spdlog/include", + "%{wks.location}/Hazel/src", + "%{wks.location}/Hazel/vendor", + "%{IncludeDir.glm}", + "%{IncludeDir.entt}" + } + + links + { + "Hazel" + } + + filter "system:windows" + systemversion "latest" + + filter "configurations:Debug" + defines "HZ_DEBUG" + runtime "Debug" + symbols "on" + + filter "configurations:Release" + defines "HZ_RELEASE" + runtime "Release" + optimize "on" + + filter "configurations:Dist" + defines "HZ_DIST" + runtime "Release" + optimize "on" diff --git a/Hazelnut/src/EditorLayer.cpp b/Hazelnut/src/EditorLayer.cpp index 7b568db29..63d4febf0 100644 --- a/Hazelnut/src/EditorLayer.cpp +++ b/Hazelnut/src/EditorLayer.cpp @@ -54,13 +54,13 @@ namespace Hazel { auto& transform = GetComponent().Transform; float speed = 5.0f; - if (Input::IsKeyPressed(KeyCode::A)) + if (Input::IsKeyPressed(Key::A)) transform[3][0] -= speed * ts; - if (Input::IsKeyPressed(KeyCode::D)) + if (Input::IsKeyPressed(Key::D)) transform[3][0] += speed * ts; - if (Input::IsKeyPressed(KeyCode::W)) + if (Input::IsKeyPressed(Key::W)) transform[3][1] += speed * ts; - if (Input::IsKeyPressed(KeyCode::S)) + if (Input::IsKeyPressed(Key::S)) transform[3][1] -= speed * ts; } }; @@ -218,8 +218,8 @@ namespace Hazel { ImVec2 viewportPanelSize = ImGui::GetContentRegionAvail(); m_ViewportSize = { viewportPanelSize.x, viewportPanelSize.y }; - uint32_t textureID = m_Framebuffer->GetColorAttachmentRendererID(); - ImGui::Image((void*)textureID, ImVec2{ m_ViewportSize.x, m_ViewportSize.y }, ImVec2{ 0, 1 }, ImVec2{ 1, 0 }); + uint64_t textureID = m_Framebuffer->GetColorAttachmentRendererID(); + ImGui::Image(reinterpret_cast(textureID), ImVec2{ m_ViewportSize.x, m_ViewportSize.y }, ImVec2{ 0, 1 }, ImVec2{ 1, 0 }); ImGui::End(); ImGui::PopStyleVar(); diff --git a/Sandbox/premake5.lua b/Sandbox/premake5.lua new file mode 100644 index 000000000..929e457dd --- /dev/null +++ b/Sandbox/premake5.lua @@ -0,0 +1,46 @@ +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}/Hazel/vendor/spdlog/include", + "%{wks.location}/Hazel/src", + "%{wks.location}/Hazel/vendor", + "%{IncludeDir.glm}", + "%{IncludeDir.entt}" + } + + links + { + "Hazel" + } + + filter "system:windows" + systemversion "latest" + + filter "configurations:Debug" + defines "HZ_DEBUG" + runtime "Debug" + symbols "on" + + filter "configurations:Release" + defines "HZ_RELEASE" + runtime "Release" + optimize "on" + + filter "configurations:Dist" + defines "HZ_DIST" + runtime "Release" + optimize "on" diff --git a/premake5.lua b/premake5.lua index 81377a1d3..0c167a418 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,3 +1,5 @@ +include "./vendor/premake/premake_customization/solution_items.lua" + workspace "Hazel" architecture "x86_64" startproject "Hazelnut" @@ -8,7 +10,12 @@ workspace "Hazel" "Release", "Dist" } - + + solution_items + { + ".editorconfig" + } + flags { "MultiProcessorCompile" @@ -18,182 +25,20 @@ outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}" -- Include directories relative to root folder (solution directory) IncludeDir = {} -IncludeDir["GLFW"] = "Hazel/vendor/GLFW/include" -IncludeDir["Glad"] = "Hazel/vendor/Glad/include" -IncludeDir["ImGui"] = "Hazel/vendor/imgui" -IncludeDir["glm"] = "Hazel/vendor/glm" -IncludeDir["stb_image"] = "Hazel/vendor/stb_image" -IncludeDir["entt"] = "Hazel/vendor/entt/include" +IncludeDir["GLFW"] = "%{wks.location}/Hazel/vendor/GLFW/include" +IncludeDir["Glad"] = "%{wks.location}/Hazel/vendor/Glad/include" +IncludeDir["ImGui"] = "%{wks.location}/Hazel/vendor/imgui" +IncludeDir["glm"] = "%{wks.location}/Hazel/vendor/glm" +IncludeDir["stb_image"] = "%{wks.location}/Hazel/vendor/stb_image" +IncludeDir["entt"] = "%{wks.location}/Hazel/vendor/entt/include" group "Dependencies" + include "vendor/premake" include "Hazel/vendor/GLFW" include "Hazel/vendor/Glad" include "Hazel/vendor/imgui" group "" -project "Hazel" - location "Hazel" - kind "StaticLib" - language "C++" - cppdialect "C++17" - staticruntime "on" - - targetdir ("bin/" .. outputdir .. "/%{prj.name}") - objdir ("bin-int/" .. outputdir .. "/%{prj.name}") - - pchheader "hzpch.h" - pchsource "Hazel/src/hzpch.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" - } - - filter "system:windows" - systemversion "latest" - - defines - { - } - - filter "configurations:Debug" - defines "HZ_DEBUG" - runtime "Debug" - symbols "on" - - filter "configurations:Release" - defines "HZ_RELEASE" - runtime "Release" - optimize "on" - - filter "configurations:Dist" - defines "HZ_DIST" - runtime "Release" - optimize "on" - -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 - { - "Hazel/vendor/spdlog/include", - "Hazel/src", - "Hazel/vendor", - "%{IncludeDir.glm}", - "%{IncludeDir.entt}" - } - - links - { - "Hazel" - } - - filter "system:windows" - systemversion "latest" - - filter "configurations:Debug" - defines "HZ_DEBUG" - runtime "Debug" - symbols "on" - - filter "configurations:Release" - defines "HZ_RELEASE" - runtime "Release" - optimize "on" - - filter "configurations:Dist" - defines "HZ_DIST" - runtime "Release" - optimize "on" - -project "Hazelnut" - location "Hazelnut" - 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 - { - "Hazel/vendor/spdlog/include", - "Hazel/src", - "Hazel/vendor", - "%{IncludeDir.glm}", - "%{IncludeDir.entt}" - } - - links - { - "Hazel" - } - - filter "system:windows" - systemversion "latest" - - filter "configurations:Debug" - defines "HZ_DEBUG" - runtime "Debug" - symbols "on" - - filter "configurations:Release" - defines "HZ_RELEASE" - runtime "Release" - optimize "on" - - filter "configurations:Dist" - defines "HZ_DIST" - runtime "Release" - optimize "on" +include "Hazel" +include "Sandbox" +include "Hazelnut" diff --git a/scripts/Win-GenProjects.bat b/scripts/Win-GenProjects.bat index ef49eac52..7325add8d 100644 --- a/scripts/Win-GenProjects.bat +++ b/scripts/Win-GenProjects.bat @@ -1,5 +1,5 @@ @echo off pushd %~dp0\..\ -call vendor\bin\premake\premake5.exe vs2019 +call vendor\premake\bin\premake5.exe vs2019 popd -PAUSE \ No newline at end of file +PAUSE 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 000000000..ab734b15f --- /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\"" + } diff --git a/vendor/premake/premake_customization/solution_items.lua b/vendor/premake/premake_customization/solution_items.lua new file mode 100644 index 000000000..f18885b6a --- /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)