glfw

package
v0.0.0-...-af47be6 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionMajor    = 2
	VersionMinor    = 7
	VersionRevision = 0
)

GLFW Version

View Source
const (
	KeyRelease = iota
	KeyPress
)

Key and button state/action definitions

View Source
const (
	KeyUnknown = -1
	KeySpace   = 32
	KeySpecial = 256
)

Keyboard key definitions: 8-bit ISO-8859-1 (Latin 1) encoding is used for printable keys (such as A-Z, 0-9 etc), and values above 256 represent Special (non-printable) keys (e.g. F1, Page Up etc).

View Source
const (
	KeyEsc
	KeyF1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyF13
	KeyF14
	KeyF15
	KeyF16
	KeyF17
	KeyF18
	KeyF19
	KeyF20
	KeyF21
	KeyF22
	KeyF23
	KeyF24
	KeyF25
	KeyUp
	KeyDown
	KeyLeft
	KeyRight
	KeyLshift
	KeyRshift
	KeyLctrl
	KeyRctrl
	KeyLalt
	KeyRalt
	KeyTab
	KeyEnter
	KeyBackspace
	KeyInsert
	KeyDel
	KeyPageup
	KeyPagedown
	KeyHome
	KeyEnd
	KeyKP0
	KeyKP1
	KeyKP2
	KeyKP3
	KeyKP4
	KeyKP5
	KeyKP6
	KeyKP7
	KeyKP8
	KeyKP9
	KeyKPDivide
	KeyKPMultiply
	KeyKPSubtract
	KeyKPAdd
	KeyKPDecimal
	KeyKPEqual
	KeyKPEnter
	KeyKPNumlock
	KeyCapslock
	KeyScrolllock
	KeyPause
	KeyLsuper
	KeyRsuper
	KeyMenu
	KeyLast = KeyMenu
)
View Source
const (
	Mouse1 = iota
	Mouse2
	Mouse3
	Mouse4
	Mouse5
	Mouse6
	Mouse7
	Mouse8
	MouseLast   = Mouse8
	MouseLeft   = Mouse1
	MouseRight  = Mouse2
	MouseMiddle = Mouse3
)

Mouse button definitions

View Source
const (
	Joy1 = iota
	Joy2
	Joy3
	Joy4
	Joy5
	Joy6
	Joy7
	Joy8
	Joy9
	Joy10
	Joy11
	Joy12
	Joy13
	Joy14
	Joy15
	Joy16
	JoyLast = Joy16
)

Joystick identifiers

View Source
const (
	Windowed
	Fullscreen
)

glfwOpenWindow modes

View Source
const (
	Opened
	Active
	Iconified
	Accelerated
	RedBits
	GreenBits
	BlueBits
	AlphaBits
	DepthBits
	StencilBits

	// The following constants are used for both glfwGetWindowParam
	// and glfwOpenWindowHint
	RefreshRate
	AccumRedBits
	AccumGreenBits
	AccumBlueBits
	AccumAlphaBits
	AuxBuffers
	Stereo
	WindowNoResize
	FsaaSamples
	OpenGLVersionMajor
	OpenGLVersionMinor
	OpenGLForwardCompat
	OpenGLDebugContext
	OpenGLProfile
)

glfwGetWindowParam / glfwOpenWindowHint tokens

View Source
const (
	OpenGLCoreProfile
	OpenGLCompatProfile
)

GLFW_OPENGL_PROFILE tokens

View Source
const (
	MouseCursor
	StickyKeys
	StickyMouseButtons
	SystemKeys
	KeyRepeat
	AutoPollEvents
)

glfwEnable/glfwDisable tokens

View Source
const (
	Wait
	NoWait
)

glfwWaitThread wait modes

View Source
const (
	Present
	Axes
	Buttons
)

glfwGetJoystickParam tokens

View Source
const (
	NoRescaleBit = 1 << iota // Only for glfwReadImage
	OriginUlBit
	BuildMipmapsBit // Only for glfwLoadTexture2D
	AlphaMapBit
)

glfwReadImage/glfwLoadTexture2D flags

View Source
const Infinity = 100000.0

Time spans longer than this (seconds) are considered to be infinity

Variables

This section is empty.

Functions

func CloseWindow

func CloseWindow()

CloseWindow closes an opened window and destroys the associated OpenGL context.

func Disable

func Disable(token int)

Disable is used to disable a certain feature.

Supported tokens are: MouseCursor, StickyKeys, StickyMouseButtons, SystemKeys, KeyRepeat, AutoPollEvents

