diff --git a/src/fart/Parser.cpp b/src/fart/Parser.cpp index 6f4e0cb..33bd203 100644 --- a/src/fart/Parser.cpp +++ b/src/fart/Parser.cpp @@ -61,8 +61,31 @@ Scene * Parser::load_scene(const string_view & input_file) return nullptr; } - /* TODO: populate the Scene from p_result(context). */ - Scene * scene = new Scene(); + Scene * scene = build_scene(p_result(context)); p_context_delete(context); return scene; } + +Scene * Parser::build_scene(PStart start) +{ + Scene * scene = new Scene(); + + for (PRenderParams rps = start.pRenderParams(); p_node_valid(rps); rps = rps.pRenderParams()) + { + PRenderParam rp = rps.pRenderParam(); + if (PBackground background = rp.pBackground(); p_node_valid(background)) + { + /* TODO: set scene->params.background from the Vector. */ + } + else if (PHeight height = rp.pHeight(); p_node_valid(height)) + { + /* TODO: set scene->params.height from the uint token. */ + } + else if (PWidth width = rp.pWidth(); p_node_valid(width)) + { + /* TODO: set scene->params.width from the uint token. */ + } + } + + return scene; +} diff --git a/src/fart/Parser.h b/src/fart/Parser.h index 1102d71..a9427fa 100644 --- a/src/fart/Parser.h +++ b/src/fart/Parser.h @@ -2,8 +2,13 @@ #include +struct PStart; + class Parser { public: static Scene * load_scene(const string_view & input_file); + +private: + static Scene * build_scene(PStart start); }; diff --git a/src/fart/Scene.h b/src/fart/Scene.h index 821f814..5349bb8 100644 --- a/src/fart/Scene.h +++ b/src/fart/Scene.h @@ -1,5 +1,9 @@ #pragma once +#include + class Scene { +public: + RenderParams params; };