ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.33k stars 10.11k forks source link

Structure of draw_data->CmdLists[n], cmd_list->VtxBuffer.Data and cmd_list->IdxBuffer.Data? #2003

Closed mario-132 closed 6 years ago

mario-132 commented 6 years ago

Hi Sorry for posting another issue, but I ran into an issue of which I wasn't able to figure out the answer of myself: I've been implementing the renderer for imgui, but I don't understand the structures of:

  1. draw_data->CmdLists[n]
  2. cmd_list->VtxBuffer.Data
  3. cmd_list->IdxBuffer.Data

Can you explain those? I have no idea what 1. contains. Am I correct that 2. contains all the vertices for the triangles? But not the UV's and Colors? Am I correct that 3. contains indexes that tell which vertex needed for the triangle, like this? If 2. contains color's and uv's, then in what order? I'm hoping you can explain above, and I have one more question, what does cmd_list->CmdBuffer represent? Is it the list of windows or something?

Thank you very much!

mario-132 commented 6 years ago

Is there maybe anyone who knows this? I read the faq and looked in the opengl implementation, but was unable to find it.

Thanks!

ocornut commented 6 years ago

Tim,

I'm not sure what to tell you. As much as we are trying to help, your questions suggest a lack of basic C++ literacy. The amount of questions here is very overwhelming for me, this is not a place for me to teach you C++.

You should look up where those structures are described in the imgui.h file, e.g. hop from ImDrawList to the various structures it uses (your programming IDE can help you there). If you intend to create your own renderer and not use the provide renderer, it is expected that you can understand how to read a C++ structure.

For example, VtxBuffer is an array/vector of vertices:

ImVector<ImDrawVert> VtxBuffer;

And this is the definition of ImDrawVert:

struct ImDrawVert
{
    ImVec2  pos;
    ImVec2  uv;
    ImU32   col;
};

If you are unfamiliar with what a vector here, look up std::vector which works similarly to ImVector. (ImVector is basically a custom/simplified version of std::vector).

If you are unfamiliar with 3d rendering techniques and terminology, there are other places to learn those things. And if you state your problems in those places you may get the help you are looking for.

mario-132 commented 6 years ago

Thanks for your reply! Indidn't have time too look those structures up, nor did I expect it to just be a simple structure. I will check more myself and the .h file from now on, thanks. But my problem wasn't with c++, but with your api. Now I don't mean to be mean, but is it maybe an idea to add what these structures are to the imgui.cpp, as I wasn't able to find it.

I think I know render techniques but I'm not sure, depends which ones

Thanks for your reply!

On Sun, Aug 5, 2018, 5:28 PM omar notifications@github.com wrote:

Tim,

I'm not sure what to tell you. As much as we are trying to help, your questions suggest a lack of basic C++ literacy. The amount of questions here is very overwhelming for me, this is not a place for me to teach you C++.

You should look up where those structures are described in the imgui.h file, e.g. hop from ImDrawList to the various structures it uses (your programming IDE can help you there). If you intend to create your own renderer and not use the provide renderer, it is expected that you can understand how to read a C++ structure.

For example, VtxBuffer is an array/vector of vertices:

ImVector VtxBuffer;

And this is the definition of ImDrawVert:

struct ImDrawVert { ImVec2 pos; ImVec2 uv; ImU32 col; };

If you are unfamiliar with what a vector here, look up std::vector which works similarly to ImVector. (ImVector is basically a custom/simplified version of std::vector).

If you are unfamiliar with 3d rendering techniques and terminology, there are other places to learn those things. And if you state your problems in those places you may get the help you are looking for.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ocornut/imgui/issues/2003#issuecomment-410527640, or mute the thread https://github.com/notifications/unsubscribe-auth/AV4BTmDvLutSJvCzYHGqMBjdKt4uPgxqks5uNw8ggaJpZM4VvGXy .