glml

package
v0.0.0-...-bb4b282 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2014 License: Zlib Imports: 3 Imported by: 0

Documentation

Overview

Copyright © 2012 Popog

Copyright © 2012 Popog

Index

Constants

This section is empty.

Variables

View Source
var ContextSettingsDefault = ContextSettings{
	MajorVersion: 2,
	MinorVersion: 0,
}

Functions

func ContextThreadGetSettings

func ContextThreadGetSettings(results chan<- ContextSettings) func(thread *Thread, t Threadable) ThreadError

A thread command helper for Context.ThreadGetSettings If an error occurs, results will not be sent, so be sure to check Context.Errors()

func ContextThreadSetVSyncEnabled

func ContextThreadSetVSyncEnabled(enabled bool) func(thread *Thread, t Threadable) ThreadError

A thread command helper for Context.ThreadSetVSyncEnabled

func EvaluateFormat

func EvaluateFormat(rBitsPerPixel uint, rSettings ContextSettings, colorBits, depthBits, stencilBits, antialiasing uint) uint

func GetMousePosition

func GetMousePosition() (x, y int)

Get the current position of the mouse in desktop coordinates

func IsMouseButtonPressed

func IsMouseButtonPressed(button MouseButton) bool

Check if a mouse button is pressed

func SetMousePosition

func SetMousePosition(x, y int)

Set the current position of the mouse in desktop coordinates

func WindowThreadGetSettings

func WindowThreadGetSettings(results chan<- ContextSettings) func(thread *Thread, t Threadable) ThreadError

A thread command helper for Window.ThreadGetSettings

func WindowThreadSetVSyncEnabled

func WindowThreadSetVSyncEnabled(enabled bool) func(thread *Thread, t Threadable) ThreadError

A thread command helper for Window.ThreadSetVSyncEnabled

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

func CreateContext

func CreateContext() *Context

Create a context with default settings and dimensions

func CreateContextFromSettings

func CreateContextFromSettings(settings ContextSettings, width, height int) *Context

A context with specific settings and back buffer dimensions

func (*Context) Close

func (c *Context) Close()

Closing a context will deactivate it if necessary. A closed context is inactive and cannot be reactivated. all of internal resources are freed, but not resources loaded by the user.

func (*Context) Commands

func (c *Context) Commands() chan<- func(thread *Thread, t Threadable) ThreadError

The channel for input functions to run on this context.

func (*Context) Errors

func (c *Context) Errors() <-chan ThreadError

The error reporting channel

func (*Context) GetThread

func (c *Context) GetThread() *Thread

Returns the thread the context is running on or nil if it is not currently running on a thread

func (*Context) InitialThread

func (c *Context) InitialThread() *Thread

Gets the thread that the context was initialized on. Returns nil if context has not been initialized

func (*Context) IsActive

func (c *Context) IsActive() bool

Literally GetThread() != nil

func (*Context) IsClosed

func (c *Context) IsClosed() bool

returns true if a context has been closed

func (*Context) SetThread

func (c *Context) SetThread(thread *Thread)

Expects to be called by Thread Sets the thread

func (*Context) ThreadActivate

func (c *Context) ThreadActivate(*Thread) ThreadError

Expects to be called on a Thread

func (*Context) ThreadClose

func (c *Context) ThreadClose(thread *Thread)

Expects to be called on a Thread

func (*Context) ThreadCommands

func (c *Context) ThreadCommands() <-chan func(thread *Thread, t Threadable) ThreadError

Expects to be called on a Thread

func (*Context) ThreadDeactivate

func (c *Context) ThreadDeactivate(*Thread) ThreadError

Expects to be called on a Thread

func (*Context) ThreadGetSettings

func (c *Context) ThreadGetSettings() (ContextSettings, ThreadError)

Expects to be called on a Thread Retrieve the OpenGL context settings

Note that these settings may be different from what was requested if one or more settings were not supported. In this case, the closest available match was chosen.

func (*Context) ThreadInitialize

func (c *Context) ThreadInitialize(thread *Thread) ThreadError

