Package imgui

Class ImDrawData


public final class ImDrawData extends ImGuiStruct
All draw data to render Dear ImGui frame (NB: the style and the naming convention here is a little inconsistent, we currently preserve them for backward compatibility purpose, as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList)

BINDING NOTICE: Since it's impossible to do a 1:1 mapping with JNI, current class provides "getCmdList*()" methods. Those are used to get the data needed to do a rendering.

  • Constructor Details

    • ImDrawData

      public ImDrawData(long ptr)
  • Method Details

    • getCmdListCmdBufferSize

      public int getCmdListCmdBufferSize(int cmdListIdx)
      Draw commands. Typically 1 command = 1 GPU draw call, unless the command is a callback.
    • getCmdListCmdBufferElemCount

      public int getCmdListCmdBufferElemCount(int cmdListIdx, int cmdBufferIdx)
      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[].
    • getCmdListCmdBufferClipRect

      public ImVec4 getCmdListCmdBufferClipRect(int cmdListIdx, int cmdBufferIdx)
      Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData.DisplayPos to get clipping rectangle in "viewport" coordinates
    • getCmdListCmdBufferClipRect

      public void getCmdListCmdBufferClipRect(ImVec4 dst, int cmdListIdx, int cmdBufferIdx)
      Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData.DisplayPos to get clipping rectangle in "viewport" coordinates
    • getCmdListCmdBufferTextureId

      public long getCmdListCmdBufferTextureId(int cmdListIdx, int cmdBufferIdx)
      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.
    • getCmdListCmdBufferVtxOffset

      public int getCmdListCmdBufferVtxOffset(int cmdListIdx, int cmdBufferIdx)
      Start offset in vertex buffer. Pre-1.71 or without ImGuiBackendFlags_RendererHasVtxOffset: always 0. With ImGuiBackendFlags_RendererHasVtxOffset: may be >0 to support meshes larger than 64K vertices with 16-bit indices.
    • getCmdListCmdBufferIdxOffset

      public int getCmdListCmdBufferIdxOffset(int cmdListIdx, int cmdBufferIdx)
      Start offset in index buffer. Always equal to sum of ElemCount drawn so far.
    • getCmdListIdxBufferSize

      public int getCmdListIdxBufferSize(int cmdListIdx)
      Index buffer. Each command consume ImDrawCmd::ElemCount of those
    • getCmdListIdxBufferData

      public ByteBuffer getCmdListIdxBufferData(int cmdListIdx)
    • getCmdListVtxBufferSize

      public int getCmdListVtxBufferSize(int cmdListIdx)
      Vertex buffer.
    • getCmdListVtxBufferData

      public ByteBuffer getCmdListVtxBufferData(int cmdListIdx)
    • sizeOfImDrawVert

      public static int sizeOfImDrawVert()
    • sizeOfImDrawIdx

      public static int sizeOfImDrawIdx()
    • getValid

      public boolean getValid()
      Only valid after Render() is called and before the next NewFrame() is called.
    • getCmdListsCount

      public int getCmdListsCount()
      Number of ImDrawList* to render
    • getTotalIdxCount

      public int getTotalIdxCount()
      For convenience, sum of all ImDrawList's IdxBuffer.Size
    • getTotalVtxCount

      public int getTotalVtxCount()
      For convenience, sum of all ImDrawList's VtxBuffer.Size
    • getDisplayPos

      public ImVec2 getDisplayPos()
      Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
    • getDisplayPosX

      public float getDisplayPosX()
      Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
    • getDisplayPosY

      public float getDisplayPosY()
      Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
    • getDisplayPos

      public void getDisplayPos(ImVec2 dst)
      Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
    • getDisplaySize

      public ImVec2 getDisplaySize()
      Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
    • getDisplaySizeX

      public float getDisplaySizeX()
      Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
    • getDisplaySizeY

      public float getDisplaySizeY()
      Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
    • getDisplaySize

      public void getDisplaySize(ImVec2 dst)
      Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
    • getFramebufferScale

      public ImVec2 getFramebufferScale()
      Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
    • getFramebufferScaleX

      public float getFramebufferScaleX()
      Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
    • getFramebufferScaleY

      public float getFramebufferScaleY()
      Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
    • getFramebufferScale

      public void getFramebufferScale(ImVec2 dst)
      Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
    • getOwnerViewport

      public ImGuiViewport getOwnerViewport()
      Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not).
    • clear

      public void clear()
    • addDrawList

      public void addDrawList(ImDrawList drawList)
      Helper to add an external draw list into an existing ImDrawData.
    • deIndexAllBuffers

      public void deIndexAllBuffers()
      Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
    • scaleClipRects

      public void scaleClipRects(ImVec2 fbScale)
      Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
    • scaleClipRects

      public void scaleClipRects(float fbScaleX, float fbScaleY)
      Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.