Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Scaling look likes junk.

This thread is locked; no one can reply to it. rss feed Print
Scaling look likes junk.
nshade
Member #4,372
February 2004

So I'm making a 2D game that runs at 1920x1080, and I want to scale the screen down a bit so it works on other 16x9/16:10 resolutions while keeping the "Base" at my native size.

I have the following code ran that scales the screen down depending on the resolution chosen.

//This scales the display to any resolution (Native is 1920x1080
float scaleX = al_get_display_width(display) / (float)1920;
float scaleY = al_get_display_height(display) / (float)1080;
ALLEGRO_TRANSFORM trans;
al_identity_transform(&trans);
al_scale_transform(&trans, scaleX, scaleY);
al_use_transform(&trans);

however, when I run my game at, say. 1280x720 everything looks all jaggy and gross. (Attached us a text example)

Is there a way to scale down without it looking like butt?

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

nshade
Member #4,372
February 2004

I'm not following ---

Where do I use this flag. I'm not scaling my bitmap, I'm transforming the whole display.

I'm looking fro something that effects al_scale_transform that has some filtering in it. Will I have to draw to a memory bitmap and then do a al_draw_scaled_bitmap() to a smaller backbuffer?

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

No, you don't need any memory bitmaps. It can all be done in video.

You use al_set_new_bitmap_flags before creating your bitmap with ALLEGRO_MIN_LINEAR to use linear filtering when drawing smaller versions of the bitmap. So you'll need a buffer at your native resolution which you draw scaled to the screen.

al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP | ALLEGRO_MIN_LINEAR);
ALLEGRO_BITMAP* buffer = al_create_bitmap(1920,1080);// make the native resolution buffer
/// Draw at full resolution
ALLEGRO_TRANSFORM t = al_create_transform();
al_identity_transform(&t);
al_scale_transform(al_get_display_width(display) / 1920.0f , al_get_display_height(display)/1080.0f);
al_use_transform(&t);
al_draw_bitmap(buffer , 0 , 0);

nshade
Member #4,372
February 2004

That's what I was looking for! Thank you so much!

Go to: