Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 45 additions & 19 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,55 @@ void main()
ImGui::ShowDemoWindow();

{
ImGui::Begin("NodeEditor");
auto change = ImGui::DragFloat3("node1", vertices[0].position(), 0.01f, -1.f, 1.f);
change = ImGui::DragFloat3("node2", vertices[1].position(), 0.01f, -1.f, 1.f) || change;
change = ImGui::DragFloat3("node3", vertices[2].position(), 0.01f, -1.f, 1.f) || change;
if (change)
ImGui::Begin("Editor");
static int current = 0;
std::array<const char*, 3> items = {"Node", "Vertex", "Fragment"};
ImGui::Combo("##Object", &current, items.data(), items.size());
switch (current)
{
vertex_buffer.upload(&vertices, sizeof(vertices), 0);
case 0:
{
auto change = ImGui::DragFloat3("##node1", vertices[0].position(), 0.01f, -1.f, 1.f);
change = ImGui::DragFloat3("##node2", vertices[1].position(), 0.01f, -1.f, 1.f) || change;
change = ImGui::DragFloat3("##node3", vertices[2].position(), 0.01f, -1.f, 1.f) || change;
if (change)
{
// TODO: shouldn't upload in tick, we should delay this into draw function.
vertex_buffer.upload(&vertices, sizeof(vertices), 0);
}
}
break;
case 1:
{
auto line_count = std::count(vertex_source.begin(), vertex_source.end(), '\n');
ImVec2 size = ImVec2(
ImGui::GetContentRegionAvail().x,
std::min(ImGui::GetTextLineHeight() * (line_count + 3), ImGui::GetContentRegionAvail().y));
if (ImGui::InputTextMultiline("##vertex editor", &vertex_source, size,
ImGuiInputTextFlags_AllowTabInput))
{
pipeline_wrapper.set_vertex_shader(vertex_source);
}
}
break;
case 2:
{
auto line_count = std::count(fragment_source.begin(), fragment_source.end(), '\n');
ImVec2 size = ImVec2(
ImGui::GetContentRegionAvail().x,
std::min(ImGui::GetTextLineHeight() * (line_count + 3), ImGui::GetContentRegionAvail().y));
if (ImGui::InputTextMultiline("##fragment editor", &fragment_source, size,
ImGuiInputTextFlags_AllowTabInput))
{
pipeline_wrapper.set_fragment_shader(fragment_source);
}
}
break;
default:
break;
}
ImGui::End();
}
{
ImGui::Begin("SourceEditor");
auto line_count = std::count(vertex_source.begin(), vertex_source.end(), '\n');
ImVec2 size =
ImVec2(ImGui::GetContentRegionAvail().x,
std::min(ImGui::GetTextLineHeight() * (line_count + 3), ImGui::GetContentRegionAvail().y));
if (ImGui::InputTextMultiline("code editor", &vertex_source, size, ImGuiInputTextFlags_AllowTabInput))
{
pipeline_wrapper.set_vertex_shader(vertex_source);
}

ImGui::End();
}

ImGui::EndFrame();
return SDL_APP_CONTINUE;
Expand Down