/
ScreenModes.lua
executable file
·71 lines (63 loc) · 1.98 KB
/
ScreenModes.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function cycleScreenModes()
if fullscreen then
pauseGame()
initializeWindowedMode()
else
pauseGame()
initializeFullscreenMode()
end
end
function initializeWindowedMode()
local width,height=2*width,2*height
love.window.setMode( width, height, {fullscreen=false, vsync=false, msaa=0} )
local flags={}
fullscreenWidth,fullscreenHeight,flags=love.window.getMode()
fullscreen=flags.fullscreen
vsyncEnabled=flags.vsync
fsaa=flags.msaa
love.window.setTitle("Arne's Spacetaxi")
borderX=0
borderY=0
screenMode="windowed"
graphicsScaleFactor=1.0
end
function initializeFullscreenMode()
local width=2*width
local height=2*height
love.window.setMode( desktopWidth, desktopHeight, {fullscreen=true, vsync=true, msaa=0} )
local flags={}
fullscreenWidth,fullscreenHeight,flags=love.window.getMode()
fullscreen=flags.fullscreen
vsyncEnabled=flags.vsync
fsaa=flags.msaa
if fullscreenWidth>width then
borderX=math.floor((fullscreenWidth-width)/2)
end
if fullscreenHeight>height then
borderY=math.floor((fullscreenHeight-height)/2)
end
screenMode="fullscreen"
graphicsScaleFactor=1.0
end
function toggleScaling()
local width=2*width
local height=2*height
if graphicsScaleFactor==1.0 then
graphicsScaleFactor=math.min(fullscreenWidth/width,fullscreenHeight/height)
if fullscreenWidth/width < fullscreenHeight/height then
borderX=0
borderY=math.floor(1/graphicsScaleFactor*(fullscreenHeight-graphicsScaleFactor*height)/2)
else
borderY=0
borderX=math.floor(1/graphicsScaleFactor*(fullscreenWidth-graphicsScaleFactor*width)/2)
end
else
graphicsScaleFactor=1.0
if fullscreenWidth>width then
borderX=math.floor((fullscreenWidth-width)/2)
end
if fullscreenHeight>height then
borderY=math.floor((fullscreenHeight-height)/2)
end
end
end