testing yoga and tinyxml2 to read some attributes from file
This commit is contained in:
@@ -53,10 +53,32 @@ void App::init()
|
||||
" frag = col;"
|
||||
"}";
|
||||
|
||||
auto y_root = YGNodeNew();
|
||||
tinyxml2::XMLDocument xml;
|
||||
auto ret = xml.LoadFile("data\\layout.xml");
|
||||
auto root = xml.RootElement();
|
||||
// root->
|
||||
auto child = root->FirstChildElement();
|
||||
while (child)
|
||||
{
|
||||
printf("Element %s: ", child->Name());
|
||||
auto attr = child->FirstAttribute();
|
||||
auto y_node = YGNodeNew();
|
||||
YGNodeInsertChild(y_root, y_node, 0);
|
||||
while (attr)
|
||||
{
|
||||
printf("%s=%s ", attr->Name(), attr->Value());
|
||||
if (strcmp("width", attr->Name()) == 0)
|
||||
{
|
||||
if (strchr(attr->Value(), '%'))
|
||||
YGNodeStyleSetWidthPercent(y_node, attr->FloatValue());
|
||||
else
|
||||
YGNodeStyleSetWidth(y_node, attr->FloatValue());
|
||||
}
|
||||
attr = attr->Next();
|
||||
}
|
||||
printf("\n");
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
|
||||
shader.create(shader_v, shader_f);
|
||||
shader_color.create(shader_color_v, shader_color_f);
|
||||
|
||||
Reference in New Issue
Block a user