pixel: github.com/faiface/pixel/pixelgl Index | Files

package pixelgl

import "github.com/faiface/pixel/pixelgl"

Package pixelgl implements efficient OpenGL targets and utilities for the Pixel game development library, specifically Window and Canvas.

It also contains a few additional utilities to help extend Pixel with OpenGL graphical effects.

Index

Package Files

canvas.go doc.go glframe.go glpicture.go glshader.go gltriangles.go input.go joystick.go monitor.go run.go util.go window.go

Constants

const (
    MouseButton1      = Button(glfw.MouseButton1)
    MouseButton2      = Button(glfw.MouseButton2)
    MouseButton3      = Button(glfw.MouseButton3)
    MouseButton4      = Button(glfw.MouseButton4)
    MouseButton5      = Button(glfw.MouseButton5)
    MouseButton6      = Button(glfw.MouseButton6)
    MouseButton7      = Button(glfw.MouseButton7)
    MouseButton8      = Button(glfw.MouseButton8)
    MouseButtonLast   = Button(glfw.MouseButtonLast)
    MouseButtonLeft   = Button(glfw.MouseButtonLeft)
    MouseButtonRight  = Button(glfw.MouseButtonRight)
    MouseButtonMiddle = Button(glfw.MouseButtonMiddle)
)

List of all mouse buttons.

