Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexed Rendering 65536 Limit per window #292

Closed
Pagghiu opened this issue Aug 6, 2015 · 6 comments
Closed

Indexed Rendering 65536 Limit per window #292

Pagghiu opened this issue Aug 6, 2015 · 6 comments

Comments

@Pagghiu
Copy link
Contributor

Pagghiu commented Aug 6, 2015

I understand that it's probably a design decision but I've been hitting the 65536 Index limit inside a single window, due to ImDrawIdx being an unsigned short. I was searching some API to "break" the index chain but looks like there's one unique VTX and IDX buffer per DrawList, and there's one DrawList per Window.
FYI, the reason is that I am drawing a good number of 2D points (as small rectangles) to display edge outlines of an image.
I could use the usercallback mechanism, but I'm wondering if there's a better way.
Additionally in my opinion the ImDrawList should assert in debug if someone tries to write more than 65536 vertices.
Suggestions?

Here's a good one.
indexed rendering limit 1

here's a bad one (more than 65536 indexes), my background image becomes garbage.
indexed rendering limit 2

@ocornut
Copy link
Owner

ocornut commented Aug 6, 2015

  • I will add an assert somewhere (likely in Render() and not when adding each index)
  • We could potentially allow the user to #define ImDrawIdx, that wouldn't be a hard patch probably. Look above IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT.
  • Otherwise you can use multiple ImDrawList, we ought to allow to insert them in arbitrary order but if you create child windows it'll allow that.

PS: I'd like to see a full resolution version of those picture! :)

@adamdmoss
Copy link
Contributor

FYI I hit this too! I decided that I didn't much care, for my use, but a relatively simple workaround would also be pleasant.

@ocornut
Copy link
Owner

ocornut commented Aug 6, 2015

What did you do to hit this Adam?

@Pagghiu
Copy link
Contributor Author

Pagghiu commented Aug 7, 2015

Hi Omar, I did it as you've been suggesting (ChildWindows) and it works perfectly!
Something like this

//...
    int currentChild = 0;
    ImVec2 wpos = ImGui::GetWindowPos();
    ImVec2 backupPos = ImGui::GetCursorScreenPos();
    ImGui::SetCursorScreenPos(wpos);
    ImGui::BeginChild(currentChild++);
    ImDrawList* draw_list = ImGui::GetWindowDrawList();
    int numberOfPoints = pDlg->cv.getObject(foundObject)->_numVerifyPts;
    double* pX = pDlg->cv.getObject(foundObject)->_aVerifyPtsX;
    double* pY = pDlg->cv.getObject(foundObject)->_aVerifyPtsY;
    for (int i = 0; i < numberOfPoints; i++)
    {
        float x = static_cast<float>(pX[i]);
        float y = static_cast<float>(pY[i]);
        x *= zoom;
        y *= zoom;
        x += topLeftScreen.x;
        y += topLeftScreen.y;

        const float w = 1.0f;
        ImVec2 minR(x - w, y - w), maxR(x + w, y + w);
        draw_list->AddRectFilled(minR, maxR,ImColor(0,255,0,128));
        if (draw_list->_VtxCurrentIdx > 65536 - 8)
        {
            ImGui::EndChild();
            ImGui::SetCursorScreenPos(wpos);
            ImGui::BeginChild(currentChild++);
            draw_list = ImGui::GetWindowDrawList();
        }
    }

    ImGui::EndChild();
    ImGui::SetCursorScreenPos(backupPos);
//...

I'm also attaching some screenshot of our Robotic Visual Guidance software (CortexRecognition:registered: ), as you're requesting ;)

It's a world class 6DOF robotic guidance solution !
Basically it's able to find from an arbitrary image, the type and location of a taught model in 6 Degrees of freedom using real millimeters and degrees. With this information you can send a robot to go and pick parts or other kind of processes. We're in the process of enhancing our website and building some new professional videos, but if you're curious you can watch those. I'm talking about real robots, not virtual ones from videogames! 👾

https://www.youtube.com/watch?v=ebob20egGjE
https://www.youtube.com/watch?v=vjlULbJYeM0

(those old videos are not featuring the new IMGUI UI...but the upcoming ones will!)

cortex recognition 1
cortex recognition 2
cortex recognition 3
cortex recognition 4
cortex recognition 5
cortex recognition 6
cortex recognition 7

@ocornut
Copy link
Owner

ocornut commented Aug 9, 2015

Thanks for the screenshots!

I have added an assert and the possibility to override ImDrawIdx with a different type. Tested with unsigned int and it works (of course you need to adjust your draw function accordingly).

@ocornut
Copy link
Owner

ocornut commented Jun 5, 2019

There's now another solution to this, see #2591

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants