Archived

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

Vanukoff

Best way to mix hardware and software blitters?

Recommended Posts

Vanukoff    122
For the (2D) game I am working on, I wrote my own blitter, for translucent sprites. It works fairly fast. I want to use DirectDraw''s blitter for normal sprites, so I can get hardware acceleration. Problem is, DD blitter requires your surfaces to be UNLOCKED, but my soft blitter needs them to be LOCKED to access the buffers. So, what is the best way? Here is what I came up with:
  

for(all active sprites)
{
    if(sprite is translucent)
    {
        add object to translucent sprite list
    }
    else
    {
        blit using direct draw
    }
}

lock surfaces

for(all sprites in translucent sprite list)
{
    blit using my software blitter
}

unlock surfaces

clear translucent sprite list

  
I want to minimize the locking/unlocking of surfaces. Is there a better way to do this?

Share this post


Link to post
Share on other sites
SikCiv    122
The only way is to lock and unlock the surface when your own blitter routine accesses them. ->Blt() requires the surfaces to be unlocked. Locking and unlocking a few surfaces every frame wont be too hard on your FPS unless you have an old video card.



  Game Download  ZeroOne Realm

Share this post


Link to post
Share on other sites
Hellaynea    122
No need to lock and unlock every frame ... don''t trust what microst says on lock ... you can easily store the data pointer and use it after like that :

Create Surface
Lock Surface
Store data pointer
Unlock

Then after when you want to blit with your own function, use the pointer ... if not, you can use Blt fo acceleration ... but of course, store only SYSTEM MEMORY surface pointers ! don''t use it for surfaces in video card.

Share this post


Link to post
Share on other sites