const (
    KeyUnknown      = Button(glfw.KeyUnknown)
    KeySpace        = Button(glfw.KeySpace)
    KeyApostrophe   = Button(glfw.KeyApostrophe)
    KeyComma        = Button(glfw.KeyComma)
    KeyMinus        = Button(glfw.KeyMinus)
    KeyPeriod       = Button(glfw.KeyPeriod)
    KeySlash        = Button(glfw.KeySlash)
    Key0            = Button(glfw.Key0)
    Key1            = Button(glfw.Key1)
    Key2            = Button(glfw.Key2)
    Key3            = Button(glfw.Key3)
    Key4            = Button(glfw.Key4)
    Key5            = Button(glfw.Key5)
    Key6            = Button(glfw.Key6)
    Key7            = Button(glfw.Key7)
    Key8            = Button(glfw.Key8)
    Key9            = Button(glfw.Key9)
    KeySemicolon    = Button(glfw.KeySemicolon)
    KeyEqual        = Button(glfw.KeyEqual)
    KeyA            = Button(glfw.KeyA)
    KeyB            = Button(glfw.KeyB)
    KeyC            = Button(glfw.KeyC)
    KeyD            = Button(glfw.KeyD)
    KeyE            = Button(glfw.KeyE)
    KeyF            = Button(glfw.KeyF)
    KeyG            = Button(glfw.KeyG)
    KeyH            = Button(glfw.KeyH)
    KeyI            = Button(glfw.KeyI)
    KeyJ            = Button(glfw.KeyJ)
    KeyK            = Button(glfw.KeyK)
    KeyL            = Button(glfw.KeyL)
    KeyM            = Button(glfw.KeyM)
    KeyN            = Button(glfw.KeyN)
    KeyO            = Button(glfw.KeyO)
    KeyP            = Button(glfw.KeyP)
    KeyQ            = Button(glfw.KeyQ)
    KeyR            = Button(glfw.KeyR)
    KeyS            = Button(glfw.KeyS)
    KeyT            = Button(glfw.KeyT)
    KeyU            = Button(glfw.KeyU)
    KeyV            = Button(glfw.KeyV)
    KeyW            = Button(glfw.KeyW)
    KeyX            = Button(glfw.KeyX)
    KeyY            = Button(glfw.KeyY)
    KeyZ            = Button(glfw.KeyZ)
    KeyLeftBracket  = Button(glfw.KeyLeftBracket)
    KeyBackslash    = Button(glfw.KeyBackslash)
    KeyRightBracket = Button(glfw.KeyRightBracket)
    KeyGraveAccent  = Button(glfw.KeyGraveAccent)
    KeyWorld1       = Button(glfw.KeyWorld1)
    KeyWorld2       = Button(glfw.KeyWorld2)
    KeyEscape       = Button(glfw.KeyEscape)
    KeyEnter        = Button(glfw.KeyEnter)
    KeyTab          = Button(glfw.KeyTab)
    KeyBackspace    = Button(glfw.KeyBackspace)
    KeyInsert       = Button(glfw.KeyInsert)
    KeyDelete       = Button(glfw.KeyDelete)
    KeyRight        = Button(glfw.KeyRight)
    KeyLeft         = Button(glfw.KeyLeft)
    KeyDown         = Button(glfw.KeyDown)
    KeyUp           = Button(glfw.KeyUp)
    KeyPageUp       = Button(glfw.KeyPageUp)
    KeyPageDown     = Button(glfw.KeyPageDown)
    KeyHome         = Button(glfw.KeyHome)
    KeyEnd          = Button(glfw.KeyEnd)
    KeyCapsLock     = Button(glfw.KeyCapsLock)
    KeyScrollLock   = Button(glfw.KeyScrollLock)
    KeyNumLock      = Button(glfw.KeyNumLock)
    KeyPrintScreen  = Button(glfw.KeyPrintScreen)
    KeyPause        = Button(glfw.KeyPause)
    KeyF1           = Button(glfw.KeyF1)
    KeyF2           = Button(glfw.KeyF2)
    KeyF3           = Button(glfw.KeyF3)
    KeyF4           = Button(glfw.KeyF4)
    KeyF5           = Button(glfw.KeyF5)
    KeyF6           = Button(glfw.KeyF6)
    KeyF7           = Button(glfw.KeyF7)
    KeyF8           = Button(glfw.KeyF8)
    KeyF9           = Button(glfw.KeyF9)
    KeyF10          = Button(glfw.KeyF10)
    KeyF11          = Button(glfw.KeyF11)
    KeyF12          = Button(glfw.KeyF12)
    KeyF13          = Button(glfw.KeyF13)
    KeyF14          = Button(glfw.KeyF14)
    KeyF15          = Button(glfw.KeyF15)
    KeyF16          = Button(glfw.KeyF16)
    KeyF17          = Button(glfw.KeyF17)
    KeyF18          = Button(glfw.KeyF18)
    KeyF19          = Button(glfw.KeyF19)
    KeyF20          = Button(glfw.KeyF20)
    KeyF21          = Button(glfw.KeyF21)
    KeyF22          = Button(glfw.KeyF22)
    KeyF23          = Button(glfw.KeyF23)
    KeyF24          = Button(glfw.KeyF24)
    KeyF25          = Button(glfw.KeyF25)
    KeyKP0          = Button(glfw.KeyKP0)
    KeyKP1          = Button(glfw.KeyKP1)
    KeyKP2          = Button(glfw.KeyKP2)
    KeyKP3          = Button(glfw.KeyKP3)
    KeyKP4          = Button(glfw.KeyKP4)
    KeyKP5          = Button(glfw.KeyKP5)
    KeyKP6          = Button(glfw.KeyKP6)
    KeyKP7          = Button(glfw.KeyKP7)
    KeyKP8          = Button(glfw.KeyKP8)
    KeyKP9          = Button(glfw.KeyKP9)
    KeyKPDecimal    = Button(glfw.KeyKPDecimal)
    KeyKPDivide     = Button(glfw.KeyKPDivide)
    KeyKPMultiply   = Button(glfw.KeyKPMultiply)
    KeyKPSubtract   = Button(glfw.KeyKPSubtract)
    KeyKPAdd        = Button(glfw.KeyKPAdd)
    KeyKPEnter      = Button(glfw.KeyKPEnter)
    KeyKPEqual      = Button(glfw.KeyKPEqual)
    KeyLeftShift    = Button(glfw.KeyLeftShift)
    KeyLeftControl  = Button(glfw.KeyLeftControl)
    KeyLeftAlt      = Button(glfw.KeyLeftAlt)
    KeyLeftSuper    = Button(glfw.KeyLeftSuper)
    KeyRightShift   = Button(glfw.KeyRightShift)
    KeyRightControl = Button(glfw.KeyRightControl)
    KeyRightAlt     = Button(glfw.KeyRightAlt)
    KeyRightSuper   = Button(glfw.KeyRightSuper)
    KeyMenu         = Button(glfw.KeyMenu)
    KeyLast         = Button(glfw.KeyLast)
)

