mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-02 12:37:20 +01:00
Examples: SDL3+SDL_GPU: use SDL_GPU_PRESENTMODE_MAILBOX swapchain parameters.
This commit is contained in:
parent
bf13442c7c
commit
3e6bdc2242
@ -7,7 +7,7 @@
|
|||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// Important note to the reader who wish to integrate imgui_impl_sdlgpu3.cpp/.h in their own engine/app.
|
// Important note to the reader who wish to integrate imgui_impl_sdlgpu3.cpp/.h in their own engine/app.
|
||||||
// - Unline other backends, the user must call the function Imgui_ImplSDLGPU_PrepareDrawData BEFORE issuing a SDL_GPURenderPass containing ImGui_ImplSDLGPU_RenderDrawData.
|
// - Unlike other backends, the user must call the function Imgui_ImplSDLGPU_PrepareDrawData() BEFORE issuing a SDL_GPURenderPass containing ImGui_ImplSDLGPU_RenderDrawData.
|
||||||
// Calling the function is MANDATORY, otherwise the ImGui will not upload neither the vertex nor the index buffer for the GPU. See imgui_impl_sdlgpu3.cpp for more info.
|
// Calling the function is MANDATORY, otherwise the ImGui will not upload neither the vertex nor the index buffer for the GPU. See imgui_impl_sdlgpu3.cpp for more info.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
@ -54,6 +54,7 @@ int main(int, char**)
|
|||||||
printf("Error: SDL_ClaimWindowForGPUDevice(): %s\n", SDL_GetError());
|
printf("Error: SDL_ClaimWindowForGPUDevice(): %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
SDL_SetGPUSwapchainParameters(gpu_device, window, SDL_GPU_SWAPCHAINCOMPOSITION_SDR, SDL_GPU_PRESENTMODE_MAILBOX);
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
@ -140,7 +141,7 @@ int main(int, char**)
|
|||||||
ImGui::Checkbox("Another Window", &show_another_window);
|
ImGui::Checkbox("Another Window", &show_another_window);
|
||||||
|
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
ImGui::ColorEdit4("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||||
|
|
||||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
counter++;
|
counter++;
|
||||||
@ -179,7 +180,7 @@ int main(int, char**)
|
|||||||
// Setup and start a render pass
|
// Setup and start a render pass
|
||||||
SDL_GPUColorTargetInfo target_info = {};
|
SDL_GPUColorTargetInfo target_info = {};
|
||||||
target_info.texture = swapchain_texture;
|
target_info.texture = swapchain_texture;
|
||||||
target_info.clear_color = SDL_FColor{ clear_color.x,clear_color.y,clear_color.z,clear_color.w };
|
target_info.clear_color = SDL_FColor { clear_color.x, clear_color.y, clear_color.z, clear_color.w };
|
||||||
target_info.load_op = SDL_GPU_LOADOP_CLEAR;
|
target_info.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||||
target_info.store_op = SDL_GPU_STOREOP_STORE;
|
target_info.store_op = SDL_GPU_STOREOP_STORE;
|
||||||
target_info.mip_level = 0;
|
target_info.mip_level = 0;
|
||||||
@ -196,6 +197,7 @@ int main(int, char**)
|
|||||||
// Submit the command buffer
|
// Submit the command buffer
|
||||||
SDL_SubmitGPUCommandBuffer(command_buffer);
|
SDL_SubmitGPUCommandBuffer(command_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
SDL_WaitForGPUIdle(gpu_device);
|
SDL_WaitForGPUIdle(gpu_device);
|
||||||
ImGui_ImplSDL3_Shutdown();
|
ImGui_ImplSDL3_Shutdown();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user