-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
59 lines (45 loc) · 1.19 KB
/
main.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
package main
import (
"github.com/go-gl/gl/all-core/gl"
"github.com/go-gl/glfw/v3.2/glfw"
"graphics/circles"
"graphics/pixel"
"runtime"
)
var position = 0
const distance = 60
func init() {
runtime.LockOSThread()
}
func main() {
window := buildWindow()
defer glfw.Terminate()
program := initOpenGL()
for !window.ShouldClose() {
draw(window, program)
}
}
func draw(window *glfw.Window, program uint32) {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.UseProgram(program)
midpoint := pixel.Point{float64(position), 0}
if position > distance {
position = 0
}
run(midpoint)
position++
window.SwapBuffers() // swap rendering and drawing buffers
glfw.PollEvents() // poll input events
}
func run(midpoint pixel.Point) {
circles.Draw(midpoint, 19, "midpoint")
//circles.Draw(pixel.Point{10, 0}, 29, "bresenhams")
//lines.Draw(pixel.Point{X: 0, Y: 20}, pixel.Point{X: 50, Y: 20}, "bresenhams")
//lines.Draw(pixel.Point{X: 0, Y: 0}, pixel.Point{X: 50, Y: 0}, "dda")
//
//ellipses.Draw(pixel.Point{X: 0, Y: 10}, 3, 10)
//ellipses.Draw(pixel.Point{X: 50, Y: 10}, 3, 10)
//
//arcs.Draw(pixel.Point{X: 25, Y: 45}, 35, true)
//arcs.Draw(pixel.Point{X: 25, Y: -25}, 35, false)
}