[a5] best way to scale/stretch screen?
Aaron Santiago

I'm creating a game where I'm going in the direction of hardcore pixel art. I might even go as far as to run the game in less than 100 * 100 resolution. The thing is, I still want people to make things out on the screen.
As far as my newly discovered a5 skills go, I have two options:
- Use a separate buffer and scale/stretch it when blitting to the Allegro backbuffer
- Find the screen resolution before the game starts, and scale every bitmap and every number accordingly.
I'm scared of the first one because of the anticipated speed hit, since: 1) It's scale/stretching a huge bitmap the entire time, and 2) It's slower drawing things with alpha to memory bitmaps than it is to the backbuffer. I'm scared of the second one because it would require me to use nothing but floats (which in itself makes me cringe) and just sounds like bug city.
Is there a magical third option I don't know about, or is there a better way to do either of the above?

Matthew Leverton

There are two main things, which you've outlined:

1. use a small buffer and scale only the final blit

2. use a full screen buffer and scale every call

The first is better for bitmap oriented games. The second is better if you are drawing everything with primitives, because you'll get higher resolution.

You can do the latter via the transformation API. Just use (0,0)-(1,1) in your code and set up a transformation that scales by (w,h).

Trent Gamblin
Aaron Santiago
1float scaleX = al_get_display_width(currentDisplay)/currentResW; 2float scaleY = al_get_display_height(currentDisplay)/currentResH; 3ALLEGRO_TRANSFORM trans; 4al_scale_transform(trans, scaleX, scaleY); 5al_use_transform(trans); 6//draw as normal?

I'm hoping that's it? Most of what I read in the docs went straight over my head.

Trent Gamblin

That's pretty much it, but watch the integer math in those divisions. You could end up with some non-exact fitting images.

Matthew Leverton
```float scaleX = al_get_display_width(currentDisplay)/(float)currentResW;
float scaleY = al_get_display_height(currentDisplay)/(float)currentResH;
ALLEGRO_TRANSFORM trans;
al_identity_transform(&trans);
al_scale_transform(&trans, scaleX, scaleY);
al_use_transform(&trans);
```

Aaron Santiago

That's pretty much it, but watch the integer math in those divisions. You could end up with some non-exact fitting images.

You, uh, you lost me there. Does that mean it's better to do:

1float screenWidth = al_get_display_width(currentDisplay); 2float screenHeight = al_get_display_height(currentDisplay); 3float floatResW = currentResW; 4float floatResH = currentResH; 5float scaleX = screenWidth/floatResW; 6float scaleY = screenHeight/floatResH; 7ALLEGRO_TRANSFORM trans; 8al_scale_transform(trans, scaleX, scaleY);

?
Because if so, then I learned something (else) new today.

Matthew Leverton

I assume you also need to initialize it to the identity first. See my previous post.

Trent Gamblin

Yeah Matthew nailed it.

Aaron Santiago

I assume you also need to initialize it to the identity first. See my previous post.

Whoa, yeah, that. I also didn't notice that I shouldn't be passing trans directly, thanks.

1float scaleX = al_get_display_width(currentDisplay)/(float)currentResW; 2float scaleY = al_get_display_height(currentDisplay)/(float)currentResH;

Matthew Leverton said:

(float)currentResH;

Matthew Leverton said:

(float)

-.- duh. Thanks a ton.

Matthew Leverton

FYI, the attributes to the <quote> and <code> tags are optional and usually not necessary.

Aaron Santiago

<quote name="Matthew Leverton">FYI, the attributes to the

and <code> tags are optional and usually not necessary.

Oh, I know. I'm just super OCD and stuff.

iseewhatyoudidthere.jpg
-_-