Jump to content
  • Advertisement


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


SDL_BlitSurface problem

This topic is 6131 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

void DrawStuff(SDL_Surface *image, SDL_Surface *screen) { SDL_BlitSurface(image, NULL, screen, NULL); } int main(void) { SDL_Surface *screen, *image; // Init SDL, set the video mode, load a bitmap into image... DrawStuff(image, screen); // Do everything to cleanly exit return 0; } ***** Why is it that the above program won''t work on my computer? All I get is a blank screen.

Share this post

Link to post
Share on other sites
Sheesh, this'll teach me not to read comments.
It's not as bad as I thought, your only missing a rectangle to blit to.

So in main() you declare a rectangle:

SDL_Rect dstrectangle; // a Destination Rectangle.

Then you give it attributes.

dstrectangle.x = 0;
dstrectangle.y = 0;
dstrectangle.w = image->w;
dstrectnalge.h = image->h;

Then you pass it do your DrawStuff()

And change your Blit call to:
SDL_BlitSurface(image, NULL, screen, &dstrectangle);

And vwallah.
Don't forget to check for errors.


Bah, You also forgot to update the screen.
If inside your SDL_SetVideoMode() you set SDL_DOUBLEBUF, then all you have to do is call SDL_Flip();

Put it in a loop which called DrawStuff() and SDL_Flip(screen); And all should work.

I'm going to create this program real quick to see if you missed anything else.


Edited by - AfroFire on February 1, 2002 7:52:51 PM

Share this post

Link to post
Share on other sites
Thanks for the help. I''ll try to use SDL_UpdateRect. I know I should always use it or SDL_Flip, but usually I don''t need to when blitting from main. Anyway, thanks for replying.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!