func Enable

func Enable(token int)

Enable is used to enable a certain feature.

Supported tokens are: MouseCursor, StickyKeys, StickyMouseButtons, SystemKeys, KeyRepeat, AutoPollEvents

func ExtensionSupported

func ExtensionSupported(name string) bool

ExtensionSupported does a string search in the list of supported OpenGL extensions to find if the specified extension is listed.

Note: An OpenGL context must be created before this function can be called.

Note: In addition to checking for OpenGL extensions, GLFW also checks for extensions in the operating system “glue API”, such as WGL extensions under Microsoft Windows and GLX extensions under the X Window System.

func GLVersion

func GLVersion() (int, int, int)

GLVersion returns the OpenGL implementation version. This is a convenient function that parses the version number information at the beginning of the string returned by calling glGetString( GL_VERSION ). The OpenGL version information can be used to determine what functionality is supported by the used OpenGL implementation.

Note: An OpenGL context must be created before this function can be called.

func IconifyWindow

func IconifyWindow()

IconifyWindow Iconifies (minimizes) a window. If the window is in fullscreen mode, then the desktop video mode will be restored.

func Init

func Init() (err error)

Init initializes GLFW. No other GLFW functions may be called before this function has succeeded.

func JoystickButtons

func JoystickButtons(joy int, buttons []byte) int

JoystickButtons queries the current state of one or more buttons of a joystick. The button states are returned in an array, where the first element represents the first button of the joystick. Each state can be either glfw.KeyPress or glfw.KeyRelease.

Note: If len(buttons) exceeds the number of buttons supported by the joystick, or if the joystick is not available, the unused elements in the buttons array will be set to glfw.KeyRelease.

Note: The function returns the number of actually returned buttons. This is the minimum of len(buttons) and the number of buttons supported by the joystick. If the joystick is not supported or connected, the function will return 0 (zero).

func JoystickParam

func JoystickParam(joy, param int) int

JoystickParam is used for acquiring various properties of a joystick.

func JoystickPos

func JoystickPos(joy int, axes []float32) int

JoystickPos queries the current position of one or more axes of a joystick. The positional values are returned in an array, where the first element represents the first axis of the joystick (normally the X axis). Each position is in the range -1.0 to 1.0. Where applicable, the positive direction of an axis is right, forward or up, and the negative direction is left, back or down.

Note: If len(axes) exceeds the number of axes supported by the joystick, or if the joystick is not available, the unused elements in the pos array will be set to 0.0 (zero).

Note: The function returns the number of actually returned axes. This is the minimum of len(axes) and the number of axes supported by the joystick. If the joystick is not supported or connected, the function will return 0 (zero).

func Key

func Key(key int) int

Key returns glfw.KeyPress if the given key is held down, or glfw.KeyRelease otherwise.

Note: Not all key codes are supported on all systems. Also, while some keys are available on some keyboard layouts, they may not be available on other keyboard layouts.

Note: For systems that do not distinguish between left and right versions of modifier keys (shift, alt and control), the left version is used (e.g. glfw.KeyLshift).

func LoadMemoryTexture2D

func LoadMemoryTexture2D(data []byte, flags int) bool

LoadMemoryTexture2D reads an image from the memory buffer specified by the parameter data and uploads the image to OpenG texture memory (using the glTexImage2D function).

Note: If the glfw.BuildMipmapsBit flag is set, all mipmap levels for the loaded texture are generated and uploaded to texture memory.

Note: The read image is always rescaled to the nearest larger power of two resolution using bilinear interpolation.

Note: Unless the glfw.OriginUlBit flag is set, the first pixel in img.Data is the lower left corner of the image. Otherwise the first pixel is the upper left corner.

Note: For single component images (i.e. gray scale), Format is set to GL_ALPHA if the glfw.AlphaMapBit flag is set, otherwise Format is set to GL_LUMINANCE.

Note: ReadImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color + alpha.

func LoadTexture2D

func LoadTexture2D(name string, flags int) bool

LoadTexture2D reads an image from the file specified by the parameter name and uploads the image to OpenGL texture memory (using the glTexImage2D function).

Note: If the glfw.BuildMipmapsBit flag is set, all mipmap levels for the loaded texture are generated and uploaded to texture memory.

Note: The read image is always rescaled to the nearest larger power of two resolution using bilinear interpolation.

Note: Unless the glfw.OriginUlBit flag is set, the first pixel in img.Data is the lower left corner of the image. Otherwise the first pixel is the upper left corner.