Expects to be called on a Thread

func (*Context) ThreadIsInitialized

func (c *Context) ThreadIsInitialized() bool

Expects to be called on a Thread

func (*Context) ThreadReportError

func (c *Context) ThreadReportError(err ThreadError)

Expects to be called on a Thread Sends an error to Context.Errors()

func (*Context) ThreadSetVSyncEnabled

func (c *Context) ThreadSetVSyncEnabled(enabled bool) ThreadError

Expects to be called on a Thread Enable or disable vertical synchronization.

Activating vertical synchronization will limit the number of frames displayed to the refresh rate of the monitor. This can avoid some visual artifacts, and limit the framerate to a good value (but not constant across different computers).

func (*Context) ThreadSwapBuffers

func (c *Context) ThreadSwapBuffers() ThreadError

Expects to be called on a Thread Swap the front and back buffers to display on screen what has been rendered so far.

This function is typically called after all OpenGL rendering has been done for the current frame, in order to show it on screen.

type ContextSettings

type ContextSettings struct {
	DepthBits,
	StencilBits,
	AntialiasingLevel,
	MajorVersion,
	MinorVersion uint // Minor number of the context version to create
}

type Event

type Event interface {
}

type Key

type Key int

Key codes

const (
	KeyUnknown   Key = -1   // Unhandled key
	KeyA         Key = iota // The A key
	KeyB                    // The B key
	KeyC                    // The C key
	KeyD                    // The D key
	KeyE                    // The E key
	KeyF                    // The F key
	KeyG                    // The G key
	KeyH                    // The H key
	KeyI                    // The I key
	KeyJ                    // The J key
	KeyK                    // The K key
	KeyL                    // The L key
	KeyM                    // The M key
	KeyN                    // The N key
	KeyO                    // The O key
	KeyP                    // The P key
	KeyQ                    // The Q key
	KeyR                    // The R key
	KeyS                    // The S key
	KeyT                    // The T key
	KeyU                    // The U key
	KeyV                    // The V key
	KeyW                    // The W key
	KeyX                    // The X key
	KeyY                    // The Y key
	KeyZ                    // The Z key
	KeyNum0                 // The 0 key
	KeyNum1                 // The 1 key
	KeyNum2                 // The 2 key
	KeyNum3                 // The 3 key
	KeyNum4                 // The 4 key
	KeyNum5                 // The 5 key
	KeyNum6                 // The 6 key
	KeyNum7                 // The 7 key
	KeyNum8                 // The 8 key
	KeyNum9                 // The 9 key
	KeyEscape               // The Escape key
	KeyLControl             // The left Control key
	KeyLShift               // The left Shift key
	KeyLAlt                 // The left Alt key
	KeyLSystem              // The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
	KeyRControl             // The right Control key
	KeyRShift               // The right Shift key
	KeyRAlt                 // The right Alt key
	KeyRSystem              // The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
	KeyMenu                 // The Menu key
	KeyLBracket             // The [ key
	KeyRBracket             // The ] key
	KeySemiColon            // The ; key
	KeyComma                // The , key
	KeyPeriod               // The . key
	KeyQuote                // The ' key
	KeySlash                // The / key
	KeyBackSlash            // The \ key
	KeyTilde                // The ~ key
	KeyEqual                // The = key
	KeyDash                 // The - key
	KeySpace                // The Space key
	KeyReturn               // The Return key
	KeyBackSpace            // The Backspace key
	KeyTab                  // The Tabulation key
	KeyPageUp               // The Page up key
	KeyPageDown             // The Page down key
	KeyEnd                  // The End key
	KeyHome                 // The Home key
	KeyInsert               // The Insert key
	KeyDelete               // The Delete key
	KeyAdd                  // +
	KeySubtract             // -
	KeyMultiply             // *
	KeyDivide               // /
	KeyLeft                 // Left arrow
	KeyRight                // Right arrow
	KeyUp                   // Up arrow
	KeyDown                 // Down arrow
	KeyNumpad0              // The numpad 0 key
	KeyNumpad1              // The numpad 1 key
	KeyNumpad2              // The numpad 2 key
	KeyNumpad3              // The numpad 3 key
	KeyNumpad4              // The numpad 4 key
	KeyNumpad5              // The numpad 5 key
	KeyNumpad6              // The numpad 6 key
	KeyNumpad7              // The numpad 7 key
	KeyNumpad8              // The numpad 8 key
	KeyNumpad9              // The numpad 9 key
	KeyF1                   // The F1 key
	KeyF2                   // The F2 key
	KeyF3                   // The F3 key
	KeyF4                   // The F4 key
	KeyF5                   // The F5 key
	KeyF6                   // The F6 key
	KeyF7                   // The F7 key
	KeyF8                   // The F8 key
	KeyF9                   // The F9 key
	KeyF10                  // The F10 key
	KeyF11                  // The F11 key
	KeyF12                  // The F12 key
	KeyF13                  // The F13 key
	KeyF14                  // The F14 key
	KeyF15                  // The F15 key
	KeyPause                // The Pause key

	KeyCount // Keep last -- the total number of keyboard keys
)

