|
[a5] best way to scale/stretch screen? |
Aaron Santiago
Member #12,074
June 2010
|
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. |
Matthew Leverton
Supreme Loser
January 1999
|
There are two main things, which you've outlined:
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
Member #261
April 2000
|
Aaron Santiago
Member #12,074
June 2010
|
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
Member #261
April 2000
|
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
Supreme Loser
January 1999
|
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
Member #12,074
June 2010
|
Trent Gamblin said: 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);
? |
Matthew Leverton
Supreme Loser
January 1999
|
I assume you also need to initialize it to the identity first. See my previous post. |
Trent Gamblin
Member #261
April 2000
|
Yeah Matthew nailed it.
|
Aaron Santiago
Member #12,074
June 2010
|
Matthew Leverton said: 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. Matthew Leverton said: 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
Supreme Loser
January 1999
|
FYI, the attributes to the <quote> and <code> tags are optional and usually not necessary. |
Aaron Santiago
Member #12,074
June 2010
|
<quote name="Matthew Leverton">FYI, the attributes to the Matthew Leverton said: and <code> tags are optional and usually not necessary. Oh, I know. I'm just super OCD and stuff. [edit] |
|