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.