List of all keyboard buttons.

const (
    Joystick1  = Joystick(glfw.Joystick1)
    Joystick2  = Joystick(glfw.Joystick2)
    Joystick3  = Joystick(glfw.Joystick3)
    Joystick4  = Joystick(glfw.Joystick4)
    Joystick5  = Joystick(glfw.Joystick5)
    Joystick6  = Joystick(glfw.Joystick6)
    Joystick7  = Joystick(glfw.Joystick7)
    Joystick8  = Joystick(glfw.Joystick8)
    Joystick9  = Joystick(glfw.Joystick9)
    Joystick10 = Joystick(glfw.Joystick10)
    Joystick11 = Joystick(glfw.Joystick11)
    Joystick12 = Joystick(glfw.Joystick12)
    Joystick13 = Joystick(glfw.Joystick13)
    Joystick14 = Joystick(glfw.Joystick14)
    Joystick15 = Joystick(glfw.Joystick15)
    Joystick16 = Joystick(glfw.Joystick16)

    JoystickLast = Joystick(glfw.JoystickLast)
)

List all of the joysticks.

func Run Uses

func Run(run func())

Run is essentially the main function of PixelGL. It exists mainly due to the technical limitations of OpenGL and operating systems. In short, all graphics and window manipulating calls must be done from the main thread. Run makes this possible.

Call this function from the main function of your application. This is necessary, so that Run runs on the main thread.

func run() {
    // interact with Pixel and PixelGL from here (even concurrently)
}

func main() {
    pixel.Run(run)
}

You can spawn any number of goroutines from your run function and interact with PixelGL concurrently. The only condition is that the Run function is called from your main function.

type Button Uses

type Button int

Button is a keyboard or mouse button. Why distinguish?

func (Button) String Uses

func (b Button) String() string

String returns a human-readable string describing the Button.

type Canvas Uses

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

Canvas is an off-screen rectangular BasicTarget and Picture at the same time, that you can draw onto.

It supports TrianglesPosition, TrianglesColor, TrianglesPicture and PictureColor.

func NewCanvas Uses

func NewCanvas(bounds pixel.Rect) *Canvas

NewCanvas creates a new empty, fully transparent Canvas with given bounds.

func (*Canvas) Bounds Uses

func (c *Canvas) Bounds() pixel.Rect

Bounds returns the rectangular bounds of the Canvas.

func (*Canvas) Clear Uses

func (c *Canvas) Clear(color color.Color)

Clear fills the whole Canvas with a single color.

func (*Canvas) Color Uses

func (c *Canvas) Color(at pixel.Vec) pixel.RGBA

Color returns the color of the pixel over the given position inside the Canvas.

func (*Canvas) Draw Uses

func (c *Canvas) Draw(t pixel.Target, matrix pixel.Matrix)

Draw draws the content of the Canvas onto another Target, transformed by the given Matrix, just like if it was a Sprite containing the whole Canvas.

func (*Canvas) DrawColorMask Uses

func (c *Canvas) DrawColorMask(t pixel.Target, matrix pixel.Matrix, mask color.Color)

DrawColorMask draws the content of the Canvas onto another Target, transformed by the given Matrix and multiplied by the given mask, just like if it was a Sprite containing the whole Canvas.

