chippy.v1: azul3d.org/chippy.v1 Index | Files

package chippy

import "azul3d.org/chippy.v1"

Package chippy implements cross platform window management, and window rendering access.

Thread Safety

Chippy is thread safe, and can be fully used from within multiple goroutines without any worry about operating system threads, or locks, etc.

It should be explicitly noted that while Chippy and it's API's are thread safe, anything to do with OpenGL needs special care regarding thread safety.

OpenGL Support

Creating both new and old style OpenGL contexts is supported (this allows creating an OpenGL context of any version). Many platform specific OpenGL functions are abstracted away for you (such as WGL, GLX, etc extensions). Shared OpenGL contexts, multisampling, vertical sync toggling, etc are all supported.

Chippy works with all OpenGL wrappers, it does not provide any OpenGL wrappers itself (although azul3d.org/v1/native/gl has some good ones).

Although we handle the platform-specific parts of OpenGL for you, no magic is performed: OpenGL still uses thread local storage so when working with OpenGL's API you'll need to utilize runtime.LockOSThread() properly.

Microsoft Windows FAQ

What versions of Windows are supported?

Chippy requires Windows XP or higher.

It might also work on Windows 2000 Professional/Server editions, but
support for these version is not tested actively.

How do I add an application icon to my program?

You can place .syso files with the source of your main package, and the
6l/8l linker will link that file with your program.

Take an look at the "app.rc" file inside the chippy/tests/data folder for
more information. Also look at the single window test located in the
chippy/tests/chippy_window_single directory for an example of this.

How do I stop the command prompt from appearing when my application starts?

You can stop the terminal from appearing by using the 8l/6l linker flag
"-H windowsgui" on your 'go install' command, like so:

go install -ldflags "-H windowsgui" path/to/pkg

Linux-X11 FAQ

What X extensions are needed?

GLX 1.4 (required, for OpenGL tasks, 1.4 is needed for multisampling)
XRandR 1.2 (optional, used for screen-mode switching, etc)
XInput 2.0 (required, for raw mouse input)
XKB 1.0 (required, for keyboard input)

What about a pure Wayland client?

A pure Wayland implementation would be interesting and could be enabled
using a build-tag until Wayland becomes more main-stream, but for now
Wayland does have the ability to still run X applications so Chippy does
still work on Wayland.

A pure Wayland client is not a priority right now, but we are open to
working with a contributor who would like to add this feature.

Index

Package Files

blit.go chippy.go chippy_linux.go defaultIcon.bin.go defaultIcon.init.go doc.go errors.go glconfig.go opengl.go opengl_linux.go screen.go screen_linux.go screenmode.go types.go window.go window_linux.go windowevents.go

Variables

var (
    ErrInvalidGLXVersion = errors.New("GLX version 1.4 is required but not available.")
    ErrInvalidXKBVersion = errors.New(fmt.Sprintf("XKB version %d.%d is required but not available.", xkbMinMajor, xkbMinMinor))
)
var (
    // Could happen due to lack of hardware support for the screen mode, or the driver may reject
    // the screen mode as well, really this could be generically anything but is typically an
    // hardware or driver issue using the screen mode.
    //
    // You should never take away the screen mode as an option from the user; as it is possible the
    // user may change an configuration setting of some sort with their operating system that will
    // allow the screen mode to be used properly.
    ErrBadScreenMode = errors.New("unable to switch screen mode; hardware or drivers do not support the mode.")

    // Only Microsoft Windows will ever return this error, systems that use DualView will sometimes
    // ignore screen mode change requests.
    ErrDualViewCapable = errors.New("unable to switch screen mode; the system is DualView capable.")
)
var (
    // Describes the worst possible OpenGL frame buffer configuration, this is
    // typically used as a parameter to GLChooseConfig.
    GLWorstConfig = &GLConfig{
        Accelerated:    false,
        Transparent:    false,
        RedBits:        0,
        GreenBits:      0,
        BlueBits:       0,
        AlphaBits:      0,
        AccumRedBits:   0,
        AccumGreenBits: 0,
        AccumBlueBits:  0,
        AccumAlphaBits: 0,
        Samples:        0,
        AuxBuffers:     0,
        DepthBits:      0,
        StencilBits:    0,
        DoubleBuffered: false,
        StereoScopic:   false,
    }

    // Describes the worst possible OpenGL frame buffer configuration while
    // still being hardware-accelerated by the graphics card, this is typically
    // used as a parameter to GLChooseConfig.
    GLWorstHWConfig = &GLConfig{
        Accelerated:    true,
        Transparent:    false,
        RedBits:        0,
        GreenBits:      0,
        BlueBits:       0,
        AlphaBits:      0,
        AccumRedBits:   0,
        AccumGreenBits: 0,
        AccumBlueBits:  0,
        AccumAlphaBits: 0,
        Samples:        0,
        AuxBuffers:     0,
        DepthBits:      0,
        StencilBits:    0,
        DoubleBuffered: false,
        StereoScopic:   false,
    }

    // Describes the best possible OpenGL frame buffer configuration that does
    // not have any transparency, this is typically used as a parameter to
    // GLChooseConfig.
    GLBestConfig = &GLConfig{
        Accelerated:    true,
        Transparent:    true,
        RedBits:        255,
        GreenBits:      255,
        BlueBits:       255,
        AlphaBits:      255,
        AccumRedBits:   255,
        AccumGreenBits: 255,
        AccumBlueBits:  255,
        AccumAlphaBits: 255,
        Samples:        255,
        AuxBuffers:     255,
        DepthBits:      255,
        StencilBits:    255,
        DoubleBuffered: true,
        StereoScopic:   false,
    }
)
var (
    ErrGLVersionNotSupported = errors.New("opengl version is not supported")
)