type KeyPressedEvent

type KeyPressedEvent struct {
	Code                        Key  // Code of the key that has been pressed
	Alt, Control, Shift, System bool // Is a modifier key pressed?
}

A key was pressed

type KeyReleasedEvent

type KeyReleasedEvent struct {
	Code                        Key  // Code of the key that has been released
	Alt, Control, Shift, System bool // Is a modifier key pressed?
}

A key was released

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitors may expire randomly

func GetDefaultMonitor

func GetDefaultMonitor() *Monitor

Get the default monitor

func GetMonitors

func GetMonitors() []*Monitor

Get all the monitors on the system

func (*Monitor) GetDesktopMode

func (m *Monitor) GetDesktopMode() VideoMode

Get the current desktop video mode

func (*Monitor) GetFullscreenVideoModes

func (m *Monitor) GetFullscreenVideoModes() []VideoMode

Get the list of all the supported fullscreen video modes

func (*Monitor) IsDefault

func (m *Monitor) IsDefault() bool

Returns true if this monitor is the default monitor

func (*Monitor) IsValid

func (m *Monitor) IsValid() bool

Returns true if the monitor is still a valid monitor

func (*Monitor) SupportsMode

func (m *Monitor) SupportsMode(mode VideoMode) bool

Returns whether or not a monitor supports a particular video mode

type MouseButton

type MouseButton uint

Mouse buttons

const (
	// Concrete buttons
	MouseLeftRH   MouseButton = iota // The left mouse button on a right-handed mouse (primary)
	MouseRightRH                     // The right mouse button on a right-handed mouse (secondary)
	MouseLeftLH                      // The left mouse button on a left-handed mouse (secondary)
	MouseRightLH                     // The right mouse button on a left-handed mouse (primary)
	MouseMiddle                      // The middle (wheel) mouse button
	MouseXButton1                    // The first extra mouse button
	MouseXButton2                    // The second extra mouse button

	// Abstract buttons. Will NOT be returned by API (e.g. Events)
	MouseButtonPrimary   // The primary mouse button regardless of handedness
	MouseButtonSecondary // The secondary mouse button regardless of handedness
	MouseButtonLeft      // The left mouse button regardless of handedness
	MouseButtonRight     // The right mouse button regardless of handedness

	MouseButtonCount // Keep last -- the total number of mouse buttons
)

type MouseButtonPressedEvent

type MouseButtonPressedEvent struct {
	Button MouseButton // Code of the concrete button that has been pressed
	X, Y   int         // X and Y position of the mouse pointer, relative to the top-left of the owner window
}

A mouse button was pressed

type MouseButtonReleasedEvent

type MouseButtonReleasedEvent struct {
	Button MouseButton // Code of the concrete button that has been released
	X, Y   int         // X and Y positions of the mouse pointer, relative to the top-left of the owner window
}

A mouse button was released

type MouseEnteredEvent