Note: For single component images (i.e. gray scale), Format is set to GL_ALPHA if the glfw.AlphaMapBit flag is set, otherwise Format is set to GL_LUMINANCE.

Note: ReadImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color + alpha.

func MouseButton

func MouseButton(btn int) int

MouseButton returns glfw.KeyPress if the given mouse button is held down. glfw.KeyRelease otherwise.

func MousePos

func MousePos() (int, int)

MousePos returns the current mouse position. If the cursor is not hidden, the mouse position is the cursor position, relative to the upper left corner of the window and with the Y-axis down. If the cursor is hidden, the mouse position is a virtual absolute position, not limited to any boundaries except to those implied by the maximum number that can be represented by a signed integer.

func MouseWheel

func MouseWheel() int

MouseWheel returns the current mouse wheel position. The mouse wheel can be thought of as a third mouse axis, which is available as a separate wheel or up/down stick on some mice.

func NumberOfProcessors

func NumberOfProcessors() int

NumberOfProcessors determines the number of active processors in the system.

Note: Systems with several logical processors per physical processor, also known as SMT (Symmetric Multi-Threading) processors, will report the number of logical processors.

func OpenWindow

func OpenWindow(width, height, r, g, b, a, depth, stencil, mode int) (err error)

OpenWindow opens a window that best matches the parameters given to the function. How well the resulting window matches the desired window depends mostly on the available hardware and OpenGL drivers. In general, selecting a fullscreen mode has better chances of generating a close match of buffers and channel sizes than does a normal desktop window, since GLFW can freely select from all the available video modes. A desktop window is normally restricted to the video mode of the desktop.

Note: For additional control of window properties, see glfw.OpenWindowHint.

width:   The width of the window. If width is zero, it will be calculated
         as width = 4/3 height, if height is not zero. If both width and
         height are zero, width will be set to 640.

height:  The height of the window. If height is zero, it will be calculated
         as height = 4/3 width, if width is not zero. If both width and
         height are zero, height will be set to 480.

r, g, b: The number of bits to use for each color component of the color
         buffer (0 means default color depth). For instance, setting
         r=5, g=6 and b=5 will create a 16-bit color buffer, if possible.

a:       The number of bits to use for the alpha channel of the color
         buffer (0 means no alpha channel).

depth:   The number of bits to use for the depth buffer (0 means no depth buffer).

stencil: The number of bits to use for the stencil buffer (0 means no
         stencil buffer).

mode:    Selects which type of OpenGL window to use. Mode must be either
         glfw.Windowed, which will generate a normal desktop window, or
         glfw.Fullscreen, which will generate a window that covers the
         entire screen. When glfw.Fullscreen is selected, the video mode
         will be changed to the resolution that closest matches the width
         and height parameters.

func OpenWindowHint

func OpenWindowHint(target, hint int)

OpenWindowHint sets additional properties for a window that is to be opened. For a hint to be registered, the function must be called /before/ calling OpenWindow. When the OpenWindow function is called, any hints that were registered with the OpenWindowHint function are used for setting the corresponding window properties, and then all hints are reset to their default values.

RefreshRate:    Vertical monitor refresh rate in Hz (only used
                for fullscreen windows). Zero means system default.
AccumRedBits:   Number of bits for the red channel of the accumulation buffer.
AccumGreenBits: Number of bits for the green channel of the accumulation buffer.
AccumBlueBits:  Number of bits for the blue channel of the accumulation buffer.
AccumAlphaBits: Number of bits for the alpha channel of the accumulation buffer.
AuxBuffers:     Number of auxiliary buffers.
Stereo:         Specify if stereo rendering should be supported (can be
                GL_TRUE or GL_FALSE).
WindowNoResize: Specify whether the window can be resized by the user
                (not used for fullscreen windows)
FsaaSamples:    Number of samples to use for the multisampling buffer.
                Zero disables multisampling.

OpenGLVersionMajor:  Major number of the desired minimum OpenGL version.
OpenGLVersionMinor:  Minor number of the desired minimum OpenGL version.
OpenGLForwardCompat: Specify whether the OpenGL context should be
                     forward-compatible (i.e. disallow legacy
                     functionality). This should only be used when
                     requesting OpenGL version 3.0 or above.
OpenGLDebugContext:  Specify whether a debug context should be created.
OpenGLProfile:       The OpenGL profile the context should implement, or
                     zero to let the system choose. Available profiles are
                     OpenGLCoreProfile and OpenGLCompatProfile.

func PollEvents

func PollEvents()

