gome

package module
v0.0.0-...-07d0059 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2014 License: MIT Imports: 5 Imported by: 0

README

gome

A simple Go library for making setting up a GLFW3 window and OpenGL context easier. Documentation can be found here.

Documentation

Overview

Package gome provides a minimal and simple library for setting up a graphical application using OpenGL. All functions should be called on the main OS thread. Init locks the goroutine to the main OS thread, so calling that early in main ensures that any subsequent calls in main are on the right thread.

The main loop of the application then looks like this:

if err := gome.Init(); err != nil {
    // handle error
}
defer gome.Terminate()

initGL()
render()
gome.Tick()

gome.Window.Show()

for gome.Tick() {
    update()
    render()
}
if err := gome.GetError(); err != nil {
    // handle error
}

A time.Ticker can be used to limit framerate.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGLFW3Initialize = errors.New("could not initialise GLFW3")
	ErrGLEWInitialize  = errors.New("could not initialise GLEW")
)
View Source
var ShouldClose = false

ShouldClose reflects whether the main loop should end. Setting ShouldClose to true causes gome.Tick to return false, which should end the main loop.

View Source
var Window *glfw3.Window

Window is the main window of the application. This is created automatically by Init and has dimensions 800x600 by default. It is hidden by default, so the application should call gome.Window.Show() after any initialisation code.

Functions

func GetError

func GetError() error

GetError polls OpenGL for an error and returns that.

func Init

func Init() error

Init initialises GLFW3 and OpenGL and creates the main window (see Window). After this has returned OpenGL functions as well as gome.Tick can be used. It also locks the current OS thread (see runtime.LockOSThread).

func Terminate

func Terminate()

Terminate cleans up and terminates GLFW3. It should be called after the main loop has finished, e.g. by deferring it in the main function.

func Tick

func Tick() bool

Tick swaps the buffers of the main window and polls GLFW3 for events. It returns true if the main loop should continue and false otherwise. It only returns false if ShouldClose is true, the window is being closed or if OpenGL reports an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL