[SDL] Blitting Speed/Surface formats

Joseph Humfrey joseph at mansefield.net
Mon Apr 7 07:29:03 PDT 2003


> I think BlitzBasic uses directly Directx, and uses it well. So even if 
> it's
> interpretted, it gives good graphical performances.

Yep it uses directx, and it's compiled, not interpreted. But why 
shouldn't SDL be as fast as directx?

> I think you should modify your code so that you always have an entire 
> map
> displayed.

Yeah, I tried that, but I found the algorithm surprisingly difficult 
because of knowing when to scroll and when not to scroll... I won't go 
into those problems here though - that's another story :-)

> If you want to keep your actual method, you could blit just the
> smallest possible rectangle and not a whole screen rectangle.

Yeah, I might do that.

> Now, back to SDL problem.
>
> [...] Do something like this :
> if(surface->flags & SDL_HWSURFACE)  print("surface in vid. mem");
> else print("surface in system mem");

Okay, I did this, and you're right, for it to use hardware it must be 
fullscreen. And that worked - apparently it can use hardware. BUT, not 
only was it still really slow, but it had nasty tearing effects due to 
the frame buffer being displayed in mid-draw.

> If you are sure you can use HW surfaces then you can add the flags
> SDL_DOUBLEBUF|SDL_FULLSCREEN and redo the the above test to see if you 
> can
> have double buffering.  If it's ok [...]

It's not okay! :-( I have no idea why, but for some reason, the double 
buffering flag wouldn't work - I tried testing to see if it had worked 
using the method you described above ( if(surface->flags & 
SDL_DOUBLEBUF) ).

> you can call the SDL_Flip function after
> the frame drawing.

I used this before anyway... but it seems that the problem is with 
getting double buffering to work.

Perhaps this was why I found BlitzBasic to be so fast - I never used 
anything but double buffering, but now I don't have it :-/ 
Frustrating... I wish I could find out what is stopping double 
buffering from working. Should I maybe send another message the list 
since someone who knows the answer might not have bothered reading the 
rest?

Thanks,
--Joe





More information about the SDL mailing list