Call widescreen() with the desired aspect ratio and the function will stretch and letterbox the camera viewport appropriately. The default ratio is usually 1.333. The standard widescreen ratio is 1.777.
Language:
Dark Basic Pro
Code:
function widescreen(aspect as float) local extra as dword if aspect <= 0 then exitfunction set camera aspect aspect if aspect > (screen width() / screen height() * 1.0) extra = (screen height() - (screen width() * (1/aspect))) / 2 set camera view 0, extra, screen width(), screen height()-extra else extra = (screen width() - (screen height() * aspect)) / 2 set camera view extra, 0, screen width()-extra, screen height() endif endfunction
(2 votes)
Thu, 08/09/2007 - 13:26
Question: What precisely does it do apart from change the aspect? Does it "letter box" the view if the aspect doesn't work - for example if I call it with an appropriate aspect for 16:10 for a 4:3 screen?
Thu, 08/09/2007 - 14:33
Yes, it will letter box the view if the monitor doesn't already have the right aspect. It can even pillarbox the left and right sides instead for if the screen needs to be taller than it is wide. Basically it makes sure there's no stretching of the view no matter what shape the screen is.
Fri, 08/10/2007 - 11:25
This is a VERY VERY cool snippet - nice work!
Wed, 10/24/2007 - 23:36
Neat and clever, thanks dude!