Widescreen & Black Bars

BlitzMax Forums/BlitzMax Beginners Area/Widescreen & Black Bars

So you've coded your game in 4:3 standard ratio but you want to center the screen on a widescreen (16:10,etc) and display black bars as needed.

It's all very doable until you start drawing graphics outside of the game area. Normally, this would all be handled due to the card clipping everything. But in this scenario, the graphics would not be clipped automatically until they went off the physical screen.

I read this in another thread: "If you want your game to play at a fixed size, then simply draw the game in the centre of the display and slap some black bars where necessary."

That's where I'm stumped. The most elegant solution would be to use the SetViewPort() function, but that seems to be broken or not 100% gpu/cross platform compatible.

Another easy solution but adding more overhead at render time, is to use DrawRect() to draw the bars at the end of your render loop.

Or am I overlooking a stable, obvious solution? Thanks.