This repository has been archived by the owner on Jul 28, 2018. It is now read-only.
/
OpenGlWindow.go
75 lines (59 loc) · 3.12 KB
/
OpenGlWindow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package env
import (
"github.com/inkyblackness/shocked-client/env/keys"
"github.com/inkyblackness/shocked-client/opengl"
)
// RenderCallback is the function to receive render events. When the callback
// returns, the window will swap the internal buffer.
type RenderCallback func()
// MouseMoveCallback is the function to receive the current mouse coordinate while moving.
// Movement is reported while the cursor is within the client area of the window, and
// beyond the window as long as at least one captured button is pressed.
// Reported values are with sub-pixel precision, if possible.
type MouseMoveCallback func(x float32, y float32)
// MouseButtonCallback is the function to receive button up/down events.
// An Up event is sent for every reported Down event, even if the mouse cursor is outside
// the client area.
type MouseButtonCallback func(buttonMask uint32, modifier keys.Modifier)
// MouseScrollCallback is the function to receive scroll events.
// Delta values are right-hand oriented: positive values go right/down/far.
type MouseScrollCallback func(dx float32, dy float32)
// ResizeCallback is called for a change of window dimensions.
type ResizeCallback func(width int, height int)
// CharCallback is called for typing a character.
type CharCallback func(char rune)
// KeyCallback is called for pressing or releasing a key on the keyboard.
type KeyCallback func(key keys.Key, modifier keys.Modifier)
// ModifierCallback is called when the currently active modifier changed.
type ModifierCallback func(modifier keys.Modifier)
// FileDropCallback is called when one or more files were dropped into the window.
type FileDropCallback func(filePaths []string)
// OpenGlWindow represents an OpenGL render surface.
type OpenGlWindow interface {
// OpenGl returns the OpenGL API wrapper for this window.
OpenGl() opengl.OpenGl
// OnRender registers a callback function which shall be called to update the scene.
OnRender(callback RenderCallback)
// OnResize registers a callback function for sizing events.
OnResize(callback ResizeCallback)
// Size returns the dimensions of the window display area in pixel.
Size() (width int, height int)
// Clipboard returns the clipboard access associated with this window.
Clipboard() Clipboard
// OnMouseMove registers a callback function for mouse move events.
OnMouseMove(callback MouseMoveCallback)
// OnMouseButtonDown registers a callback function for mouse button down events.
OnMouseButtonDown(callback MouseButtonCallback)
// OnMouseButtonUp registers a callback function for mouse button up events.
OnMouseButtonUp(callback MouseButtonCallback)
// OnMouseScroll registers a callback function for mouse scroll events.
OnMouseScroll(callback MouseScrollCallback)
// OnKey registers a callback function for key events.
OnKey(callback KeyCallback)
// OnModifier registers a callback function for change of modifier events.
OnModifier(callback ModifierCallback)
// OnCharCallback registers a callback function for typed characters.
OnCharCallback(callback CharCallback)
// OnFileDropCallback registers a callback function for dropped files.
OnFileDropCallback(callback FileDropCallback)
}