Java Hates 0xFF000000
In my previous post I noted that Java seemed unsuitable for Bunnies since I was demanding more textures, etc. But behind the scenes I noticed something very odd. When I was on a large grassy patch in the middle of the track the framerate was fine. However, when I neared the large patch of pure black track tiles the framerate plummeted to around 2fps. Changing the tile from pure black to not black brought the framerate back up.
Bunnies now runs at 30fps at 320×240 with the following addition of code to the texture loading routine:
int k =0;
int m = textures[num].w * textures[num].h;
for(k = 0;k<m ;k++)
if(textures[num].pixels[k]==0xFF000000)
textures[num].pixels[k] = 0xFF010101;
That’s right, every pure black pixel is changed to not quite black and now Java is cruising along. Another side effect is that the mystery gaps between floor tiles has also disappeared.
Maybe there’s some logical explaination to this mystery but I havn’t figured it out yet. Silly me thinking black would be treated just like every other color. Apparently, Java thinks differently.
Leave a comment
You must be logged in to post a comment.