If the color mask is nil, a fully opaque white mask will be used causing no effect.

func (*Canvas) Frame Uses

func (c *Canvas) Frame() *glhf.Frame

Frame returns the underlying OpenGL Frame of this Canvas.

func (*Canvas) MakePicture Uses

func (c *Canvas) MakePicture(p pixel.Picture) pixel.TargetPicture

MakePicture create a specialized copy of the supplied Picture that draws onto this Canvas.

PictureColor is supported.

func (*Canvas) MakeTriangles Uses

func (c *Canvas) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles

MakeTriangles creates a specialized copy of the supplied Triangles that draws onto this Canvas.

TrianglesPosition, TrianglesColor and TrianglesPicture are supported.

func (*Canvas) Pixels Uses

func (c *Canvas) Pixels() []uint8

Pixels returns an alpha-premultiplied RGBA sequence of the content of the Canvas.

func (*Canvas) SetBounds Uses

func (c *Canvas) SetBounds(bounds pixel.Rect)

SetBounds resizes the Canvas to the new bounds. Old content will be preserved.

func (*Canvas) SetColorMask Uses

func (c *Canvas) SetColorMask(col color.Color)

SetColorMask sets a color that every color in triangles or a picture will be multiplied by.

func (*Canvas) SetComposeMethod Uses

func (c *Canvas) SetComposeMethod(cmp pixel.ComposeMethod)

SetComposeMethod sets a Porter-Duff composition method to be used in the following draws onto this Canvas.

func (*Canvas) SetFragmentShader Uses

func (c *Canvas) SetFragmentShader(src string)

SetFragmentShader allows you to set a new fragment shader on the underlying framebuffer. Argument "src" is the GLSL source, not a filename.

func (*Canvas) SetMatrix Uses

func (c *Canvas) SetMatrix(m pixel.Matrix)

SetMatrix sets a Matrix that every point will be projected by.

func (*Canvas) SetPixels Uses

func (c *Canvas) SetPixels(pixels []uint8)

SetPixels replaces the content of the Canvas with the provided pixels. The provided slice must be an alpha-premultiplied RGBA sequence of correct length (4 * width * height).

func (*Canvas) SetSmooth Uses

func (c *Canvas) SetSmooth(smooth bool)

SetSmooth sets whether stretched Pictures drawn onto this Canvas should be drawn smooth or pixely.

func (*Canvas) SetUniform Uses

func (c *Canvas) SetUniform(name string, value interface{})

SetUniform will update the named uniform with the value of any supported underlying attribute variable. If the uniform already exists, including defaults, they will be reassigned to the new value. The value can be a pointer.

func (*Canvas) Smooth Uses

func (c *Canvas) Smooth() bool

Smooth returns whether stretched Pictures drawn onto this Canvas are set to be drawn smooth or pixely.

func (*Canvas) Texture Uses

func (c *Canvas) Texture() *glhf.Texture

Texture returns the underlying OpenGL Texture of this Canvas.

Implements GLPicture interface.

type GLFrame Uses

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

GLFrame is a type that helps implementing OpenGL Targets. It implements most common methods to avoid code redundancy. It contains an glhf.Frame that you can draw on.

func NewGLFrame Uses

func NewGLFrame(bounds pixel.Rect) *GLFrame

NewGLFrame creates a new GLFrame with the given bounds.

func (*GLFrame) Bounds Uses

func (gf *GLFrame) Bounds() pixel.Rect

Bounds returns the current GLFrame's bounds.

func (*GLFrame) Color Uses

func (gf *GLFrame) Color(at pixel.Vec) pixel.RGBA

Color returns the color of the pixel under the specified position.

func (*GLFrame) Dirty Uses

func (gf *GLFrame) Dirty()

Dirty marks the GLFrame as changed. Always call this method when you draw onto the GLFrame's Frame.

func (*GLFrame) Frame Uses

func (gf *GLFrame) Frame() *glhf.Frame

