| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <vk_engine.h> | ||
| 2 | |||
| 3 | // #include "graphed/graphed.h" | ||
| 4 | #include "imgui_impl_vulkan.h" | ||
| 5 | |||
| 6 | #include "node.h" | ||
| 7 | |||
| 8 | void ShowExampleAppCustomNodeGraph(bool* opened); | ||
| 9 | |||
| 10 | class App: public VulkanEngine { | ||
| 11 | public: | ||
| 12 | GraphEditor editor; | ||
| 13 | |||
| 14 | App() {} | ||
| 15 | |||
| 16 | void start() { | ||
| 17 | ✗ | Forest& forest = editor.forests.emplace_back(); | |
| 18 | ✗ | Tree& tree = forest.trees.emplace_back(); | |
| 19 | |||
| 20 | ✗ | Node& n1 = tree.nodes.emplace_back(); | |
| 21 | ✗ | n1.pos = ImVec2(10, 10); | |
| 22 | ✗ | n1.name = "First Node"; | |
| 23 | |||
| 24 | { | ||
| 25 | ✗ | Pin& p = n1.inputs.emplace_back(); | |
| 26 | ✗ | p.kind = PinKind::Flow; | |
| 27 | ✗ | p.type = PinType::Flow; | |
| 28 | } | ||
| 29 | |||
| 30 | { | ||
| 31 | ✗ | Pin& p = n1.inputs.emplace_back(); | |
| 32 | ✗ | p.name = "x"; | |
| 33 | ✗ | p.type = PinType::Float; | |
| 34 | } | ||
| 35 | |||
| 36 | { | ||
| 37 | ✗ | Pin& p = n1.inputs.emplace_back(); | |
| 38 | ✗ | p.name = "y"; | |
| 39 | } | ||
| 40 | |||
| 41 | { | ||
| 42 | ✗ | Pin& p = n1.outputs.emplace_back(); | |
| 43 | ✗ | p.kind = PinKind::Flow; | |
| 44 | ✗ | p.type = PinType::Flow; | |
| 45 | } | ||
| 46 | |||
| 47 | ✗ | Pin& p1 = n1.outputs.emplace_back(); | |
| 48 | ✗ | p1.name = "z"; | |
| 49 | ✗ | ImVec2 s1 = editor.estimate_size(n1); | |
| 50 | |||
| 51 | // -- NODE 2 | ||
| 52 | ✗ | Node& n2 = tree.nodes.emplace_back(); | |
| 53 | ✗ | n2.pos = s1 * ImVec2(1, 0) + ImVec2(40, 10); | |
| 54 | ✗ | n2.name = "+"; | |
| 55 | ✗ | Pin& p2 = n2.inputs.emplace_back(); | |
| 56 | ✗ | p2.name = "b"; | |
| 57 | ✗ | tree.links.emplace_back(&p1, &p2); | |
| 58 | { | ||
| 59 | ✗ | Pin& p = n2.outputs.emplace_back(); | |
| 60 | ✗ | p.name = "a"; | |
| 61 | } | ||
| 62 | |||
| 63 | { | ||
| 64 | ✗ | Pin& p = n2.outputs.emplace_back(); | |
| 65 | ✗ | p.name = "c"; | |
| 66 | } | ||
| 67 | |||
| 68 | { | ||
| 69 | ✗ | Node& n3 = tree.nodes.emplace_back(); | |
| 70 | ✗ | n3.pos = ImVec2(600, 100); | |
| 71 | ✗ | n3.name = "Pure Function"; | |
| 72 | ✗ | Pin& p3 = n3.outputs.emplace_back(); | |
| 73 | ✗ | p3.name = "b"; | |
| 74 | } | ||
| 75 | |||
| 76 | // Condition | ||
| 77 | { | ||
| 78 | ✗ | Node& n = tree.nodes.emplace_back(); | |
| 79 | ✗ | n.pos = ImVec2(600, 100); | |
| 80 | ✗ | n.name = "Cond"; | |
| 81 | |||
| 82 | { | ||
| 83 | ✗ | Pin& p = n.inputs.emplace_back(); | |
| 84 | ✗ | p.kind = PinKind::Flow; | |
| 85 | ✗ | p.type = PinType::Flow; | |
| 86 | } | ||
| 87 | |||
| 88 | { | ||
| 89 | ✗ | Pin& p = n.outputs.emplace_back(); | |
| 90 | ✗ | p.kind = PinKind::Flow; | |
| 91 | ✗ | p.type = PinType::Flow; | |
| 92 | ✗ | p.name = "True"; | |
| 93 | } | ||
| 94 | |||
| 95 | { | ||
| 96 | ✗ | Pin& p = n.outputs.emplace_back(); | |
| 97 | ✗ | p.kind = PinKind::Flow; | |
| 98 | ✗ | p.type = PinType::Flow; | |
| 99 | ✗ | p.name = "False"; | |
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | ✗ | } | |
| 104 | |||
| 105 | void handle_event(SDL_Event const& event) {} | ||
| 106 | |||
| 107 | void tick(float dt) { | ||
| 108 | ✗ | editor.draw(); | |
| 109 | |||
| 110 | //bool opened = true; | ||
| 111 | //ShowExampleAppCustomNodeGraph(&opened); | ||
| 112 | ✗ | } | |
| 113 | |||
| 114 | void end() { | ||
| 115 | ✗ | } | |
| 116 | }; | ||
| 117 | |||
| 118 | #include <iostream> | ||
| 119 | |||
| 120 | int main(int argc, char* argv[]) | ||
| 121 | { | ||
| 122 | ✗ | App engine; | |
| 123 | |||
| 124 | ✗ | engine.init(); | |
| 125 | |||
| 126 | ✗ | engine.run(); | |
| 127 | |||
| 128 | ✗ | engine.cleanup(); | |
| 129 | |||
| 130 | ✗ | return 0; | |
| 131 | ✗ | } | |
| 132 |