Correct resize and safer pointers
This commit is contained in:
parent
20835586ab
commit
3b2be83590
9 changed files with 193 additions and 81 deletions
|
|
@ -26,10 +26,11 @@ public:
|
|||
~GlApplication();
|
||||
|
||||
void run();
|
||||
std::weak_ptr<GlWindow> create_window(int width, int height, const std::string& title);
|
||||
std::shared_ptr<GlWindow> create_window(int width, int height, const std::string& title);
|
||||
std::shared_ptr<GlWindow> get_window(size_t index) const;
|
||||
|
||||
private:
|
||||
static bool application_created;
|
||||
static GlApplication* application_pointer;
|
||||
};
|
||||
|
||||
class GlComponent;
|
||||
|
|
@ -46,22 +47,28 @@ public:
|
|||
GlWindow(GlWindow&&) = delete;
|
||||
~GlWindow();
|
||||
|
||||
std::weak_ptr<GlComponent> create_component(
|
||||
std::shared_ptr<GlComponent> create_component(
|
||||
const std::variant<int, float> x, const std::variant<int, float> y, const std::variant<int, float> width,
|
||||
const std::variant<int, float> height);
|
||||
|
||||
private:
|
||||
const GlApplication& app;
|
||||
GlApplication* app;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
bool need_resize_refresh;
|
||||
|
||||
size_t index;
|
||||
bool initialized;
|
||||
|
||||
GLFWwindow* glfw_window;
|
||||
|
||||
GLuint gl_program;
|
||||
|
||||
GlWindow(const GlApplication& app, int width, int height, const std::string& title);
|
||||
GlWindow(GlApplication* app, size_t index, int width, int height, const std::string& title);
|
||||
|
||||
void init();
|
||||
void deinit();
|
||||
void draw();
|
||||
|
||||
static void glfw_resize_callback(GLFWwindow* window, int width, int height);
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ public:
|
|||
GlComponent(GlComponent&&) = delete;
|
||||
~GlComponent();
|
||||
|
||||
void render();
|
||||
void set_background_color(float r, float g, float b, float a = 0.0f);
|
||||
|
||||
private:
|
||||
// std::weak_ptr<GlWindow> window;
|
||||
GlWindow* window;
|
||||
std::shared_ptr<GlWindow> window;
|
||||
|
||||
std::variant<int, float> position_x;
|
||||
std::variant<int, float> position_y;
|
||||
std::variant<int, float> size_width;
|
||||
std::variant<int, float> size_height;
|
||||
bool coord_all_relative;
|
||||
|
||||
std::array<float, 4> background_color;
|
||||
|
||||
|
|
@ -38,11 +38,14 @@ private:
|
|||
GLuint gl_ebo;
|
||||
|
||||
GlComponent(
|
||||
GlWindow* window, const std::variant<int, float> x, const std::variant<int, float> y,
|
||||
std::shared_ptr<GlWindow> window, const std::variant<int, float> x, const std::variant<int, float> y,
|
||||
const std::variant<int, float> width, const std::variant<int, float> height);
|
||||
|
||||
void init();
|
||||
void set_vbo_data();
|
||||
void deinit();
|
||||
void render();
|
||||
void on_resize();
|
||||
};
|
||||
|
||||
} // namespace uui
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue