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
49 changes: 42 additions & 7 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ void main()
}

/**
* @brief Advance the application by one frame: update UI, apply vertex edits and live shader recompilation, render,
* and submit GPU work.
* @brief Advance the UI frame, present interactive editors for triangle vertices and shader source, and apply
* edits.
*
* Processes ImGui frames, uploads vertex data when edited, recompiles and replaces the vertex shader and graphics
* pipeline on shader edits, records a render pass that draws the triangle and ImGui draw lists, and submits the GPU
* command buffer for presentation.
* Presents a NodeEditor with draggable 3D position editors for each vertex and a SourceEditor with a multiline
* shader text editor. If a vertex position is modified, the vertex buffer is updated with the new vertex data.
* If the shader source is modified, the pipeline's vertex shader source is updated.
*
* @return `SDL_APP_CONTINUE` to continue the main loop.
* @return SDL_AppResult SDL_APP_CONTINUE to indicate the application should continue running.
*/
virtual SDL_AppResult iterate() override
SDL_AppResult tick()
{
ImGui_ImplSDLGPU3_NewFrame();
ImGui_ImplSDL3_NewFrame();
Expand Down Expand Up @@ -157,6 +157,22 @@ void main()
ImGui::End();
}

ImGui::EndFrame();
return SDL_APP_CONTINUE;
}

/**
* @brief Render ImGui draw data and the application's triangle to the GPU, then present the swapchain texture.
*
* Prepares ImGui draw data, submits the graphics pipeline, acquires a GPU command buffer and the current
* swapchain texture, records rendering commands (including binding the pipeline and vertex buffer and issuing
* a draw call), executes ImGui rendering into the render pass, and submits the command buffer for presentation.
* If no swapchain texture is available the function still submits the command buffer and continues.
*
* @return SDL_AppResult `SDL_APP_CONTINUE` to continue the application main loop.
*/
SDL_AppResult draw()
{
ImGui::Render();
ImDrawData* draw_data = ImGui::GetDrawData();

Expand Down Expand Up @@ -213,6 +229,25 @@ void main()
return SDL_APP_CONTINUE;
}

/**
* @brief Advance the application one iteration by performing per-frame updates and rendering.
*
* Performs per-frame UI and state updates; if those updates indicate continuation, executes rendering and submits
* GPU work for presentation.
*
* @return `SDL_APP_CONTINUE` to continue the main loop, or another `SDL_AppResult` to terminate.
*/
virtual SDL_AppResult iterate() override
{

auto result = tick();
if (result == SDL_APP_CONTINUE)
{
result = draw();
}
return result;
}

/**
* @brief Handle an SDL event by forwarding it to ImGui and handling window-close requests.
*
Expand Down