Skip to content

Latest commit

 

History

History
69 lines (52 loc) · 1.84 KB

README.md

File metadata and controls

69 lines (52 loc) · 1.84 KB

TGE-GL - OpenGL plugin for TGE

Godoc Go Report Card

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.

Targets

  • OpenGL 3.3 core on Desktop
  • WebGL2 on Browsers
  • OpenGLES 3 on Mobile

Dependencies

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

Limitations

Not implemented

  • glUniformMatrix2x3fv
  • glUniformMatrix3x2fv
  • glUniformMatrix2x4fv
  • glUniformMatrix4x2fv
  • glUniformMatrix3x4fv
  • glUniformMatrix4x3fv
  • glBlitFramebuffer
  • PolygonMode on Mobile/Browser

Implementation

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
}

...