func DisplayName Uses

func DisplayName() string

DisplayName returns the display_name string, as it was passed into SetDisplayName.

This function is only available on Linux.

func Exit Uses

func Exit()

Exit will exit the main loop previously entered via MainLoop(). All windows will be destroyed, etc.

You may call Init() again after calling this function should you want to re-gain access to the API.

func Init Uses

func Init() error

Init initializes Chippy, returning an error if there is a problem initializing some lower level part of Chippy, if an error was returned, it is disallowed to call any other Chippy functions. (And any attempt to do so will cause the program to panic.)

func IsInit Uses

func IsInit() bool

IsInit returns whether Chippy has been initialized via a previous call to Init().

IsInit() returns false if Destroy() was previously called.

func MainLoop Uses

func MainLoop()

MainLoop enters chippy's main loop.

This function *must* be called on the main thread (due to the restrictions that some platforms place, I.e. Cocoa on OS-X)

It's best to place this function inside either your init or main function.

This function will not return until chippy.Exit() is called.

If chippy is not initialized (via an previous call to the Init() function) then a panic will occur.

func MainLoopFrames Uses

func MainLoopFrames() chan func() bool

MainLoopFrames returns an channel of functions which return an boolean status as to whether you should continue running the 'main loop'.

Typically you would not use this function and would instead use the MainLoop() function.

This is for advanced users where the main loop is required to be shared with some other external library. I.e. this allows for communicative main loop handling.

See the MainLoop() function source code in chippy.go for an example of using this function properly.

This function should only really be called once (the same channel is always returned).

func RefreshScreens Uses

func RefreshScreens()

RefreshScreens queries for all available screens, and updates the internal cache returned by the Screens() function, such that the Screens() function returns new set of attatched/detatched Screen devices.

func Screens Uses

func Screens() []*Screen

Screens returns all available, attached, and activated screens possible. Once this function is called, the result is cached such that future calls to this function are faster and return the cached result.

To update the internal screen cache, see the RefreshScreens function.

func SetDebugOutput Uses

func SetDebugOutput(w io.Writer)

SetDebugOutput specifies the io.Writer that debug output will be written to (ioutil.Discard by default).

func SetDisplayName Uses

func SetDisplayName(displayName string)

SetDisplayName sets the string that will be passed into XOpenDisplay; equivalent to the DISPLAY environment variable on posix complaint systems.

If set, this is used in place of the default DISPLAY environment variable.

This function is only available on Linux.

type Blitable Uses

type Blitable interface {
    // PixelBlit blits the specified RGBA image onto the window, at the given X
    // and Y coordinates.
    PixelBlit(x, y uint, pixels *image.RGBA)

    // PixelClear clears the given rectangle on the window's client region.
    PixelClear(rect image.Rectangle)
}

type CloseEvent Uses

type CloseEvent struct {
    T time.Time
}

CloseEvent is an event where the user attempted to close the window, using either the exit button, an quick-key combination like alt+F4, etc.

func (CloseEvent) String Uses

func (ev CloseEvent) String() string

String returns an string representation of this event.

func (CloseEvent) Time Uses

func (ev CloseEvent) Time() time.Time

Time implements the generic event interface.

type Cursor Uses

type Cursor struct {
    // Cursor image, internally it will be converted to an RGBA image.
    Image image.Image

    // Cursor Hotspot
    X, Y uint
}

Cursor represents the image and hotspot of an graphical mouse cursor.

type CursorPositionEvent Uses

type CursorPositionEvent struct {
    // Position of cursor relative to the window's client region.
    X, Y float64

    T   time.Time
}

CursorPositionEvent is an event where the user moved the mouse cursor inside the window's client region.

func (CursorPositionEvent) String Uses

func (ev CursorPositionEvent) String() string

String returns an string representation of this event.

func (CursorPositionEvent) Time Uses

func (ev CursorPositionEvent) Time() time.Time

Time implements the generic event interface.

type CursorWithinEvent Uses

type CursorWithinEvent struct {
    // Weather the mouse cursor is within the window's client region or not.
    Within bool

    T   time.Time
}

CursorWithinEvent is an event where the user moved the mouse cursor inside or outside the window's client region.

func (CursorWithinEvent) String Uses

