SDL & scaling

Hi

I have a graphic which is 1024x768, and a window which may (or may not) be the same size. Usually not :slight_smile:

So, using SDL 2.0, how do I make my graphic scale correctly and at a good quality to another size? I have seen the function SDL_RenderSetLogicalSize but I have not used SDL since before this was introduced, so I am not sure exactly how to use it.

My maximum window size will be 1920x1080, smallest window size 1024x600.

Can anyone help?

Thanks
Ed

SDL_RenderSetLogicalSize(renderer, width, height);

Where width and height are the resolution your program will give to
the SDL functions (i.e. the one that isn’t the real resolution). All
renderer functions called after this will scale their coordinates
accordingly.

Of course this only applies if you’re using SDL’s rendering functions,
not if you’re e.g. using OpenGL directly.

2013/4/3, ebyard <e_byard at yahoo.co.uk>:> Hi

I have a graphic which is 1024x768, and a window which may (or may not) be
the same size. Usually not :slight_smile:

So, using SDL 2.0, how do I make my graphic scale correctly and at a good
quality to another size? I have seen the function SDL_RenderSetLogicalSize
but I have not used SDL since before this was introduced, so I am not sure
exactly how to use it.

My maximum window size will be 1920x1080, smallest window size 1024x600.

Can anyone help?

Thanks
Ed

Personally, I’d make a few versions of the same image, one for 16:10, 16:9,
4:3, 1:1, and all of those in high resolution. Scaling down is never as
bad as scaling up, and it’s fairly easy to detect aspect ratio by checking
(resolution.width / resolution.height) =? (16/10), etc.On Wed, Apr 3, 2013 at 8:58 AM, ebyard <e_byard at yahoo.co.uk> wrote:

**
Hi

I have a graphic which is 1024x768, and a window which may (or may not) be
the same size. Usually not [image: Smile]

So, using SDL 2.0, how do I make my graphic scale correctly and at a good
quality to another size? I have seen the function SDL_RenderSetLogicalSize
but I have not used SDL since before this was introduced, so I am not sure
exactly how to use it.

My maximum window size will be 1920x1080, smallest window size 1024x600.

Can anyone help?

Thanks
Ed


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Sik wrote:

SDL_RenderSetLogicalSize(renderer, width, height);

Where width and height are the resolution your program will give to
the SDL functions (i.e. the one that isn’t the real resolution). All
renderer functions called after this will scale their coordinates
accordingly.

Of course this only applies if you’re using SDL’s rendering functions,
not if you’re e.g. using OpenGL directly.

OK, so do I just open a window to 1280x1024, for example, and then call SDL_RenderSetLogicalSize(myRenderer,1024,768) - and after this will all graphics be scaled to 1280x1024?

Thanks

Yes. Well, the coordinates (so e.g. if you draw a line it’ll be still
one pixel thick no matter what), but you get the idea.

2013/4/3, ebyard <e_byard at yahoo.co.uk>:>

Sik wrote:

SDL_RenderSetLogicalSize(renderer, width, height);

Where width and height are the resolution your program will give to
the SDL functions (i.e. the one that isn’t the real resolution). All
renderer functions called after this will scale their coordinates
accordingly.

Of course this only applies if you’re using SDL’s rendering functions,
not if you’re e.g. using OpenGL directly.

OK, so do I just open a window to 1280x1024, for example, and then call
SDL_RenderSetLogicalSize(myRenderer,1024,768) - and after this will all
graphics be scaled to 1280x1024?

Thanks