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
5
Average: 5 (2 votes)