window

package
v0.0.0-...-63a8a9f Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: Unlicense Imports: 11 Imported by: 0

Documentation

Overview

Package window handles window creation, drawing and events. It uses a small subset of the features provided by the SFML library version 2.5 1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Style

type Style int

Style specifies the style and behavior of windows.

const (
	// Fixed states that the window cannot be resized.
	Fixed Style = iota
	// FullScreen states that the window is in full screen mode.
	FullScreen
)

Window styles.

type Window

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

A Window represents a graphical window capable of handling draw operations and window events. It implements the wandi.Window interface.

func Open

func Open(width, height int, style ...Style) (*Window, error)

Open opens a new window of the specified dimensions. An optional window style may be provided. By default the window is resizeable and not in full screen mode.

Note: The main thread must be used for both window creation and event handling. It is perfectly fine to use separate threads for rendering and event handling, as long as all event handling takes place in the main thread.

Note: The Close method of the window must be called when finished using it.

func (*Window) Close

func (win *Window) Close()

Close closes the window.

func (*Window) CursorPos

func (win *Window) CursorPos() image.Point

CursorPos returns the current cursor position within the given window.

func (*Window) Display

func (win *Window) Display()

Display displays what has been rendered so far to the window.

func (*Window) Draw

func (win *Window) Draw(dp image.Point, src wandi.Image) error

Draw draws the entire src image onto the window starting at the destination point dp.

func (*Window) DrawRect

func (win *Window) DrawRect(dp image.Point, src wandi.Image, sr image.Rectangle) error

DrawRect draws a subset of the src image, as defined by the source rectangle sr, onto the window starting at the destination point dp.

func (*Window) Fill

func (win *Window) Fill(c color.Color)

Fill fills the entire window with the provided color.

func (*Window) GrabCursor

func (win *Window) GrabCursor(grab bool)

GrabCursor specifies whether to grab the mouse cursor within the given window.

func (*Window) Height

func (win *Window) Height() int

Height returns the height of the window.

func (Window) PollEvent

func (win Window) PollEvent() we.Event

PollEvent returns a pending event from the event queue or nil if the queue was empty. Note that more than one event may be present in the event queue.

Note: The main thread must be used for both window creation and event handling. It is perfectly fine to use separate threads for rendering and event handling, as long as all event handling takes place in the main thread.

Note: Some internal window events of SFML depend on calls to PollEvent to take effect. For instance a call to SetTitle will not update the window title until the next call of PollEvent.

func (*Window) SetActive

func (win *Window) SetActive()

SetActive activates the CPU context of the window.

func (*Window) SetCursorPos

func (win *Window) SetCursorPos(pt image.Point)

SetCursorPos sets the position of the cursor in the given window.

func (*Window) SetTitle

func (win *Window) SetTitle(title string)

SetTitle sets the title of the window.

Note: The title will be updated on the next call to PollEvent.

func (*Window) ShowCursor

func (win *Window) ShowCursor(visible bool)

ShowCursor displays or hides the mouse cursor depending on the value of visible. It is visible by default.

func (*Window) Width

func (win *Window) Width() int

Width returns the width of the window.

Jump to

Keyboard shortcuts

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