-
Notifications
You must be signed in to change notification settings - Fork 136
/
engo_empty.go
138 lines (109 loc) · 2.96 KB
/
engo_empty.go
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// +build headless
package engo
import (
"io"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/EngoEngine/gl"
)
var (
// Gl is the current OpenGL context
Gl *gl.Context
scale = float32(1)
)
// CreateWindow sets up the GLFW window and prepares the OpenGL surface for rendering
func CreateWindow(title string, width, height int, fullscreen bool, msaa int) {
CurrentBackEnd = BackEndHeadless
gameWidth = float32(width)
gameHeight = float32(height)
Gl = gl.NewContext()
windowWidth, windowHeight = float32(width), float32(height)
canvasWidth, canvasHeight = float32(width), float32(height)
}
// DestroyWindow handles the termination of windows
func DestroyWindow() {}
// SetTitle sets the title of the window
func SetTitle(title string) {
log.Println("Title set to:", title)
}
// RunIteration runs one iteration per frame
func RunIteration() {
Time.Tick()
currentUpdater.Update(Time.Delta())
}
// RunPreparation is called automatically when calling Open. It should only be called once.
func RunPreparation(defaultScene Scene) {
Time = NewClock()
SetScene(defaultScene, false)
}
func runLoop(defaultScene Scene, headless bool) {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, syscall.SIGTERM)
go func() {
<-c
closeEvent()
}()
RunPreparation(defaultScene)
ticker := time.NewTicker(time.Duration(int(time.Second) / opts.FPSLimit))
// Start tick, minimize the delta
Time.Tick()
for {
select {
case <-ticker.C:
RunIteration()
case <-resetLoopTicker:
ticker.Stop()
ticker = time.NewTicker(time.Duration(int(time.Second) / opts.FPSLimit))
case <-closeGame:
ticker.Stop()
closeEvent()
return
}
}
}
// CursorPos returns (0, 0) because there is no cursor
func CursorPos() (x, y float32) {
return float32(0), float32(0)
}
// WindowSize gets the current window size
func WindowSize() (w, h int) {
return int(windowWidth), int(windowHeight)
}
// WindowWidth gets the current window width
func WindowWidth() float32 {
return windowWidth
}
// WindowHeight gets the current window height
func WindowHeight() float32 {
return windowHeight
}
// CanvasWidth gets the width of the current OpenGL Framebuffer
func CanvasWidth() float32 {
return canvasWidth
}
// CanvasHeight gets the height of the current OpenGL Framebuffer
func CanvasHeight() float32 {
return canvasHeight
}
// CanvasScale gets the ratio of the canvas to the window sizes
func CanvasScale() float32 {
return scale
}
// SetCursor does nothing since there's no headless cursor
func SetCursor(c Cursor) {}
// SetVSync does nothing since there's no monitor to synchronize with
func SetVSync(enabled bool) {}
//SetCursorVisibility does nothing since there's no headless cursor
func SetCursorVisibility(visible bool) {}
// openFile is the desktop-specific way of opening a file
func openFile(url string) (io.ReadCloser, error) {
return os.Open(url)
}
// IsAndroidChrome tells if the browser is Chrome for android
func IsAndroidChrome() bool {
return false
}