sbarisic / NuklearDotNet

.NET binding for the Nuklear immediate mode GUI
Other
189 stars 15 forks source link

Method like "GetSubMeshCount()" missing. #23

Open DaEgi01 opened 2 years ago

DaEgi01 commented 2 years ago

I tried to integrate this lib into unity 5.6. I am currently working with Submeshes and Graphics.DrawMesh. What I need is a way to know, how many objects are generated from the vertices in vertexBuffer, before the Render Methods are called for each.

Donaut commented 2 years ago

You are better off using the GL class it's more low level and you can pretty much just copy-paste the SFML example. The Render method is gonna called for each mesh. The Count parameter tells how many vertexes the mesh has.

DaEgi01 commented 2 years ago

But the counter is available right and could in theory be exposed? Graphics.DrawMesh also works fine, I see the UI there. My issue is just that I have hardcoded the submeshCount for now. It could be an additional parameter of the SetBuffer method maybe? Anyway, its up to you. I ll try the GL class instead. Thx.

sbarisic commented 2 years ago

Exposed how and where exactly? If you're creating your own device, then as @Donaut said, you get the vertex count in the Render() method.

Nuklear has some sort of "command buffer" in the background, which basically says "draw a mesh with X clip rectangle and Y assigned texture" and gives you the offset and count into a vertex/index array, which can be drawn multiple times. The SetBuffer method is just there for you to keep track of vertices/indices combo to be used in the Render method.

Therefore it's okay to recreate all the graphics objects you are going to use in the Render method, because that can be cached, and RenderFinal would get called every frame to do the actual drawing.