Added GetDrawData() alternative to setting a Render function.

This commit is contained in:
ocornut
2015-09-07 14:56:39 +01:00
parent 93f9ad9ddf
commit dafad3903e
3 changed files with 31 additions and 13 deletions

12
imgui.h
View File

@ -105,6 +105,7 @@ namespace ImGui
// Main
IMGUI_API ImGuiIO& GetIO();
IMGUI_API ImGuiStyle& GetStyle();
IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame()
IMGUI_API void NewFrame();
IMGUI_API void Render();
IMGUI_API void Shutdown();
@ -694,8 +695,9 @@ struct ImGuiIO
// User Functions
//------------------------------------------------------------------
// REQUIRED: rendering function.
// See example code if you are unsure of how to implement this.
// Rendering function, will be called in Render().
// Alternatively you can keep this to NULL and call GetDrawData() after Render() to get the same pointer.
// See example applications if you are unsure of how to implement this.
void (*RenderDrawListsFn)(ImDrawData* data);
// Optional: access OS clipboard
@ -1149,14 +1151,16 @@ struct ImDrawList
// All draw data to render an ImGui frame
struct ImDrawData
{
bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
ImDrawList** CmdLists;
int CmdListsCount;
int TotalVtxCount; // For convenience, sum of all cmd_lists vtx_buffer.Size
int TotalIdxCount; // For convenience, sum of all cmd_lists idx_buffer.Size
// Functions
void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
IMGUI_API ImDrawData() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; }
IMGUI_API void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
IMGUI_API void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
};
struct ImFontConfig