This snippet demonstrates how to automatically detect the user's screen resolution. This lets people with smaller screens run your programs without having to degrade performance for the power users. There's no need to bombard the user with a menu of screen resolutions to pick from either - it's all figured out automatically.

It only works if it's compiled in 640x480 Windowed or Windowed Fullscreen mode through the IDE, but after it auto detects you can set it back to Fullscreen Exclusive mode with set window off.

Language: 
Dark Basic Pro
Code: 
#constant User32 = 1

sync on
sync rate 0

load dll "User32.dll", User32

width = call dll(User32, "GetSystemMetrics", 0)
height = call dll(User32, "GetSystemMetrics", 1)
depth = 32

set window off
set display mode width, height, depth, 1

make object cube 1, 1

do
  text 0, 0, "Automatically detected a " + str$(width) + "x" + str$(height) + " screen"
  yrotate object 1, object angle y(1) + 1
  sync
loop
5
Average: 5 (1 vote)