pixelgl

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

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

Constants

View Source
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.

View Source
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.

Variables

This section is empty.

Functions

func Run

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.

Types

type Button

type Button int

Button is a keyboard or mouse button. Why distinguish?

func (Button) String

func (b Button) String() string

String returns a human-readable string describing the Button.

type Canvas

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

func NewCanvas(bounds pixel.Rect) *Canvas

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

func (*Canvas) Bounds

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

Bounds returns the rectangular bounds of the Canvas.

func (*Canvas) Clear

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

Clear fills the whole Canvas with a single color.

func (*Canvas) Color

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

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 added in v0.6.0

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 added in v0.6.0

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

Frame returns the underlying OpenGL Frame of this Canvas.

func (*Canvas) MakePicture

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

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 added in v0.5.1

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

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

func (*Canvas) SetBounds

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

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

func (*Canvas) SetColorMask

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

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 added in v0.8.0

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

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

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

func (*Canvas) SetPixels added in v0.5.1

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

func (c *Canvas) SetSmooth(smooth bool)

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

func (*Canvas) SetUniform added in v0.8.0

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

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

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

Texture returns the underlying OpenGL Texture of this Canvas.

Implements GLPicture interface.

type GLFrame

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

func NewGLFrame(bounds pixel.Rect) *GLFrame

NewGLFrame creates a new GLFrame with the given bounds.

func (*GLFrame) Bounds

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

Bounds returns the current GLFrame's bounds.

func (*GLFrame) Color

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

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

func (*GLFrame) Dirty

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

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

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

func (*GLFrame) SetBounds

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

SetBounds resizes the GLFrame to the new bounds.

func (*GLFrame) Texture

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

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

Implements GLPicture interface.

type GLPicture

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

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

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

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

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

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

func (*GLTriangles) Copy

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

func (gt *GLTriangles) Len() int

Len returns the number of vertices.

func (*GLTriangles) Picture

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

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

func (*GLTriangles) Position

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

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

func (*GLTriangles) SetLen

func (gt *GLTriangles) SetLen(length int)

SetLen efficiently resizes GLTriangles to len.

Time complexity is amortized O(1).

func (*GLTriangles) Shader

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

Shader returns the GLTriangles's associated shader.

func (*GLTriangles) Slice

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

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

func (*GLTriangles) Update

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

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

VertexSlice returns the VertexSlice of this GLTriangles.

You can use it to draw them.

type Monitor

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

Monitor represents a physical display attached to your computer.

func Monitors

func Monitors() []*Monitor

Monitors returns a slice of all currently available monitors.

func PrimaryMonitor

func PrimaryMonitor() *Monitor

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

func (*Monitor) BitDepth

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

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

func (*Monitor) Name

func (m *Monitor) Name() string

Name returns a human-readable name of the Monitor.

func (*Monitor) PhysicalSize

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

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

func (*Monitor) Position

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

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

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

func (*Monitor) Size

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

Size returns the resolution of the Monitor in pixels.

func (*Monitor) VideoModes added in v0.8.0

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

VideoModes returns all available video modes for the monitor.

type VideoMode added in v0.8.0

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

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

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

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

Bounds returns the current bounds of the Window.

func (*Window) Canvas added in v0.8.0

func (w *Window) Canvas() *Canvas

Canvas returns the window's underlying Canvas

func (*Window) Clear

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

Clear clears the Window with a single color.

func (*Window) Closed

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

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 added in v0.6.0

func (w *Window) CursorVisible() bool

CursorVisible returns the visibility status of the mouse cursor.

func (*Window) Destroy

func (w *Window) Destroy()

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

func (*Window) Focused

func (w *Window) Focused() bool

Focused returns true if the Window has input focus.

func (*Window) GetPos added in v0.7.0

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) JustPressed

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

JustPressed returns whether the Button has just been pressed down.

func (*Window) JustReleased

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

JustReleased returns whether the Button has just been released up.

func (*Window) MakePicture

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

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

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) MousePosition

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

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

func (*Window) MouseScroll

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

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

Pressed returns whether the Button is currently pressed down.

func (*Window) Repeated added in v0.6.0

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

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

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

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

SetColorMask sets a global color mask for the Window.

func (*Window) SetComposeMethod

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 added in v0.6.0

func (w *Window) SetCursorVisible(visible bool)

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

func (*Window) SetMatrix

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

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

func (*Window) SetMonitor

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) SetPos added in v0.7.0

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

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

func (w *Window) SetTitle(title string)

SetTitle changes the title of the Window.

func (*Window) SetVSync

func (w *Window) SetVSync(vsync bool)

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

func (*Window) Smooth

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 added in v0.6.0

func (w *Window) Typed() string

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

func (*Window) Update

func (w *Window) Update()

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

func (*Window) UpdateInput added in v0.7.0

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

func (w *Window) VSync() bool

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

type WindowConfig

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

	// 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.

Jump to

Keyboard shortcuts

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