0
votes

I am using SDLDotNet.dll 6.1.1 (which I think is SDL 1.2). Whenever I blit onto a transparent surface quickly in succession (e.g when a player is clicking fast) it drops in FPS around 5 fps a click (from 350fps down to 5fps)

Here is my surface:

    ChunkSurface = new Surface(256, 256) {Transparent = true};

and my code to update a chunk

            if (ReRerenderPartial)
            {
                foreach (Point poin in ReRenderPoints)
                {
                    int ChunkX = poin.X;
                    int ChunkY = poin.Y;
                    int Block = Blocks[ChunkX, ChunkY];
                    var b = BaseBlock.blockList.Find(Block);
                    if (b.Surface().Transparent)
                    {
                        ChunkSurface.Fill(new Rectangle(new Point(poin.X * 16, poin.Y * 16), new Size(16, 16)), Color.Black);
                    }
                    if (Block > 0)
                    {
                        ChunkSurface.Blit(b.Surface(), new Point(poin.X*16, poin.Y*16));
                    }
                }
            }

If I set Transparent to false there is no FPS loss when clicking fast (and requiring a re-render) but if it's true then it drops FPS. The two functions that cause the FPS loss are the Fill & Blit

If you want to see it in action my repo is @ https://github.com/Snowl/PlataJumperSDL relevant file is Chunk.cs

1

1 Answers

0
votes

My bad, I wasn't clearing the render points list, causing a lot of points to be rendered when they didn't need to be re-rendered, increasing with the amount of points requiring to be rendered.

ReRenderPoints = new List<Point>();

at the end of my render function fixed it.

Thanks anyway.