OpenGL support for TGE runtime - TGE
Based on :
- go-gl - Copyright (c) 2014 Eric Woroshow
- gomobile - Copyright (c) 2009 The Go Authors. All rights reserved.
- OpenGL 3.3 core on Desktop
- WebGL2 on Browsers
- OpenGLES 3 on Mobile
In order to use this package on Linux desktop distros, you may need OpenGL library as an external dependency:
sudo apt-get install libgl1-mesa-dev
- glUniformMatrix2x3fv
- glUniformMatrix3x2fv
- glUniformMatrix2x4fv
- glUniformMatrix4x2fv
- glUniformMatrix3x4fv
- glUniformMatrix4x3fv
- glBlitFramebuffer
- PolygonMode on Mobile/Browser
See example at OpenGL example
Just import package and OpenGL API is available in all methods of your App except OnCreate():
package main
import (
tge "github.com/thommil/tge"
gl "github.com/thommil/tge-gl"
)
type MyApp struct {
}
func (app *MyApp) OnStart(runtime tge.Runtime) error {
runtime.Subscribe(tge.ResizeEvent{}.Channel(), app.OnResize)
gl.ClearColor(0.15, 0.04, 0.15, 1)
return nil
}
func (app *MyApp) OnResize(event tge.Event) bool {
gl.Viewport(0, 0, int(event.(tge.ResizeEvent).Width), int(event.(tge.ResizeEvent).Height))
return false
}
...