Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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
*.vcxproj.user
32 changes: 27 additions & 5 deletions OpenGL-Core/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ project "OpenGL-Core"

defines
{
"_CRT_SECURE_NO_WARNINGS"
"_CRT_SECURE_NO_WARNINGS",
"GLFW_INCLUDE_NONE"
}

includedirs
Expand All @@ -40,17 +41,38 @@ project "OpenGL-Core"
{
"GLFW",
"Glad",
"ImGui",
"opengl32.lib"
"ImGui"
}

filter "system:windows"
systemversion "latest"

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"
Expand Down
2 changes: 1 addition & 1 deletion OpenGL-Core/src/GLCore/Core/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "Input.h"

#include <glfw/glfw3.h>
#include <GLFW/glfw3.h>

namespace GLCore {

Expand Down
11 changes: 10 additions & 1 deletion OpenGL-Core/src/GLCore/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@

#include <memory>

#if defined GLCORE_PLATFORM_WINDOWS
#define GLCORE_DEBUG_BREAK() __debugbreak()
#elif defined GLCORE_PLATFORM_LINUX
#include <signal.h>
#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
Expand Down
2 changes: 1 addition & 1 deletion OpenGL-Core/src/GLCore/Events/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }\

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that Yan is using the token-pasting operator (##) to concat EventType:: with whatever is the name pasted as type argument, so I wouldn't remove the operator here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ## operator is proprietary to Microsoft's compiler!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I am not so sure about it tho as I have used it with gcc and clang professionally under various architecture implementations of the compiler standard. Here's an example code that makes use of the ## operator compiled using gcc-7: https://godbolt.org/z/TEGszs

Also, the cppreference preprocessor docs don't seem to say anything about compiler specifics: https://en.cppreference.com/w/cpp/preprocessor/replace

And I have personally compiled the code under clang and gcc on both Linux (gcc and clang) and MacOS (clang) as is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this operator on Godbolt during the summer and found that ## works on the most recent few major versions of GCC. The above is ::## which is different.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sweet, well not cool but ... 😆 I am wondering what could've made this compile fine for me, as far as I remember tho.
I guess there's nothing more that can be done for the above compiler feature support war. I've been misled :(

virtual const char* GetName() const override { return #type; }

Expand Down
4 changes: 2 additions & 2 deletions OpenGL-Core/src/GLCore/ImGui/ImGuiLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 4 additions & 0 deletions OpenGL-Core/vendor/Glad/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ project "Glad"
{
"include"
}

filter "system:linux"
pic "On"
systemversion "latest"

filter "system:windows"
systemversion "latest"
Expand Down
24 changes: 23 additions & 1 deletion OpenGL-Examples/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -44,4 +66,4 @@ project "OpenGL-Examples"
filter "configurations:Release"
defines "GLCORE_RELEASE"
runtime "Release"
optimize "on"
optimize "on"
24 changes: 23 additions & 1 deletion OpenGL-Sandbox/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -44,4 +66,4 @@ project "OpenGL-Sandbox"
filter "configurations:Release"
defines "GLCORE_RELEASE"
runtime "Release"
optimize "on"
optimize "on"
10 changes: 5 additions & 5 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ 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"
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 ""
Expand Down Expand Up @@ -55,18 +55,18 @@ 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"
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"
include "OpenGL-Examples"
6 changes: 6 additions & 0 deletions scripts/Linux-Premake.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions scripts/Linux-RunSandbox.sh
Original file line number Diff line number Diff line change
@@ -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
Binary file added vendor/bin/premake/premake5
Binary file not shown.