PollEvents is used for polling for events, such as user input and window resize events. Upon calling this function, all window states, keyboard states and mouse states are updated. If any related callback functions are registered, these are called during the call to glfw.PollEvents.

Note: glfw.PollEvents is called implicitly from glfw.SwapBuffers if glfw.AutoPollEvents is enabled (as it is by default). Thus, if glfw.SwapBuffers is called frequently, which is normally the case, there is no need to call glfw.PollEvents.

func ProcAddress

func ProcAddress(name string) uintptr

ProcAddress acquires the pointer to an OpenGL extension function. Some (but not all) OpenGL extensions define new API functions, which are usually not available through normal linking. It is therefore necessary to get access to those API functions at runtime.

Note: An OpenGL context must be created before this function can be called.

Note: Some systems do not support dynamic function pointer retrieval, in which case this function will always return 0 (NULL).

func RestoreWindow

func RestoreWindow()

RestoreWindow restores an iconified window. If the window that is restored is in fullscreen mode, then the fullscreen video mode will be restored.

func SetCharCallback

func SetCharCallback(f CharHandler)

SetCharCallback sets the callback for keyboard character events. The callback function is called every time a key that results in a printable Unicode character is pressed or released. Characters are affected by modifiers (such as shift or alt).

func SetKeyCallback

func SetKeyCallback(f KeyHandler)

SetKeyCallback sets the callback for keyboard key events. The callback function is called every time the state of a single key is changed (from released to pressed or vice versa). The reported keys are unaffected by any modifiers (such as shift or alt) and each modifier is reported as a separate key.

There can be more than one handler.

func SetMouseButtonCallback

func SetMouseButtonCallback(f MouseButtonHandler)

SetMouseButtonCallback sets the callback for mouse button events. There can be more than one handler.

func SetMousePos

func SetMousePos(x, y int)

SetMousePos changes the position of the mouse. If the cursor is visible (not disabled), the cursor will be moved to the specified position, relative to the upper left corner of the window client area and with the Y-axis down. If the cursor is hidden (disabled), only the mouse position that is reported by GLFW is changed.

func SetMousePosCallback

func SetMousePosCallback(f MousePosHandler)

SetMousePosCallback sets a callback for mouse motion events. There can be more than one handler.

func SetMouseWheel

func SetMouseWheel(pos int)

This function changes the position of the mouse wheel.

func SetMouseWheelCallback

func SetMouseWheelCallback(f MouseWheelHandler)

This function sets the callback for mouse wheel events. There can be more than one handler.

func SetSwapInterval

func SetSwapInterval(interval int)

SetSwapInterval selects the minimum number of monitor vertical retraces that should occur between two buffer swaps. If the selected swap interval is one, the rate of buffer swaps will never be higher than the vertical refresh rate of the monitor. If the selected swap interval is zero, the rate of buffer swaps is only limited by the speed of the software and the hardware.

func SetTime

func SetTime(t float64)

SetTime sets the current time of the high precision timer to the specified time. Subsequent calls to glfw.Time will be relative to this time. The time is given in seconds.

func SetWindowCloseCallback

func SetWindowCloseCallback(f WindowCloseHandler)

SetWindowCloseCallback sets the callback for window close events. A window has to be opened for this function to have any effect.

func SetWindowPos

func SetWindowPos(x, y int)

SetWindowPos changes the position of an opened window. It does not have any effect on a fullscreen window.

Note: The behaviour of this function on multi-monitor systems is ill-defined.

func SetWindowRefreshCallback

func SetWindowRefreshCallback(f WindowRefreshHandler)

SetWindowRefreshCallback sets the callback for window refresh events, which occurs when any part of the window client area has been damaged, and needs to be repainted (for instance, if a part of the window that was previously occluded by another window has become visible).

func SetWindowSize

func SetWindowSize(width, height int)

SetWindowSize changes the size of an opened window. The width and height parameters denote the size of the client area of the window (i.e. excluding any window borders and decorations). If the window is in fullscreen mode, the video mode will be changed to a resolution that closest matches the width and height parameters (the number of color bits will not be changed).

Note: This function has no effect if the window is iconified.

Note: The OpenGL context is guaranteed to be preserved after calling SetWindowSize, even if the video mode is changed.

func SetWindowSizeCallback

func SetWindowSizeCallback(f WindowSizeHandler)

SetWindowSizeCallback sets the callback for window size change events.

func SetWindowTitle

func SetWindowTitle(title string)

SetWindowTitle changes the title of the opened window.

func Sleep