type MouseEnteredEvent struct {
}

The mouse cursor entered the area of the window

type MouseLeftEvent

type MouseLeftEvent struct {
}

The mouse cursor left the area of the window

type MouseMoveEvent

type MouseMoveEvent struct {
	X, Y int // X and Y positions of the mouse pointer, relative to the top-left of the owner window
}

The mouse cursor moved

type MouseWheelEvent

type MouseWheelEvent struct {
	Delta int // Number of ticks the wheel has moved (positive is up, negative is down)
	X, Y  int // X and Y position of the mouse pointer, relative to the top-left of the owner window
}

The mouse wheel was scrolled

type TextEnteredEvent

type TextEnteredEvent struct {
	Character rune // character
}

A character was entered

type Thread

type Thread struct {
	// contains filtered or unexported fields
}

For things which need to be run on a consistent thread

func CreateThread

func CreateThread() *Thread

func (*Thread) Close

func (thread *Thread) Close()

Closing a thread deactivates any active context The thread will remain until all threadables that were initialized on the thread are closed

func (*Thread) CloseThreadable

func (thread *Thread) CloseThreadable(item Threadable)

Cause ThreadClose to be called

func (*Thread) ForceClose

func (thread *Thread) ForceClose()

Forcibly close all initialized items. You probably don't want to do this.

func (*Thread) GetActive

func (thread *Thread) GetActive() Threadable

Get active returns the currently active context

func (*Thread) SetActive

func (thread *Thread) SetActive(item Threadable) error

Deactivates the current threaded item and activate the new threaded item. Passing the same value as the previous call does nothing. passing nil deactivates just deactivates the current running item Returns nil if the new context is activated without error. Otherwise the error that prevented the context from being activated is returned

type ThreadError

type ThreadError interface {
	error
	Fatal() bool // returns true if the error is fatal
}

func ContextThreadSwapBuffers

func ContextThreadSwapBuffers(_ *Thread, t Threadable) ThreadError

A thread command wrapper for Context.ThreadSwapBuffers

func NewThreadError

func NewThreadError(err error, fatal bool) ThreadError

func WindowThreadSwapBuffers

func WindowThreadSwapBuffers(_ *Thread, t Threadable) ThreadError

A thread command wrapper for Window.ThreadSwapBuffers

type Threadable

type Threadable interface {
	// If threadables do not need thread-dependent setup and teardown
	// ThreadIsInitialized should always return true.
	// If ThreadIsInitialized returns false, ThreadInitialize is called
	// and the threadable is recorded in a teardown list.
	// ThreadClose will be called on the thread when either the Threadable
	// is requested to be closed on the thread on which it was created
	//
	ThreadIsInitialized() bool
	ThreadInitialize(thread *Thread) ThreadError
	ThreadClose(thread *Thread)

	ThreadActivate(thread *Thread) ThreadError                             // The first function run on the thread. Any error returned is considered fatal.
	ThreadDeactivate(thread *Thread) ThreadError                           // The last function run on the thread
	ThreadCommands() <-chan func(thread *Thread, t Threadable) ThreadError // The channel from which more functions will be run

	// All errors which occur on the thread will be sent via
	// calls to item.ReportError()
	// it is recommended that the contents of ReportError be
	// non-blocking
	ThreadReportError(err ThreadError)

	// For recording which thread the threadable is running on
	SetThread(t *Thread)
	GetThread() *Thread

	// Threadables are closed if they encounter a fatal error
	// If ThreadInitialize(thread) was called, Close must call
	// thread.CloseThreadable to ensure ThreadClose is called properly.
	Close()
	IsClosed() bool
}

type VideoMode

type VideoMode struct {
	Width, Height uint // Video mode width and height, in pixels
	BitsPerPixel  uint // Video mode pixel depth, in bits per pixels
}

func (VideoMode) Less

func (lhs VideoMode) Less(rhs VideoMode) bool

Compare two video modes. Pixel depth is considered more significant than dimensions

type Window

type Window struct {
	// contains filtered or unexported fields
}