Frame returns the GLFrame's Frame that you can draw on.

func (*GLFrame) SetBounds Uses

func (gf *GLFrame) SetBounds(bounds pixel.Rect)

SetBounds resizes the GLFrame to the new bounds.

func (*GLFrame) Texture Uses

func (gf *GLFrame) Texture() *glhf.Texture

Texture returns the underlying Texture of the GLFrame's Frame.

Implements GLPicture interface.

type GLPicture Uses

type GLPicture interface {
    pixel.PictureColor
    Texture() *glhf.Texture
}

GLPicture is a pixel.PictureColor with a Texture. All OpenGL Targets should implement and accept this interface, because it enables seamless drawing of one to another.

Implementing this interface on an OpenGL Target enables other OpenGL Targets to efficiently draw that Target onto them.

func NewGLPicture Uses

func NewGLPicture(p pixel.Picture) GLPicture

NewGLPicture creates a new GLPicture with it's own static OpenGL texture. This function always allocates a new texture that cannot (shouldn't) be further modified.

type GLTriangles Uses

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

GLTriangles are OpenGL triangles implemented using glhf.VertexSlice.

Triangles returned from this function support TrianglesPosition, TrianglesColor and TrianglesPicture. If you need to support more, you can "override" SetLen and Update methods.

func NewGLTriangles Uses

func NewGLTriangles(shader *glhf.Shader, t pixel.Triangles) *GLTriangles

NewGLTriangles returns GLTriangles initialized with the data from the supplied Triangles.

Only draw the Triangles using the provided Shader.

func (*GLTriangles) Color Uses

func (gt *GLTriangles) Color(i int) pixel.RGBA

Color returns the Color property of the i-th vertex.

func (*GLTriangles) Copy Uses

func (gt *GLTriangles) Copy() pixel.Triangles

Copy returns an independent copy of this GLTriangles.

The returned Triangles are *GLTriangles as the underlying type.

func (*GLTriangles) Len Uses

func (gt *GLTriangles) Len() int

Len returns the number of vertices.

func (*GLTriangles) Picture Uses

func (gt *GLTriangles) Picture(i int) (pic pixel.Vec, intensity float64)

Picture returns the Picture property of the i-th vertex.

func (*GLTriangles) Position Uses

func (gt *GLTriangles) Position(i int) pixel.Vec

Position returns the Position property of the i-th vertex.

func (*GLTriangles) SetLen Uses

func (gt *GLTriangles) SetLen(length int)

SetLen efficiently resizes GLTriangles to len.

Time complexity is amortized O(1).

func (*GLTriangles) Shader Uses

func (gt *GLTriangles) Shader() *glhf.Shader

Shader returns the GLTriangles's associated shader.

func (*GLTriangles) Slice Uses

func (gt *GLTriangles) Slice(i, j int) pixel.Triangles

Slice returns a sub-Triangles of this GLTriangles in range [i, j).

func (*GLTriangles) Update Uses

func (gt *GLTriangles) Update(t pixel.Triangles)

Update copies vertex properties from the supplied Triangles into this GLTriangles.

The two Triangles (gt and t) must be of the same len.

func (*GLTriangles) VertexSlice Uses

func (gt *GLTriangles) VertexSlice() *glhf.VertexSlice

VertexSlice returns the VertexSlice of this GLTriangles.

You can use it to draw them.

type Joystick Uses

type Joystick int

Joystick is a joystick or controller.

type Monitor Uses

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

Monitor represents a physical display attached to your computer.

func Monitors Uses

func Monitors() []*Monitor

Monitors returns a slice of all currently available monitors.

func PrimaryMonitor Uses

func PrimaryMonitor() *Monitor

PrimaryMonitor returns the main monitor (usually the one with the taskbar and stuff).

func (*Monitor) BitDepth Uses

func (m *Monitor) BitDepth() (red, green, blue int)

BitDepth returns the number of bits per color of the Monitor.