func Sleep(t float64)

Sleep puts the calling thread to sleep for the requested period of time. Only the calling thread is put to sleep. Other threads within the same process can still execute.

Note: There is usually a system dependent minimum time for which it is possible to sleep. This time is generally in the range 1 ms to 20 ms, depending on thread sheduling time slot intervals etc. Using a shorter time as a parameter to glfwSleep can give one of two results: either the thread will sleep for the minimum possible sleep time, or the thread will not sleep at all (glfw.Sleep returns immediately). The latter should only happen when very short sleep times are specified, if at all.

func SwapBuffers

func SwapBuffers()

SwapBuffers swaps the back and front color buffers of the window. If glfw.AutoPollEvents is enabled (which is the default), glfw.PollEvents() is called after swapping the front and back buffers.

func Terminate

func Terminate()

Terminate closes the window, if open, and kills any running threads. This function should be called before a program exits

func Time

func Time() float64

Time returns the state of a high precision timer. Unless the timer has been set by the glfw.SetTime function, the time is measured as the number of seconds that have passed since glfwInit was called.

Note: The resolution of the timer depends on which system the program is running on.

func WaitEvents

func WaitEvents()

WaitEvents is used for waiting for events, such as user input and window resize events. Upon calling this function, the calling thread will be put to sleep until any event appears in the event queue. When events are available, they will be processed just as they are processed by glfw.PollEvents.

Note: It is guaranteed that glfw.WaitEvents will wake up on any event that can be processed by glfw.PollEvents. However, GLFW receives many events that are only processed internally and the function may behave differently on different systems. Do not make any assumptions about when or why glfw.WaitEvents will return.

func WindowParam

func WindowParam(param int) int

WindowParam is used for acquiring various properties of an opened window.

Opened:         GL_TRUE if window is opened, else GL_FALSE.
Active:         GL_TRUE if window has focus, else GL_FALSE.
Iconified:      GL_TRUE if window is iconified, else GL_FALSE.
Accelerated:    GL_TRUE if window is hardware accelerated, else GL_FALSE.
RedBits:        Number of bits for the red color component.
GreenBits:      Number of bits for the green color component.
BlueBits:       Number of bits for the blue color component.
AlphaBits:      Number of bits for the alpha buffer.
DepthBits:      Number of bits for the depth buffer.
StencilBits:    Number of bits for the stencil buffer.
RefreshRate:    Vertical monitor refresh rate in Hz. Zero indicates an
                unknown or a default refresh rate.
AccumRedBits:   Number of bits for the red channel of the accumulation buffer.
AccumGreenBits: Number of bits for the green channel of the accumulation buffer.
AccumBlueBits:  Number of bits for the blue channel of the accumulation buffer.
AccumAlphaBits: Number of bits for the alpha channel of the accumulation buffer.
AuxBuffers:     Number of auxiliary buffers.
Stereo:         GL_TRUE if stereo rendering is supported, else GL_FALSE.
WindowNoResize: GL_TRUE if the window cannot be resized by the user, else GL_FALSE.
FsaaSamples:    Number of multisampling buffer samples. Zero indicated
                multisampling is disabled.

OpenGLVersionMajor:  Major number of the actual version of the context.
OpenGLVersionMinor:  Minor number of the actual version of the context.
OpenGLForwardCompat: GL_TRUE if the context is forward-compatible, else GL_FALSE.
OpenGLDebugContext:  GL_TRUE if the context is a debug context.
OpenGLProfile:       The profile implemented by the context, or zero.

Note: 'Accelerated' is only supported under Windows. Other systems will always return GL_TRUE. Under Windows, Accelerated means that the OpenGL renderer is a 3rd party renderer, rather than the fallback Microsoft software OpenGL renderer. In other words, it is not a real guarantee that the OpenGL renderer is actually hardware accelerated.

func WindowSize

func WindowSize() (int, int)

WindowSize is used for determining the size of an opened window. The returned values are dimensions of the client area of the window (i.e. excluding any window borders and decorations).

Note: Even if the size of a fullscreen window does not change once the window has been opened, it does not necessarily have to be the same as the size that was requested using glfw.OpenWindow. Therefor it is wise to use this function to determine the true size of the window once it has been opened.

Types

type CharHandler

type CharHandler func(int, int)

type Image

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

The Image type holds data for loaded images.

func ReadImage

func ReadImage(name string, flags int) (i *Image, err error)

ReadImage reads an image from the file specified by the parameter name and returns the image or an error.

