Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Vertex Or Sprite Batching in Csharp  (Read 5672 times)

0 Members and 1 Guest are viewing this topic.

yolan51

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Vertex Or Sprite Batching in Csharp
« 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


yolan51

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Vertex Or Sprite Batching in Csharp
« Reply #1 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3385
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Vertex Or Sprite Batching in Csharp
« Reply #2 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!
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11044
    • View Profile
    • development blog
    • Email
Re: Vertex Or Sprite Batching in Csharp
« Reply #3 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/