github.com/thommil/tge-gl@v0.0.0-20190313100017-83d8f10f8fae/README.md (about)

     1  <h1 align="center">TGE-GL - OpenGL plugin for TGE</h1>
     2  
     3   <p align="center">
     4      <a href="https://godoc.org/github.com/thommil/tge-gl"><img src="https://godoc.org/github.com/thommil/tge-gl?status.svg" alt="Godoc"></img></a>
     5      <a href="https://goreportcard.com/report/github.com/thommil/tge-gl"><img src="https://goreportcard.com/badge/github.com/thommil/tge-gl"  alt="Go Report Card"/></a>
     6  </p>
     7  
     8  OpenGL support for TGE runtime - [TGE](https://github.com/thommil/tge)
     9  
    10  Based on :
    11   * [go-gl](https://github.com/go-gl/gl) - Copyright (c) 2014 Eric Woroshow
    12   * [gomobile](https://github.com/golang/mobile) - Copyright (c) 2009 The Go Authors. All rights reserved.
    13  
    14  ## Targets
    15   * OpenGL 3.3 core on Desktop
    16   * WebGL2 on Browsers
    17   * OpenGLES 3 on Mobile
    18  
    19  ## Dependencies
    20   * [TGE core](https://github.com/thommil/tge)
    21  
    22  ### Mobile
    23  In order to use this package on Linux desktop distros, you may need OpenGL library as an external dependency:
    24  
    25  ```
    26  sudo apt-get install libgl1-mesa-dev
    27  ```
    28  
    29  ## Limitations
    30  ### Not implemented
    31   * glUniformMatrix2x3fv
    32   * glUniformMatrix3x2fv
    33   * glUniformMatrix2x4fv
    34   * glUniformMatrix4x2fv
    35   * glUniformMatrix3x4fv
    36   * glUniformMatrix4x3fv
    37   * glBlitFramebuffer
    38   * PolygonMode on Mobile/Browser 
    39  
    40  ## Implementation
    41  See example at [OpenGL example](https://github.com/Thommil/tge-examples/tree/master/plugins/tge-gl)
    42  
    43  Just import package and OpenGL API is available in all methods of your App except OnCreate():
    44  
    45  ```golang
    46  package main
    47  
    48  import (
    49  	tge "github.com/thommil/tge"
    50  	gl "github.com/thommil/tge-gl"
    51  )
    52  
    53  type MyApp struct {
    54  }
    55  
    56  func (app *MyApp) OnStart(runtime tge.Runtime) error {
    57  	runtime.Subscribe(tge.ResizeEvent{}.Channel(), app.OnResize)
    58  	gl.ClearColor(0.15, 0.04, 0.15, 1)
    59  	return nil
    60  }
    61  
    62  func (app *MyApp) OnResize(event tge.Event) bool {
    63  	gl.Viewport(0, 0, int(event.(tge.ResizeEvent).Width), int(event.(tge.ResizeEvent).Height))
    64  	return false
    65  }
    66  
    67  ...
    68  
    69  ```