Recommended Posts

Well, I created this with nothing but a description of how to do it. This method creates an array of scanline positions. One set of coordinates relate to the outline of the polygon, and the other one relates to the texture coordinates. It is all integer based, and for better precision I did some bit shifting to allow me to use integers with comparable precision to a float. It also does a simple test for clipping.
Anyway, I thought I would throw it up here in case anyone wanted to see it. Hopefully some of you can give me ideas on how I can make it even faster.
Rendering Function

Share this post

Link to post

Share on other sites

Why do you use statics for all your local variables? They ain't any faster, if not slower, than normal locals. I used to think that they would be faster too, because you wouldn't have to allocate them each time you run the function, but that's not true. Local variables are placed on the stack, a block of memory of 1 or 2 mb or so (depending on the compiler), and the only extra time local variables cost, is on a function call, when it has to update the stack pointer so that it points to the top of the stack again. static variables can be slower, because there's more chance that they are not in the cache.

Share this post

Link to post

Share on other sites

Well, I always rendered each scanline as I came to it, rather than wasting the memory to store a list, then drawing the list... I just drew as I got values (each scanline). It was rather fast, and more efficient (memory wise, and probably speed wise due to not first building, then traversing a list).

0

Share this post

Link to post

Share on other sites

Good thing with mapping polygons like Zefrieg does is that it''s really simple to allow >3 sides, you just scan a few sides more. This is good for clipped triangles, but I guess the direct method might be quicker for full, non-clipped triangles.

You can also reduce the two checks for the extreme bounds into two functions doing it directly, but I won''t go into that...