|
How implemennt multipes viewports |
Bungow
Member #16,693
June 2017
|
Hello, I'm trying to implement a 2D camera with viewport resize capability. The idea is being able to resize the level render, to specific size (smaller than display) to allow ui elements. What is the best aproach? render the entire level to a bitmap and scale this bitmap? Thanks! |
Eric Johnson
Member #14,841
January 2013
|
Have you looked into using transformations (ALLEGRO_TRANSFORM)? You could scale ("resize") the display and translate ("move") it around wherever you want on the screen.
|
Chris Katko
Member #1,881
January 2002
|
I've never used transforms for that... unless you really want scaling or something. But just re-adjusting the size of the viewport is as simple as keeping track of it. Either: 1. Make a sub-bitmap the size of the viewport, draw to it, and then draw the "viewport bitmap" to the screen. 2. Change the clipping rectangle for the screen, draw your viewport graphics, and then change the clipping rectangle back to normal. All my viewports (I don't do scaling) are simply x, y, w, h, x_offset, y_offset. x,y - position on the SCREEN -----sig: |
|