Fellow developers,
I'm currently writing a game that uses a lot of transparent sprites, and am currently trying to optimize the colorkey blitter (it doesn't use any of the well-known commercial game engines).
I know there is a way to optimize this by taking two 16-bit pixels at once, but the results aren't satisfying enough yet. Maybe one of you can help with a specific part of the algorithm.
I need to quickly compare a 32-bit value (containing 2 pixels) if it contains no transparent pixels (so I can draw these 2 pixels immediatly). The code is something like this:
There must be a way to make the "checking for two non-transparent pixels" check faster, but I can't find of a way to do it. The rest of the code has been simplified to improve readability of the code.
Someone with a good tip?
I'm currently writing a game that uses a lot of transparent sprites, and am currently trying to optimize the colorkey blitter (it doesn't use any of the well-known commercial game engines).
I know there is a way to optimize this by taking two 16-bit pixels at once, but the results aren't satisfying enough yet. Maybe one of you can help with a specific part of the algorithm.
I need to quickly compare a 32-bit value (containing 2 pixels) if it contains no transparent pixels (so I can draw these 2 pixels immediatly). The code is something like this:
- Code:
unsigned long d_colorkey = (colorkey << 16);
unsigned long d_pixel = src[x * 2] + src[x * 2 + 1];
if (((d_pixel & 0xFFFF) != colorkey) && ((d_pixel & 0xFFFF0000) != d_colorkey))
//draw 2 pixels
There must be a way to make the "checking for two non-transparent pixels" check faster, but I can't find of a way to do it. The rest of the code has been simplified to improve readability of the code.
Someone with a good tip?