2D and 3D graphic development in Golang using Processing Design.
Package required:
- libgl1-mesa-dev
- xorg-dev
You need to initialize a struct that implements Setup and Draw methods:
type model struct {
/* */
}
func (m *model) Setup() *p5go.Window {
return p5go.Canvas2D(500, 500)
}
func (m *model) Draw(window *p5go.Window) {
/* */
}
func init() { runtime.LockOSThread() }
func main() {
p := p5go.NewProgram(&model{}, p5go.P2D)
err := p.Run()
if err != nil {
log.Fatal(err)
}
}
Pay attention to
func init() { runtime.LockOSThread() }
You need this to make open gl work properly.
At this point you can draw something:
func (m *model) Draw(window *p5go.Window) {
window.Triangle(100, 100, 200, 200, 300, 300)
}
- camera()
- rotateX()
- rotateY()
- rotateZ()
- perspective()
- mouseX()
- mouseY()
- background()
- fill()
- arc()
- circle()
- ellipse()
- line()
- point()
- quad()
- rect()
- square()
- triangle()
- box()