How implemennt multipes viewports
Bungow

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

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

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
w,h - width/height
x_offset,y_offset - offset into the world in map coordinates.

Thread #616963. Printed from Allegro.cc