diff --git a/.gitmodules b/.gitmodules index 14d5d0d..42df602 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,3 +8,6 @@ [submodule "Navigator/vendor/glfw"] path = Navigator/vendor/glfw url = https://github.com/gwm17/glfw.git +[submodule "Navigator/vendor/implot"] + path = Navigator/vendor/implot + url = https://github.com/gwm17/implot.git diff --git a/Navigator/src/Navigator/Application.cpp b/Navigator/src/Navigator/Application.cpp index b0ef921..25ba800 100644 --- a/Navigator/src/Navigator/Application.cpp +++ b/Navigator/src/Navigator/Application.cpp @@ -1,4 +1,6 @@ #include "Application.h" +#include "Renderer/Renderer.h" +#include "Renderer/RenderCommand.h" namespace Navigator { @@ -57,6 +59,9 @@ namespace Navigator { while(m_runFlag) { + RenderCommand::SetClearColor(m_bckgnd_color); + RenderCommand::Clear(); + for(auto layer : m_stack) layer->OnUpdate(); diff --git a/Navigator/src/Navigator/Application.h b/Navigator/src/Navigator/Application.h index af398de..c5d29dc 100644 --- a/Navigator/src/Navigator/Application.h +++ b/Navigator/src/Navigator/Application.h @@ -34,6 +34,8 @@ namespace Navigator { std::unique_ptr m_window; ImGuiLayer* m_imgui_layer; bool m_runFlag; + + float m_bckgnd_color[4] = {0.1, 0.1, 0.1, 1.0}; static Application* s_instance; }; diff --git a/Navigator/src/Navigator/ImGui/ImGuiLayer.cpp b/Navigator/src/Navigator/ImGui/ImGuiLayer.cpp index 7754c4a..0f4a52b 100644 --- a/Navigator/src/Navigator/ImGui/ImGuiLayer.cpp +++ b/Navigator/src/Navigator/ImGui/ImGuiLayer.cpp @@ -3,6 +3,7 @@ #include "Navigator/NavCore.h" #include "imgui.h" +#include "implot.h" #include "backends/imgui_impl_opengl3.h" #include "backends/imgui_impl_glfw.h" @@ -23,7 +24,11 @@ namespace Navigator { void ImGuiLayer::OnAttach() { IMGUI_CHECKVERSION(); + + NAV_INFO("Creating ImGui Context..."); + ImGui::CreateContext(); + ImPlot::CreateContext(); ImGuiIO& io = ImGui::GetIO(); io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; @@ -45,12 +50,15 @@ namespace Navigator { ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 410"); + + NAV_INFO("ImGui Finished initializing."); } void ImGuiLayer::OnDetach() { ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); + ImPlot::DestroyContext(); ImGui::DestroyContext(); } @@ -86,5 +94,6 @@ namespace Navigator { { static bool show = true; ImGui::ShowDemoWindow(&show); + ImPlot::ShowDemoWindow(); } } \ No newline at end of file diff --git a/Navigator/src/Navigator/Renderer/RenderCommand.cpp b/Navigator/src/Navigator/Renderer/RenderCommand.cpp new file mode 100644 index 0000000..61bcd39 --- /dev/null +++ b/Navigator/src/Navigator/Renderer/RenderCommand.cpp @@ -0,0 +1,6 @@ +#include "RenderCommand.h" +#include "Platform/OpenGL/OpenGLRendererAPI.h" + +namespace Navigator { + RendererAPI* RenderCommand::s_api = new OpenGLRendererAPI(); +} \ No newline at end of file diff --git a/Navigator/src/Navigator/Renderer/RenderCommand.h b/Navigator/src/Navigator/Renderer/RenderCommand.h new file mode 100644 index 0000000..4d41acf --- /dev/null +++ b/Navigator/src/Navigator/Renderer/RenderCommand.h @@ -0,0 +1,19 @@ +#ifndef RENDER_COMMAND_H +#define RENDER_COMMAND_H + +#include "RendererAPI.h" + +namespace Navigator { + + class RenderCommand + { + public: + inline static void SetClearColor(const float* color_array) { s_api->SetClearColor(color_array); } + inline static void Clear() { s_api->Clear(); } + private: + static RendererAPI* s_api; + }; + +} + +#endif \ No newline at end of file diff --git a/Navigator/src/Navigator/Renderer/Renderer.h b/Navigator/src/Navigator/Renderer/Renderer.h new file mode 100644 index 0000000..9dbbcf8 --- /dev/null +++ b/Navigator/src/Navigator/Renderer/Renderer.h @@ -0,0 +1,18 @@ +#ifndef RENDERER_H +#define RENDERER_H + +#include "RendererAPI.h" +#include "RenderCommand.h" + +namespace Navigator { + + class Renderer + { + public: + + static inline RendererAPI::API GetAPI() { return RendererAPI::GetAPI(); } + + }; +} + +#endif \ No newline at end of file diff --git a/Navigator/src/Navigator/Renderer/RendererAPI.cpp b/Navigator/src/Navigator/Renderer/RendererAPI.cpp new file mode 100644 index 0000000..df515ac --- /dev/null +++ b/Navigator/src/Navigator/Renderer/RendererAPI.cpp @@ -0,0 +1,5 @@ +#include "RendererAPI.h" + +namespace Navigator { + RendererAPI::API RendererAPI::s_api = RendererAPI::API::OpenGL; +} \ No newline at end of file diff --git a/Navigator/src/Navigator/Renderer/RendererAPI.h b/Navigator/src/Navigator/Renderer/RendererAPI.h new file mode 100644 index 0000000..38a9fdc --- /dev/null +++ b/Navigator/src/Navigator/Renderer/RendererAPI.h @@ -0,0 +1,26 @@ +#ifndef RENDERER_API_H +#define RENDERER_API_H + +namespace Navigator { + + class RendererAPI + { + public: + enum class API + { + None = 0, + OpenGL = 1 + }; + + virtual void Clear() = 0; + virtual void SetClearColor(const float* color_array) = 0; + + inline static API GetAPI() { return s_api; } + + private: + static API s_api; + }; + +} + +#endif \ No newline at end of file diff --git a/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.cpp b/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.cpp new file mode 100644 index 0000000..9ed9e21 --- /dev/null +++ b/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.cpp @@ -0,0 +1,17 @@ +#include "OpenGLRendererAPI.h" + +#include "glad/glad.h" + +namespace Navigator { + + void OpenGLRendererAPI::Clear() + { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + + void OpenGLRendererAPI::SetClearColor(const float* color_array) + { + glClearColor(color_array[0], color_array[1], color_array[2], color_array[3]); + } + +} \ No newline at end of file diff --git a/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.h b/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.h new file mode 100644 index 0000000..f712b36 --- /dev/null +++ b/Navigator/src/Platform/OpenGL/OpenGLRendererAPI.h @@ -0,0 +1,17 @@ +#ifndef OPENGL_RENDERER_API_H +#define OPENGL_RENDERER_API_H + +#include "Navigator/Renderer/RendererAPI.h" + +namespace Navigator { + + class OpenGLRendererAPI : public RendererAPI + { + public: + virtual void Clear() override; + virtual void SetClearColor(const float* color_array) override; + }; + +} + +#endif \ No newline at end of file diff --git a/Navigator/vendor/implot b/Navigator/vendor/implot new file mode 160000 index 0000000..4fcc6e0 --- /dev/null +++ b/Navigator/vendor/implot @@ -0,0 +1 @@ +Subproject commit 4fcc6e01aca406ef17d5a2dabdcbc9e1bd962c0d diff --git a/navigator.sublime-project b/navigator.sublime-project index 2f7eedd..74c977f 100644 --- a/navigator.sublime-project +++ b/navigator.sublime-project @@ -7,6 +7,6 @@ ], "settings": { - "SublimeLinter.linters.g++.args": ["-c","-Wall","-fsyntax-only","-std=c++17","-include${folder}/Navigator/src/navpch.h","-INavigator/src/", "-INavigator/src/Navigator/","-INavigator/vendor/spdlog/include", "-INavigator/vendor/glfw/include/","-INavigator/vendor/glad/include","-INavigator/vendor/imgui"] + "SublimeLinter.linters.g++.args": ["-c","-Wall","-fsyntax-only","-std=c++17","-include${folder}/Navigator/src/navpch.h","-INavigator/src/", "-INavigator/src/Navigator/","-INavigator/vendor/spdlog/include", "-INavigator/vendor/glfw/include/","-INavigator/vendor/glad/include","-INavigator/vendor/imgui","-INavigator/vendor/implot"] } } \ No newline at end of file diff --git a/premake5.lua b/premake5.lua index db2d8f3..2207b55 100644 --- a/premake5.lua +++ b/premake5.lua @@ -14,6 +14,7 @@ IncludeDirs ={} IncludeDirs["glfw"] = "Navigator/vendor/glfw/include" IncludeDirs["ImGui"] = "Navigator/vendor/imgui" IncludeDirs["glad"] = "Navigator/vendor/glad/include" +IncludeDirs["ImPlot"] = "Navigator/vendor/implot" include "Navigator/vendor/glfw" include "Navigator/vendor/imgui" @@ -41,14 +42,17 @@ project "Navigator" "%{prj.name}/vendor/spdlog/include/", "%{IncludeDirs.glfw}", "%{IncludeDirs.ImGui}", - "%{IncludeDirs.glad}" + "%{IncludeDirs.glad}", + "%{IncludeDirs.ImPlot}" } filter {} files { "%{prj.name}/src/**.h", - "%{prj.name}/src/**.cpp" + "%{prj.name}/vendor/implot/*.h", + "%{prj.name}/src/**.cpp", + "%{prj.name}/vendor/implot/*.cpp" } defines { @@ -116,6 +120,7 @@ project "NavProject" "Navigator/src", "Navigator/src/Navigator", "Navigator/vendor/spdlog/include/", + "Navigator/vendor/implot/", "Navigator/vendor" }