Sorry for late reply
But i "solved" my issue by using Image and Texture instead of VertexArray
That's the only way i found to be able to render 4 millions of tiles while zoomed out with constant 60+ FPS
And i'm able to save lot of texture swap since i'm only dealing with colors data (only one draw call by chunks, even if i'm using multiple different tilesets)
Here is the updated code of the Chunk:
using System;using SFML.Graphics;using SFML.System;using TheRoguer.Client.Legacy.Managers;using TheRoguer.Client.Legacy.Utils;using TheRoguer.Client.Legacy.Data;namespace TheRoguer
.Client.Legacy.World.Map{ public class Chunk
: Drawable
{ private Texture m_texture
; public Vector2f Position
; private Image m_image
; private Sprite m_sprite
; private bool m_dirty
; public Chunk
() { m_texture
= new Texture
(TileMap
.CHUNK_SIZE * TileMap
.TILE_SIZE, TileMap
.CHUNK_SIZE * TileMap
.TILE_SIZE); m_image
= new Image
(TileMap
.CHUNK_SIZE * TileMap
.TILE_SIZE, TileMap
.CHUNK_SIZE * TileMap
.TILE_SIZE); m_sprite
= new Sprite
(m_texture
); } public void Reset
(int offsetX,
int offsetY
) { Position
= new Vector2f
(offsetX, offsetY
+ 4); m_sprite
.Position = Position
; } public void Draw
(RenderTarget target, RenderStates states
) { target
.Draw(m_sprite
); } public void Update
(int time,
int delta
) { if (m_dirty
) { m_texture
.Update(m_image
); m_sprite
.Texture = m_texture
; m_dirty
= false; } } public void Paint
(int x,
int y, TextureData textureData
) { var textureRegion
= AssetManager
.Instance.GetRegion(textureData
); if (textureRegion
.Texture == null) Log
.Error(GetType
(), $
"Texture Region for {textureData.File}:{textureData.Index} not found"); var world_x
= x
* TileMap
.TILE_SIZE; var world_y
= y
* TileMap
.TILE_SIZE; for (var tex
= 0; tex
< textureRegion
.Width; tex
++) { for (var tey
= 0; tey
< textureRegion
.Height; tey
++) { var color
= textureRegion
.GetColor(tex, tey
); var pix_x
= world_x
+ tex
; var pix_y
= world_y
+ tey
; m_image
.SetPixel((uint) pix_x,
(uint) pix_y, color
); } } m_dirty
= true; } public void Dispose
() { PoolingManager
.Instance.Recycle(this); } }}