SDL - Multiple surface blit issue

Started by
3 comments, last by aleisterbukowski 15 years, 1 month ago
Hi everyone I'm playing with SDL, trying to make a simple Tetris derivative, but I've run into some problems with some of the extra stuff I'm trying to do. A situation I've run into twice now in two separate places is when I try to do multiple surface blits. In each case, I start out loading an image from disk into a surface, and from there will construct a separate surface by blitting certain portions of the image. e.g. in one case, I have a menu where I'm trying to be able to dynamically position the buttons, so the image I have has the menu background in one part, and then in another part the buttons, and then I blit it all together dynamically in the surface. However, when I try to blit the resultant surface to the screen, it doesn't seem to do anything, or at least blits transparently. The game doesn't crash or throw any errors at me, I just don't get visual where the blitting should be occuring. So basically anytime I go Surface from disk -> Screen The blit is succesful, but if I go Surface from disk -> Non-screen surface -> Screen There's no output. Is there something I'm missing? I've tried Google and haven't been able to find much on it. Any help is appreciated!
Advertisement
As far as I know it is not recommended and is slower to blit into the non screen surface and then into the screen. Try to blit everything onto the screen directly, should work as well.

If you insist on bliting on a non-screen surface, do you SDL_flip the surface you are bliting at, like you do with the screen surface?

kost.
I think what you're trying to do can easily be done with sprite sheets.

I'm not fully understanding what you are trying to do, but in any case a single image should be blitted to the surface, which is then drawn to the screen, and there shouldn't be any complexities with that.

If you want I can dig out my old code, and we can jump on AIM, or MSN and I can walk you through this if you'd like?

AIM coden4fun
MSN coden4fun@hotmail.com

in any case maybe going to this tutorial here

could help you out anyways as blitting a surface correctly, or if you are what I'm guessing you are doing which is using sprite sheets it's a good tutorial anyways.

Good Luck, and if you can't figure it out I'll be online another 6 hours
afaik you can't flip a surface that wasn't created as the screen, and you only have one screen... might be wrong on that.

In essence what I'm trying to do already is a sprite sheet, but I'm trying to draw it all to a surface, then return that surface from a public method in my menu class to be drawn on to the main screen of my video management class. I'm guessing I probably just have to do some restructuring to get it to work in a more straightforward way... I've just kinda been hacking away at this for practice, so not everything is the most sensical way, just what seemed most practical with the groundwork that was there :)
you could post some code. Then we could look at the code and tell you what's not working.

This topic is closed to new replies.

Advertisement