Refactoring code and working directory

dev
ambigipathyv ago%!(EXTRA string=2 years)
parent f82851d6d3
commit 1f0a314e9c
  1. 2
      bakara/src/bakara.h
  2. 6
      bakara/src/bakara/core/Layer.cpp
  3. 18
      bakara/src/bakara/core/Layer.h
  4. 13
      bakara/src/bakara/core/application.cpp
  5. 6
      bakara/src/bakara/core/application.h
  6. 2
      bakara/src/bakara/events/event.h
  7. 7
      bakara/src/bakara/events/events.h
  8. 2
      bakara/src/bakara/events/key_event.h
  9. 2
      bakara/src/bakara/events/mouse_event.h
  10. 0
      bakara/src/bakara/io/io_codes.h
  11. 4
      bakara/src/bakara/io/window.h
  12. 5
      bakara/src/bakara/plaforms/window/glfw/win_glfw.cpp
  13. 5
      bakara/src/bakara/plaforms/window/glfw/win_glfw.h
  14. 4
      sandbox/src/sandbox.cpp

@ -4,7 +4,7 @@
#include <bakara/core/log.h>
#include <bakara/core/base.h>
#include <bakara/core/assert.h>
#include <bakara/core/io_codes.h>
#include <bakara/io/io_codes.h>
#include <bakara/events/event.h>
#include <bakara/events/key_event.h>
#include <bakara/events/mouse_event.h>

@ -0,0 +1,6 @@
#include "Layer.h"
namespace Bk {
Layer::Layer(const std::string& name)
: name(name) {}
}

@ -0,0 +1,18 @@
#pragma once
#include <bkpch.h>
namespace Bk {
class Layer
{
public:
Layer(const std::string& name = "Layer");
virtual ~Layer() {}
virtual void on_attach() {}
virtual void on_detach() {}
virtual void on_event() {}
virtual void on_update() {}
private:
std::string name;
};
}

@ -11,9 +11,22 @@ namespace Bk {
void Application::on_event(Event& e)
{
EventDispatcher dispatcher(e);
dispatcher.dispatch<WindowCloseEvent>(BK_BIND_EVENT_FN(Application::on_window_close));
dispatcher.dispatch<WindowResizeEvent>(BK_BIND_EVENT_FN(Application::on_window_resize));
BK_CORE_INFO("Event : {0}", EVENT_STRING(e));
}
void Application::on_window_close(WindowCloseEvent& e)
{
p_window.close();
}
void Application::on_window_resize(WindowResizeEvent& e)
{
}
void Application::run()
{
while (p_running)

@ -1,8 +1,8 @@
#pragma once
#include <bkpch.h>
#include "window.h"
#include <bakara/events/event.h>
#include <bakara/io/window.h>
#include <bakara/events/events.h>
namespace Bk {
@ -14,6 +14,8 @@ namespace Bk {
Application();
virtual ~Application();
void on_event(Event& e);
void on_window_close(WindowCloseEvent& e);
void on_window_resize(WindowResizeEvent& e);
void run();
private:
std::unique_ptr<Window> p_window;

@ -66,7 +66,7 @@ namespace Bk {
bool is_in_category(EventCategory category)
{
return (get_category_flags() & (int)category) == get_category_flags();
return get_category_flags() & category;
}
};

@ -0,0 +1,7 @@
#pragma once
#include <bakara/events/event.h>
#include <bakara/events/app_event.h>
#include <bakara/events/window_event.h>
#include <bakara/events/mouse_event.h>
#include <bakara/events/key_event.h>

@ -1,7 +1,7 @@
#pragma once
#include <bakara/core/io_codes.h>
#include <bakara/io/io_codes.h>
#include "event.h"
namespace Bk {

@ -2,7 +2,7 @@
#include "event.h"
#include <bakara/math/type.h>
#include <bakara/core/io_codes.h>
#include <bakara/io/io_codes.h>
namespace Bk
{

@ -18,7 +18,7 @@ namespace Bk {
{
public:
using EventCallback = std::function<void(Event& e)>;
virtual ~Window(){}
virtual ~Window() {}
virtual uint get_width() const = 0;
virtual uint get_height() const = 0;
@ -29,6 +29,8 @@ namespace Bk {
virtual void set_vsync(bool enable) = 0;
virtual bool is_vsync() const = 0;
virtual void close() = 0;
static std::unique_ptr<Window> create_window(const WindowPros& props = WindowPros());
};
}

@ -21,7 +21,7 @@ namespace Bk {
WinGLFW::~WinGLFW()
{
shutdown();
close();
}
void WinGLFW::init(const WindowPros& props)
@ -53,7 +53,6 @@ namespace Bk {
WindowResizeEvent e((uint)width, (uint)height);
data.callback(e);
});
glfwSetWindowCloseCallback(p_window, [](GLFWwindow* window)
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
@ -145,7 +144,7 @@ namespace Bk {
return p_data.vsync;
}
void WinGLFW::shutdown()
void WinGLFW::close()
{
glfwDestroyWindow(p_window);
}

@ -1,6 +1,6 @@
#pragma once
#include <bkpch.h>
#include <bakara/core/window.h>
#include <bakara/io/window.h>
#include <bakara/events/mouse_event.h>
#include <bakara/events/key_event.h>
#include <bakara/events/window_event.h>
@ -23,6 +23,8 @@ namespace Bk::Plaform {
void set_vsync(bool enable) override;
bool is_vsync() const override;
void close() override;
private:
GLFWwindow* p_window;
@ -39,6 +41,5 @@ namespace Bk::Plaform {
void init_event_callbacks();
void init(const WindowPros& props);
void shutdown();
};
}

@ -1,6 +1,7 @@
#include <iostream>
#include <memory>
#include <utility>
#include <string>
#include <bakara.h>
@ -9,8 +10,7 @@ class Sandbox : public Bk::Application
public:
Sandbox()
{
Bk::Vec2 vec(2.0f, 2.0f);
BK_INFO("My Vec 2 ({0}, {1})", vec.x, vec.y);
}
~Sandbox()

Loading…
Cancel
Save