added queuing push and pop logic and having fun with c# integration
This commit is contained in:
@@ -24,8 +24,11 @@ target_link_libraries(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
|||||||
spdlog::spdlog
|
spdlog::spdlog
|
||||||
imgui::imgui
|
imgui::imgui
|
||||||
open_engine
|
open_engine
|
||||||
|
dl
|
||||||
|
nethost
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
target_link_directories(${PROJECT_EXECUTABLE_NAME} PRIVATE
|
||||||
${PROJECT_SOURCE_DIR}/lib
|
${PROJECT_SOURCE_DIR}/lib
|
||||||
|
/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.0/runtimes/arch-x64/native
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,10 +3,13 @@
|
|||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <open_engine.hpp>
|
#include <open_engine.hpp>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.0/runtimes/arch-x64/native/nethost.h"
|
#include "/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.0/runtimes/arch-x64/native/nethost.h"
|
||||||
#include "/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.0/runtimes/arch-x64/native/hostfxr.h"
|
#include "/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.0/runtimes/arch-x64/native/hostfxr.h"
|
||||||
#include "/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.0/runtimes/arch-x64/native/coreclr_delegates.h"
|
#include "/usr/share/dotnet/packs/Microsoft.NETCore.App.Host.arch-x64/10.0.0/runtimes/arch-x64/native/coreclr_delegates.h"
|
||||||
|
#include "open_engine/core/time.hpp"
|
||||||
|
#include "open_engine/logging.hpp"
|
||||||
|
|
||||||
class Modding : public OpenEngine::Layer
|
class Modding : public OpenEngine::Layer
|
||||||
{
|
{
|
||||||
@@ -74,6 +77,7 @@ class Modding : public OpenEngine::Layer
|
|||||||
void OnAttach() override
|
void OnAttach() override
|
||||||
{
|
{
|
||||||
load_hostfxr();
|
load_hostfxr();
|
||||||
|
|
||||||
auto load_assembly_and_get_function_pointer = get_dotnet_load_assembly("assets/scripts/mod_loader.runtimeconfig.json");
|
auto load_assembly_and_get_function_pointer = get_dotnet_load_assembly("assets/scripts/mod_loader.runtimeconfig.json");
|
||||||
component_entry_point_fn init = nullptr;
|
component_entry_point_fn init = nullptr;
|
||||||
int rc = load_assembly_and_get_function_pointer(
|
int rc = load_assembly_and_get_function_pointer(
|
||||||
@@ -85,6 +89,14 @@ class Modding : public OpenEngine::Layer
|
|||||||
(void**)&init);
|
(void**)&init);
|
||||||
|
|
||||||
init(nullptr, 1);
|
init(nullptr, 1);
|
||||||
|
|
||||||
|
rc = load_assembly_and_get_function_pointer(
|
||||||
|
dotnet_lib_path,
|
||||||
|
dotnet_type,
|
||||||
|
"Hello",
|
||||||
|
UNMANAGEDCALLERSONLY_METHOD /*delegate_type_name*/,
|
||||||
|
nullptr,
|
||||||
|
(void**)&hello);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDetach() override
|
void OnDetach() override
|
||||||
@@ -93,6 +105,14 @@ class Modding : public OpenEngine::Layer
|
|||||||
|
|
||||||
void OnUpdate() override
|
void OnUpdate() override
|
||||||
{
|
{
|
||||||
|
static float time = 0;
|
||||||
|
|
||||||
|
time += OpenEngine::Time::Get().DeltaTime();
|
||||||
|
|
||||||
|
if (time >= 1) {
|
||||||
|
hello(nullptr, 1);
|
||||||
|
time = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEvent(OpenEngine::Event& event) override
|
void OnEvent(OpenEngine::Event& event) override
|
||||||
@@ -111,6 +131,8 @@ class Modding : public OpenEngine::Layer
|
|||||||
hostfxr_get_runtime_delegate_fn get_delegate_fptr;
|
hostfxr_get_runtime_delegate_fn get_delegate_fptr;
|
||||||
hostfxr_close_fn close_fptr;
|
hostfxr_close_fn close_fptr;
|
||||||
|
|
||||||
|
component_entry_point_fn hello = nullptr;
|
||||||
|
|
||||||
const char_t* dotnet_lib_path = "assets/scripts/mod_loader.dll";
|
const char_t* dotnet_lib_path = "assets/scripts/mod_loader.dll";
|
||||||
const char_t* dotnet_type = "OpenEngine.ModLoader, mod_loader";
|
const char_t* dotnet_type = "OpenEngine.ModLoader, mod_loader";
|
||||||
const char_t* dotnet_type_method = "Init";
|
const char_t* dotnet_type_method = "Init";
|
||||||
|
|||||||
@@ -47,8 +47,15 @@ class SandboxLayer : public OpenEngine::Layer
|
|||||||
return square_vertex_array;
|
return square_vertex_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnDetach() override
|
||||||
|
{
|
||||||
|
OE_DEBUG("OnDetach {}", __PRETTY_FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
SandboxLayer()
|
SandboxLayer()
|
||||||
: Layer("Sandbox")
|
: Layer("sandbox"),
|
||||||
|
camera((float)OpenEngine::Application::Get().GetWindow().GetWidth() /
|
||||||
|
OpenEngine::Application::Get().GetWindow().GetHeight(), 1.0f)
|
||||||
{
|
{
|
||||||
//vertex_array.reset(OpenEngine::VertexArray::Create());
|
//vertex_array.reset(OpenEngine::VertexArray::Create());
|
||||||
square = CreateSquare();
|
square = CreateSquare();
|
||||||
@@ -82,11 +89,11 @@ class SandboxLayer : public OpenEngine::Layer
|
|||||||
texture = OpenEngine::Texture2D::Create("./assets/textures/container.jpg");
|
texture = OpenEngine::Texture2D::Create("./assets/textures/container.jpg");
|
||||||
face = OpenEngine::Texture2D::Create("./assets/textures/awesomeface.png");
|
face = OpenEngine::Texture2D::Create("./assets/textures/awesomeface.png");
|
||||||
|
|
||||||
std::dynamic_pointer_cast<OpenEngine::OpenGLShader>(texture_shader)->Bind();
|
texture_shader->Bind();
|
||||||
std::dynamic_pointer_cast<OpenEngine::OpenGLShader>(texture_shader)->SetInt("u_Texture", 0);
|
texture_shader->SetInt("u_Texture", 0);
|
||||||
|
|
||||||
for (auto joystick : OpenEngine::Input::GetJoystickList())
|
for (auto joystick : OpenEngine::Input::GetJoystickList())
|
||||||
OE_TRACE("Joystick {}: {}", joystick.first, joystick.second);
|
OE_DEBUG("Joystick {}: {}", joystick.first, joystick.second);
|
||||||
|
|
||||||
bindings = {
|
bindings = {
|
||||||
{"fwd/bckwd", 1},
|
{"fwd/bckwd", 1},
|
||||||
@@ -155,9 +162,9 @@ class SandboxLayer : public OpenEngine::Layer
|
|||||||
auto texture_shader = shader_library.Get("texture");
|
auto texture_shader = shader_library.Get("texture");
|
||||||
|
|
||||||
texture_shader->Bind();
|
texture_shader->Bind();
|
||||||
texture->Bind();
|
//texture->Bind();
|
||||||
glm::mat4 square_transform = glm::translate(glm::mat4(1.0f), square_pos) * scale;
|
glm::mat4 square_transform = glm::translate(glm::mat4(1.0f), square_pos) * scale;
|
||||||
OpenEngine::Renderer::Submit(texture_shader, square, square_transform);
|
//OpenEngine::Renderer::Submit(texture_shader, square, square_transform);
|
||||||
moveSquare(square_pos);
|
moveSquare(square_pos);
|
||||||
moveSquareF(square_pos);
|
moveSquareF(square_pos);
|
||||||
|
|
||||||
@@ -174,21 +181,10 @@ class SandboxLayer : public OpenEngine::Layer
|
|||||||
void OnEvent(OpenEngine::Event& event) override
|
void OnEvent(OpenEngine::Event& event) override
|
||||||
{
|
{
|
||||||
OpenEngine::EventDispatcher dispatcher(event);
|
OpenEngine::EventDispatcher dispatcher(event);
|
||||||
dispatcher.Dispatch<OpenEngine::KeyPressedEvent>(BIND_EVENT_FN(SandboxLayer::QuitRunning));
|
|
||||||
|
|
||||||
camera.OnEvent(event);
|
camera.OnEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuitRunning(OpenEngine::KeyPressedEvent& event)
|
|
||||||
{
|
|
||||||
if (event.GetKeyCode() == OE_KEY_ESCAPE) {
|
|
||||||
OpenEngine::Application::Get().StopRunning();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnImGuiRender() override
|
void OnImGuiRender() override
|
||||||
{
|
{
|
||||||
static std::vector<std::string> axis_labels;
|
static std::vector<std::string> axis_labels;
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ bool ControlLayer::SwitchLayer(OpenEngine::KeyPressedEvent& event)
|
|||||||
OE_DEBUG("Sandbox2D Layer");
|
OE_DEBUG("Sandbox2D Layer");
|
||||||
layer = OpenEngine::CreateRef<Sandbox2DLayer>();
|
layer = OpenEngine::CreateRef<Sandbox2DLayer>();
|
||||||
|
|
||||||
app.PushLayer(layer);
|
app.QueueLayerPush(layer);
|
||||||
app.PopLayer(active_layer);
|
app.QueueLayerPop(active_layer);
|
||||||
active_layer = layer;
|
active_layer = layer;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -30,8 +30,8 @@ bool ControlLayer::SwitchLayer(OpenEngine::KeyPressedEvent& event)
|
|||||||
OE_DEBUG("Sandbox Layer");
|
OE_DEBUG("Sandbox Layer");
|
||||||
layer = OpenEngine::CreateRef<SandboxLayer>();
|
layer = OpenEngine::CreateRef<SandboxLayer>();
|
||||||
|
|
||||||
app.PushLayer(layer);
|
app.QueueLayerPush(layer);
|
||||||
app.PopLayer(active_layer);
|
app.QueueLayerPop(active_layer);
|
||||||
active_layer = layer;
|
active_layer = layer;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,8 +1,20 @@
|
|||||||
|
#include <memory>
|
||||||
|
#include <sandbox2d.hpp>
|
||||||
#include <sandbox.hpp>
|
#include <sandbox.hpp>
|
||||||
|
#include <control_layer.hpp>
|
||||||
|
#include <modding.hpp>
|
||||||
|
|
||||||
|
#include <open_engine/entry_point.hpp>
|
||||||
|
|
||||||
Sandbox::Sandbox()
|
Sandbox::Sandbox()
|
||||||
{
|
{
|
||||||
PushLayer(new SandboxLayer());
|
OpenEngine::Ref<Sandbox2DLayer> initial_layer = std::make_shared<Sandbox2DLayer>();
|
||||||
|
OpenEngine::Ref<ControlLayer> control_layer = std::make_shared<ControlLayer>(initial_layer);
|
||||||
|
OpenEngine::Ref<Modding> modding_layer = std::make_shared<Modding>();
|
||||||
|
|
||||||
|
QueueLayerPush(modding_layer);
|
||||||
|
QueueLayerPush(control_layer);
|
||||||
|
QueueLayerPush(initial_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sandbox::~Sandbox()
|
Sandbox::~Sandbox()
|
||||||
|
|||||||
@@ -12,12 +12,8 @@
|
|||||||
#include "open_engine/input/keycodes.hpp"
|
#include "open_engine/input/keycodes.hpp"
|
||||||
#include "open_engine/renderer/buffer.hpp"
|
#include "open_engine/renderer/buffer.hpp"
|
||||||
#include "open_engine/renderer/shader.hpp"
|
#include "open_engine/renderer/shader.hpp"
|
||||||
#include "open_engine/opengl/opengl_shader.hpp"
|
|
||||||
#include "open_engine/renderer/texture.hpp"
|
#include "open_engine/renderer/texture.hpp"
|
||||||
#include "open_engine/orthographic_camera_controller.hpp"
|
#include "open_engine/orthographic_camera_controller.hpp"
|
||||||
|
#include "open_engine/renderer/renderer2d.hpp"
|
||||||
// Entry Point -------------------------
|
|
||||||
#include "open_engine/entry_point.hpp"
|
|
||||||
// -------------------------------------
|
|
||||||
|
|
||||||
#endif // OPEN_ENGINE_HPP
|
#endif // OPEN_ENGINE_HPP
|
||||||
|
|||||||
@@ -15,14 +15,21 @@ namespace OpenEngine {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Application();
|
Application();
|
||||||
virtual ~Application() = default;
|
~Application();
|
||||||
|
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
virtual void OnEvent(Event& event);
|
virtual void OnEvent(Event& event);
|
||||||
|
|
||||||
void PushLayer(Layer* layer);
|
//void PushOverlay(Ref<Layer> overlay);
|
||||||
void PushOverlay(Layer* overlay);
|
//void PopOverlay(Ref<Layer> overlay);
|
||||||
|
|
||||||
|
//void PushLayer(Ref<Layer> layer);
|
||||||
|
//void PopLayer();
|
||||||
|
void QueueLayerPush(Ref<Layer> layer);
|
||||||
|
void QueueLayerPop(Ref<Layer> layer);
|
||||||
|
void QueueOverlayPush(Ref<Layer> layer);
|
||||||
|
void QueueOverlayPop(Ref<Layer> layer);
|
||||||
|
|
||||||
inline static Application& Get() { return *instance; }
|
inline static Application& Get() { return *instance; }
|
||||||
|
|
||||||
@@ -38,7 +45,7 @@ namespace OpenEngine {
|
|||||||
bool running = true;
|
bool running = true;
|
||||||
std::unique_ptr<Window> window;
|
std::unique_ptr<Window> window;
|
||||||
|
|
||||||
ImGuiLayer* imgui_layer;
|
Ref<ImGuiLayer> imgui_layer;
|
||||||
LayerStack layer_stack;
|
LayerStack layer_stack;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,19 @@
|
|||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using Scope = std::unique_ptr<T>;
|
using Scope = std::unique_ptr<T>;
|
||||||
|
template<typename T, typename ... Args>
|
||||||
|
constexpr Scope<T> CreateScope(Args&& ... args)
|
||||||
|
{
|
||||||
|
return std::make_unique<T>(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using Ref = std::shared_ptr<T>;
|
using Ref = std::shared_ptr<T>;
|
||||||
|
template<typename T, typename ... Args>
|
||||||
|
constexpr Ref<T> CreateRef(Args&& ... args)
|
||||||
|
{
|
||||||
|
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CORE_HPP
|
#endif // CORE_HPP
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
auto app = OpenEngine::CreateApplication();
|
auto app = OpenEngine::CreateApplication();
|
||||||
app->Run();
|
app->Run();
|
||||||
|
|
||||||
delete app;
|
delete app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace OpenEngine {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImGuiLayer();
|
ImGuiLayer();
|
||||||
~ImGuiLayer() = default;
|
~ImGuiLayer();
|
||||||
|
|
||||||
virtual void OnAttach() override;
|
virtual void OnAttach() override;
|
||||||
virtual void OnDetach() override;
|
virtual void OnDetach() override;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace OpenEngine {
|
|||||||
private:
|
private:
|
||||||
inline static const std::string GetJoystickName(unsigned int joystick) { return instance->GetJoystickNameImpl(joystick); };
|
inline static const std::string GetJoystickName(unsigned int joystick) { return instance->GetJoystickNameImpl(joystick); };
|
||||||
|
|
||||||
static Input* instance;
|
static Scope<Input> instance;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ namespace OpenEngine {
|
|||||||
virtual unsigned int GetJoystickAxesCountImpl(unsigned int joystick) override;
|
virtual unsigned int GetJoystickAxesCountImpl(unsigned int joystick) override;
|
||||||
|
|
||||||
virtual bool IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) override;
|
virtual bool IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) override;
|
||||||
|
|
||||||
private:
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "events/event.hpp"
|
#include "events/event.hpp"
|
||||||
#include "core.hpp"
|
#include "core.hpp"
|
||||||
|
#include "open_engine/logging.hpp"
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
class OE_API Layer
|
class OE_API Layer
|
||||||
|
|||||||
@@ -13,15 +13,23 @@ namespace OpenEngine {
|
|||||||
LayerStack();
|
LayerStack();
|
||||||
~LayerStack();
|
~LayerStack();
|
||||||
|
|
||||||
void PushLayer(Layer* layer);
|
void QueueLayerPush(Ref<Layer> layer);
|
||||||
void PopLayer(Layer* layer);
|
void QueueLayerPop(Ref<Layer> layer);
|
||||||
void PushOverlay(Layer* overlay);
|
void QueueOverlayPush(Ref<Layer> layer);
|
||||||
void PopOverlay(Layer* overlay);
|
void QueueOverlayPop(Ref<Layer> layer);
|
||||||
|
void UpdateLayers();
|
||||||
|
|
||||||
|
std::vector<Ref<Layer>>::iterator begin() { return layers.begin(); }
|
||||||
|
std::vector<Ref<Layer>>::iterator end() { return layers.end(); }
|
||||||
|
|
||||||
std::vector<Layer*>::iterator begin() { return layers.begin(); }
|
|
||||||
std::vector<Layer*>::iterator end() { return layers.end(); }
|
|
||||||
private:
|
private:
|
||||||
std::vector<Layer*> layers;
|
std::vector<Ref<Layer>> layers;
|
||||||
|
std::vector<Ref<Layer>> layers_to_pop;
|
||||||
|
std::vector<Ref<Layer>> layers_to_push;
|
||||||
|
|
||||||
|
std::vector<Ref<Layer>> overlay_to_pop;
|
||||||
|
std::vector<Ref<Layer>> overlay_to_push;
|
||||||
|
|
||||||
unsigned int layer_insert_index = 0;
|
unsigned int layer_insert_index = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,19 @@ namespace OpenEngine {
|
|||||||
virtual void Unbind() const override;
|
virtual void Unbind() const override;
|
||||||
|
|
||||||
// utility uniform functions
|
// utility uniform functions
|
||||||
virtual void SetBool(const std::string &name, bool value) const;
|
void UploadBool(const std::string &name, bool value) const;
|
||||||
virtual void SetInt(const std::string &name, int value) const;
|
void UploadInt(const std::string &name, int value) const;
|
||||||
virtual void SetFloat(const std::string &name, float value) const;
|
void UploadFloat(const std::string &name, float value) const;
|
||||||
virtual void SetMat4(const std::string &name, const glm::mat4& value) const;
|
void UploadMat4(const std::string &name, const glm::mat4& value) const;
|
||||||
virtual void SetVec3(const std::string &name, const glm::vec3& value) const;
|
void UploadVec3(const std::string &name, const glm::vec3& value) const;
|
||||||
|
void UploadVec4(const std::string &name, const glm::vec4& value) const;
|
||||||
|
|
||||||
|
virtual void SetBool(const std::string &name, bool value) const override;
|
||||||
|
virtual void SetInt(const std::string &name, int value) const override;
|
||||||
|
virtual void SetFloat(const std::string &name, float value) const override;
|
||||||
|
virtual void SetMat4(const std::string &name, const glm::mat4& value) const override;
|
||||||
|
virtual void SetVec3(const std::string &name, const glm::vec3& value) const override;
|
||||||
|
virtual void SetVec4(const std::string &name, const glm::vec4& value) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string ReadFile(const std::string& shader_path);
|
std::string ReadFile(const std::string& shader_path);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ namespace OpenEngine {
|
|||||||
class GraphicsContext
|
class GraphicsContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// TODO: Check this!
|
||||||
|
virtual ~GraphicsContext() = default;
|
||||||
virtual void Init() = 0;
|
virtual void Init() = 0;
|
||||||
virtual void SwapBuffers() = 0;
|
virtual void SwapBuffers() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "../renderer/renderer_api.hpp"
|
#include "../renderer/renderer_api.hpp"
|
||||||
#include "../opengl/opengl_renderer_api.hpp"
|
#include "../opengl/opengl_renderer_api.hpp"
|
||||||
|
#include "open_engine/core.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
@@ -35,7 +36,7 @@ namespace OpenEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static inline RendererAPI* api = new OpenGLRendererAPI();
|
static inline Scope<RendererAPI> api = CreateScope<OpenGLRendererAPI>();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#ifndef RENDERER_HPP
|
#ifndef RENDERER_HPP
|
||||||
#define RENDERER_HPP
|
#define RENDERER_HPP
|
||||||
|
|
||||||
#include "../renderer/renderer_api.hpp"
|
#include "open_engine/renderer/renderer_api.hpp"
|
||||||
#include "../renderer/vertex_array.hpp"
|
#include "open_engine/renderer/vertex_array.hpp"
|
||||||
#include "../orthographic_camera.hpp"
|
#include "open_engine/orthographic_camera.hpp"
|
||||||
|
#include "open_engine/core.hpp"
|
||||||
#include <open_engine/renderer/shader.hpp>
|
#include <open_engine/renderer/shader.hpp>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
@@ -32,7 +33,7 @@ namespace OpenEngine {
|
|||||||
glm::mat4 view_projection_matrix;
|
glm::mat4 view_projection_matrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline static SceneData* scene_data = new SceneData;
|
inline static Scope<SceneData> scene_data = CreateScope<SceneData>();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace OpenEngine {
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual void Init() = 0;
|
virtual void Init() = 0;
|
||||||
|
virtual ~RendererAPI() = default;
|
||||||
|
|
||||||
virtual void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) = 0;
|
virtual void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
virtual void Bind() const = 0;
|
virtual void Bind() const = 0;
|
||||||
virtual void Unbind() const = 0;
|
virtual void Unbind() const = 0;
|
||||||
|
|
||||||
|
virtual void SetBool(const std::string &name, bool value) const = 0;
|
||||||
|
virtual void SetInt(const std::string &name, int value) const = 0;
|
||||||
|
virtual void SetFloat(const std::string &name, float value) const = 0;
|
||||||
|
virtual void SetMat4(const std::string &name, const glm::mat4& value) const = 0;
|
||||||
|
virtual void SetVec3(const std::string &name, const glm::vec3& value) const = 0;
|
||||||
|
virtual void SetVec4(const std::string &name, const glm::vec4& value) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShaderLibrary
|
class ShaderLibrary
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#ifndef VERTEX_ARRAY_HPP
|
#ifndef VERTEX_ARRAY_HPP
|
||||||
#define VERTEX_ARRAY_HPP
|
#define VERTEX_ARRAY_HPP
|
||||||
|
|
||||||
#include "../renderer/buffer.hpp"
|
#include "open_engine/core.hpp"
|
||||||
|
#include "open_engine/renderer/buffer.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ namespace OpenEngine {
|
|||||||
virtual const std::vector<std::shared_ptr<VertexBuffer>>& GetVertexBuffers() const = 0;
|
virtual const std::vector<std::shared_ptr<VertexBuffer>>& GetVertexBuffers() const = 0;
|
||||||
virtual const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const = 0;
|
virtual const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const = 0;
|
||||||
|
|
||||||
static VertexArray* Create();
|
static Ref<VertexArray> Create();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
WindowData data;
|
WindowData data;
|
||||||
GLFWwindow* gl_window;
|
GLFWwindow* gl_window;
|
||||||
GraphicsContext* context;
|
Scope<GraphicsContext> context;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
virtual void* GetNativeWindow() const = 0;
|
virtual void* GetNativeWindow() const = 0;
|
||||||
|
|
||||||
static Window* Create(const WindowProps& props = WindowProps());
|
static std::unique_ptr<Window> Create(const WindowProps& props = WindowProps());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +1,51 @@
|
|||||||
#include <pch.hpp>
|
#include <pch.hpp>
|
||||||
|
|
||||||
#include <core.hpp>
|
|
||||||
#include <events/application_event.hpp>
|
|
||||||
#include <imgui/imgui_layer.hpp>
|
|
||||||
#include <core/time.hpp>
|
|
||||||
#include <renderer/renderer.hpp>
|
|
||||||
#include <application.hpp>
|
#include <application.hpp>
|
||||||
#include <input/input_system.hpp>
|
|
||||||
|
|
||||||
|
#include <core.hpp>
|
||||||
|
#include <core/time.hpp>
|
||||||
|
#include <events/application_event.hpp>
|
||||||
|
#include <renderer/renderer2d.hpp>
|
||||||
|
#include <renderer/renderer.hpp>
|
||||||
|
#include <input/input_system.hpp>
|
||||||
|
#include <imgui/imgui_layer.hpp>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
|
|
||||||
Application::Application()
|
Application::Application()
|
||||||
{
|
{
|
||||||
OE_CORE_ASSERT(!instance, "Application already exists!");
|
OE_CORE_ASSERT(!instance, "Application already exists!");
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
window = std::unique_ptr<Window>(Window::Create());
|
window = Window::Create();
|
||||||
window->SetEventCallback(BIND_EVENT_FN(Application::OnEvent));
|
window->SetEventCallback(BIND_EVENT_FN(Application::OnEvent));
|
||||||
|
|
||||||
Renderer::Init();
|
Renderer::Init();
|
||||||
|
Renderer2D::Init();
|
||||||
|
|
||||||
imgui_layer = new ImGuiLayer();
|
imgui_layer = std::make_shared<ImGuiLayer>();
|
||||||
PushOverlay(imgui_layer);
|
QueueOverlayPush(imgui_layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
Application::~Application()
|
||||||
|
{
|
||||||
|
Renderer2D::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::Run()
|
void Application::Run()
|
||||||
{
|
{
|
||||||
while(running) {
|
while(running) {
|
||||||
Time::Get().Update();
|
Time::Get().Update();
|
||||||
|
layer_stack.UpdateLayers();
|
||||||
|
|
||||||
for (Layer* layer : layer_stack)
|
for (auto layer : layer_stack)
|
||||||
layer->OnUpdate();
|
layer->OnUpdate();
|
||||||
|
|
||||||
imgui_layer->Begin();
|
imgui_layer->Begin();
|
||||||
|
|
||||||
for (Layer* layer : layer_stack)
|
for (auto layer : layer_stack)
|
||||||
layer->OnImGuiRender();
|
layer->OnImGuiRender();
|
||||||
|
|
||||||
imgui_layer->End();
|
imgui_layer->End();
|
||||||
@@ -72,13 +81,23 @@ namespace OpenEngine {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::PushLayer(Layer* layer)
|
void Application::QueueLayerPush(Ref<Layer> layer)
|
||||||
{
|
{
|
||||||
layer_stack.PushLayer(layer);
|
layer_stack.QueueLayerPush(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::PushOverlay(Layer* overlay)
|
void Application::QueueLayerPop(Ref<Layer> layer)
|
||||||
{
|
{
|
||||||
layer_stack.PushOverlay(overlay);
|
layer_stack.QueueLayerPop(layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::QueueOverlayPush(Ref<Layer> overlay)
|
||||||
|
{
|
||||||
|
layer_stack.QueueOverlayPush(overlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::QueueOverlayPop(Ref<Layer> overlay)
|
||||||
|
{
|
||||||
|
layer_stack.QueueOverlayPop(overlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,6 +253,10 @@ namespace OpenEngine {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGuiLayer::~ImGuiLayer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void ImGuiLayer::OnAttach()
|
void ImGuiLayer::OnAttach()
|
||||||
{
|
{
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <pch.hpp>
|
#include <pch.hpp>
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
#include "core.hpp"
|
||||||
#include "logging.hpp"
|
#include "logging.hpp"
|
||||||
#include <input/linux_input.hpp>
|
#include <input/linux_input.hpp>
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@
|
|||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
|
|
||||||
Input* Input::instance = new LinuxInput();
|
Scope<Input> Input::instance = CreateScope<LinuxInput>();
|
||||||
|
|
||||||
bool LinuxInput::IsKeyPressedImpl(int keycode)
|
bool LinuxInput::IsKeyPressedImpl(int keycode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "logging.hpp"
|
||||||
#include <layer_stack.hpp>
|
#include <layer_stack.hpp>
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
@@ -7,25 +8,34 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
LayerStack::~LayerStack()
|
LayerStack::~LayerStack()
|
||||||
{
|
{
|
||||||
for (Layer* layer : layers)
|
for (auto& layer : layers)
|
||||||
delete layer;
|
layer->OnDetach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStack::PushLayer(Layer* layer)
|
void LayerStack::QueueLayerPush(Ref<Layer> layer)
|
||||||
{
|
{
|
||||||
layers.emplace(layers.begin() + layer_insert_index, layer);
|
layers_to_push.emplace_back(layer);
|
||||||
layer_insert_index++;
|
|
||||||
layer->OnAttach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStack::PushOverlay(Layer* overlay)
|
void LayerStack::QueueLayerPop(Ref<Layer> layer)
|
||||||
{
|
{
|
||||||
layers.emplace_back(overlay);
|
layers_to_pop.emplace_back(layer);
|
||||||
overlay->OnAttach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStack::PopLayer(Layer* layer)
|
void LayerStack::QueueOverlayPush(Ref<Layer> overlay)
|
||||||
{
|
{
|
||||||
|
overlay_to_push.emplace_back(overlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerStack::QueueOverlayPop(Ref<Layer> overlay)
|
||||||
|
{
|
||||||
|
overlay_to_pop.emplace_back(overlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerStack::UpdateLayers()
|
||||||
|
{
|
||||||
|
// processing pop queue layers
|
||||||
|
for (auto& layer : layers_to_pop) {
|
||||||
auto it = std::find(layers.begin(), layers.begin() + layer_insert_index, layer);
|
auto it = std::find(layers.begin(), layers.begin() + layer_insert_index, layer);
|
||||||
if (it != layers.end()) {
|
if (it != layers.end()) {
|
||||||
layer->OnDetach();
|
layer->OnDetach();
|
||||||
@@ -34,12 +44,35 @@ namespace OpenEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStack::PopOverlay(Layer* overlay)
|
layers_to_pop.clear();
|
||||||
{
|
|
||||||
|
// processing pop queue overlays
|
||||||
|
for (auto& overlay : overlay_to_pop) {
|
||||||
auto it = std::find(layers.begin() + layer_insert_index, layers.end(), overlay);
|
auto it = std::find(layers.begin() + layer_insert_index, layers.end(), overlay);
|
||||||
if (it != layers.end()) {
|
if (it != layers.end()) {
|
||||||
overlay->OnDetach();
|
overlay->OnDetach();
|
||||||
layers.erase(it);
|
layers.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
overlay_to_pop.clear();
|
||||||
|
|
||||||
|
// processing push queue layers
|
||||||
|
for (auto& layer : layers_to_push) {
|
||||||
|
layers.emplace(layers.begin() + layer_insert_index, layer);
|
||||||
|
layer_insert_index++;
|
||||||
|
layer->OnAttach();
|
||||||
|
OE_CORE_DEBUG("Added layer: {}", layer->GetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
layers_to_push.clear();
|
||||||
|
|
||||||
|
// processing push queue overlays
|
||||||
|
for (auto& overlay : overlay_to_push) {
|
||||||
|
layers.emplace_back(overlay);
|
||||||
|
overlay->OnAttach();
|
||||||
|
}
|
||||||
|
|
||||||
|
overlay_to_push.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace OpenEngine {
|
|||||||
{
|
{
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLRendererAPI::SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
|
void OpenGLRendererAPI::SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
|
||||||
|
|||||||
@@ -114,8 +114,10 @@ namespace OpenEngine {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < sources.size(); i++)
|
for (int i = 0; i < sources.size(); i++) {
|
||||||
glDetachShader(program, gl_shader_ids[i]);
|
glDetachShader(program, gl_shader_ids[i]);
|
||||||
|
glDeleteShader(gl_shader_ids[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<GLenum, std::string> OpenGLShader::PreProcess(const std::string& shader_source)
|
std::unordered_map<GLenum, std::string> OpenGLShader::PreProcess(const std::string& shader_source)
|
||||||
@@ -174,26 +176,53 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
void OpenGLShader::SetBool(const std::string &name, bool value) const
|
void OpenGLShader::SetBool(const std::string &name, bool value) const
|
||||||
{
|
{
|
||||||
glUniform1i(glGetUniformLocation(id, name.c_str()), (int)value);
|
UploadBool(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLShader::SetInt(const std::string &name, int value) const
|
void OpenGLShader::SetInt(const std::string &name, int value) const
|
||||||
{
|
{
|
||||||
glUniform1i(glGetUniformLocation(id, name.c_str()), value);
|
UploadInt(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLShader::SetFloat(const std::string &name, float value) const
|
void OpenGLShader::SetFloat(const std::string &name, float value) const
|
||||||
{
|
{
|
||||||
glUniform1f(glGetUniformLocation(id, name.c_str()), value);
|
UploadFloat(name, value);
|
||||||
}
|
}
|
||||||
void OpenGLShader::SetMat4(const std::string &name, const glm::mat4& value) const
|
void OpenGLShader::SetMat4(const std::string &name, const glm::mat4& value) const
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(glGetUniformLocation(id, name.c_str()), 1, GL_FALSE, glm::value_ptr(value));
|
UploadMat4(name, value);
|
||||||
}
|
}
|
||||||
void OpenGLShader::SetVec3(const std::string &name, const glm::vec3& value) const
|
void OpenGLShader::SetVec3(const std::string &name, const glm::vec3& value) const
|
||||||
|
{
|
||||||
|
UploadVec3(name, value);
|
||||||
|
}
|
||||||
|
void OpenGLShader::SetVec4(const std::string &name, const glm::vec4& value) const
|
||||||
|
{
|
||||||
|
UploadVec4(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLShader::UploadBool(const std::string &name, bool value) const
|
||||||
|
{
|
||||||
|
glUniform1i(glGetUniformLocation(id, name.c_str()), (int)value);
|
||||||
|
}
|
||||||
|
void OpenGLShader::UploadInt(const std::string &name, int value) const
|
||||||
|
{
|
||||||
|
glUniform1i(glGetUniformLocation(id, name.c_str()), value);
|
||||||
|
}
|
||||||
|
void OpenGLShader::UploadFloat(const std::string &name, float value) const
|
||||||
|
{
|
||||||
|
glUniform1f(glGetUniformLocation(id, name.c_str()), value);
|
||||||
|
}
|
||||||
|
void OpenGLShader::UploadMat4(const std::string &name, const glm::mat4& value) const
|
||||||
|
{
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(id, name.c_str()), 1, GL_FALSE, glm::value_ptr(value));
|
||||||
|
}
|
||||||
|
void OpenGLShader::UploadVec3(const std::string &name, const glm::vec3& value) const
|
||||||
{
|
{
|
||||||
glUniform3fv(glGetUniformLocation(id, name.c_str()), 1, glm::value_ptr(value));
|
glUniform3fv(glGetUniformLocation(id, name.c_str()), 1, glm::value_ptr(value));
|
||||||
}
|
}
|
||||||
|
void OpenGLShader::UploadVec4(const std::string &name, const glm::vec4& value) const
|
||||||
|
{
|
||||||
|
glUniform4fv(glGetUniformLocation(id, name.c_str()), 1, glm::value_ptr(value));
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLShader::CheckCompileErrors(unsigned int shader, const std::string& type)
|
void OpenGLShader::CheckCompileErrors(unsigned int shader, const std::string& type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ namespace OpenEngine {
|
|||||||
: path(path)
|
: path(path)
|
||||||
{
|
{
|
||||||
int image_width, image_height, channels;
|
int image_width, image_height, channels;
|
||||||
stbi_uc* data = stbi_load(path.c_str(), &image_width, &image_height, &channels, 0);
|
|
||||||
stbi_set_flip_vertically_on_load(1);
|
stbi_set_flip_vertically_on_load(1);
|
||||||
|
stbi_uc* data = stbi_load(path.c_str(), &image_width, &image_height, &channels, 0);
|
||||||
OE_CORE_ASSERT(data, "Image could not be loaded!");
|
OE_CORE_ASSERT(data, "Image could not be loaded!");
|
||||||
|
|
||||||
width = image_width;
|
width = image_width;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <memory>
|
|
||||||
#include <pch.hpp>
|
#include <pch.hpp>
|
||||||
#include <renderer/renderer.hpp>
|
|
||||||
#include "opengl/opengl_shader.hpp"
|
|
||||||
#include "renderer/render_command.hpp"
|
|
||||||
|
|
||||||
|
#include "open_engine/renderer/renderer.hpp"
|
||||||
|
#include "open_engine/renderer/render_command.hpp"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ namespace OpenEngine {
|
|||||||
const glm::mat4& transform)
|
const glm::mat4& transform)
|
||||||
{
|
{
|
||||||
shader->Bind();
|
shader->Bind();
|
||||||
std::dynamic_pointer_cast<OpenGLShader>(shader)->SetMat4("u_ViewProjection", scene_data->view_projection_matrix);
|
shader->SetMat4("u_ViewProjection", scene_data->view_projection_matrix);
|
||||||
std::dynamic_pointer_cast<OpenGLShader>(shader)->SetMat4("u_Transform", transform);
|
shader->SetMat4("u_Transform", transform);
|
||||||
|
|
||||||
vertex_array->Bind();
|
vertex_array->Bind();
|
||||||
RenderCommand::DrawIndexed(vertex_array);
|
RenderCommand::DrawIndexed(vertex_array);
|
||||||
|
|||||||
@@ -2,15 +2,16 @@
|
|||||||
|
|
||||||
#include "opengl/opengl_vertex_array.hpp"
|
#include "opengl/opengl_vertex_array.hpp"
|
||||||
#include "renderer/renderer.hpp"
|
#include "renderer/renderer.hpp"
|
||||||
|
|
||||||
#include <renderer/vertex_array.hpp>
|
#include <renderer/vertex_array.hpp>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace OpenEngine {
|
namespace OpenEngine {
|
||||||
VertexArray* VertexArray::Create()
|
Ref<VertexArray> VertexArray::Create()
|
||||||
{
|
{
|
||||||
switch (Renderer::GetApi()) {
|
switch (Renderer::GetApi()) {
|
||||||
case RendererAPI::API::None : OE_CORE_ASSERT(false, "No render API selected!"); return nullptr;
|
case RendererAPI::API::None : OE_CORE_ASSERT(false, "No render API selected!"); return nullptr;
|
||||||
case RendererAPI::API::OpenGL : return new OpenGLVertexArray();
|
case RendererAPI::API::OpenGL : return std::make_shared<OpenGLVertexArray>();
|
||||||
}
|
}
|
||||||
|
|
||||||
OE_CORE_ASSERT(false, "Selected API not supported");
|
OE_CORE_ASSERT(false, "Selected API not supported");
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "logging.hpp"
|
#include "logging.hpp"
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <memory>
|
||||||
#include <window/linux_window.hpp>
|
#include <window/linux_window.hpp>
|
||||||
#include <opengl/opengl_context.hpp>
|
#include <opengl/opengl_context.hpp>
|
||||||
#include "renderer/graphics_context.hpp"
|
#include "renderer/graphics_context.hpp"
|
||||||
@@ -17,9 +18,9 @@ namespace OpenEngine {
|
|||||||
OE_CORE_ERROR("GLFW Error {}: {}", error, description);
|
OE_CORE_ERROR("GLFW Error {}: {}", error, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
Window* Window::Create(const WindowProps& props)
|
std::unique_ptr<Window> Window::Create(const WindowProps& props)
|
||||||
{
|
{
|
||||||
return new LinuxWindow(props);
|
return std::make_unique<LinuxWindow>(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinuxWindow::LinuxWindow(const WindowProps& props)
|
LinuxWindow::LinuxWindow(const WindowProps& props)
|
||||||
@@ -56,7 +57,7 @@ namespace OpenEngine {
|
|||||||
|
|
||||||
gl_window = glfwCreateWindow((int)props.width, (int)props.height, props.title.c_str(), nullptr, nullptr);
|
gl_window = glfwCreateWindow((int)props.width, (int)props.height, props.title.c_str(), nullptr, nullptr);
|
||||||
|
|
||||||
context = new OpenGLContext(gl_window);
|
context = CreateScope<OpenGLContext>(gl_window);
|
||||||
context->Init();
|
context->Init();
|
||||||
|
|
||||||
glfwSetWindowUserPointer(gl_window, &data);
|
glfwSetWindowUserPointer(gl_window, &data);
|
||||||
@@ -156,6 +157,7 @@ namespace OpenEngine {
|
|||||||
void LinuxWindow::Shutdown()
|
void LinuxWindow::Shutdown()
|
||||||
{
|
{
|
||||||
glfwDestroyWindow(gl_window);
|
glfwDestroyWindow(gl_window);
|
||||||
|
gl_window = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinuxWindow::OnUpdate()
|
void LinuxWindow::OnUpdate()
|
||||||
|
|||||||
47
project_config.json
Normal file
47
project_config.json
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"project_name": "solution name",
|
||||||
|
"sub_projects": [
|
||||||
|
{
|
||||||
|
"project_name": "exec_proj2",
|
||||||
|
"binary_name": "hello_world",
|
||||||
|
"binary_type": "exec",
|
||||||
|
"include_directories": [
|
||||||
|
"./include/test"
|
||||||
|
],
|
||||||
|
"libraries": [
|
||||||
|
{
|
||||||
|
"name" : "nlohmann_json",
|
||||||
|
"org" : "nlohmann_json",
|
||||||
|
"find" : true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "shared_proj",
|
||||||
|
"find" : false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"project_name": "shared_proj",
|
||||||
|
"binary_name": "hello_shared",
|
||||||
|
"binary_type": "shared",
|
||||||
|
"include_directories": [
|
||||||
|
"./include/test2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"project_name": "static_proj",
|
||||||
|
"binary_name": "hello_static",
|
||||||
|
"binary_type": "static",
|
||||||
|
"include_directories": [
|
||||||
|
"./include/test2"
|
||||||
|
],
|
||||||
|
"libraries": [
|
||||||
|
{
|
||||||
|
"name" : "nlohmann_json",
|
||||||
|
"org" : "nlohmann_json",
|
||||||
|
"find" : true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user