Setup for Imgui

main
anulax1225 ago%!(EXTRA string=11 months)
parent d40fa774c1
commit 06a1c6c246
  1. 4
      premake5.lua
  2. 7
      src/bakara/core/application.cpp
  3. 9
      src/bakara/core/application.h
  4. 10
      src/bakara/core/base.h
  5. 30
      src/bakara/core/layer_stack.cpp
  6. 14
      src/bakara/core/layer_stack.h
  7. 14
      src/bakara/events/event.h
  8. 5
      src/bakara/imgui/imgui_build.cpp
  9. 12
      src/bakara/io/input.h
  10. 1
      src/platforms/glfw/glfw_window.h

@ -13,9 +13,6 @@ project "bakara"
{
"%{wks.location}/vendor/glm/glm/**.hpp",
"%{wks.location}/vendor/glm/glm/**.inl",
"%{wks.location}/vendor/imgui/misc/cpp/imgui_stdlib.cpp",
"%{wks.location}/vendor/imgui/backends/imgui_impl_opengl3.cpp",
"%{wks.location}/vendor/imgui/backends/imgui_impl_glfw.cpp",
"src/bakara/**.h",
"src/bakara/**.cpp",
"src/platforms/**.h",
@ -27,7 +24,6 @@ project "bakara"
{
"_CRT_SECURE_NO_WARNINGS",
"GLFW_INCLUDE_NONE",
"IMGUI_IMPL_OPENGL_LOADER_GLAD",
"BKMOD_ALL"
}

@ -27,10 +27,15 @@ namespace Bk {
}
}
bool Application::on_window_close(WindowCloseEvent& e)
void Application::close()
{
h_window->close();
p_running = false;
}
bool Application::on_window_close(WindowCloseEvent& e)
{
close();
return true;
}

@ -51,7 +51,7 @@ namespace Bk {
/*! \fn Bk::Application::pop_overlay
Pop's the layer on top of the layer stack
*/
inline void pop_overlay() { p_layer_stack.pop_overlay(); }
inline void pop_overlay(Layer* layer) { p_layer_stack.pop_overlay(layer); }
/*! \fn Bk::Application::push_overlay
Push's the layer at the bottom of the layer stack
@param layer : Layer pointer to push
@ -60,7 +60,7 @@ namespace Bk {
/*! \fn Bk::Application::push_overlay
Pop's the layer at the bottom of the layer stack
*/
inline void pop_layer() { p_layer_stack.pop_layer(); }
inline void pop_layer(Layer* layer) { p_layer_stack.pop_layer(layer); }
/*! \fn Bk::Application::run
Starts the application and the update loop.
@ -74,6 +74,11 @@ namespace Bk {
protected:
std::shared_ptr<Window> h_window; //!< Pointer to the main window
/*! \fn Bk::Application::close
Stops the application and the update loop without creating an event.
*/
void close();
private:
LayerStack p_layer_stack; //!< Layer stack of the application
bool p_running; //!< Flag that indicates if the update loop should stop or not

@ -1,10 +0,0 @@
#pragma once
#define BK_STRINGIFY(x) #x
#define BIT_SHIFT(x) (1 << x)
#define BK_BIND_EVENT_FN(fn) [this](Event& e) { fn(e); }
#define BK_BIND_DISPACHER_FN(event, fn) [this](event& e) -> bool{ return fn(e); }

@ -1,10 +1,7 @@
#include "layer_stack.h"
namespace Bk {
LayerStack::~LayerStack()
{
clear();
}
LayerStack::~LayerStack() { clear(); }
void LayerStack::push_overlay(Layer* layer)
{
@ -12,29 +9,31 @@ namespace Bk {
p_layers.emplace_back(layer);
}
void LayerStack::pop_overlay()
void LayerStack::pop_overlay(Layer* layer)
{
if(auto layer = p_layers.back())
{
auto it = std::find(p_layers.begin() + p_layer_index, p_layers.end(), layer);
if (it != p_layers.end())
{
layer->on_detach();
p_layers.pop_back();
delete layer;
p_layers.erase(it);
}
}
void LayerStack::push_layer(Layer* layer)
{
layer->on_attach();
p_layers.emplace_front(layer);
p_layers.emplace(p_layers.begin() + p_layer_index, layer);
p_layer_index++;
}
void LayerStack::pop_layer()
void LayerStack::pop_layer(Layer* layer)
{
if(auto layer = p_layers.front())
{
auto it = std::find(p_layers.begin(), p_layers.begin() + p_layer_index, layer);
if (it != p_layers.begin() + p_layer_index)
{
layer->on_detach();
p_layers.pop_front();
delete layer;
p_layers.erase(it);
p_layer_index--;
}
}
@ -46,5 +45,6 @@ namespace Bk {
delete layer;
});
p_layers.clear();
p_layer_index = 0;
}
}

@ -11,19 +11,19 @@ namespace Bk {
~LayerStack();
void push_overlay(Layer* layer);
void pop_overlay();
void pop_overlay(Layer* layer);
void push_layer(Layer* layer);
void pop_layer();
void pop_layer(Layer* layer);
void clear();
std::deque<Layer*>::iterator begin() { return p_layers.begin(); }
std::deque<Layer*>::iterator end() { return p_layers.end(); }
std::vector<Layer*>::iterator begin() { return p_layers.begin(); }
std::vector<Layer*>::iterator end() { return p_layers.end(); }
std::deque<Layer*>::reverse_iterator rbegin() { return p_layers.rbegin(); }
std::deque<Layer*>::reverse_iterator rend() { return p_layers.rend(); }
std::vector<Layer*>::reverse_iterator rbegin() { return p_layers.rbegin(); }
std::vector<Layer*>::reverse_iterator rend() { return p_layers.rend(); }
private:
std::deque<Layer*> p_layers;
std::vector<Layer*> p_layers;
uint p_layer_index = 0;
};
}

@ -1,8 +1,10 @@
#pragma once
#include <bakara/core/base.h>
#include <bakarapch.h>
#define BK_BIND_EVENT_FN(fn) [this](Event& e) { fn(e); }
#define BK_BIND_DISPACHER_FN(event, fn) [this](event& e) -> bool{ return fn(e); }
namespace Bk {
enum class EventType
{
@ -27,11 +29,11 @@ namespace Bk {
enum EventCategory
{
None = 0,
AppCategory = BIT_SHIFT(0),
InputCategory = BIT_SHIFT(1),
KeyboardCategory = BIT_SHIFT(2),
MouseCategory = BIT_SHIFT(3),
MouseButtonCategory = BIT_SHIFT(4)
AppCategory = BK_BIT_SHIFT(0),
InputCategory = BK_BIT_SHIFT(1),
KeyboardCategory = BK_BIT_SHIFT(2),
MouseCategory = BK_BIT_SHIFT(3),
MouseButtonCategory = BK_BIT_SHIFT(4)
};
#define EVENT_CLASS_TYPE(type) static EventType get_static_type() { return EventType::type; }\

@ -0,0 +1,5 @@
#include <misc/cpp/imgui_stdlib.cpp>
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
#include <backends/imgui_impl_glfw.cpp>
#include <backends/imgui_impl_opengl3.cpp>

@ -0,0 +1,12 @@
#pragma once
#include "bakarapch.h"
#include "io_codes.h"
namespace Bk
{
class Input
{
};
}

@ -2,7 +2,6 @@
#include <bakarapch.h>
#include <bakara/core/window.h>
#include <bakara/events/events.h>
#include <mutex>
#include <GLFW/glfw3.h>
namespace Bk::Plaform {

Loading…
Cancel
Save