Sign in to follow this  

Help with SDL.

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

Hi everyone. I'd like to know how could I draw a image (image.png) the has 32x32 pixels in a SDL screen with a different size. Particularlly in percentage. Instead of drawing a 32x32 pixels image in the screen, I'd like to draw it as a 20%x20% of the screen....so I can draw 25 images on the screen, no matter what resolution I'm using and how large/small my image is. I'm making my own game, and that would be usefull since it's not a full screen game, and it will have variable resolution. For a person that has 800x600, the image might appear as 32x32 pixel, but for someone that uses 1600x1200, double the original resolution, I must have the image as 64x64 pixels, so the sight of view is the same. The way I thought of doing that was drawing it as % of the screen, instead of pixels. So, if anyone can help me with that, or maybe with another solution, I'd be gratefull. Thanks in advance, Emilio.

Share this post


Link to post
Share on other sites
If you want to rescale each individual image (i.e. they have varying sizes) then using SDL will most likely be slow and I would recommend using a 3d API such as OpenGL where scaling is done similar to what you described.

However, there is also a library called SDL_gfx which has a rotozoom feature where you can stretch and rotate images if you wish to stick with just SDL for rendering.

If all of your individual images are the same size however then SDL with SDL_gfx may be more acceptable. I would make a surface that fits your desired dimensions for 25 images and do normal SDL_BlitSurface operations to that surface. Then stretch that image to the screen to give your desired effect. This makes only 1 expensive stretch call per frame as opposed to multiple.

Share this post


Link to post
Share on other sites
Hello, for future references follow these two sites:

http://lazyfoo.net/SDL_tutorials/index.php
http://www.sdltutorials.com/

The first site shows you a lot of tutorials to get yourself started, the second site I haven't personally used but I'm sure it's worth checking out.

Share this post


Link to post
Share on other sites

This topic is 3291 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this