82 lines
3.4 KiB
C
82 lines
3.4 KiB
C
// dear imgui: CPU framebuffer renderer backend
|
|
// (supports caller-owned framebuffers/textures in generic packed pixel formats)
|
|
//
|
|
// Implemented features:
|
|
// [X] Renderer: User texture binding. Use 'ImGui_ImplCPU_Texture*' as texture identifier.
|
|
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices.
|
|
// [X] Renderer: Texture updates support for dynamic font atlas.
|
|
|
|
#pragma once
|
|
#ifndef IMGUI_DISABLE
|
|
#include "imgui.h"
|
|
|
|
struct ImGui_ImplCPU_PixelFormat;
|
|
typedef ImU32 (*ImGui_ImplCPU_MapColorFn)(const ImGui_ImplCPU_PixelFormat* format, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
|
|
|
struct ImGui_ImplCPU_PixelFormat
|
|
{
|
|
int BitsPerPixel;
|
|
int BytesPerPixel;
|
|
ImU32 Rmask;
|
|
ImU32 Gmask;
|
|
ImU32 Bmask;
|
|
ImU32 Amask;
|
|
ImU8 Rshift;
|
|
ImU8 Gshift;
|
|
ImU8 Bshift;
|
|
ImU8 Ashift;
|
|
ImU8 Rloss;
|
|
ImU8 Gloss;
|
|
ImU8 Bloss;
|
|
ImU8 Aloss;
|
|
const ImU32* Palette; // Optional palette entries stored as IM_COL32(r, g, b, a).
|
|
int PaletteSize; // Number of palette entries, or 0 when Palette is unused.
|
|
ImGui_ImplCPU_MapColorFn MapColorFn; // Optional indexed/paletted mapping override. Return a raw packed pixel value.
|
|
};
|
|
|
|
enum ImGui_ImplCPU_BuiltinFormat
|
|
{
|
|
ImGui_ImplCPU_BuiltinFormat_RGBA8888 = 0,
|
|
ImGui_ImplCPU_BuiltinFormat_BGRA8888,
|
|
ImGui_ImplCPU_BuiltinFormat_ARGB8888,
|
|
ImGui_ImplCPU_BuiltinFormat_ABGR8888,
|
|
ImGui_ImplCPU_BuiltinFormat_RGB565,
|
|
ImGui_ImplCPU_BuiltinFormat_ARGB1555,
|
|
ImGui_ImplCPU_BuiltinFormat_RGBA4444,
|
|
ImGui_ImplCPU_BuiltinFormat_RGB888,
|
|
ImGui_ImplCPU_BuiltinFormat_BGR888,
|
|
ImGui_ImplCPU_BuiltinFormat_Alpha8,
|
|
ImGui_ImplCPU_BuiltinFormat_COUNT
|
|
};
|
|
|
|
struct ImGui_ImplCPU_Framebuffer
|
|
{
|
|
unsigned char* Pixels;
|
|
int Width;
|
|
int Height;
|
|
int Pitch;
|
|
const ImGui_ImplCPU_PixelFormat* Format; // Optional. Defaults to ImGui_ImplCPU_BuiltinFormat_RGBA8888.
|
|
};
|
|
|
|
struct ImGui_ImplCPU_Texture
|
|
{
|
|
const unsigned char* Pixels;
|
|
int Width;
|
|
int Height;
|
|
int Pitch;
|
|
const ImGui_ImplCPU_PixelFormat* Format; // Optional. Defaults to ImGui_ImplCPU_BuiltinFormat_RGBA8888.
|
|
};
|
|
|
|
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
|
|
IMGUI_IMPL_API const ImGui_ImplCPU_PixelFormat* ImGui_ImplCPU_GetBuiltinPixelFormat(ImGui_ImplCPU_BuiltinFormat format);
|
|
IMGUI_IMPL_API bool ImGui_ImplCPU_Init();
|
|
IMGUI_IMPL_API void ImGui_ImplCPU_Shutdown();
|
|
IMGUI_IMPL_API void ImGui_ImplCPU_NewFrame();
|
|
IMGUI_IMPL_API void ImGui_ImplCPU_RenderDrawData(ImDrawData* draw_data, ImGui_ImplCPU_Framebuffer* framebuffer);
|
|
|
|
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates
|
|
// by setting ImDrawData::Textures = nullptr to handle this manually.
|
|
IMGUI_IMPL_API void ImGui_ImplCPU_UpdateTexture(ImTextureData* tex);
|
|
|
|
#endif // #ifndef IMGUI_DISABLE
|