add Sampler class, add attributes system
This commit is contained in:
@@ -53,6 +53,10 @@ void App::init()
|
||||
" frag = col;"
|
||||
"}";
|
||||
|
||||
auto w = att::Width(10.f);
|
||||
printf("type: %d\n", att::value("Height"));
|
||||
|
||||
std::vector<std::unique_ptr<Shape>> s;
|
||||
auto y_root = YGNodeNew();
|
||||
tinyxml2::XMLDocument xml;
|
||||
auto ret = xml.LoadFile("data\\layout.xml");
|
||||
@@ -63,23 +67,37 @@ void App::init()
|
||||
printf("Element %s: ", child->Name());
|
||||
auto attr = child->FirstAttribute();
|
||||
auto y_node = YGNodeNew();
|
||||
YGNodeInsertChild(y_root, y_node, 0);
|
||||
std::unique_ptr<Shape> shape = std::make_unique<Plane>();
|
||||
while (attr)
|
||||
{
|
||||
const auto ka = att::value(attr->Name());
|
||||
printf("%s=%s ", attr->Name(), attr->Value());
|
||||
if (strcmp("width", attr->Name()) == 0)
|
||||
switch (ka)
|
||||
{
|
||||
case att::kAttribute::Width:
|
||||
if (strchr(attr->Value(), '%'))
|
||||
YGNodeStyleSetWidthPercent(y_node, attr->FloatValue());
|
||||
else
|
||||
YGNodeStyleSetWidth(y_node, attr->FloatValue());
|
||||
shape->attribs[ka] = std::make_unique<att::Width>(attr->FloatValue());
|
||||
break;
|
||||
case att::kAttribute::Height:
|
||||
if (strchr(attr->Value(), '%'))
|
||||
YGNodeStyleSetHeightPercent(y_node, attr->FloatValue());
|
||||
else
|
||||
YGNodeStyleSetHeight(y_node, attr->FloatValue());
|
||||
shape->attribs[ka] = std::make_unique<att::Height>(attr->FloatValue());
|
||||
break;
|
||||
}
|
||||
attr = attr->Next();
|
||||
}
|
||||
|
||||
YGNodeInsertChild(y_root, y_node, 0);
|
||||
printf("\n");
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
|
||||
sampler.create();
|
||||
shader.create(shader_v, shader_f);
|
||||
shader_color.create(shader_color_v, shader_color_f);
|
||||
shader_uv.create(shader_v, shader_uv_f);
|
||||
@@ -141,6 +159,7 @@ void App::update(float dt)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
tex.bind();
|
||||
sampler.bind(0);
|
||||
shader.u_int("tex", 0);
|
||||
shader.u_mat4("mvp", proj * glm::translate(glm::vec3{75 + h * 1, 75 + h * i, 0.f}) * s);
|
||||
shapes[i]->draw_fill();
|
||||
|
||||
Reference in New Issue
Block a user