added queuing push and pop logic and having fun with c# integration
This commit is contained in:
@@ -12,12 +12,8 @@
|
||||
#include "open_engine/input/keycodes.hpp"
|
||||
#include "open_engine/renderer/buffer.hpp"
|
||||
#include "open_engine/renderer/shader.hpp"
|
||||
#include "open_engine/opengl/opengl_shader.hpp"
|
||||
#include "open_engine/renderer/texture.hpp"
|
||||
#include "open_engine/orthographic_camera_controller.hpp"
|
||||
|
||||
// Entry Point -------------------------
|
||||
#include "open_engine/entry_point.hpp"
|
||||
// -------------------------------------
|
||||
#include "open_engine/renderer/renderer2d.hpp"
|
||||
|
||||
#endif // OPEN_ENGINE_HPP
|
||||
|
||||
@@ -15,14 +15,21 @@ namespace OpenEngine {
|
||||
{
|
||||
public:
|
||||
Application();
|
||||
virtual ~Application() = default;
|
||||
~Application();
|
||||
|
||||
void Run();
|
||||
|
||||
virtual void OnEvent(Event& event);
|
||||
|
||||
void PushLayer(Layer* layer);
|
||||
void PushOverlay(Layer* overlay);
|
||||
//void PushOverlay(Ref<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; }
|
||||
|
||||
@@ -38,7 +45,7 @@ namespace OpenEngine {
|
||||
bool running = true;
|
||||
std::unique_ptr<Window> window;
|
||||
|
||||
ImGuiLayer* imgui_layer;
|
||||
Ref<ImGuiLayer> imgui_layer;
|
||||
LayerStack layer_stack;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,9 +28,19 @@
|
||||
namespace OpenEngine {
|
||||
template<typename 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>
|
||||
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
|
||||
|
||||
@@ -11,6 +11,7 @@ int main(int argc, char** argv)
|
||||
|
||||
auto app = OpenEngine::CreateApplication();
|
||||
app->Run();
|
||||
|
||||
delete app;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace OpenEngine {
|
||||
{
|
||||
public:
|
||||
ImGuiLayer();
|
||||
~ImGuiLayer() = default;
|
||||
~ImGuiLayer();
|
||||
|
||||
virtual void OnAttach() override;
|
||||
virtual void OnDetach() override;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenEngine {
|
||||
private:
|
||||
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 bool IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) override;
|
||||
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "events/event.hpp"
|
||||
#include "core.hpp"
|
||||
#include "open_engine/logging.hpp"
|
||||
|
||||
namespace OpenEngine {
|
||||
class OE_API Layer
|
||||
|
||||
@@ -13,15 +13,23 @@ namespace OpenEngine {
|
||||
LayerStack();
|
||||
~LayerStack();
|
||||
|
||||
void PushLayer(Layer* layer);
|
||||
void PopLayer(Layer* layer);
|
||||
void PushOverlay(Layer* overlay);
|
||||
void PopOverlay(Layer* overlay);
|
||||
void QueueLayerPush(Ref<Layer> layer);
|
||||
void QueueLayerPop(Ref<Layer> layer);
|
||||
void QueueOverlayPush(Ref<Layer> layer);
|
||||
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:
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,12 +22,19 @@ namespace OpenEngine {
|
||||
virtual void Unbind() const override;
|
||||
|
||||
// utility uniform functions
|
||||
virtual void SetBool(const std::string &name, bool value) const;
|
||||
virtual void SetInt(const std::string &name, int value) const;
|
||||
virtual void SetFloat(const std::string &name, float value) const;
|
||||
virtual void SetMat4(const std::string &name, const glm::mat4& value) const;
|
||||
virtual void SetVec3(const std::string &name, const glm::vec3& value) const;
|
||||
void UploadBool(const std::string &name, bool value) const;
|
||||
void UploadInt(const std::string &name, int value) const;
|
||||
void UploadFloat(const std::string &name, float value) const;
|
||||
void UploadMat4(const std::string &name, const glm::mat4& 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:
|
||||
std::string ReadFile(const std::string& shader_path);
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace OpenEngine {
|
||||
class GraphicsContext
|
||||
{
|
||||
public:
|
||||
// TODO: Check this!
|
||||
virtual ~GraphicsContext() = default;
|
||||
virtual void Init() = 0;
|
||||
virtual void SwapBuffers() = 0;
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "../renderer/renderer_api.hpp"
|
||||
#include "../opengl/opengl_renderer_api.hpp"
|
||||
#include "open_engine/core.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace OpenEngine {
|
||||
@@ -35,7 +36,7 @@ namespace OpenEngine {
|
||||
}
|
||||
|
||||
private:
|
||||
static inline RendererAPI* api = new OpenGLRendererAPI();
|
||||
static inline Scope<RendererAPI> api = CreateScope<OpenGLRendererAPI>();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#ifndef RENDERER_HPP
|
||||
#define RENDERER_HPP
|
||||
|
||||
#include "../renderer/renderer_api.hpp"
|
||||
#include "../renderer/vertex_array.hpp"
|
||||
#include "../orthographic_camera.hpp"
|
||||
#include "open_engine/renderer/renderer_api.hpp"
|
||||
#include "open_engine/renderer/vertex_array.hpp"
|
||||
#include "open_engine/orthographic_camera.hpp"
|
||||
#include "open_engine/core.hpp"
|
||||
#include <open_engine/renderer/shader.hpp>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
@@ -32,7 +33,7 @@ namespace OpenEngine {
|
||||
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 ~RendererAPI() = default;
|
||||
|
||||
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 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
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#ifndef VERTEX_ARRAY_HPP
|
||||
#define VERTEX_ARRAY_HPP
|
||||
|
||||
#include "../renderer/buffer.hpp"
|
||||
#include "open_engine/core.hpp"
|
||||
#include "open_engine/renderer/buffer.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -20,7 +21,7 @@ namespace OpenEngine {
|
||||
virtual const std::vector<std::shared_ptr<VertexBuffer>>& GetVertexBuffers() 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;
|
||||
GLFWwindow* gl_window;
|
||||
GraphicsContext* context;
|
||||
Scope<GraphicsContext> context;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenEngine {
|
||||
|
||||
virtual void* GetNativeWindow() const = 0;
|
||||
|
||||
static Window* Create(const WindowProps& props = WindowProps());
|
||||
static std::unique_ptr<Window> Create(const WindowProps& props = WindowProps());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user