func (ev CursorWithinEvent) String() string

String returns an string representation of this event.

func (CursorWithinEvent) Time Uses

func (ev CursorWithinEvent) Time() time.Time

Time implements the generic event interface.

type DestroyedEvent Uses

type DestroyedEvent struct {
    T time.Time
}

DestroyedEvent is an event where the window was destroyed.

func (DestroyedEvent) String Uses

func (ev DestroyedEvent) String() string

String returns an string representation of this event.

func (DestroyedEvent) Time Uses

func (ev DestroyedEvent) Time() time.Time

Time implements the generic event interface.

type Event Uses

type Event interface {
    Time() time.Time
}

Event represents an event of some sort. The only requirement is that the event specify the point in time at which it happened.

Normally you will use an type assertion or type switch to retrieve more useful information from the underlying type.

type FocusedEvent Uses

type FocusedEvent struct {
    // Weather the window has focus or not.
    Focused bool

    T   time.Time
}

FocusedEvent is an event where the user changed the focus of the window.

func (FocusedEvent) String Uses

func (ev FocusedEvent) String() string

String returns an string representation of this event.

func (FocusedEvent) Time Uses

func (ev FocusedEvent) Time() time.Time

Time implements the generic event interface.

type GLConfig Uses

type GLConfig struct {

    // Tells whether this configuration is hardware accelerated or uses some
    // software implementation version of OpenGL.
    //
    // Note: Most software implementations are very low OpenGL versions. (I.e.
    // GL 1.1)
    Accelerated bool

    // Tells whether or not this config will support the window being
    // transparent while using OpenGL rendering
    Transparent bool

    // The number of bits that represent an color per pixel in the frame buffer.
    RedBits, GreenBits, BlueBits, AlphaBits uint8

    // The number of bits that represent an color per pixel in the accumulation
    // buffer.
    //
    // Note: GLSL shaders can perform an much better job of anything you would
    // be trying to do with the accumulation buffer.
    AccumRedBits, AccumGreenBits, AccumBlueBits, AccumAlphaBits uint8

    // Number of Multi Sample Anti Aliasing samples this configuration supports
    // (e.g. 2 for 2x MSAA, 16 for 16x MSAA, etc)
    Samples uint8

    // The number of auxiliary buffers available.
    //
    // Note: Auxiliary buffers are very rarely supported on most OpenGL
    // implementations (or choosing a configuration with them causes
    // non-accelerated rendering).
    //
    // For more information about this see the following forum URL:
    //     http://www.opengl.org/discussion_boards/showthread.php/171060-auxiliary-buffers
    AuxBuffers uint8

    // The number of bits that represent an pixel in the depth buffer.
    DepthBits uint8

    // The number of bits that represent an pixel in the stencil buffer.
    StencilBits uint8

    // Weather this frame buffer configuration is double buffered.
    DoubleBuffered bool

    // Weather this frame buffer configuration is stereoscopic capable.
    StereoScopic bool
    // contains filtered or unexported fields
}

GLConfig represents an single opengl (frame buffer / pixel) configuration.

func GLChooseConfig Uses

func GLChooseConfig(possible []*GLConfig, minConfig, maxConfig *GLConfig) *GLConfig

GLChooseConfig chooses an appropriate configuration from the slice of possible configurations.

The returned configuration will have at least minConfig's attributes, or nil will be returned if there is no configuration that has at least minConfig's attributes.

The returned configuration will have no greater than maxConfig's attributes, or nil will be returned if there is no configuration that is below maxConfig's attributes.

After the selection process excludes configurations below minConfig and above maxConfig, the compatible configurations not excluded are sorted in order of closest-to maxConfig in the order of the following configuration attributes:

Accelerated
RedBits, GreenBits, BlueBits, AlphaBits
DoubleBuffered
Samples
DepthBits
StencilBits
StereoScopic
Transparent
AccumRedBits, AccumGreenBits, AccumBlueBits, AccumAlphaBits
AuxBuffers

And the first configuration in the sorted list is returned. (I.e. you are most likely to recieve a Accelerated configuration, then one with high bytes per pixel, then one who is DoubleBuffered, Transparent, and so forth).

You may use the predefined GLWorstConfig and GLBestConfig variables if they suite your case.

func (*GLConfig) Equals Uses

func (c *GLConfig) Equals(other *GLConfig) bool

Equals tells whether this GLConfig equals the other GLFrameBufferConfig, by comparing each attribute.

func (*GLConfig) String Uses

func (c *GLConfig) String() string

type GLContext Uses

type GLContext interface {
}

GLContext represents an OpenGL contect; although it represents any value it represents an important idea of what it's data actually is.

type GLContextFlags Uses

type GLContextFlags uint8
const (
    GLDebug GLContextFlags = iota
    GLForwardCompatible
    GLCoreProfile
    GLCompatibilityProfile
)

type GLRenderable Uses

