uui/include/uui/opengl/component.hpp
2021-07-13 01:30:37 +09:00

51 lines
1,012 B
C++

#pragma once
#include <array>
// #include <memory>
#include <variant>
#include "graphic_context.hpp"
#include "window.hpp"
namespace uui
{
class GlComponent
{
friend class GlWindow;
public:
GlComponent(const GlComponent&) = delete;
GlComponent(GlComponent&&) = delete;
~GlComponent();
void set_background_color(float r, float g, float b, float a = 0.0f);
private:
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;
bool initialized;
GLuint gl_vbo;
GLuint gl_vao;
GLuint gl_ebo;
GlComponent(
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