Windows contain an context, but note that fatal errors on the context will not close the window They will just make it mostly useless as you cannot spawn a new context.

func CreateWindow

func CreateWindow(monitor *Monitor, mode VideoMode, title string, style WindowStyle, settings ContextSettings) (*Window, error)

Construct a new window

monitor The monitor to create the window on. If nil, the default monitor is used. mode Video mode to use (defines the width, height and depth of the rendering area of the window). title Title of the window. style Customize the look and behaviour of the window (borders, title bar, resizable, closable, ...)

If style is StyleFullscreen, then mode must be a valid video mode.

settings Additional settings for the underlying OpenGL context.

func (*Window) Close

func (w *Window) Close()

Closing a window will deactivate it if necessary. A closed context is inactive and cannot be reactivated. all of window resources are freed, but not resources loaded by the user.

func (*Window) Commands

func (w *Window) Commands() chan<- func(thread *Thread, t Threadable) ThreadError

The channel for input functions to run on this window.

func (*Window) Errors

func (w *Window) Errors() <-chan ThreadError

The error reporting channel

func (*Window) GetThread

func (w *Window) GetThread() *Thread

Returns the thread the window is running on or nil if it is not currently running on a thread

func (*Window) InitialThread

func (w *Window) InitialThread() *Thread

Gets the thread that the window was initialized on. Returns nil if window has not been initialized

func (*Window) IsActive

func (w *Window) IsActive() bool

Literally GetThread() != nil

func (*Window) IsClosed

func (w *Window) IsClosed() bool

returns true if a context has been closed

func (*Window) SetThread

func (w *Window) SetThread(thread *Thread)

Expects to be called by Thread Sets the thread

func (*Window) ThreadActivate

func (w *Window) ThreadActivate(thread *Thread) ThreadError

Expects to be called on a Thread

func (*Window) ThreadClose

func (w *Window) ThreadClose(thread *Thread)

Expects to be called on a Thread

func (*Window) ThreadCommands

func (w *Window) ThreadCommands() <-chan func(thread *Thread, t Threadable) ThreadError

Expects to be called on a Thread

func (*Window) ThreadDeactivate

func (w *Window) ThreadDeactivate(thread *Thread) ThreadError

Expects to be called on a Thread

func (*Window) ThreadGetMousePosition

func (w *Window) ThreadGetMousePosition(thread *Thread) (x, y int, err ThreadError)

Get the current position of the mouse in window coordinates Panics if window is nil or closed.

func (*Window) ThreadGetPosition

func (w *Window) ThreadGetPosition(thread *Thread) (x, y int)

Expects to be called on InitialThread() Get the position of the window

func (*Window) ThreadGetSettings

func (w *Window) ThreadGetSettings() (ContextSettings, ThreadError)

Expects to be called on a Thread Retrieve the OpenGL context settings

Note that these settings may be different from what was requested if one or more settings were not supported. In this case, the closest available match was chosen.

func (*Window) ThreadGetSize

func (w *Window) ThreadGetSize(thread *Thread) (x, y uint)

Expects to be called on InitialThread() Get the size of the rendering region of the window

The size doesn't include the titlebar and borders of the window.

func (*Window) ThreadGetSystemHandle

func (w *Window) ThreadGetSystemHandle(thread *Thread) WindowHandle

Expects to be called on InitialThread() Get the OS-specific handle of the window

The type of the returned handle is WindowHandle, which is a typedef to the handle type defined by the OS. You shouldn't need to use this function, unless you have very specific stuff to implement that this library doesn't support, or implement a temporary workaround until a bug is fixed.

func (*Window) ThreadInitialize

func (w *Window) ThreadInitialize(thread *Thread) ThreadError

Perform some common internal initializations

func (*Window) ThreadIsInitialized

func (w *Window) ThreadIsInitialized() bool

Expects to be called on a Thread

func (*Window) ThreadPollEvents

func (w *Window) ThreadPollEvents(thread *Thread, block bool) ([]Event, []ThreadError)

Expects to be called on InitialThread() Get the contents of the window's event queue and evacuate it.