type GLRenderable interface {
    // GLConfigs returns all possible OpenGL configurations, these are valid
    // configurations that may be used in an call to GLSetConfig.
    GLConfigs() []*GLConfig

    // GLSetConfig sets the OpenGL framebuffer configuration, unlike other
    // window management libraries, this action may be performed multiple
    // times.
    //
    // The config parameter must be an *GLConfig that originally came from the
    // GLConfigs() function mainly do to the fact that it must be initialized
    // internally.
    GLSetConfig(config *GLConfig)

    // GLConfig returns the currently in use *GLConfig or nil, as it was
    // previously set via an call to GLSetConfig()
    GLConfig() *GLConfig

    // GLCreateContext creates an OpenGL context for the specified OpenGL
    // version, or returns an error in the event that we cannot create an
    // context for that version.
    //
    // The flags parameter may be any combination of the predifined flags, as
    // follows:
    //
    // GLDebug, you will receive an OpenGL debug context. *
    //
    // GLForwardCompatible, you will receive an OpenGL forward compatible
    // context. *
    //
    // GLCoreProfile, you will receive an OpenGL core context.
    //
    // GLCompatibilityProfile, you will receive an OpenGL compatibility
    // context.
    //
    // Only one of GLCoreProfile or GLCompatibilityProfile should be present.
    //
    // GLCompatabilityProfile will be used if neither GLCoreProfile or
    // GLCompatibilityProfile are present, or if both are present.
    //
    // * = It is not advised to use this flag in production.
    //
    // You must call GLSetConfig() before calling this function.
    //
    // If the error returned is not nil, it will either be an undefined error
    // (which may indicate an error with the user's graphics card, or drivers),
    // or will be ErrGLVersionNotSupported, which indicates that the requested
    // OpenGL version is not available.
    GLCreateContext(major, minor uint, flags GLContextFlags, share GLContext) (GLContext, error)

    // GLDestroyContext destroys the specified OpenGL context.
    //
    // The context to destroy must not be active in any thread, period.
    GLDestroyContext(c GLContext)

    // GLMakeCurrent makes the specified context the current, active OpenGL
    // context in the current operating system thread.
    //
    // To make the OpenGL context inactive, you may call this function using
    // nil as the context, which will release the context.
    //
    // This function may be called from any thread, but an OpenGL context may
    // only be active inside one thread at an time.
    GLMakeCurrent(c GLContext)

    // GLSwapBuffers swaps the front and back buffers of this Renderable.
    //
    // This function may only be called in the presence of an active OpenGL
    // context.
    //
    // If the GLConfig set previously via GLSetConfig() is not DoubleBuffered,
    // then this function is no-op.
    GLSwapBuffers()

    // GLSetVerticalSync sets the vertical refresh rate sync mode (vsync).
    //
    // This function should only be called in the presence of an active OpenGL
    // context or else the call may fail due to drivers or platforms that
    // require an active context (e.g. Mesa).
    GLSetVerticalSync(mode VSyncMode)
}

type MaximizedEvent Uses

type MaximizedEvent struct {
    // Weather or not the window is currently maximized.
    Maximized bool

    T   time.Time
}

MaximizedEvent is an event where the user maximized (or un-maximized) the window.

func (MaximizedEvent) String Uses

func (ev MaximizedEvent) String() string

String returns an string representation of this event.

func (MaximizedEvent) Time Uses

func (ev MaximizedEvent) Time() time.Time

Time implements the generic event interface.

type MinimizedEvent Uses

type MinimizedEvent struct {
    // Weather or not the window is currently minimized.
    Minimized bool

    T   time.Time
}

MinimizedEvent is an event where the user minimized (or un-minimized) the window.

func (MinimizedEvent) String Uses

func (ev MinimizedEvent) String() string

String returns an string representation of this event.

func (MinimizedEvent) Time Uses

func (ev MinimizedEvent) Time() time.Time

Time implements the generic event interface.

type NativeScreen Uses

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

type NativeScreenMode Uses

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

type NativeWindow Uses

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

func (*NativeWindow) GLConfig Uses

func (w *NativeWindow) GLConfig() *GLConfig

func (*NativeWindow) GLConfigs Uses

func (w *NativeWindow) GLConfigs() (configs []*GLConfig)

func (*NativeWindow) GLCreateContext Uses

func (w *NativeWindow) GLCreateContext(glVersionMajor, glVersionMinor uint, flags GLContextFlags, share GLContext) (GLContext, error)

func (*NativeWindow) GLDestroyContext Uses

func (w *NativeWindow) GLDestroyContext(c GLContext)

func (*NativeWindow) GLMakeCurrent Uses

func (w *NativeWindow) GLMakeCurrent(c GLContext)

func (*NativeWindow) GLSetConfig Uses

func (w *NativeWindow) GLSetConfig(config *GLConfig)

func (*NativeWindow) GLSetVerticalSync Uses

func (w *NativeWindow) GLSetVerticalSync(mode VSyncMode)

func (*NativeWindow) GLSwapBuffers Uses

func (w *NativeWindow) GLSwapBuffers()

