0

I want to optimize rendering in ImGui. Here's what I'm trying to.

// This function is called in my rendering loop.
void Backend::render() {
  static ImDrawList* previousDrawList = nullptr;
  ImGui::Begin("List Widget");
  if (m_dataChanged) {
    for (int i = 0; i < m_data.size(); i++) {
      ImGui::Text(data[i]);
    }
    previousDrawList = ImGui::GetWindowDrawList()->CloneOutput();
    m_dataChanged = false;
  }
  else {
    ImDrawList* currentDrawList = ImGui::GetWindowDrawList();
    currentDrawList = previousDrawList;
  }
  ImGui::End();
}

This code generates the drawing list only if the data has changed, otherwise use previous draw list, and it didn't work. The "List Widget" shows the data only when m_dataChanged == true.
I already use other drawing list data API such as ImDrawListSharedData, ImDrawList::_Data, etc. for copying, storing, and assigning the drawing list, but these are all not work.
How to solve this problem? Is this even possible?

WOOSEOK CHOI
  • 165
  • 9

0 Answers0