Box implementation, improved window API
This commit is contained in:
parent
1ae16b306f
commit
988b0bdbcd
12 changed files with 224 additions and 27 deletions
|
|
@ -1,13 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "window.hpp"
|
||||
|
||||
namespace uui
|
||||
{
|
||||
class Application
|
||||
{
|
||||
public:
|
||||
virtual void run() = 0;
|
||||
virtual void add_window(int width, int height, const std::string& title) = 0;
|
||||
virtual std::weak_ptr<Window> add_window(int width, int height, const std::string& title) = 0;
|
||||
};
|
||||
} // namespace uui
|
||||
|
|
|
|||
12
include/uui/component.hpp
Normal file
12
include/uui/component.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
namespace uui
|
||||
{
|
||||
|
||||
class Component
|
||||
{
|
||||
public:
|
||||
virtual void render() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -16,14 +16,18 @@ class GlApplication: public Application
|
|||
friend class GlWindow;
|
||||
|
||||
public:
|
||||
#ifdef DEBUG
|
||||
constexpr static bool debug_mode = true;
|
||||
#else
|
||||
constexpr static bool debug_mode = false;
|
||||
#endif
|
||||
std::vector<std::shared_ptr<GlWindow>> windows;
|
||||
|
||||
GlApplication();
|
||||
~GlApplication();
|
||||
|
||||
void run();
|
||||
void add_window(int width, int height, const std::string& title);
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<GlWindow>> windows;
|
||||
std::weak_ptr<Window> add_window(int width, int height, const std::string& title);
|
||||
};
|
||||
|
||||
class GlWindow: public Window
|
||||
|
|
@ -34,6 +38,8 @@ public:
|
|||
GlWindow(const GlApplication& app, int width, int height, const std::string& title);
|
||||
~GlWindow();
|
||||
|
||||
void add_box();
|
||||
|
||||
private:
|
||||
const GlApplication& app;
|
||||
|
||||
|
|
|
|||
22
include/uui/opengl/box.hpp
Normal file
22
include/uui/opengl/box.hpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include "graphic_context.hpp"
|
||||
#include "uui/component.hpp"
|
||||
|
||||
namespace uui
|
||||
{
|
||||
class GlBox: public Component
|
||||
{
|
||||
public:
|
||||
GlBox();
|
||||
~GlBox();
|
||||
|
||||
void render();
|
||||
|
||||
private:
|
||||
GLuint gl_vbo;
|
||||
GLuint gl_vao;
|
||||
GLuint gl_program;
|
||||
};
|
||||
|
||||
} // namespace uui
|
||||
|
|
@ -1,22 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "graphic_context.hpp"
|
||||
#include "uui/component.hpp"
|
||||
|
||||
namespace uui
|
||||
{
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
std::string title;
|
||||
std::vector<std::unique_ptr<Component>> components;
|
||||
|
||||
virtual void draw() = 0;
|
||||
virtual void add_box() = 0;
|
||||
|
||||
protected:
|
||||
GLFWwindow* glfw_window;
|
||||
|
||||
virtual void draw() = 0;
|
||||
};
|
||||
} // namespace uui
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue