/
winoptions.go
70 lines (62 loc) · 1.25 KB
/
winoptions.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
package win
func applyWindowOptions(opts ...WindowOption) windowOption {
opt := windowOption{
resizable: false,
majorVersion: 2,
minorVersion: 0,
width: 800,
height: 600,
title: "",
f: nil,
}
for _, o := range opts {
o(&opt)
}
return opt
}
type windowOption struct {
resizable bool
majorVersion int
minorVersion int
width int
height int
title string
f func(w *Window)
}
// Options for Window creation.
type WindowOption func(opt *windowOption)
// Provide the window size in pixels.
//
// Default: 800x600
func Size(width, height int) WindowOption {
return func(opt *windowOption) {
opt.width = width
opt.height = height
}
}
// Provide the window title.
func Title(title string) WindowOption {
return func(opt *windowOption) {
opt.title = title
}
}
// Make the window resizable.
func Resizable() WindowOption {
return func(opt *windowOption) {
opt.resizable = true
}
}
// Set the minimum OpenGL context version.
//
// Default: 2.0
func Version(major, minor int) WindowOption {
return func(opt *windowOption) {
opt.majorVersion = major
opt.minorVersion = minor
}
}
func Func(f func(w *Window)) WindowOption {
return func(opt *windowOption) {
opt.f = f
}
}