func (*Monitor) Name Uses

func (m *Monitor) Name() string

Name returns a human-readable name of the Monitor.

func (*Monitor) PhysicalSize Uses

func (m *Monitor) PhysicalSize() (width, height float64)

PhysicalSize returns the size of the display area of the Monitor in millimeters.

func (*Monitor) Position Uses

func (m *Monitor) Position() (x, y float64)

Position returns the position of the upper-left corner of the Monitor in screen coordinates.

func (*Monitor) RefreshRate Uses

func (m *Monitor) RefreshRate() (rate float64)

RefreshRate returns the refresh frequency of the Monitor in Hz (refreshes/second).

func (*Monitor) Size Uses

func (m *Monitor) Size() (width, height float64)

Size returns the resolution of the Monitor in pixels.

func (*Monitor) VideoModes Uses

func (m *Monitor) VideoModes() (vmodes []VideoMode)

VideoModes returns all available video modes for the monitor.

type VideoMode Uses

type VideoMode struct {
    // Width is the width of the vide mode in pixels.
    Width int
    // Height is the height of the video mode in pixels.
    Height int
    // RefreshRate holds the refresh rate of the associated monitor in Hz.
    RefreshRate int
}

VideoMode represents all properties of a video mode and is associated with a monitor if it is used in fullscreen mode.

type Window Uses

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

Window is a window handler. Use this type to manipulate a window (input, drawing, etc.).

func NewWindow Uses

func NewWindow(cfg WindowConfig) (*Window, error)

NewWindow creates a new Window with it's properties specified in the provided config.

If Window creation fails, an error is returned (e.g. due to unavailable graphics device).

func (*Window) Bounds Uses

func (w *Window) Bounds() pixel.Rect

Bounds returns the current bounds of the Window.

func (*Window) Canvas Uses

func (w *Window) Canvas() *Canvas

Canvas returns the window's underlying Canvas

func (*Window) Clear Uses

func (w *Window) Clear(c color.Color)

Clear clears the Window with a single color.

func (*Window) Closed Uses

func (w *Window) Closed() bool

Closed returns the closed flag of the Window, which reports whether the Window should be closed.

The closed flag is automatically set when a user attempts to close the Window.

func (*Window) Color Uses

func (w *Window) Color(at pixel.Vec) pixel.RGBA

Color returns the color of the pixel over the given position inside the Window.

func (*Window) CursorVisible Uses

func (w *Window) CursorVisible() bool

CursorVisible returns the visibility status of the mouse cursor.

func (*Window) Destroy Uses

func (w *Window) Destroy()

Destroy destroys the Window. The Window can't be used any further.

func (*Window) Focused Uses

func (w *Window) Focused() bool

Focused returns true if the Window has input focus.

func (*Window) GetPos Uses

func (w *Window) GetPos() pixel.Vec

GetPos gets the position, in screen coordinates, of the upper-left corner of the client area of the window. The position is rounded to integers.

func (*Window) JoystickAxis Uses

func (w *Window) JoystickAxis(js Joystick, axis int) float64

JoystickAxis returns the value of a joystick axis at the last call to Window.Update. If the axis index is out of range, this will return 0.

This API is experimental.

func (*Window) JoystickAxisCount Uses

func (w *Window) JoystickAxisCount(js Joystick) int

JoystickAxisCount returns the number of axes a connected joystick has.

This API is experimental.

func (*Window) JoystickButtonCount Uses

func (w *Window) JoystickButtonCount(js Joystick) int

JoystickButtonCount returns the number of buttons a connected joystick has.

This API is experimental.

func (*Window) JoystickJustPressed Uses

func (w *Window) JoystickJustPressed(js Joystick, button int) bool

JoystickJustPressed returns whether the joystick Button has just been pressed down. If the button index is out of range, this will return false.

This API is experimental.

func (*Window) JoystickJustReleased Uses

