-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.go
55 lines (45 loc) · 1.25 KB
/
render.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
package main
import (
al "github.com/tapir/allegro5"
"runtime"
"log"
)
// Some settings
const (
title = "Core Game"
width = 800
height = 600
)
func render(alphaIn <-chan float64, displayOut chan<- *al.Display) {
// Lock the render thread
runtime.LockOSThread()
// Setup display flag and options
al.SetNewDisplayFlags(al.Windowed | al.Opengl30)
al.SetNewDisplayOption(al.Vsync, 1, al.Suggest)
al.SetNewDisplayOption(al.DepthSize, 0, al.Suggest)
al.SetNewDisplayOption(al.SampleBuffers, 1, al.Suggest)
al.SetNewDisplayOption(al.UpdateDisplayRegion_, 1, al.Suggest)
al.SetNewDisplayOption(al.RedSize, 8, al.Require)
al.SetNewDisplayOption(al.GreenSize, 8, al.Require)
al.SetNewDisplayOption(al.BlueSize, 8, al.Require)
al.SetNewDisplayOption(al.AlphaSize, 8, al.Require)
// Create window
display := al.CreateDisplay(width, height)
if display == nil {
log.Fatalln("Could not create display.")
}
defer display.Destroy()
// Set title
display.SetWindowTitle(title)
// Send display to main goroutine
displayOut <- display
// Make context current in this goroutine
display.SetTargetBackbuffer()
// Main rendering loop
for {
//Do things with interpolation value
<-alphaIn
al.ClearToColor(al.MapRgb(255, 0, 255))
al.FlipDisplay()
}
}