added color attribute and scissor clipping. Added debug callback to OpenGL messages
This commit is contained in:
@@ -7,7 +7,8 @@ namespace att
|
||||
Height, MinHeight, MaxHeight,
|
||||
Divisions, InnerRadius, OuterRadius,
|
||||
Grow, Shrink, FlexDir, FlexWrap,
|
||||
Padding, Margin
|
||||
Padding, Margin,
|
||||
Color
|
||||
};
|
||||
|
||||
struct AttributeBase
|
||||
@@ -47,7 +48,8 @@ namespace att
|
||||
{ "dir", kAttribute::FlexDir },
|
||||
{ "wrap", kAttribute::FlexWrap },
|
||||
{ "pad", kAttribute::Padding },
|
||||
{ "margin", kAttribute::Margin},
|
||||
{ "margin", kAttribute::Margin },
|
||||
{ "color", kAttribute::Color },
|
||||
};
|
||||
constexpr int map_size = sizeof(map) / sizeof(typemap) - 1;
|
||||
constexpr bool same(const char* a, const char* b)
|
||||
@@ -88,6 +90,7 @@ namespace att
|
||||
DECLARE_ATTRIBUTE(FlexWrap, int);
|
||||
DECLARE_ATTRIBUTE(Padding, glm::vec4);
|
||||
DECLARE_ATTRIBUTE(Margin, glm::vec4);
|
||||
DECLARE_ATTRIBUTE(Color, glm::vec4);
|
||||
|
||||
#undef DECLARE_ATTRIBUTE
|
||||
}
|
||||
@@ -95,19 +98,24 @@ namespace att
|
||||
class Shape
|
||||
{
|
||||
protected:
|
||||
GLuint buffers[2];
|
||||
GLuint arrays[2];
|
||||
GLuint count[2];
|
||||
GLvoid* ioff[2];
|
||||
GLuint buffers[2]{ 0 };
|
||||
GLuint arrays[2]{ 0 };
|
||||
GLuint count[2]{ 0 };
|
||||
GLvoid* ioff[2]{ 0 };
|
||||
struct vertex_t { glm::vec4 pos; glm::vec2 uvs; };
|
||||
public:
|
||||
YGNodeRef y_node;
|
||||
float x, y;
|
||||
glm::vec4 color;
|
||||
att::AttrubutesMap attribs;
|
||||
bool create_buffers(GLvoid* idx, GLvoid* vertices, int isize, int vsize);
|
||||
void draw_fill() const;
|
||||
void draw_stroke() const;
|
||||
virtual bool create_attrib() { return true; };
|
||||
~Shape()
|
||||
{
|
||||
glDeleteBuffers(2, buffers);
|
||||
glDeleteVertexArrays(2, arrays);
|
||||
}
|
||||
protected:
|
||||
glm::vec2 quad_mid_point(glm::vec2 a, glm::vec2 b, glm::vec2 c, glm::vec2 d)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user