From 49e577b6567edc8f586a76f5b1c78bee40099f4e Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 12:40:20 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`pip?= =?UTF-8?q?iline`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @WSQS. * https://github.com/WSQS/sdl_test/pull/7#issuecomment-3521731024 The following files were modified: * `main.cpp` * `sdl_wrapper/sdl_callback_implement.cpp` --- main.cpp | 24 ++++++++++++++++++- sdl_wrapper/sdl_callback_implement.cpp | 32 +++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 75916c2..38ffdc3 100644 --- a/main.cpp +++ b/main.cpp @@ -70,6 +70,13 @@ void main() SDL_GPUVertexAttribute vertexAttributes[2]{}; SDL_GPUVertexBufferDescription vertexBufferDesctiptions[1]{}; + /** + * @brief Initialize the application: create window, compile shaders, create GPU pipeline and resources, and initialize ImGui. + * + * @param argc Number of command-line arguments provided to the application. + * @param argv Command-line argument vector provided to the application. + * @return SDL_AppResult SDL_APP_CONTINUE to proceed with the main loop, SDL_APP_SUCCESS to request termination. + */ virtual SDL_AppResult init(int argc, char** argv) override { // create a window @@ -216,6 +223,13 @@ void main() return SDL_APP_CONTINUE; } + /** + * @brief Advance the application by one frame: update ImGui, handle UI for vertex editing and live shader recompilation, record GPU commands to render the triangle and ImGui, and submit the GPU command buffer. + * + * Performs per-frame UI updates (including draggable vertex positions and a multiline shader editor), uploads vertex data when modified, recompiles and replaces the vertex shader and graphics pipeline on shader edits, acquires a GPU command buffer and the swapchain texture, executes a render pass that draws the triangle and ImGui draw lists, and submits the command buffer. + * + * @return SDL_AppResult SDL_APP_CONTINUE to continue the main loop. + */ virtual SDL_AppResult iterate() override { ImGui_ImplSDLGPU3_NewFrame(); @@ -346,6 +360,14 @@ void main() return SDL_APP_CONTINUE; } + /** + * @brief Cleanly shuts down the application and releases GPU and UI resources. + * + * Performs final cleanup: shuts down ImGui SDL/SDLGPU backends, destroys the ImGui context, + * releases the vertex buffer, shaders, and graphics pipeline, and destroys the SDL window. + * + * @param result The application's exit result code provided by the SDL app framework. + */ virtual void quit(SDL_AppResult result) override { ImGui_ImplSDL3_Shutdown(); @@ -366,4 +388,4 @@ void main() } }; -sopho::App* create_app() { return new UserApp(); } +sopho::App* create_app() { return new UserApp(); } \ No newline at end of file diff --git a/sdl_wrapper/sdl_callback_implement.cpp b/sdl_wrapper/sdl_callback_implement.cpp index 4786de6..41533fc 100644 --- a/sdl_wrapper/sdl_callback_implement.cpp +++ b/sdl_wrapper/sdl_callback_implement.cpp @@ -8,6 +8,14 @@ import sdl_wrapper; extern sopho::App* create_app(); +/** + * @brief Initializes the SDL video subsystem, constructs the application, and invokes its initialization. + * + * @param appstate Pointer to storage that will receive the created sopho::App* on success. + * @param argc Program argument count forwarded to the application's init. + * @param argv Program argument vector forwarded to the application's init. + * @return SDL_AppResult Result returned by the application's init, or SDL_APP_FAILURE if application creation failed. + */ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv) { SDL_Init(SDL_INIT_VIDEO); @@ -18,21 +26,43 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv) return app->init(argc, argv); } +/** + * @brief Invoke the application's per-frame iterate handler. + * + * @param appstate Pointer to the sopho::App instance previously stored in SDL_AppInit. + * @return SDL_AppResult The result of the application's iterate call indicating the application's requested next action. + */ SDL_AppResult SDL_AppIterate(void* appstate) { auto* app = static_cast(appstate); return app->iterate(); } +/** + * @brief Dispatches an SDL event to the stored application instance. + * + * @param appstate Opaque pointer previously set by SDL_AppInit; must point to a `sopho::App` instance. + * @param event Pointer to the SDL event to deliver to the application. + * @return SDL_AppResult Result returned by the application's event handler. + */ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) { auto* app = static_cast(appstate); return app->event(event); } +/** + * @brief Shuts down the application and releases its instance. + * + * Invokes the application's quit handler with the provided result and destroys + * the stored application instance. + * + * @param appstate Pointer to the sopho::App instance previously stored by SDL_AppInit. + * @param result Result code describing why the application is quitting. + */ void SDL_AppQuit(void* appstate, SDL_AppResult result) { auto* app = static_cast(appstate); app->quit(result); delete app; -} +} \ No newline at end of file From 268cca29e4988a2443397fde6675b6331b66fedf Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 12:40:45 +0000 Subject: [PATCH 2/2] style: format code with ClangFormat This commit fixes the style issues introduced in 49e577b according to the output from ClangFormat. Details: https://github.com/WSQS/sdl_test/pull/8 --- main.cpp | 15 ++++++++++----- sdl_wrapper/sdl_callback_implement.cpp | 5 +++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 38ffdc3..45d4c22 100644 --- a/main.cpp +++ b/main.cpp @@ -71,11 +71,12 @@ void main() SDL_GPUVertexBufferDescription vertexBufferDesctiptions[1]{}; /** - * @brief Initialize the application: create window, compile shaders, create GPU pipeline and resources, and initialize ImGui. + * @brief Initialize the application: create window, compile shaders, create GPU pipeline and resources, and + * initialize ImGui. * * @param argc Number of command-line arguments provided to the application. * @param argv Command-line argument vector provided to the application. - * @return SDL_AppResult SDL_APP_CONTINUE to proceed with the main loop, SDL_APP_SUCCESS to request termination. + * @return SDL_AppResult SDL_APP_CONTINUE to proceed with the main loop, SDL_APP_SUCCESS to request termination. */ virtual SDL_AppResult init(int argc, char** argv) override { @@ -224,9 +225,13 @@ void main() } /** - * @brief Advance the application by one frame: update ImGui, handle UI for vertex editing and live shader recompilation, record GPU commands to render the triangle and ImGui, and submit the GPU command buffer. + * @brief Advance the application by one frame: update ImGui, handle UI for vertex editing and live shader + * recompilation, record GPU commands to render the triangle and ImGui, and submit the GPU command buffer. * - * Performs per-frame UI updates (including draggable vertex positions and a multiline shader editor), uploads vertex data when modified, recompiles and replaces the vertex shader and graphics pipeline on shader edits, acquires a GPU command buffer and the swapchain texture, executes a render pass that draws the triangle and ImGui draw lists, and submits the command buffer. + * Performs per-frame UI updates (including draggable vertex positions and a multiline shader editor), uploads + * vertex data when modified, recompiles and replaces the vertex shader and graphics pipeline on shader edits, + * acquires a GPU command buffer and the swapchain texture, executes a render pass that draws the triangle and ImGui + * draw lists, and submits the command buffer. * * @return SDL_AppResult SDL_APP_CONTINUE to continue the main loop. */ @@ -388,4 +393,4 @@ void main() } }; -sopho::App* create_app() { return new UserApp(); } \ No newline at end of file +sopho::App* create_app() { return new UserApp(); } diff --git a/sdl_wrapper/sdl_callback_implement.cpp b/sdl_wrapper/sdl_callback_implement.cpp index 41533fc..4407bef 100644 --- a/sdl_wrapper/sdl_callback_implement.cpp +++ b/sdl_wrapper/sdl_callback_implement.cpp @@ -30,7 +30,8 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv) * @brief Invoke the application's per-frame iterate handler. * * @param appstate Pointer to the sopho::App instance previously stored in SDL_AppInit. - * @return SDL_AppResult The result of the application's iterate call indicating the application's requested next action. + * @return SDL_AppResult The result of the application's iterate call indicating the application's requested next + * action. */ SDL_AppResult SDL_AppIterate(void* appstate) { @@ -65,4 +66,4 @@ void SDL_AppQuit(void* appstate, SDL_AppResult result) auto* app = static_cast(appstate); app->quit(result); delete app; -} \ No newline at end of file +}