Archived

This topic is now archived and is closed to further replies.

Jiia

Hard-code irregular shaped blits?

Recommended Posts

Really a very simple question. In my 2D isometric game (please don't move this to that thread ), I draw all of the flat diamond shaped floor tiles before I draw anything else (to prevent moving objects from slipping under the corners). Anyway, it does seem like a huge waste to draw all of them as rectangles, since those 4 corners amount to 50% of the image, plus having to check for transparent pixels for every single pixel. Would it be a good idea to hard code a specific blitting function and use it to manually treverse the pointers instead of using a loop? The only problem I can come up with is that it would look very ugly. Also clipping - I don't know how I could clip correctly with this method, unless I only use it for tiles that are completely on the screen. Any opinions on this? [edited by - Jiia on November 1, 2002 11:48:13 PM]

Share this post


Link to post
Share on other sites
My recommendation: profile your drawing routines. If they aren''t taking up enough cycles that this type of potential optimization would make a large difference, then don''t bother.

Or, you can always just move to a 3D-rendered isometric world. After all, a single tile is simply two triangles.

RomSteady - Test Locally, Test Globally, Test Early, Test Often

Share this post


Link to post
Share on other sites
2D scan conversion. you move along the outlines of your tile shape, and fill line per line inbetween. That''s very fast (that''s how all the software 3D renderers work), esp. with simple shapes, and you won''t waste any pixels.

Share this post


Link to post
Share on other sites
Well, I tried the line approach. Perhaps it would have a greater effect with smaller tiles, but there was very little change in the % of time spent drawing the tiles, and the number of tiles I can draw within 60 seconds. Either my code could have been written better, or the time my cpu takes to skip over transparent pixels is blazing fast.

Thanks again though,
Jiia

Share this post


Link to post
Share on other sites
The only issue is that the rectangle blitting routines are highly optimized and are likely done with special CPU instruction or hardware support. So unless your method of drawing is significantly faster, you won''t gain much speed by doing it yourself.

tj963

Share this post


Link to post
Share on other sites