Skip to content

jphsd/glui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Image Display Using Open GL in Go

This package wraps the Go port of the C implementation of GLFW in some boilerplate to make displaying an image on the screen almost trivial.

The version of OpenGL used is 4.1 and the boilerplate includes the necessary shaders to perform the rendering.

See glui/cmd/image.go for a simple example of reading an image and displaying it in a window.

$ go run image.go <your image here - most image types supported>

The glui/cmd/images.go version takes multiple images on the command line and rotates through them. This example also demonstrates attaching a call back for character processing - hitting ESC will close the window.

Functions are included to allow you to create new windows with a backing image, set that image to some other image and a loop function (which actually does the rendering). The loop function can take a zero argument function that will be called once per loop iteration. In addition to handling the window rendering, the loop function also handles any call backs registered on the windows.

Mouse Click, Scroll and Drag Listeners

These allow click, scroll and drag events to be generated and a list of observers to be called with the event location. See the mouse.go and drag.go examples in cmd/.

Key and Character Listeners

These provide glui style wrappers around GLFW's Key and Char window callbacks. Key provides access to press, release and repeat events, in addition to the key code and scan code of the actual button pressed. Character will only be notified for regular alphanumeric runes and any modifiers will have been applied.

Events.go

Finally, the events.c program provided in the C implementation of GLFW has been ported over to Go and is in glui/cmd/events.go.

$ go run events.go

This will dump out all the event types for which call backs can be registered, to the terminal. It doesn't utilize the glui package itself.

About

Convenience wrapper around GLFW for image display and mouse events

Topics

Resources

License

Stars

Watchers

Forks

Languages