Note: By default the read image is rescaled to the nearest larger power of two resolution using bilinear interpolation, if necessary. Which is useful if the image is to be used as an OpenGL texture. This behavior can be disabled by setting the glfw.NoRescaleBit flag.

Note: Unless the glfw.OriginUlBit flag is set, the first pixel in img.Data is the lower left corner of the image. Otherwise the first pixel is the upper left corner.

Note: For single component images (i.e. gray scale), Format is set to GL_ALPHA if the glfw.AlphaMapBit flag is set, otherwise Format is set to GL_LUMINANCE.

Note: ReadImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color + alpha.

func ReadMemoryImage

func ReadMemoryImage(data []byte, flags int) (i *Image, err error)

ReadMemoryImage reads an image file from the memory buffer specified by the parameter data and returns the image information or an error.

Note: ReadMemoryImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color + alpha.

func (*Image) BytesPerPixel

func (i *Image) BytesPerPixel() int

BytesPerPixel specifies the number of bytes per pixel.

func (*Image) Data

func (i *Image) Data() []byte

Data returns the actual pixel data.

FIXME(jimt): This assumes images <= 2gb in size.

func (*Image) Format

func (i *Image) Format() int

Format specifies an OpenGL pixel format, which can be GL_LUMINANCE or GL_ALPHA (for gray scale images), GL_RGB or GL_RGBA.

func (*Image) Height

func (i *Image) Height() int

func (*Image) LoadTextureImage2D

func (i *Image) LoadTextureImage2D(flags int) bool

LoadTextureImage2D uploads the image specified by the parameter img to OpenGL texture memory (using the glTexImage2D function).

Note: If the glfw.BuildMipmapsBit flag is set, all mipmap levels for the loaded texture are generated and uploaded to texture memory.

Note: The read image is always rescaled to the nearest larger power of two resolution using bilinear interpolation.

Note: Unless the glfw.OriginUlBit flag is set, the first pixel in img.Data is the lower left corner of the image. Otherwise the first pixel is the upper left corner.

Note: For single component images (i.e. gray scale), Format is set to GL_ALPHA if the glfw.AlphaMapBit flag is set, otherwise Format is set to GL_LUMINANCE.

Note: ReadImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color + alpha.

func (*Image) Release

func (i *Image) Release()

Release frees any memory occupied by a loaded image, and clears all the fields of the GLFWimage struct. Any image that has been loaded by the glfw.ReadImage function should be deallocated using this function once the image is no longer needed.

func (*Image) SetBytesPerPixel

func (i *Image) SetBytesPerPixel(v int)

func (*Image) SetData

func (i *Image) SetData(v []byte)

SetData sets the actual pixel data.

FIXME(jimt): This assumes images <= 2gb in size.

func (*Image) SetFormat

func (i *Image) SetFormat(v int)

func (*Image) SetHeight

func (i *Image) SetHeight(v int)

func (*Image) SetWidth

func (i *Image) SetWidth(v int)

func (*Image) Width

func (i *Image) Width() int

type KeyHandler

type KeyHandler func(key, state int)

type MouseButtonHandler

type MouseButtonHandler func(button, state int)

type MousePosHandler

type MousePosHandler func(x, y int)

type MouseWheelHandler

type MouseWheelHandler func(pos int)

type VidMode

type VidMode struct {
	W int // width
	H int // height
	R int // red bits
	G int // green bits
	B int // blue bits
}

func DesktopMode

func DesktopMode() *VidMode

DesktopMode returns the desktop video mode.

Note: The color depth of the desktop display is always reported as the number of bits for each individual color component (red, green and blue), even if the desktop is not using an RGB or RGBA color format. For instance, an indexed 256 color display may report RedBits = 3, GreenBits = 3 and BlueBits = 2, which adds up to 8 bits in total.

Note: The desktop video mode is the video mode used by the desktop at the time the GLFW window was opened, not the current video mode (which may differ from the desktop video mode if the GLFW window is a fullscreen window).

func VideoModes

func VideoModes(max int) []*VidMode

VideoModes returns a list of supported video modes.

The returned list is sorted, first by color depth (RedBits + GreenBits + BlueBits), and then by resolution (W idth × Height), with the lowest resolution, fewest bits per pixel mode first.

func (*VidMode) String

func (this *VidMode) String() string

type WindowCloseHandler

type WindowCloseHandler func() int

type WindowRefreshHandler

type WindowRefreshHandler func()

type WindowSizeHandler

type WindowSizeHandler func(width, height int)

Jump to

Keyboard shortcuts

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