func (*NativeWindow) GLVerticalSync Uses

func (w *NativeWindow) GLVerticalSync() VSyncMode

func (*NativeWindow) PixelBlit Uses

func (w *NativeWindow) PixelBlit(x, y uint, img *image.RGBA)

func (*NativeWindow) PixelClear Uses

func (w *NativeWindow) PixelClear(rect image.Rectangle)

type PaintEvent Uses

type PaintEvent struct {
    // Rectangle that needs to be redrawn / has been damaged.
    Rectangle image.Rectangle

    T   time.Time
}

PaintEvent is an event where the pixels inside the window's client region where damaged and need to be redrawn.

func (PaintEvent) String Uses

func (ev PaintEvent) String() string

String returns an string representation of this event.

func (PaintEvent) Time Uses

func (ev PaintEvent) Time() time.Time

Time implements the generic event interface.

type PositionEvent Uses

type PositionEvent struct {
    // Position of the window's client region.
    X, Y int

    T   time.Time
}

PositionEvent is an event where the user changed the position of the window.

func (PositionEvent) String Uses

func (ev PositionEvent) String() string

String returns an string representation of this event.

func (PositionEvent) Time Uses

func (ev PositionEvent) Time() time.Time

Time implements the generic event interface.

type ResizedEvent Uses

type ResizedEvent struct {
    // Size of the window's client region.
    Width, Height int

    T   time.Time
}

ResizedEvent is an event where the user changed the size of the window's client region.

func (ResizedEvent) String Uses

func (ev ResizedEvent) String() string

String returns an string representation of this event.

func (ResizedEvent) Time Uses

func (ev ResizedEvent) Time() time.Time

Time implements the generic event interface.

type Screen Uses

type Screen struct {
    *NativeScreen
    // contains filtered or unexported fields
}

Screen represents an single physical screen device. It is only possible to get an screen from either the Screens or DefaultScreen functions.

func DefaultScreen Uses

func DefaultScreen() *Screen

