Documentation
¶
Overview ¶
Package glui provides a simple way to display an image or images on a screen, each in its own window. The package makes use of the GLFW library and OpenGL v4.1
Index ¶
Constants ¶
const (
DefaultClickLimit = 2
)
Variables ¶
var (
ClickLimit float64 = DefaultClickLimit // Max allowed distance between press and release
)
var WinMap = make(map[*glfw.Window]*GLWin)
WinMap provides a map of all windows to their corresponding GLWin
Functions ¶
func GetKeyName ¶
func Loop ¶
func Loop(update func())
Loop is how window events get processed and the images rendered to their windows. It will run until there are no windows left to process. The update function provides a way to insert codeinto this loop - it should be non-blocking, otherwise window updates and callbacks will stall.
Types ¶
type CharacterListener ¶
CharaterListener adds a wrapper around glfw's character callback.
func NewCharacterListener ¶
func NewCharacterListener(win *GLWin, onChar func(rune)) *CharacterListener
NewCharacterListener adds a key listener to the supplied window and the function to be called when a character is detected.
type GLWin ¶
type GLWin struct {
Img *image.RGBA // Image to load, nil otherwise
Win *glfw.Window // Underlying GL window
// contains filtered or unexported fields
}
GLWin ties an image to a window
type KeyListener ¶
type KeyListener struct {
Window *GLWin
Observers []func(int, int, Action, ModifierKey)
}
KeyListener adds a wrapper around glfw's key callback.
func NewKeyListener ¶
func NewKeyListener(win *GLWin, onKey func(int, int, Action, ModifierKey)) *KeyListener
NewKeyListener adds a key listener to the supplied window and the function to be called when a key action is detected.
type ModifierKey ¶
type ModifierKey = glfw.ModifierKey
const ( ModShift ModifierKey = glfw.ModShift ModControl ModifierKey = glfw.ModControl ModAlt ModifierKey = glfw.ModAlt ModSuper ModifierKey = glfw.ModSuper ModCapsLock ModifierKey = glfw.ModCapsLock ModNumLock ModifierKey = glfw.ModNumLock )
type MouseButton ¶
type MouseButton = glfw.MouseButton
const ( MouseButton1 MouseButton = glfw.MouseButton1 MouseButton2 MouseButton = glfw.MouseButton2 MouseButton3 MouseButton = glfw.MouseButton3 MouseButton4 MouseButton = glfw.MouseButton4 MouseButton5 MouseButton = glfw.MouseButton5 MouseButton6 MouseButton = glfw.MouseButton6 MouseButton7 MouseButton = glfw.MouseButton7 MouseButton8 MouseButton = glfw.MouseButton8 MouseButtonLast MouseButton = glfw.MouseButtonLast MouseButtonLeft MouseButton = glfw.MouseButtonLeft MouseButtonRight MouseButton = glfw.MouseButtonRight MouseButtonMiddle MouseButton = glfw.MouseButtonMiddle )
type MouseClickListener ¶
type MouseClickListener struct {
Window *GLWin
Button MouseButton
Point []float64
Observers []func(point []float64)
}
MouseClickListener adds some processing to the mouse button press and release events generated by glfw to turn them into single click events at the point the button was first pressed.
func NewMouseClickListener ¶
func NewMouseClickListener(win *GLWin, button MouseButton, onClick func([]float64)) *MouseClickListener
NewMouseClickListener adds a listener to the supplied window for the indicated button, and the function to be called when a click is detected.
type MouseDragListener ¶
type MouseDragListener struct {
Window *GLWin
Button MouseButton
Observers []func(point []float64, dx, dy float64, act Action)
Point []float64
State bool
}
MouseDragListener adds some processing to the mouse button press and release events generated by glfw to turn them into a sequence of drag events from the point the button was first pressed until it is released.
func NewMouseDragListener ¶
func NewMouseDragListener(win *GLWin, button MouseButton, onDrag func([]float64, float64, float64, Action)) *MouseDragListener
NewMouseDragListener adds a listener to the supplied window for the indicated button, and the function to be called when a drag occurs.
type MouseMoveListener ¶
MouseMoveListener is a wrapper around the cursor position callback.
func NewMouseMoveListener ¶
func NewMouseMoveListener(win *GLWin, onMove func([]float64)) *MouseMoveListener
NewMouseMoveListener adds a listener to the supplied window, and the function to be called when mouse movement occurs.
type MouseScrollListener ¶
MouseScrollListener is a wrapper around the mouse scroll callback.
func NewMouseScrollListener ¶
func NewMouseScrollListener(win *GLWin, onScroll func(float64, float64)) *MouseScrollListener
NewMouseScrollListener adds a listener to the supplied window, and the function to be called when mouse movement occurs.