Jump to content
  • Advertisement
Sign in to follow this  
h0ts0up

loading images using SDL

This topic is 3397 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've been messing around with SDL and blitting surfaces and what not and found out that the function SDL_DisplayFormat() didn't do what I thought it did. I assumed that it changed the dimensions of the image to fit that of a predetermined screen via the SDL_SetVideoMode(). As I played with the functions I discovered that SDL_DisplayFormat() just starts at (0,0) and and cuts off everything not in the specified dimensions. Am I correct? If so, is there any function that will resize my image or will I just have to draw my images so that they are already the right size?

Share this post


Link to post
Share on other sites
Advertisement
The purpose of SDL_DisplayFormat() is to change the format of the surface, to match the display surface. This makes it faster to blit.

You could use SDL_gfx, which has routines for scaling sprites.

Share this post


Link to post
Share on other sites
Quote:
Original post by h0ts0up
So, when game makers draw their sprites and what not, they draw them to scale?


I think you may have misunderstood. :)
SDL_gfx library (an add-on to SDL) includes routines that will stretch or shrink the image to a given size. For example, you could make 64x64 sprite 128x128 or some other arbitrary dimensions.

Share this post


Link to post
Share on other sites
Your follow-up question is a little ambiguous. Pixel artists "draw" sprites in whatever size is appropriate for the window's resolution (which shouldn't vary for a game using pixel art). For a game that uses pixel art and blits sprites directly in 2d, no scaling should be neccesary. Typically, games that have "drawn" sprites use a low resolution for the window. If you want to use a high window resolution or you need to scale your sprites, use a graphics API such as DirectX or OpenGL.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!