mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
Backends: Null: added imgui_impl_null platform/renderer backend.
This commit is contained in:
parent
9e15ebb402
commit
b885382a63
12 changed files with 392 additions and 12 deletions
97
backends/imgui_impl_null.cpp
Normal file
97
backends/imgui_impl_null.cpp
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
// dear imgui: Null Platform+Renderer Backends
|
||||
// This is designed if you need to use a blind Dear Imgui context with no input and no output.
|
||||
|
||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||
// Learn about Dear ImGui:
|
||||
// - FAQ https://dearimgui.com/faq
|
||||
// - Getting Started https://dearimgui.com/getting-started
|
||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||
// - Introduction, links and more at the top of imgui.cpp
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2025-11-17: Initial version.
|
||||
|
||||
#include "imgui.h"
|
||||
#ifndef IMGUI_DISABLE
|
||||
#include "imgui_impl_null.h"
|
||||
|
||||
bool ImGui_ImplNull_Init()
|
||||
{
|
||||
ImGui_ImplNullPlatform_Init();
|
||||
ImGui_ImplNullRender_Init();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplNull_Shutdown()
|
||||
{
|
||||
ImGui_ImplNullRender_Shutdown();
|
||||
ImGui_ImplNullPlatform_Shutdown();
|
||||
}
|
||||
|
||||
void ImGui_ImplNull_NewFrame()
|
||||
{
|
||||
ImGui_ImplNullPlatform_NewFrame();
|
||||
ImGui_ImplNullRender_NewFrame();
|
||||
}
|
||||
|
||||
bool ImGui_ImplNullPlatform_Init()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplNullPlatform_Shutdown()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_HasMouseCursors;
|
||||
}
|
||||
|
||||
void ImGui_ImplNullPlatform_NewFrame()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.DisplaySize = ImVec2(1920, 1080);
|
||||
io.DeltaTime = 1.0f / 60.0f;
|
||||
}
|
||||
|
||||
bool ImGui_ImplNullRender_Init()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset;
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasTextures;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplNullRender_Shutdown()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasVtxOffset;
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_RendererHasTextures;
|
||||
}
|
||||
|
||||
void ImGui_ImplNullRender_NewFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void ImGui_ImplNullRender_UpdateTexture(ImTextureData* tex)
|
||||
{
|
||||
if (tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantDestroy)
|
||||
tex->SetStatus(ImTextureStatus_OK);
|
||||
if (tex->Status == ImTextureStatus_WantDestroy)
|
||||
{
|
||||
tex->SetTexID(ImTextureID_Invalid);
|
||||
tex->SetStatus(ImTextureStatus_Destroyed);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui_ImplNullRender_RenderDrawData(ImDrawData* draw_data)
|
||||
{
|
||||
if (draw_data->Textures != nullptr)
|
||||
for (ImTextureData* tex : *draw_data->Textures)
|
||||
if (tex->Status != ImTextureStatus_OK)
|
||||
ImGui_ImplNullRender_UpdateTexture(tex);
|
||||
}
|
||||
|
||||
#endif // #ifndef IMGUI_DISABLE
|
||||
34
backends/imgui_impl_null.h
Normal file
34
backends/imgui_impl_null.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// dear imgui: Null Platform+Renderer Backends
|
||||
// This is designed if you need to use a blind Dear Imgui context with no input and no output.
|
||||
|
||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||
// Learn about Dear ImGui:
|
||||
// - FAQ https://dearimgui.com/faq
|
||||
// - Getting Started https://dearimgui.com/getting-started
|
||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||
// - Introduction, links and more at the top of imgui.cpp
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
#ifndef IMGUI_DISABLE
|
||||
|
||||
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
||||
|
||||
// Null = NullPlatform + NullRender
|
||||
IMGUI_IMPL_API bool ImGui_ImplNull_Init();
|
||||
IMGUI_IMPL_API void ImGui_ImplNull_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplNull_NewFrame();
|
||||
|
||||
// Null platform only (single screen, fixed timestep, no inputs)
|
||||
IMGUI_IMPL_API bool ImGui_ImplNullPlatform_Init();
|
||||
IMGUI_IMPL_API void ImGui_ImplNullPlatform_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplNullPlatform_NewFrame();
|
||||
|
||||
// Null renderer only (no output)
|
||||
IMGUI_IMPL_API bool ImGui_ImplNullRender_Init();
|
||||
IMGUI_IMPL_API void ImGui_ImplNullRender_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplNullRender_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplNullRender_RenderDrawData(ImDrawData* draw_data);
|
||||
|
||||
#endif // #ifndef IMGUI_DISABLE
|
||||
Loading…
Add table
Add a link
Reference in a new issue