SFML community forums

Bindings - other languages => DotNet => Topic started by: yolan51 on June 01, 2023, 10:48:51 pm

Title: Vertex Or Sprite Batching in Csharp
Post by: yolan51 on June 01, 2023, 10:48:51 pm
I'm trying to do a hell-bullet game , so more than maybe 2000-5000 entities in the screen but i can't find a good way to do batching.

I found some c/c++ code to make SFML batching but i'm no genius so i dont understand how to translate it into C# code !

Others things the documentation show off some C++ way to extend SF::Drawable and SF::Transformable.

I can't find C# documentation , if anyone could tell me how to batch eitheir Vertex or Sprite in C# in a good way.

As of now the vertex batching i made , make it hard to apply rotation or animation , when I apply rotation to a renderstates it make my vertex texture dissapear i don't know why !

I'm ready to pay for some help if anyone has clue on how to fix this  in C sharp , her my discord :: https://discord.gg/srzchsKDEq

Title: Re: Vertex Or Sprite Batching in Csharp
Post by: yolan51 on June 01, 2023, 11:28:47 pm
I'm thinking of making everything a sprite , then cycle trought all of them every frame then put it into a vertexarray , but i dont know if it is a good idea ,

VA = new VertexArray();
foreach(sprites){

vertex = new Vertex();
vertex.position = sprites.getPosition();
vertex.texture.position = sprite.GetTexturePosition();

VA.AddVertex(vertex);
}

window.Draw(VA,Renderstates);

something around those lines would work i think.
Title: Re: Vertex Or Sprite Batching in Csharp
Post by: Hapax on November 23, 2023, 04:01:46 pm
Hi. I just noticed this post.

I've recently created a simple sprite batcher that may be of some use to you. It's in C++ but it's very simple and short so you should be able to easily convert it to C# or, at least, use it as a base for building your own!

See this thread here:
https://en.sfml-dev.org/forums/index.php?topic=29286.msg180697#msg180697
It has a link to the SFML wiki page that explains it.

Hope it helps!
Title: Re: Vertex Or Sprite Batching in Csharp
Post by: eXpl0it3r on November 25, 2023, 09:23:55 pm
Using a VertexArray or VertexBuffer in SFML.Net is a bit trickier than maybe in C++, but if you need an example, I've converted on of my talks from C++ to C# here (https://github.com/eXpl0it3r/Talks/blob/master/2023%20-%20Team%20Meeting/SFML%202D%20Graphics/VertexArraysBuffers/Program.cs).