There's been some comment lately on the performance hit of using the built-in clipper in GD 2.04. Just thought I'd drop in my $.0000002 ...
My current project involves a 200x200 area of the screen that is used for the actual game action, the rest of the screen rarely changes (i.e., scores and some incidental graphics, etc.). The 200x200 area has a 240x240 border around it, and as you might expect, I needed to clip all my graphics against that 200x200 area.
I wrote my own clipper for it (the one posted in the sticky thread here), and it worked pretty well. However, I prefer my code be a concise as possible, and the extra RECT setups and function calls didn't thrill me.
So, based on a suggestion I read here, what I did was to create a 400x400 surface, and then blit all the game elements to that. Then, at the end of ProcessNextFrame, I blit the center 200x200 RECT of that onto backbuffer, and I basically get clipping "for free" (as in no additional code required) and I keep my code less verbose than before.
On my stock MIPS-based Casio E-125 (150MHz that is), I was getting a fairly solid 40FPS (which is what it's coded to) all the time. There were some parts that would dip down to 37-39. That seemed pretty good to me, certainly sufficient for this game.
However, with the addition of GD 2.04's clipping, I decided to do away with the extra surface-to-backbuffer blit, if for no other reason than to have some extra speed overhead, assuming it was faster than the double-blit approach.
I can report that the frame rate now stays solidly at 40 at all times with only one exception (which is due to a bit of unoptimized code on my part).
So, while I don't have any comment on the built-in clipper vs. my own clipper, since I didn't make that comparison, I can say that if you are using the extra surface approach that I was, you can safely do away with it and actually gain a little bit of performance, not to mention a little bit of memory, since you won't have that extra surface floating around.
Take that for whatever it's worth, which probably isn't much!, but there it is anyway.
My current project involves a 200x200 area of the screen that is used for the actual game action, the rest of the screen rarely changes (i.e., scores and some incidental graphics, etc.). The 200x200 area has a 240x240 border around it, and as you might expect, I needed to clip all my graphics against that 200x200 area.
I wrote my own clipper for it (the one posted in the sticky thread here), and it worked pretty well. However, I prefer my code be a concise as possible, and the extra RECT setups and function calls didn't thrill me.
So, based on a suggestion I read here, what I did was to create a 400x400 surface, and then blit all the game elements to that. Then, at the end of ProcessNextFrame, I blit the center 200x200 RECT of that onto backbuffer, and I basically get clipping "for free" (as in no additional code required) and I keep my code less verbose than before.
On my stock MIPS-based Casio E-125 (150MHz that is), I was getting a fairly solid 40FPS (which is what it's coded to) all the time. There were some parts that would dip down to 37-39. That seemed pretty good to me, certainly sufficient for this game.
However, with the addition of GD 2.04's clipping, I decided to do away with the extra surface-to-backbuffer blit, if for no other reason than to have some extra speed overhead, assuming it was faster than the double-blit approach.
I can report that the frame rate now stays solidly at 40 at all times with only one exception (which is due to a bit of unoptimized code on my part).
So, while I don't have any comment on the built-in clipper vs. my own clipper, since I didn't make that comparison, I can say that if you are using the extra surface approach that I was, you can safely do away with it and actually gain a little bit of performance, not to mention a little bit of memory, since you won't have that extra surface floating around.
Take that for whatever it's worth, which probably isn't much!, but there it is anyway.