Skip to main content
gamedev.net
🔒 Locked

2D image blitting algorithm

Started by vongodric 8 replies 3.6k views
Original Post
vongodric
vongodric
Hey guys, Im trying to optimize my graphics engine and seeking for a little help regarding surface overlapping. My case is that I blit loads of surfaces to screen where many are hidden or partially hidden uner others. So I'm seeking a good tutorial or algorithms for creating "blitting pool" that would calculate me only regions from the surfaces that are actually visible. Thus it would be a great speedup I guess.
ToohrVyk
ToohrVyk
You might want to use either 2D CSG (constructive solid geometry) or S-trees (span trees) for each line. The second is the easiest to create.

Also, watch out for the cache.
vongodric
vongodric
do you have links or smth to them? I searcged google and found nothing of use. I have a gui -it blits lot of rectangles and often some are invisible or only party visible. So there is no 3D or circular objects. Only plain rectangles.
Heewa
Heewa
What about implementing a zbuffer? The idea is that as you render each pixel of a rectangle, you store its height (z coordinate in 3d, you'd use whatever value you have for indicating that a rectangle is "on top" of another) in a buffer. Next time a rectangle is drawn, for each pixel, check the zbuffer first, if there's a pixel there that has a hight value higher than what you're drawing, don't bother drawing that pixel.
Heewa
Heewa
Quote:
Original post by Anonymous Poster
and you have any idea how slow it would be? it's all software afterall.


I assumed he's doing his own blitting, so he'd be drawing the pixels anyway using software. This would just be another step in the process. If he's using something like DirectX to draw, then it's almost always better to let the graphics card worry about it, and just draw every surface.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.