Skip to content
New issue

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

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

Already on GitHub? # to your account

Advice on creating a backend not using vertex buffers. #3175

Open
Convery opened this issue Apr 28, 2020 · 5 comments
Open

Advice on creating a backend not using vertex buffers. #3175

Convery opened this issue Apr 28, 2020 · 5 comments

Comments

@Convery
Copy link

Convery commented Apr 28, 2020

Greetings fellow humans, quick question on backends that I couldn't find in the docs:

Consider a system where there's no viable API for drawing with vertices / triangles. A system where you pass a structure in the form of { DRAW_LINE, x0, y0, x1, y1, colour } to a device and it does the rendering on its own.

Is there any proper customization-point to capture the calls or is the only option to replace ImDrawList or modify AddPolyline() and friends in imgui_draw.cpp?

Somewhat related to #2724 which could probably benefit from the advice.

@thedmd
Copy link
Contributor

thedmd commented Apr 28, 2020

There is no customization point where you can capture individual draw commands.

Only way is to do as you suggested and replace AddXXX function implementations.

@ocornut
Copy link
Owner

ocornut commented Apr 28, 2020

I think you'd want to #ifdef out the ImDrawList header and implementation and create your own in another file.

I don't mind supporting this for experiments such as https://github.com/ggerganov/imtui etc. but I'd only do this with an actual implementation lined up. Aka if you have something useful working, I would take the PR to add an official way to ifdef the default implementation out. But I suspect it's going to be more subtle than that. So first I suggest you hack imgui with the minimum amount of change (only new #ifdef blocks) and add the rest in separate code.

@Convery
Copy link
Author

Convery commented May 1, 2020

So far the least intrusive implementation has been to create a define in imconfig to select between the original ImDrawList and one that inherits and extends. Seems to be the minimum amount of change, added a PR for that alone. #3185

@MouriNaruto
Copy link

It's a good idea for the pull request created by myself. (#2724)

I am agree with that "Probably a better idea to allow passing a custom drawlist to context creation." in #3185 (comment).

@englercj
Copy link

englercj commented Jun 6, 2021

The ability to configure this part of ImGui is more interesting to me than the various PRs/Issues about improved font rendering. I don't mind writing the things necessary to do better font handling (maybe Slug) or rendering (maybe Primitive Buffers), but don't have a good hook for it right now. Even a compile-time one would be nice.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

5 participants