mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Merge branch '2015-04-indexed-rendering' into 2015-03-antialiased-primitives
Conflicts: imgui.cpp imgui.h
This commit is contained in:
21
imgui.h
21
imgui.h
@ -695,6 +695,7 @@ struct ImGuiIO
|
||||
float Framerate; // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames
|
||||
int MetricsAllocs; // Number of active memory allocations
|
||||
int MetricsRenderVertices; // Vertices processed during last call to Render()
|
||||
int MetricsRenderIndices; //
|
||||
int MetricsActiveWindows; // Number of visible windows (exclude child windows)
|
||||
|
||||
//------------------------------------------------------------------
|
||||
@ -979,13 +980,16 @@ typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* c
|
||||
// Typically, 1 command = 1 gpu draw call (unless command is a callback)
|
||||
struct ImDrawCmd
|
||||
{
|
||||
unsigned int vtx_count; // Number of vertices (multiple of 3) to be drawn as triangles. The vertices are stored in the callee ImDrawList's vtx_buffer[] array.
|
||||
unsigned int idx_count; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
|
||||
ImVec4 clip_rect; // Clipping rectangle (x1, y1, x2, y2)
|
||||
ImTextureID texture_id; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
|
||||
ImDrawCallback user_callback; // If != NULL, call the function instead of rendering the vertices. vtx_count will be 0. clip_rect and texture_id will be set normally.
|
||||
void* user_callback_data; // The draw callback code can access this.
|
||||
};
|
||||
|
||||
// Vertex index
|
||||
typedef unsigned short ImDrawIdx;
|
||||
|
||||
// Vertex layout
|
||||
#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
|
||||
struct ImDrawVert
|
||||
@ -1013,12 +1017,15 @@ struct ImDrawList
|
||||
// This is what you have to render
|
||||
ImVector<ImDrawCmd> commands; // Commands. Typically 1 command = 1 gpu draw call.
|
||||
ImVector<ImDrawVert> vtx_buffer; // Vertex buffer. Each command consume ImDrawCmd::vtx_count of those
|
||||
ImVector<ImDrawIdx> idx_buffer; // Index buffer. Each command consume ImDrawCmd::idx_count of those
|
||||
|
||||
// [Internal to ImGui]
|
||||
ImVector<ImVec4> clip_rect_stack; // [Internal]
|
||||
ImVector<ImTextureID> texture_id_stack; // [Internal]
|
||||
ImDrawVert* vtx_write; // [Internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)
|
||||
ImVector<ImVec2> path; // [Internal]
|
||||
ImDrawVert* vtx_write; // [Internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)
|
||||
ImDrawIdx vtx_current_idx; // [Internal] == vtx_buffer.size()
|
||||
ImDrawIdx* idx_write; // [Internal] point within idx_buffer after each add command (to avoid using the ImVector<> operators too much)
|
||||
|
||||
ImDrawList() { Clear(); }
|
||||
IMGUI_API void Clear();
|
||||
@ -1051,15 +1058,17 @@ struct ImDrawList
|
||||
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col);
|
||||
|
||||
// Advanced
|
||||
IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'user_callback' in ImDrawCmd and call the function instead of rendering triangles.
|
||||
IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
|
||||
IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'user_callback' in ImDrawCmd and call the function instead of rendering triangles.
|
||||
IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
|
||||
|
||||
// Internal helpers
|
||||
IMGUI_API void PrimReserve(unsigned int vtx_count);
|
||||
IMGUI_API void PrimReserve(unsigned int idx_count, unsigned int vtx_count);
|
||||
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col);
|
||||
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
|
||||
IMGUI_API void UpdateClipRect();
|
||||
IMGUI_API void UpdateTextureID();
|
||||
IMGUI_API void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { vtx_write->pos = pos; vtx_write->uv = uv; vtx_write->col = col; vtx_write++; }
|
||||
IMGUI_API void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { vtx_write->pos = pos; vtx_write->uv = uv; vtx_write->col = col; vtx_write++; vtx_current_idx++; }
|
||||
IMGUI_API void PrimIdx(unsigned int idx) { *idx_write++ = (ImDrawIdx)idx; }
|
||||
};
|
||||
|
||||
// Load and rasterize multiple TTF fonts into a same texture.
|
||||
|
Reference in New Issue
Block a user