mirror of
https://github.com/gwm17/Specter.git
synced 2024-11-22 18:28:52 -05:00
Added very barebones renderer to facilitate clearing and setting the background. Added ImPlot for the desired plotting functionality.
This commit is contained in:
parent
e7ae9301e4
commit
7001ef21a4
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ namespace Navigator {
|
|||
ImGuiLayer* m_imgui_layer;
|
||||
bool m_runFlag;
|
||||
|
||||
float m_bckgnd_color[4] = {0.1, 0.1, 0.1, 1.0};
|
||||
|
||||
static Application* s_instance;
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
6
Navigator/src/Navigator/Renderer/RenderCommand.cpp
Normal file
6
Navigator/src/Navigator/Renderer/RenderCommand.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include "RenderCommand.h"
|
||||
#include "Platform/OpenGL/OpenGLRendererAPI.h"
|
||||
|
||||
namespace Navigator {
|
||||
RendererAPI* RenderCommand::s_api = new OpenGLRendererAPI();
|
||||
}
|
19
Navigator/src/Navigator/Renderer/RenderCommand.h
Normal file
19
Navigator/src/Navigator/Renderer/RenderCommand.h
Normal file
|
@ -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
|
18
Navigator/src/Navigator/Renderer/Renderer.h
Normal file
18
Navigator/src/Navigator/Renderer/Renderer.h
Normal file
|
@ -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
|
5
Navigator/src/Navigator/Renderer/RendererAPI.cpp
Normal file
5
Navigator/src/Navigator/Renderer/RendererAPI.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include "RendererAPI.h"
|
||||
|
||||
namespace Navigator {
|
||||
RendererAPI::API RendererAPI::s_api = RendererAPI::API::OpenGL;
|
||||
}
|
26
Navigator/src/Navigator/Renderer/RendererAPI.h
Normal file
26
Navigator/src/Navigator/Renderer/RendererAPI.h
Normal file
|
@ -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
|
17
Navigator/src/Platform/OpenGL/OpenGLRendererAPI.cpp
Normal file
17
Navigator/src/Platform/OpenGL/OpenGLRendererAPI.cpp
Normal file
|
@ -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]);
|
||||
}
|
||||
|
||||
}
|
17
Navigator/src/Platform/OpenGL/OpenGLRendererAPI.h
Normal file
17
Navigator/src/Platform/OpenGL/OpenGLRendererAPI.h
Normal file
|
@ -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
|
1
Navigator/vendor/implot
vendored
Submodule
1
Navigator/vendor/implot
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 4fcc6e01aca406ef17d5a2dabdcbc9e1bd962c0d
|
|
@ -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"]
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user