DefaultScreen returns the 'default' screen, this is determined by either the window manager itself (as per an user's personal setup and configuration) or will be best-guessed by Chippy.

It is possible for this function to return nil, in the highly unlikely event that Screens() returns no screens at all, due to an user having none plugged in or activated.

func (*Screen) Equals Uses

func (s *Screen) Equals(other *Screen) bool

Equals compares this screen with the other screen, determining whether or not they are the same physical screen.

func (*Screen) Mode Uses

func (s *Screen) Mode() *ScreenMode

Mode returns the current screen mode in use by this screen, this will be either the last screen mode set via SetMode, or the original screen mode from OriginalMode in the event that no screen mode was previously set on this screen.

func (*Screen) Modes Uses

func (s *Screen) Modes() []*ScreenMode

Modes returns all available screen modes on this screen, sorted by highest resolution, then highest bytes per pixel, then highest refresh rate.

func (*Screen) Name Uses

func (s *Screen) Name() string

Name returns an formatted string of the screens name, this is something that the user should be able to relate on their own to the actual physical screen device, this typically includes device brand name or model etc..

func (*Screen) OriginalMode Uses

func (s *Screen) OriginalMode() *ScreenMode

OriginalMode returns the original screen mode of this screen, as it was when this screen was created.

func (*Screen) PhysicalSize Uses

func (s *Screen) PhysicalSize() (width float32, height float32)

PhysicalSize returns the physical width and height of this screen, in millimeters, or zero as both width and height in the event there is no way to determine the physical size of this screen.

func (*Screen) Restore Uses

func (s *Screen) Restore()

Restore is short-hand for:

s.SetMode(s.OriginalMode())

func (*Screen) SetMode Uses

func (s *Screen) SetMode(newMode *ScreenMode) error

SetMode switches this screen to the specified screen mode, or returns an error in the event that we where unable to switch the screen to the specified screen mode.

The newMode parameter must be an screen mode that originally came from one of the methods Modes(), Mode(), or OriginalMode(), or else this function will panic.

If an error is returned, it will be either ErrBadScreenMode, or ErrDualViewCapable.

func (*Screen) String Uses

func (s *Screen) String() string

String returns an nice string representation of this Screen

type ScreenChangedEvent Uses

type ScreenChangedEvent struct {
    // Screen that the window is located on.
    Screen *Screen

    T   time.Time
}

ScreenChangedEvent is an event where the user moved the window onto an different screen.

func (ScreenChangedEvent) String Uses

func (ev ScreenChangedEvent) String() string

String returns an string representation of this event.

func (ScreenChangedEvent) Time Uses

func (ev ScreenChangedEvent) Time() time.Time

Time implements the generic event interface.

type ScreenMode Uses

type ScreenMode struct {
    *NativeScreenMode
    // contains filtered or unexported fields
}

ScreenMode represents an single, unique, screen mode, with an resolution, refresh rate, and bpp.

It is possible for multiple different ScreenMode's to exist with the same resolution, each with different refresh rates or bytes per pixel, respectively.

func (*ScreenMode) BytesPerPixel Uses

func (m *ScreenMode) BytesPerPixel() int

BytesPerPixel returns the number of bytes that represent an single pixel of this ScreenMode, or 0 if the bytes per pixel is unable to be determined.

func (*ScreenMode) Equals Uses

func (m *ScreenMode) Equals(other *ScreenMode) bool

Equals compares two ScreenMode(s) for equality. It does this by comparing resolutions, refresh rates, and bytes per pixels.

func (*ScreenMode) RefreshRate Uses

func (m *ScreenMode) RefreshRate() float32

RefreshRate returns the refresh rate of this ScreenMode, in hertz, or 0 if the refresh rate is unable to be determined.

func (*ScreenMode) Resolution Uses

func (m *ScreenMode) Resolution() (width, height int)

Resolution returns the width and height of this ScreenMode, in pixels.

func (*ScreenMode) String Uses

func (m *ScreenMode) String() string

String returns an nice string representing this ScreenMode

type VSyncMode Uses

type VSyncMode uint8

VSyncMode represents an single vertical reresh rate sync mode.

const (
    VerticalSync VSyncMode = iota
    NoVerticalSync
    AdaptiveVerticalSync
)

func (VSyncMode) String Uses

func (mode VSyncMode) String() string

String returns a string representation of this vertical sync mode.

func (VSyncMode) Valid Uses

func (mode VSyncMode) Valid() bool

Valid tells if the vertical sync mode is one of the predefined constants defined in this package or not.

type Window Uses

type Window struct {
    *NativeWindow

    Keyboard *keyboard.Watcher
    Mouse    *mouse.Watcher
    // contains filtered or unexported fields
}

Window represents an single window, it will be non-visible untill the Open function is called.

func NewWindow Uses

func NewWindow() *Window

func (*Window) AlwaysOnTop Uses

func (w *Window) AlwaysOnTop() bool

AlwaysOnTop tells whether the window is currently always on top of other windows, due to an previous call to the SetAlwaysOnTop function, or due to the user changing the always on top state directly through the window manager itself.

func (*Window) AspectRatio Uses

func (w *Window) AspectRatio() float32

AspectRatio tells the aspect ratio that the window should try and keep when the user resizes the window, as previously set via SetAspectRatio, or the default of 0.

Note: If you want to determine the aspect ratio of the window, you should instead calculate it from the Size() function, by dividing width by height.

(Because if there was no previous call to SetAspectRatio, this function will return 0, which is not the actual window aspect ratio.)

func (*Window) CloseEvents Uses

func (w *Window) CloseEvents(ch chan Event)

CloseEvents stops the specified channel from receiving any more window events.

Call this function whenever you are done receiving window events from the given channel.

This is important for channels which have an very large buffer size to reduce memory consumption.

func (*Window) Cursor Uses

func (w *Window) Cursor() *Cursor

Cursor returns the currently in use cursor image, as previously set via an call to SetCursor.

Changes made to this Image *after* an initial call to SetCursor will not be reflected by the window unless you call SetCursor again.

func (*Window) CursorGrabbed Uses

func (w *Window) CursorGrabbed() bool

CursorGrabbed tells whether the mouse cursor is currently grabbed, as previously set via an call to the SetCursorGrabbed function.

func (*Window) CursorPosition Uses

func (w *Window) CursorPosition() (x, y int)

CursorPosition tells the current mouse cursor position, both x and y, relative to the client region of this window (specified in pixels)

func (*Window) CursorWithin Uses

func (w *Window) CursorWithin() bool

CursorWithin tells whether the mouse cursor is inside the window's client region or not.

func (*Window) Decorated Uses

func (w *Window) Decorated() bool

Decorations tells whether this window has window decorations on, as previously set by the SetDecorations function, or the default value of true (on).

func (*Window) Destroy Uses

func (w *Window) Destroy()

Destroy destroys the window. It is closed, and is then considered to be in an destroyed state.

After calling this function, the window is considered destroyed.

If the window is not currently open or is already destroyed then this function is no-op.

func (*Window) Destroyed Uses

func (w *Window) Destroyed() bool

Destroyed tells whether there was an previous call to the Destroy function.

func (*Window) Events Uses

func (w *Window) Events() chan Event

Events is short-hand for:

w.EventsBuffer(64)

func (*Window) EventsBuffer Uses

func (w *Window) EventsBuffer(bufferSize int) chan Event

EventsBuffer returns an new read-only channel over which window events will be sent.

Events are sent in an non-blocking fashion. As such once the amount of buffered items in the channel reaches the maximum, then events will stop being sent.

You should ensure that the buffer size is large enough for you to read the events in an short amount of time.

func (*Window) Extents Uses

func (w *Window) Extents() (left, right, bottom, top int)

Extents returns how far the window region extends outward from the client region of this window, in pixels.

If the window's extents are unknown, [0, 0, 0, 0] is returned.

If the window is not open yet, [0, 0, 0, 0] is returned.

If the window is destroyed, [0, 0, 0, 0] is returned.

None of the extents will ever be less than zero.

func (*Window) Focused Uses

func (w *Window) Focused() bool

Focused tells whether this window currently has focus, and is therefor the current window that is being interacted with by the user.

func (*Window) FreeCursor Uses

func (w *Window) FreeCursor(cursor *Cursor)

FreeCursor removes the specified cursor from the internal cache. Cursors are cached because it allows for SetCursor() operations to perform more quickly without performing multiple copy operations underneath.

This allows you to simply use SetCursor() as often as you wish, for instance creating cursor animations and such.

If the specified cursor is nil; an panic will occur.

If the specified cursor is the active cursor (previously set via the SetCursor function); then the default cursor (nil) will be set and then the specified cursor free'd.

func (*Window) Fullscreen Uses

func (w *Window) Fullscreen() bool

Fullscreen tells whether the window is currently full screen, as previously set by an call to the SetFullscreen function.

func (*Window) Icon Uses

func (w *Window) Icon() image.Image

Icon returns the currently in use icon image, as previously set via an call to SetIcon.

Changes made to this Image *after* an initial call to SetIcon will not be reflected by the window unless you call SetIcon again.

func (*Window) Maximized Uses

func (w *Window) Maximized() bool

Maximized tells whether the window is currently maximized, as previously set via an call to the SetMaximized function, or due to the user changing the maximized status of the window directly through the window manager, or the default value of false.

func (*Window) MaximumSize Uses

func (w *Window) MaximumSize() (width, height int)

MaximumSize tells the current maximum width and height of this windows client region, as set previously via the SetMaximumSize function, or the default values of width=0, height=0

Both width and height will be at least 1.

func (*Window) Minimized Uses

func (w *Window) Minimized() bool

Minimized tells whether the window is currently minimized, as previously set via an call to the SetMinimized function, or due to the user changing the minimized status of the window directly through the window manager, or the default value of false.

func (*Window) MinimumSize Uses

func (w *Window) MinimumSize() (width, height int)

MinimumSize tells the current minimum width and height of this windows client region, as set previously via the SetMinimumSize function, or the default values of width=150, height=150.

Both width and height will be at least 1.

func (*Window) Notify Uses

func (w *Window) Notify()

Notify causes the window to notify the user that an event has happened with the application, and they should look at the application.

Typically this is an small flashing animation, etc.

func (*Window) Open Uses

func (w *Window) Open(screen *Screen) error

Open opens the window using the current settings, on the specified screen, or returns an error in the event that we are unable to open the window for some reason (the error will be descriptive).

If the window is already open this function is no-op.

If the window is destroyed, it's NativeWindow struct will be replaced with a new one and the window will become valid again.

func (*Window) Opened Uses

func (w *Window) Opened() bool

Opened tells whether the window is currently open.

If the window is destroyed, the returned value will be false.

func (*Window) OriginalScreen Uses

func (w *Window) OriginalScreen() *Screen

OriginalScreen returns the screen that this window was created on at the time Open() was called.

func (*Window) Position Uses

func (w *Window) Position() (x, y int)

Position tells what the current x and y position of this window's client region.

func (*Window) PrepareCursor Uses

func (w *Window) PrepareCursor(cursor *Cursor)

PrepareCursor prepares the specified cursor to be displayed, but does not display it. This is useful when you wish to load each frame for an cursor animation, but not cause the cursor to flicker while loading them into the internal cache.

If the specified cursor is nil; an panic will occur.

If the window is not open or is destroyed; the cursor cannot be prepared and this function is no-op.

func (*Window) Screen Uses

func (w *Window) Screen() *Screen

Screen returns the current screen that this window is currently residing on.

This function will return the original screen the window was created on in the event that we are unable to determine the current screen.

func (*Window) SetAlwaysOnTop Uses

func (w *Window) SetAlwaysOnTop(alwaysOnTop bool)

SetAlwaysOnTop specifies whether the window should be always on top of other windows.

If the window is destroyed, this function will panic.

func (*Window) SetAspectRatio Uses

func (w *Window) SetAspectRatio(ratio float32)

SetAspectRatio specifies the aspect ratio that the window should try to keep when the user resizes the window.

If the ratio is zero, then the window will be allowed to resize freely, without being restricted to an aspect ratio.

func (*Window) SetCursor Uses

func (w *Window) SetCursor(cursor *Cursor)

SetCursor specifies the cursor to become the default cursor while the mouse is inside this window's client region.

If the cursor does not exist within the internal cache already -- it will be cached using PrepareCursor() automatically. Once you are done using the cursor, you should use the FreeCursor() function to remove the cursor from the internal cache (the cursor can still be displayed again after using FreeCursor(), it just will have to be loaded into the cache again).

func (*Window) SetCursorGrabbed Uses

func (w *Window) SetCursorGrabbed(grabbed bool)

SetCursorGrabbed specifies whether the mouse cursor should be grabbed, this means the cursor will be invisible, and will be forced to stay within the client region of the window. This behavior is the same as you would typically see in first person shooter games.

If the cursor is being released (false), then the original cursor position will be restored to where it was originally at the time of the last call to SetCursorGrabbed(true).

func (*Window) SetCursorPosition Uses

func (w *Window) SetCursorPosition(x, y int)

SetCursorPosition sets the mouse cursor to the new position x and y, specified in pixels relative to the client region of this window.

It is possible to move the cursor outside both the client region and window region, either by specifying an negative number, or an positive number larger than the window region.

func (*Window) SetDecorated Uses

func (w *Window) SetDecorated(decorated bool)

SetDecorated specifies whether this window should have window decorations, this includes the title bar, exit buttons, borders, system menu buttons, icons, etc.

If the window is destroyed, this function will panic.

func (*Window) SetFullscreen Uses

func (w *Window) SetFullscreen(fullscreen bool)

SetFullscreen specifies whether the window should be full screen, consuming the entire screen's size, and being the only thing displayed on the screen.

If the window is destroyed, this function will panic.

func (*Window) SetIcon Uses

func (w *Window) SetIcon(icon image.Image)

SetIcon specifies the window icon which should be displayed anywhere that an window icon is needed, this typically includes in the title bar decoration, or in the icon tray.

If the icon is nil; the default 'chippy' icon is restored.

func (*Window) SetMaximized Uses

func (w *Window) SetMaximized(maximized bool)

SetMaximized specifies whether the window should currently be maximized.

func (*Window) SetMaximumSize Uses

func (w *Window) SetMaximumSize(width, height int)

SetMaximumSize specifies the maximum width and height that this windows client region is allowed to have, the user will be disallowed to resize the window any larger than this specified size.

If the size passed into both SetMaximumSize and SetMinimumSize are the same, then the window will be non-resizable.

If either width or height are zero, then there will be no maximum size restriction placed.

If the window is destroyed, this function will panic.

func (*Window) SetMinimized Uses

func (w *Window) SetMinimized(minimized bool)

SetMinimized specifies whether the window should currently be minimized.

func (*Window) SetMinimumSize Uses

func (w *Window) SetMinimumSize(width, height int)

SetMinimumSize specifies the minimum width and height that this windows client region is allowed to have, the user will be disallowed to resize the window any smaller than this specified size.

If either width or height are zero, then there will be no maximum size restriction placed.

If the size passed into both SetMinimumSize and SetMaximumSize are the same, then the window will be non-resizable.

func (*Window) SetPosition Uses

func (w *Window) SetPosition(x, y int)

SetPosition specifies the new x and y position of this window's client region, relative to the top-left corner of the screen, in pixels.

If the window is destroyed, this function will panic.

func (*Window) SetPositionCenter Uses

func (w *Window) SetPositionCenter(screen *Screen)

SetPositionCenter sets the window position such that it is perfectly in the center of the specified screen.

func (*Window) SetSize Uses

func (w *Window) SetSize(width, height int)

SetSize specifies the new width and height of this window's client region, in pixels.

The window's size will be clamped such that it is always 1px wide/tall; and never exceeds the bounds of the minimum or maximum size of the window if one is specified.

If w.Size() is later called, it will return the identical (non-clamped) values you provide here.

func (*Window) SetTitle Uses

func (w *Window) SetTitle(title string)

SetTitle sets the title of the window, this is shown anywhere where there needs to be an string representation, typical places include the window's Title Bar decoration, and in the icon tray (which displays minimized windows, etc).

If the window is destroyed, this function will panic.

func (*Window) SetTransparent Uses

func (w *Window) SetTransparent(transparent bool)

SetTransparent specifies whether this window should be transparent, used in things like splash screens, etc.

Default: false

func (*Window) SetVisible Uses

func (w *Window) SetVisible(visible bool)

SetVisible specifies whether this window should be visibly seen by the user, if false the window will appear simply gone (even though it actually exists, and you may render to it, and at an later time show the window again).

If the window is destroyed, this function will panic.

func (*Window) Size Uses

func (w *Window) Size() (width, height int)

Size tells the current width and height of this window, as set previously by an call to the SetSize function, or due to the user resizing the window through the window manager itself.

Both width and height will be at least 1.

func (*Window) String Uses

func (w *Window) String() string

String returns an string representation of this window.

func (*Window) Title Uses

func (w *Window) Title() string

Title returns the title of the window, as it was set by SetTitle, or the default title: "Chippy Window".

func (*Window) Transparent Uses

func (w *Window) Transparent() bool

Transparent tells whether this window is transparent, via an previous call to SetTransparent()

func (*Window) Visible Uses

func (w *Window) Visible() bool

Visible tells whether this window is currently visible to the user, as previously set by the SetVisible function, or the default value of true (visible).

type X11GLContext Uses

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

Package chippy imports 24 packages (graph) and is imported by 4 packages. Updated 2016-07-15. Refresh now. Tools for package owners.