-
Notifications
You must be signed in to change notification settings - Fork 905
Expand file tree
/
Copy pathtriangle.go
More file actions
41 lines (38 loc) · 938 Bytes
/
triangle.go
File metadata and controls
41 lines (38 loc) · 938 Bytes
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
// Copyright 2021 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"github.com/go-gl/gl/all-core/gl"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
)
func main() {
MainWindow{
Title: "Walk OpenGL Example",
MinSize: Size{320, 240},
Layout: HBox{},
Children: []Widget{
OpenGL{
Setup: func(*walk.OpenGLContext) error {
return gl.Init()
},
Paint: func(glc *walk.OpenGLContext) error {
sz := glc.Widget().Size()
gl.Viewport(0, 0, int32(sz.Width), int32(sz.Height))
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.Begin(gl.TRIANGLES)
gl.Color3f(1.0, 0.0, 0.0)
gl.Vertex2i(0, 1)
gl.Color3f(0.0, 1.0, 0.0)
gl.Vertex2i(-1, -1)
gl.Color3f(0.0, 0.0, 1.0)
gl.Vertex2i(1, -1)
gl.End()
gl.Flush()
return nil
},
},
},
}.Run()
}