Archived

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

SDL blits

This topic is 5497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to make a very basic game with sdl, but even though the program is double-buffered, the objects leave marks across the screen as they''re moved. Its not that they arent being covered, its just its ugly looking. Any ideas what would cause this?

Share this post


Link to post
Share on other sites
hey,
I''m working on a Map editor and need a library for the graphics in Windows/Linux, I had a look at SDL and downloaded the Windows runtime libraries and the development kit thing, I set it up with VC++ just like it said (I used the precompiled binaries) but I get errors when I tried to compile the test program. Do you think you can help? but at the moment I don''t have a solution to your problem (obviously)
slip

Share this post


Link to post
Share on other sites
ohohvi: Do you clear the screen before drawing the objets? (or draw a background picture?)
slip: What errors do you have?
As I remember, you need to do:
1) In the project options, the project has to be configured as "multithreaded dll".
2) You need to link this libraries: SDL and SDL_main
3) Be sure that the compiler can find the libraries and the header files (configuring include and library directories).

Share this post


Link to post
Share on other sites
I''m just covering up (reblitting) the areas of the background that are affected by sprites, which in this program is 6 or less. It''s just that im covering them up before redraw but i can still see it. The framerate isnt bad either.
I''ve also tried it with SDL_FillRect, but my "bullets" that are moved across the screen at 20 pixels a frame seem to leave behind a couple old copies.

Share this post


Link to post
Share on other sites
Your problem is because of double buffer.
I supose you are doing this:

-Draw the objects (1)
-SDL_Flip()
-Clear the position of the objects in previous frame (ERROR!!!) (2)
-Calculate new position
-Draw the objects
....

You have two buffers. When you draw (1) you draw in one buffer, then with SDL_Flip you make this buffer visible and the other buffer is active to draw. When you try to clear the position (2) you are clearing the objets in a buffer that isn´t the buffer you use to draw it and it might contains the objets drawed two frames before. This is the cause of your problem.

Share this post


Link to post
Share on other sites
He is my current game loop in puesdo code, and under SDL it looks messy. Its not that theyre not getting cleaned up, it just the animation isnt clean.

  
while( grass_grows )
{
CheckInputAndUpdateSpritePosistions();
DrawABigBlackRectangleAcrossTheWholeScreen();
DrawAllMySprites();
FlipBuffers
}

Share this post


Link to post
Share on other sites