Colorkey will be much better, especially if the image being copied is just
replacing the destination colors. It also shouldnt look any worse.
Based on the description on what your doing I think using opengl to accelerate
all of your blending and blits would be a huge speed increase. But of course
that requires a good rewrite on the rendering engine.________________________________
From: goswin-v-b@web.de (Goswin von Brederlow)
To: SDL Development List
Sent: Tue, May 8, 2012 11:54:24 AM
Subject: Re: [SDL] How do I make my game render faster?
Scott Smith <@Scott_Smith> writes:
Are you using alpha blending? If so that can be a high consumer of the CPU.
I need transparency but I have considered using COLORKEY. I suspected
that alpha blending might be expensive but it is good to see it
confirmed. I will have to add some code to convert images to COLORKEY
after loading and compare the two. Alpha blending would allow better
graphics though.
Use SDL_UpdateRects to only update parts of screen (requires more logic to
handle, and may not be worth it if the background changes)
There is a minimap of 300x200 pixel that changes every frame and a main
map of (width - 200) * height that also changes every frame. What’s left
is a 200 * (height - 200) region for GUI elements that will change
ocasionaly (when the user switches tabs) or frequently (when the user
switches to a statistics tab), but probably less than every frame.
But the main map is where all the work is spend. I 'm using a hexagonal
grid so I’m blitting in a lots of triangles for the terrain, ontop each
another for terrain modification (rivers so far). After that it is
buildings, items and units as present on the tiles. That comes to up to
6 surfaces per tile (up+down triangle, up+down modifier, building | item
Idealy I want terrain to be animated. Wind going through the grass,
little waves on the ocean, … Then the terrain would change every
frame.
Units are to be animated even when stationary (cleaning their nose,
looking around, that kind of thing) and most certainly while moving. So
they often change between frames. And that means items and buildings
must be drawn too in case they overlap. Buildings can be animated too,
smoke in the chimeny or the like. Not that I have that yet but it should
be an option. Tracking where items or buildings overlap units or when
units change their look between frames would be complicated.
Lower the bpp for your images i.e from 32 bpp to 16 bpp.
Won’t that be slower when running on a 32 bpp display (as I usualy do)?
Switch to opengl if you platform can support it.
Profile your code
MfG
Goswin
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org