func (w *Window) JoystickJustReleased(js Joystick, button int) bool

JoystickJustReleased returns whether the joystick Button has just been released up. If the button index is out of range, this will return false.

This API is experimental.

func (*Window) JoystickName Uses

func (w *Window) JoystickName(js Joystick) string

JoystickName returns the name of the joystick. A disconnected joystick will return an empty string.

This API is experimental.

func (*Window) JoystickPresent Uses

func (w *Window) JoystickPresent(js Joystick) bool

JoystickPresent returns if the joystick is currently connected.

This API is experimental.

func (*Window) JoystickPressed Uses

func (w *Window) JoystickPressed(js Joystick, button int) bool

JoystickPressed returns whether the joystick Button is currently pressed down. If the button index is out of range, this will return false.

This API is experimental.

func (*Window) JustPressed Uses

func (w *Window) JustPressed(button Button) bool

JustPressed returns whether the Button has just been pressed down.

func (*Window) JustReleased Uses

func (w *Window) JustReleased(button Button) bool

JustReleased returns whether the Button has just been released up.

func (*Window) MakePicture Uses

func (w *Window) MakePicture(p pixel.Picture) pixel.TargetPicture

MakePicture generates a specialized copy of the supplied Picture that will draw onto this Window.

Window supports PictureColor.

func (*Window) MakeTriangles Uses

func (w *Window) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles

MakeTriangles generates a specialized copy of the supplied Triangles that will draw onto this Window.

Window supports TrianglesPosition, TrianglesColor and TrianglesPicture.

func (*Window) Monitor Uses

func (w *Window) Monitor() *Monitor

Monitor returns a monitor the Window is fullscreen on. If the Window is not fullscreen, this function returns nil.

func (*Window) MouseInsideWindow Uses

func (w *Window) MouseInsideWindow() bool

MouseInsideWindow returns true if the mouse position is within the Window's Bounds.

func (*Window) MousePosition Uses

func (w *Window) MousePosition() pixel.Vec

MousePosition returns the current mouse position in the Window's Bounds.

func (*Window) MousePreviousPosition Uses

func (w *Window) MousePreviousPosition() pixel.Vec

MousePreviousPosition returns the previous mouse position in the Window's Bounds.

func (*Window) MouseScroll Uses

func (w *Window) MouseScroll() pixel.Vec

MouseScroll returns the mouse scroll amount (in both axes) since the last call to Window.Update.

func (*Window) Pressed Uses

func (w *Window) Pressed(button Button) bool

Pressed returns whether the Button is currently pressed down.

func (*Window) Repeated Uses

func (w *Window) Repeated(button Button) bool

Repeated returns whether a repeat event has been triggered on button.

Repeat event occurs repeatedly when a button is held down for some time.

func (*Window) SetBounds Uses

func (w *Window) SetBounds(bounds pixel.Rect)

SetBounds sets the bounds of the Window in pixels. Bounds can be fractional, but the actual size of the window will be rounded to integers.

func (*Window) SetClosed Uses

func (w *Window) SetClosed(closed bool)

SetClosed sets the closed flag of the Window.

This is useful when overriding the user's attempt to close the Window, or just to close the Window from within the program.

func (*Window) SetColorMask Uses

func (w *Window) SetColorMask(c color.Color)

SetColorMask sets a global color mask for the Window.

func (*Window) SetComposeMethod Uses

func (w *Window) SetComposeMethod(cmp pixel.ComposeMethod)

SetComposeMethod sets a Porter-Duff composition method to be used in the following draws onto this Window.

func (*Window) SetCursorVisible Uses

func (w *Window) SetCursorVisible(visible bool)

SetCursorVisible sets the visibility of the mouse cursor inside the Window client area.

func (*Window) SetMatrix Uses

func (w *Window) SetMatrix(m pixel.Matrix)

SetMatrix sets a Matrix that every point will be projected by.

func (*Window) SetMonitor Uses

