diff --git a/.gitignore b/.gitignore index 7c74e301..13c330d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,19 @@ # Directories **bin/ **bin-int/ +!/vendor/bin +run/ # Files *.user *imgui.ini +Makefile +*.make # Visual Studio .vs/ +.vscode/ *.sln *.vcxproj *.vcxproj.filters -*.vcxproj.user \ No newline at end of file +*.vcxproj.user diff --git a/OpenGL-Core/premake5.lua b/OpenGL-Core/premake5.lua index f6095633..1328fcac 100644 --- a/OpenGL-Core/premake5.lua +++ b/OpenGL-Core/premake5.lua @@ -22,7 +22,8 @@ project "OpenGL-Core" defines { - "_CRT_SECURE_NO_WARNINGS" + "_CRT_SECURE_NO_WARNINGS", + "GLFW_INCLUDE_NONE" } includedirs @@ -40,8 +41,7 @@ project "OpenGL-Core" { "GLFW", "Glad", - "ImGui", - "opengl32.lib" + "ImGui" } filter "system:windows" @@ -49,8 +49,30 @@ project "OpenGL-Core" defines { - "GLCORE_PLATFORM_WINDOWS", - "GLFW_INCLUDE_NONE" + "GLCORE_PLATFORM_WINDOWS" + } + + links + { + "opengl32.lib" + } + + filter "system:linux" + pic "On" + systemversion "latest" + + defines + { + "GLCORE_PLATFORM_LINUX" + } + + links + { + "Xrandr", + "Xi", + "GLU", + "GL", + "X11" } filter "configurations:Debug" diff --git a/OpenGL-Core/src/GLCore/Core/Application.cpp b/OpenGL-Core/src/GLCore/Core/Application.cpp index ad93a482..7937a560 100644 --- a/OpenGL-Core/src/GLCore/Core/Application.cpp +++ b/OpenGL-Core/src/GLCore/Core/Application.cpp @@ -5,7 +5,7 @@ #include "Input.h" -#include +#include namespace GLCore { diff --git a/OpenGL-Core/src/GLCore/Core/Core.h b/OpenGL-Core/src/GLCore/Core/Core.h index b59cf72b..de3b4fb0 100644 --- a/OpenGL-Core/src/GLCore/Core/Core.h +++ b/OpenGL-Core/src/GLCore/Core/Core.h @@ -3,12 +3,21 @@ #include +#if defined GLCORE_PLATFORM_WINDOWS + #define GLCORE_DEBUG_BREAK() __debugbreak() +#elif defined GLCORE_PLATFORM_LINUX + #include + #define GLCORE_DEBUG_BREAK() raise(SIGTRAP) +#else + #error Unsupported platform! +#endif + #ifdef GLCORE_DEBUG #define GLCORE_ENABLE_ASSERTS #endif #ifdef GLCORE_ENABLE_ASSERTS - #define GLCORE_ASSERT(x, ...) { if(!(x)) { LOG_ERROR("Assertion Failed: {0}", __VA_ARGS__); __debugbreak(); } } + #define GLCORE_ASSERT(x, ...) { if(!(x)) { LOG_ERROR("Assertion Failed: {0}", __VA_ARGS__); GLCORE_DEBUG_BREAK(); } } #else #define GLCORE_ASSERT(x, ...) #endif diff --git a/OpenGL-Core/src/GLCore/Events/Event.h b/OpenGL-Core/src/GLCore/Events/Event.h index 040d98de..8de24c1d 100644 --- a/OpenGL-Core/src/GLCore/Events/Event.h +++ b/OpenGL-Core/src/GLCore/Events/Event.h @@ -29,7 +29,7 @@ namespace GLCore { EventCategoryMouseButton = BIT(4) }; -#define EVENT_CLASS_TYPE(type) static EventType GetStaticType() { return EventType::##type; }\ +#define EVENT_CLASS_TYPE(type) static EventType GetStaticType() { return EventType::type; }\ virtual EventType GetEventType() const override { return GetStaticType(); }\ virtual const char* GetName() const override { return #type; } diff --git a/OpenGL-Core/src/GLCore/ImGui/ImGuiLayer.h b/OpenGL-Core/src/GLCore/ImGui/ImGuiLayer.h index 2b25206e..9cf2e323 100644 --- a/OpenGL-Core/src/GLCore/ImGui/ImGuiLayer.h +++ b/OpenGL-Core/src/GLCore/ImGui/ImGuiLayer.h @@ -20,8 +20,8 @@ namespace GLCore { void Begin(); void End(); - virtual void ImGuiLayer::OnEvent(Event& event); - bool ImGuiLayer::OnMouseButtonPressed(MouseButtonPressedEvent& e); + virtual void OnEvent(Event& event); + bool OnMouseButtonPressed(MouseButtonPressedEvent& e); private: float m_Time = 0.0f; }; diff --git a/OpenGL-Core/src/Platform/Windows/WindowsWindow.cpp b/OpenGL-Core/src/Platform/Windows/WindowsWindow.cpp index 322e4b66..6b1a6576 100644 --- a/OpenGL-Core/src/Platform/Windows/WindowsWindow.cpp +++ b/OpenGL-Core/src/Platform/Windows/WindowsWindow.cpp @@ -46,6 +46,10 @@ namespace GLCore { s_GLFWInitialized = true; } + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + m_Window = glfwCreateWindow((int)props.Width, (int)props.Height, m_Data.Title.c_str(), nullptr, nullptr); glfwMakeContextCurrent(m_Window); diff --git a/OpenGL-Core/vendor/Glad/premake5.lua b/OpenGL-Core/vendor/Glad/premake5.lua index 5c87ad13..4add0f8f 100644 --- a/OpenGL-Core/vendor/Glad/premake5.lua +++ b/OpenGL-Core/vendor/Glad/premake5.lua @@ -17,6 +17,10 @@ project "Glad" { "include" } + + filter "system:linux" + pic "On" + systemversion "latest" filter "system:windows" systemversion "latest" diff --git a/OpenGL-Examples/premake5.lua b/OpenGL-Examples/premake5.lua index 686b1adf..4c5db8b9 100644 --- a/OpenGL-Examples/premake5.lua +++ b/OpenGL-Examples/premake5.lua @@ -36,6 +36,28 @@ project "OpenGL-Examples" "GLCORE_PLATFORM_WINDOWS" } + filter "system:linux" + systemversion "latest" + + links + { + "GLFW", + "Glad", + "ImGui", + "Xrandr", + "Xi", + "GLU", + "GL", + "X11", + "dl", + "pthread", + } + + defines + { + "GLCORE_PLATFORM_LINUX" + } + filter "configurations:Debug" defines "GLCORE_DEBUG" runtime "Debug" @@ -44,4 +66,4 @@ project "OpenGL-Examples" filter "configurations:Release" defines "GLCORE_RELEASE" runtime "Release" - optimize "on" + optimize "on" diff --git a/OpenGL-Sandbox/premake5.lua b/OpenGL-Sandbox/premake5.lua index 467323f0..5ad51b96 100644 --- a/OpenGL-Sandbox/premake5.lua +++ b/OpenGL-Sandbox/premake5.lua @@ -36,6 +36,28 @@ project "OpenGL-Sandbox" "GLCORE_PLATFORM_WINDOWS" } + filter "system:linux" + systemversion "latest" + + links + { + "GLFW", + "Glad", + "ImGui", + "Xrandr", + "Xi", + "GLU", + "GL", + "X11", + "dl", + "pthread", + } + + defines + { + "GLCORE_PLATFORM_LINUX" + } + filter "configurations:Debug" defines "GLCORE_DEBUG" runtime "Debug" @@ -44,4 +66,4 @@ project "OpenGL-Sandbox" filter "configurations:Release" defines "GLCORE_RELEASE" runtime "Release" - optimize "on" + optimize "on" diff --git a/premake5.lua b/premake5.lua index 9c88aaec..c2ebfbf8 100644 --- a/premake5.lua +++ b/premake5.lua @@ -18,7 +18,7 @@ outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}" -- Include directories relative to OpenGL-Core IncludeDir = {} -IncludeDir["GLFW"] = "vendor/GLFW/include" +IncludeDir["GLFW"] = "vendor/glfw/include" IncludeDir["Glad"] = "vendor/Glad/include" IncludeDir["ImGui"] = "vendor/imgui" IncludeDir["glm"] = "vendor/glm" @@ -26,7 +26,7 @@ IncludeDir["stb_image"] = "vendor/stb_image" -- Projects group "Dependencies" - include "OpenGL-Core/vendor/GLFW" + include "OpenGL-Core/vendor/glfw" include "OpenGL-Core/vendor/Glad" include "OpenGL-Core/vendor/imgui" group "" @@ -55,7 +55,7 @@ outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}" -- Include directories relative to OpenGL-Core IncludeDir = {} -IncludeDir["GLFW"] = "vendor/GLFW/include" +IncludeDir["GLFW"] = "vendor/glfw/include" IncludeDir["Glad"] = "vendor/Glad/include" IncludeDir["ImGui"] = "vendor/imgui" IncludeDir["glm"] = "vendor/glm" @@ -63,10 +63,10 @@ IncludeDir["stb_image"] = "vendor/stb_image" -- Projects group "Dependencies" - includeexternal "OpenGL-Core/vendor/GLFW" + includeexternal "OpenGL-Core/vendor/glfw" includeexternal "OpenGL-Core/vendor/Glad" includeexternal "OpenGL-Core/vendor/imgui" group "" includeexternal "OpenGL-Core" -include "OpenGL-Examples" \ No newline at end of file +include "OpenGL-Examples" diff --git a/scripts/Linux-Premake.sh b/scripts/Linux-Premake.sh new file mode 100755 index 00000000..f883d869 --- /dev/null +++ b/scripts/Linux-Premake.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd "$SCRIPTS_DIR/.." + +vendor/bin/premake/premake5 gmake2 \ No newline at end of file diff --git a/scripts/Linux-RunSandbox.sh b/scripts/Linux-RunSandbox.sh new file mode 100755 index 00000000..c13a7869 --- /dev/null +++ b/scripts/Linux-RunSandbox.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd "$SCRIPTS_DIR/.." + +mkdir -p run + +rm -rf run/assets +cp -rf OpenGL-Sandbox/assets run + +cd run + +../bin/Debug-linux-x86_64/OpenGL-Sandbox/OpenGL-Sandbox \ No newline at end of file diff --git a/vendor/bin/premake/premake5 b/vendor/bin/premake/premake5 new file mode 100755 index 00000000..0526ed6f Binary files /dev/null and b/vendor/bin/premake/premake5 differ