SFML / imgui-sfml

Dear ImGui backend for use with SFML
MIT License
1.08k stars 163 forks source link

Drawing an sf::VertexArray #236

Closed arnokret closed 1 year ago

arnokret commented 1 year ago

Would you know by any chance a good way to render an sf::VertexArray onto an ImGui window?

eliasdaler commented 1 year ago

Hello. I can recommend drawing it to sf::RenderTexture and then drawing it with ImGui::Image.

arnokret commented 1 year ago

Thanks for the response. I thought of that option, but my Vertex array changes every frame, so then with this method of copying textures around, I would get very low frame rate.

But, if I understand it correctly, there is no way to somehow directly map the sf::VertexArray to the drawlist in imgui?

eliasdaler commented 1 year ago

I thought of that option, but my Vertex array changes every frame, so then with this method of copying textures around, I would get very low frame rate.

You must be doing something wrong.

Rendering to a texture shouldn't involve any copying - it's not very different from drawing to a window.

Maybe you're creating sf::RenderTexture in every frame? You shouldn't do that. You should reuse it.

You can also use ImDrawList directly. See this example

arnokret commented 1 year ago

Thanks a lot for your comment, I was indeed doing something wrong and it is working now. The other pointers you gave are also very helpful.

eliasdaler commented 1 year ago

You're welcome :)