Sdl Image Copying Problem


Sephnroth

Member
Joined
Dec 25, 2005
Messages
151
Age
39
Location
UK
Website
Visit site
Okay,

i've been trying to optimise my tile renderer. Instead of dumping the full screen every frame it instead performs one full screen write to some buffers once, then it blits the buffer and offsets it by pixel values for scrolling and when you've scrolled one full tile it then updates again.

Further, instead of redrawing all the tiles when it updates the idea is that it shifts the contents of the buffer in one direction (ie, if you are walking right it should shift the contents to the left) and then merely draws the new tiles that have appeared on the edge.


I started implementing this and things are working bueatifully for moving right. But when it came to doing left things went crazy wrong. My dbxPasteImageEx() function (its just a wrapper around sdl commands) seems to end up turning x and y co-ordinates into width and height somehow and you end up with odd errors like:

Error 1

where it has taken the first 16 pixels then just repeated them across the entire buffer. The whole 16pixel issue can be seen again if i change either the destination or source Y coordinate to 1 (leaving the other as 0) because it copies in steps of 16:

Error 2

in some circemstances i've managed to get it copying properly (but stepped) by offseting one of the the y's, but when i make both source and destination y's the same i end up with the original problem :/

Code can be seen at:

Source

contains the two scrolling blocks of code and the full source to my paste image function. I_TILE_BUFFER_A are just numerical enumerations - my sdl wrapper uses numerical id's for images (ie, load image(BLAH); pasteimage(blah); etc)

in that source the RIGHT COLLUM REFRESH block is working FINE. its the left collum thats causing all these errors. I've fiddled so many things now i've lost track - anyone have any ideas?

Thanks :)
 
solved.

oddbot informed me that, despite what i had been told by other people previously, you cannot blit a surface to itself - utilising a temporary buffer fixed this :)
 
thanks for your support :)

Word to the wise for anyone else making a tile based system - i just finished the function and the difference in speed between it and standard map renderering methods is shocking - what was a jerky and nasty thing to watch on the gp2x is now so blindingly fast i may have to slow down the game even further manually!
 
Back
Top