func (w *Window) SetMonitor(monitor *Monitor)

SetMonitor sets the Window fullscreen on the given Monitor. If the Monitor is nil, the Window will be restored to windowed state instead.

The Window will be automatically set to the Monitor's resolution. If you want a different resolution, you will need to set it manually with SetBounds method.

func (*Window) SetMousePosition Uses

func (w *Window) SetMousePosition(v pixel.Vec)

SetMousePosition positions the mouse cursor anywhere within the Window's Bounds.

func (*Window) SetPos Uses

func (w *Window) SetPos(pos pixel.Vec)

SetPos sets the position, in screen coordinates, of the upper-left corner of the client area of the window. Position can be fractional, but the actual position of the window will be rounded to integers.

If it is a full screen window, this function does nothing.

func (*Window) SetSmooth Uses

func (w *Window) SetSmooth(smooth bool)

SetSmooth sets whether the stretched Pictures drawn onto this Window should be drawn smooth or pixely.

func (*Window) SetTitle Uses

func (w *Window) SetTitle(title string)

SetTitle changes the title of the Window.

func (*Window) SetVSync Uses

func (w *Window) SetVSync(vsync bool)

SetVSync sets whether the Window's Update should synchronize with the monitor refresh rate.

func (*Window) Smooth Uses

func (w *Window) Smooth() bool

Smooth returns whether the stretched Pictures drawn onto this Window are set to be drawn smooth or pixely.

func (*Window) Typed Uses

func (w *Window) Typed() string

Typed returns the text typed on the keyboard since the last call to Window.Update.

func (*Window) Update Uses

func (w *Window) Update()

Update swaps buffers and polls events. Call this method at the end of each frame.

func (*Window) UpdateInput Uses

func (w *Window) UpdateInput()

UpdateInput polls window events. Call this function to poll window events without swapping buffers. Note that the Update method invokes UpdateInput.

func (*Window) VSync Uses

func (w *Window) VSync() bool

VSync returns whether the Window is set to synchronize with the monitor refresh rate.

type WindowConfig Uses

type WindowConfig struct {
    // Title at the top of the Window.
    Title string

    // Icon specifies the icon images available to be used by the window. This is usually
    // displayed in the top bar of the window or in the task bar of the desktop environment.
    //
    // If passed one image, it will use that image, if passed an array of images those of or
    // closest to the sizes desired by the system are selected. The desired image sizes varies
    // depending on platform and system settings. The selected images will be rescaled as
    // needed. Good sizes include 16x16, 32x32 and 48x48.
    //
    // Note: Setting this value doesn't have an effect on OSX. You'll need to set the icon when
    // bundling your application for release.
    Icon []pixel.Picture

    // Bounds specify the bounds of the Window in pixels.
    Bounds pixel.Rect

    // If set to nil, the Window will be windowed. Otherwise it will be fullscreen on the
    // specified Monitor.
    Monitor *Monitor

    // Whether the Window is resizable.
    Resizable bool

    // Undecorated Window ommits the borders and decorations (close button, etc.).
    Undecorated bool

    // NoIconify specifies whether fullscreen windows should not automatically
    // iconify (and restore the previous video mode) on focus loss.
    NoIconify bool

    // AlwaysOnTop specifies whether the windowed mode window will be floating
    // above other regular windows, also called topmost or always-on-top.
    // This is intended primarily for debugging purposes and cannot be used to
    // implement proper full screen windows.
    AlwaysOnTop bool

    // VSync (vertical synchronization) synchronizes Window's framerate with the framerate of
    // the monitor.
    VSync bool
}

WindowConfig is a structure for specifying all possible properties of a Window. Properties are chosen in such a way, that you usually only need to set a few of them - defaults (zeros) should usually be sensible.

Note that you always need to set the Bounds of a Window.

Package pixelgl imports 11 packages (graph) and is imported by 65 packages. Updated 2019-06-13. Refresh now. Tools for package owners.