Documentation
¶
Overview ¶
Package windstorm is a window creation library for Go.
Index ¶
- Constants
- func Stop()
- type Action
- type CloseEvent
- type FocusEvent
- type Key
- type KeyboardEvent
- type MouseButton
- type MouseButtonEvent
- type MouseEnterWindowEvent
- type MouseLeaveWindowEvent
- type MouseMoveEvent
- type ResizeEvent
- type Window
- func (window *Window) Close() error
- func (window *Window) CreateContext() error
- func (window *Window) Height() int
- func (window *Window) Hide() error
- func (window *Window) InFocus() bool
- func (window *Window) KeyState(key Key) Action
- func (window *Window) MakeContextCurrent() error
- func (window *Window) MouseButtonState(button MouseButton) Action
- func (window *Window) MouseInWindow() bool
- func (window *Window) MousePosition() (int, int)
- func (window *Window) SetRecievesEvents(recieves bool)
- func (window *Window) SetSize(width, height int) error
- func (window *Window) SetTitle(title string) error
- func (window *Window) ShouldClose() bool
- func (window *Window) Show() error
- func (window *Window) SwapBuffers() error
- func (window *Window) Title() string
- func (window *Window) UpdateEvents() error
- func (window *Window) Width() int
Constants ¶
const ( MouseButton1 = MouseButton(C.Button1) MouseButton2 = MouseButton(C.Button2) MouseButton3 = MouseButton(C.Button3) MouseButton4 = MouseButton(C.Button4) MouseButton5 = MouseButton(C.Button5) )
Constants representing mouse buttons.
const ( KeySpace = Key(C.XK_space) KeyApostrophe = Key(C.XK_apostrophe) KeyComma = Key(C.XK_comma) KeyMinus = Key(C.XK_minus) KeyPeriod = Key(C.XK_period) KeySlash = Key(C.XK_slash) Key0 = Key(C.XK_0) Key1 = Key(C.XK_1) Key2 = Key(C.XK_2) Key3 = Key(C.XK_3) Key4 = Key(C.XK_4) Key5 = Key(C.XK_5) Key6 = Key(C.XK_6) Key7 = Key(C.XK_7) Key8 = Key(C.XK_8) Key9 = Key(C.XK_9) KeySemicolon = Key(C.XK_semicolon) KeyEqual = Key(C.XK_equal) KeyA = Key(C.XK_A) KeyB = Key(C.XK_B) KeyC = Key(C.XK_C) KeyD = Key(C.XK_D) KeyE = Key(C.XK_E) KeyF = Key(C.XK_F) KeyG = Key(C.XK_G) KeyH = Key(C.XK_H) KeyI = Key(C.XK_I) KeyJ = Key(C.XK_J) KeyK = Key(C.XK_K) KeyL = Key(C.XK_L) KeyM = Key(C.XK_M) KeyN = Key(C.XK_N) KeyO = Key(C.XK_O) KeyP = Key(C.XK_P) KeyQ = Key(C.XK_Q) KeyR = Key(C.XK_R) KeyS = Key(C.XK_S) KeyT = Key(C.XK_T) KeyU = Key(C.XK_U) KeyV = Key(C.XK_V) KeyW = Key(C.XK_W) KeyX = Key(C.XK_X) KeyY = Key(C.XK_Y) KeyZ = Key(C.XK_Z) KeyLeftBracket = Key(C.XK_bracketleft) KeyBackslash = Key(C.XK_backslash) KeyRightBracket = Key(C.XK_bracketright) KeyGraveAccent = Key(C.XK_grave) KeyEscape = Key(C.XK_Escape) KeyEnter = Key(C.XK_Return) KeyTab = Key(C.XK_Tab) KeyBackspace = Key(C.XK_BackSpace) KeyInsert = Key(C.XK_Insert) KeyDelete = Key(C.XK_Delete) KeyRight = Key(C.XK_Right) KeyLeft = Key(C.XK_Left) KeyDown = Key(C.XK_Down) KeyUp = Key(C.XK_Up) KeyPageUp = Key(C.XK_Page_Up) KeyPageDown = Key(C.XK_Page_Down) KeyHome = Key(C.XK_Home) KeyEnd = Key(C.XK_End) KeyCapsLock = Key(C.XK_Caps_Lock) KeyScrollLock = Key(C.XK_Scroll_Lock) KeyNumLock = Key(C.XK_Num_Lock) KeyPrKeyScreen = Key(C.XK_3270_PrintScreen) KeyPause = Key(C.XK_Pause) KeyF1 = Key(C.XK_F1) KeyF2 = Key(C.XK_F2) KeyF3 = Key(C.XK_F3) KeyF4 = Key(C.XK_F4) KeyF5 = Key(C.XK_F5) KeyF6 = Key(C.XK_F6) KeyF7 = Key(C.XK_F7) KeyF8 = Key(C.XK_F8) KeyF9 = Key(C.XK_F9) KeyF10 = Key(C.XK_F10) KeyF11 = Key(C.XK_F11) KeyF12 = Key(C.XK_F12) KeyF13 = Key(C.XK_F13) KeyF14 = Key(C.XK_F14) KeyF15 = Key(C.XK_F15) KeyF16 = Key(C.XK_F16) KeyF17 = Key(C.XK_F17) KeyF18 = Key(C.XK_F18) KeyF19 = Key(C.XK_F19) KeyF20 = Key(C.XK_F20) KeyF21 = Key(C.XK_F21) KeyF22 = Key(C.XK_F22) KeyF23 = Key(C.XK_F23) KeyF24 = Key(C.XK_F24) KeyKp0 = Key(C.XK_KP_0) KeyKp1 = Key(C.XK_KP_1) KeyKp2 = Key(C.XK_KP_2) KeyKp3 = Key(C.XK_KP_3) KeyKp4 = Key(C.XK_KP_4) KeyKp5 = Key(C.XK_KP_5) KeyKp6 = Key(C.XK_KP_6) KeyKp7 = Key(C.XK_KP_7) KeyKp8 = Key(C.XK_KP_8) KeyKp9 = Key(C.XK_KP_9) KeyKpDecimal = Key(C.XK_KP_Decimal) KeyKpDivide = Key(C.XK_KP_Divide) KeyKpMultiply = Key(C.XK_KP_Multiply) KeyKpSubtract = Key(C.XK_KP_Subtract) KeyKpAdd = Key(C.XK_KP_Add) KeyKpEnter = Key(C.XK_KP_Enter) KeyKpEqual = Key(C.XK_KP_Equal) KeyLeftShift = Key(C.XK_Shift_L) KeyRightShift = Key(C.XK_Shift_R) KeyLeftControl = Key(C.XK_Control_L) KeyLeftAlt = Key(C.XK_Alt_L) KeyLeftSuper = Key(C.XK_Super_L) KeyRightControl = Key(C.XK_Control_R) KeyRightAlt = Key(C.XK_Alt_R) KeyRightSuper = Key(C.XK_Super_R) KeyMenu = Key(C.XK_Menu) )
Constants representing keyboard buttons.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action int
Action is a constant type for key and button states.
const ( Press Action Release )
Constants representing button and key states.
type FocusEvent ¶
type FocusEvent struct {
Focused bool
}
FocusEvent represents a change in window focus.
type KeyboardEvent ¶
KeyboardEvent represents a user triggered keyboard press or release event.
type MouseButtonEvent ¶
type MouseButtonEvent struct {
Button MouseButton
Action Action
}
MouseButtonEvent represents a user triggered mouse button press or release event.
type MouseEnterWindowEvent ¶
MouseEnterWindowEvent represents an event triggered by the mouse entering back into a window.
type MouseLeaveWindowEvent ¶
type MouseLeaveWindowEvent struct {
}
MouseLeaveWindowEvent represents an event triggered by the mouse leaving a window.
type MouseMoveEvent ¶
MouseMoveEvent represents a movement of the mouse cursor.
type ResizeEvent ¶
ResizeEvent represents a user or window manager triggered resizing of a window.
type Window ¶
type Window struct {
OnClose chan CloseEvent
OnResize chan ResizeEvent
OnKeyboard chan KeyboardEvent
OnMouseMove chan MouseMoveEvent
OnMouseButton chan MouseButtonEvent
OnFocus chan FocusEvent
OnMouseEnterWindow chan MouseEnterWindowEvent
OnMouseLeaveWindow chan MouseLeaveWindowEvent
// contains filtered or unexported fields
}
Window is an object representing a window with an OpenGL context inside of it. Most operations are done through a Window object. OnX channels are exposed through this object that may be read for user input. These channels should never be written to.
func NewWindow ¶
NewWindow creates a new Window object with the given width, height, and title. Width and height attributes must be above zero. The window will not immediately appear on screen. The Show method must be called first. The window will also not capture user input by default. The SetRetrievesInput method must be called first.
func (*Window) Close ¶
Close closes the window. Drawing should not be performed on it's context after this method is called. User input will stop being fed to the window, as well.
func (*Window) CreateContext ¶
CreateContext creates a new OpenGL context.
func (*Window) MakeContextCurrent ¶
MakeContextCurrent makes the window's context current. Future OpenGL draw operations will be done on this context.
func (*Window) MouseButtonState ¶
func (window *Window) MouseButtonState(button MouseButton) Action
MouseButtonState returns the state of a mouse button.
func (*Window) MouseInWindow ¶
MouseInWindow returns true if the cursor currently resides in the window space.
func (*Window) MousePosition ¶
MousePosition returns the position of the cursor.
func (*Window) SetRecievesEvents ¶
SetRecievesEvents toggles whether the window should recieve user input events or not. The default value is false.
func (*Window) SetSize ¶
SetSize sets the width and height of the window in pixels. Valid values must be above zero.
func (*Window) ShouldClose ¶
ShouldClose returns true if the window has recieved a close request from the user or the OS.
func (*Window) SwapBuffers ¶
SwapBuffers updates the display in the window.
func (*Window) UpdateEvents ¶
UpdateEvents checks for new user input events.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
simple.go A simple program that draws a red box on screen, has it move around relative to the position of the mouse, and quits when the user hits escape.
|
simple.go A simple program that draws a red box on screen, has it move around relative to the position of the mouse, and quits when the user hits escape. |