If block is true, this function will wait for an event. If block is false and there are no pending events then the return value is nil.

func (*Window) ThreadReportError

func (w *Window) ThreadReportError(err ThreadError)

Expects to be called on a Thread Sends an error to Window.Errors()

func (*Window) ThreadSetIcon

func (w *Window) ThreadSetIcon(thread *Thread, icon image.Image) error

Expects to be called on InitialThread() Change the window's icon The OS default icon is used by default.

func (*Window) ThreadSetKeyRepeatEnabled

func (w *Window) ThreadSetKeyRepeatEnabled(thread *Thread, enabled bool) ThreadError

Expects to be called on InitialThread() Enable or disable automatic key-repeat

If key repeat is enabled, you will receive repeated KeyPressed events while keeping a key pressed. If it is disabled, you will only get a single event when the key is pressed.

Key repeat is enabled by default.

func (*Window) ThreadSetMouseCursorVisible

func (w *Window) ThreadSetMouseCursorVisible(thread *Thread, visible bool) ThreadError

Expects to be called on InitialThread() Show or hide the mouse cursor

The mouse cursor is visible by default.

func (*Window) ThreadSetMousePosition

func (w *Window) ThreadSetMousePosition(thread *Thread, x, y int) ThreadError

Set the current position of the mouse in window coordinates Panics if window is nil or closed.

func (*Window) ThreadSetPosition

func (w *Window) ThreadSetPosition(thread *Thread, x, y int)

Expects to be called on InitialThread() Change the position of the window on screen

This function only works for top-level windows (i.e. it will be ignored for windows created from the handle of a child window/control).

func (*Window) ThreadSetSize

func (w *Window) ThreadSetSize(thread *Thread, x, y uint)

Expects to be called on InitialThread() Change the size of the rendering region of the window

func (*Window) ThreadSetTitle

func (w *Window) ThreadSetTitle(thread *Thread, title string)

Expects to be called on InitialThread() Change the title of the window

func (*Window) ThreadSetVSyncEnabled

func (w *Window) ThreadSetVSyncEnabled(enabled bool) ThreadError

Expects to be called on a Thread Enable or disable vertical synchronization.

Activating vertical synchronization will limit the number of frames displayed to the refresh rate of the monitor. This can avoid some visual artifacts, and limit the framerate to a good value (but not constant across different computers).

func (*Window) ThreadSetVisible

func (w *Window) ThreadSetVisible(thread *Thread, visible bool) ThreadError

Expects to be called on InitialThread() Show or hide the window

The window is shown by default.

func (*Window) ThreadSwapBuffers

func (w *Window) ThreadSwapBuffers() ThreadError

Expects to be called on a Thread Swap the front and back buffers to display on screen what has been rendered so far.

This function is typically called after all OpenGL rendering has been done for the current frame, in order to show it on screen.

type WindowClosedEvent

type WindowClosedEvent struct {
}

The window requested to be closed

type WindowGainedFocusEvent

type WindowGainedFocusEvent struct {
}

The window gained the focus

type WindowLostFocusEvent

type WindowLostFocusEvent struct {
}

The window lost the focus

type WindowResizeEvent

type WindowResizeEvent struct {
	Width, Height uint // New width and height, in pixels
}

The window was resized

type WindowStyle

type WindowStyle int

Enumeration of the window styles

const (
	WindowStyleNone       WindowStyle = 0         // No border / title bar
	WindowStyleTitlebar   WindowStyle = 1 << iota // Title bar + border
	WindowStyleResize                             // Resizable border + maximize button (requires StyleTitlebar)
	WindowStyleClose                              // Close button (requires StyleTitlebar)
	WindowStyleFullscreen                         // Fullscreen mode (this flag and all others are mutually exclusive)

	WindowStyleDefault = WindowStyleTitlebar | WindowStyleResize | WindowStyleClose // Default window style
)

func (WindowStyle) Check

func (ws WindowStyle) Check() error

return nil if there is no error

Jump to

Keyboard shortcuts

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