dep -> govendor
This commit is contained in:
36
vendor/github.com/go-gl/glfw/v3.0/glfw/clipboard.go
generated
vendored
Normal file
36
vendor/github.com/go-gl/glfw/v3.0/glfw/clipboard.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
package glfw
|
||||
|
||||
//#include <stdlib.h>
|
||||
//#include <GLFW/glfw3.h>
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
//SetClipboardString sets the system clipboard to the specified UTF-8 encoded
|
||||
//string.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) SetClipboardString(str string) {
|
||||
cp := C.CString(str)
|
||||
defer C.free(unsafe.Pointer(cp))
|
||||
|
||||
C.glfwSetClipboardString(w.data, cp)
|
||||
}
|
||||
|
||||
//GetClipboardString returns the contents of the system clipboard, if it
|
||||
//contains or is convertible to a UTF-8 encoded string.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) GetClipboardString() (string, error) {
|
||||
cs := C.glfwGetClipboardString(w.data)
|
||||
if cs == nil {
|
||||
return "", errors.New("Can't get clipboard string.")
|
||||
}
|
||||
|
||||
return C.GoString(cs), nil
|
||||
}
|
72
vendor/github.com/go-gl/glfw/v3.0/glfw/context.go
generated
vendored
Normal file
72
vendor/github.com/go-gl/glfw/v3.0/glfw/context.go
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
package glfw
|
||||
|
||||
//#include <stdlib.h>
|
||||
//#include <GLFW/glfw3.h>
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
//MakeContextCurrent makes the context of the window current.
|
||||
//Originally GLFW 3 passes a null pointer to detach the context.
|
||||
//But since we're using receievers, DetachCurrentContext should
|
||||
//be used instead.
|
||||
func (w *Window) MakeContextCurrent() {
|
||||
C.glfwMakeContextCurrent(w.data)
|
||||
}
|
||||
|
||||
//DetachCurrentContext detaches the current context.
|
||||
func DetachCurrentContext() {
|
||||
C.glfwMakeContextCurrent(nil)
|
||||
}
|
||||
|
||||
//GetCurrentContext returns the window whose context is current.
|
||||
func GetCurrentContext() (*Window, error) {
|
||||
w := C.glfwGetCurrentContext()
|
||||
if w == nil {
|
||||
return nil, errors.New("Current context is not set.")
|
||||
}
|
||||
return windows.get(w), nil
|
||||
}
|
||||
|
||||
//SwapBuffers swaps the front and back buffers of the window. If the
|
||||
//swap interval is greater than zero, the GPU driver waits the specified number
|
||||
//of screen updates before swapping the buffers.
|
||||
func (w *Window) SwapBuffers() {
|
||||
C.glfwSwapBuffers(w.data)
|
||||
}
|
||||
|
||||
//SwapInterval sets the swap interval for the current context, i.e. the number
|
||||
//of screen updates to wait before swapping the buffers of a window and
|
||||
//returning from SwapBuffers. This is sometimes called
|
||||
//'vertical synchronization', 'vertical retrace synchronization' or 'vsync'.
|
||||
//
|
||||
//Contexts that support either of the WGL_EXT_swap_control_tear and
|
||||
//GLX_EXT_swap_control_tear extensions also accept negative swap intervals,
|
||||
//which allow the driver to swap even if a frame arrives a little bit late.
|
||||
//You can check for the presence of these extensions using
|
||||
//ExtensionSupported. For more information about swap tearing,
|
||||
//see the extension specifications.
|
||||
//
|
||||
//Some GPU drivers do not honor the requested swap interval, either because of
|
||||
//user settings that override the request or due to bugs in the driver.
|
||||
func SwapInterval(interval int) {
|
||||
C.glfwSwapInterval(C.int(interval))
|
||||
}
|
||||
|
||||
//ExtensionSupported returns whether the specified OpenGL or context creation
|
||||
//API extension is supported by the current context. For example, on Windows
|
||||
//both the OpenGL and WGL extension strings are checked.
|
||||
//
|
||||
//As this functions searches one or more extension strings on each call, it is
|
||||
//recommended that you cache its results if it's going to be used frequently.
|
||||
//The extension strings will not change during the lifetime of a context, so
|
||||
//there is no danger in doing this.
|
||||
func ExtensionSupported(extension string) bool {
|
||||
e := C.CString(extension)
|
||||
defer C.free(unsafe.Pointer(e))
|
||||
|
||||
return glfwbool(C.glfwExtensionSupported(e))
|
||||
}
|
9
vendor/github.com/go-gl/glfw/v3.0/glfw/error.c
generated
vendored
Normal file
9
vendor/github.com/go-gl/glfw/v3.0/glfw/error.c
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "_cgo_export.h"
|
||||
|
||||
void glfwErrorCB(int code, const char *desc) {
|
||||
goErrorCB(code, (char*)desc);
|
||||
}
|
||||
|
||||
void glfwSetErrorCallbackCB() {
|
||||
glfwSetErrorCallback(glfwErrorCB);
|
||||
}
|
41
vendor/github.com/go-gl/glfw/v3.0/glfw/error.go
generated
vendored
Normal file
41
vendor/github.com/go-gl/glfw/v3.0/glfw/error.go
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
package glfw
|
||||
|
||||
//#include <GLFW/glfw3.h>
|
||||
//void glfwSetErrorCallbackCB();
|
||||
import "C"
|
||||
|
||||
//ErrorCode corresponds to an error code.
|
||||
type ErrorCode int
|
||||
|
||||
//Error codes.
|
||||
const (
|
||||
NotInitialized ErrorCode = C.GLFW_NOT_INITIALIZED //GLFW has not been initialized.
|
||||
NoCurrentContext ErrorCode = C.GLFW_NO_CURRENT_CONTEXT //No context is current.
|
||||
InvalidEnum ErrorCode = C.GLFW_INVALID_ENUM //One of the enum parameters for the function was given an invalid enum.
|
||||
InvalidValue ErrorCode = C.GLFW_INVALID_VALUE //One of the parameters for the function was given an invalid value.
|
||||
OutOfMemory ErrorCode = C.GLFW_OUT_OF_MEMORY //A memory allocation failed.
|
||||
ApiUnavailable ErrorCode = C.GLFW_API_UNAVAILABLE //GLFW could not find support for the requested client API on the system.
|
||||
VersionUnavailable ErrorCode = C.GLFW_VERSION_UNAVAILABLE //The requested client API version is not available.
|
||||
PlatformError ErrorCode = C.GLFW_PLATFORM_ERROR //A platform-specific error occurred that does not match any of the more specific categories.
|
||||
FormatUnavailable ErrorCode = C.GLFW_FORMAT_UNAVAILABLE //The clipboard did not contain data in the requested format.
|
||||
)
|
||||
|
||||
var fErrorHolder func(code ErrorCode, desc string)
|
||||
|
||||
//export goErrorCB
|
||||
func goErrorCB(code C.int, desc *C.char) {
|
||||
fErrorHolder(ErrorCode(code), C.GoString(desc))
|
||||
}
|
||||
|
||||
//SetErrorCallback sets the error callback, which is called with an error code
|
||||
//and a human-readable description each time a GLFW error occurs.
|
||||
//
|
||||
//This function may be called before Init.
|
||||
func SetErrorCallback(cbfun func(code ErrorCode, desc string)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetErrorCallback(nil)
|
||||
} else {
|
||||
fErrorHolder = cbfun
|
||||
C.glfwSetErrorCallbackCB()
|
||||
}
|
||||
}
|
85
vendor/github.com/go-gl/glfw/v3.0/glfw/glfw.go
generated
vendored
Normal file
85
vendor/github.com/go-gl/glfw/v3.0/glfw/glfw.go
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
package glfw
|
||||
|
||||
// Not sure about the darwin flag
|
||||
|
||||
// Windows users: If you download the GLFW 64-bit binaries, when you copy over the contents of the lib folder make sure to rename
|
||||
// glfw3dll.a to libglfw3dll.a, it doesn't work otherwise.
|
||||
|
||||
//#cgo windows LDFLAGS: -lglfw3dll -lopengl32 -lgdi32
|
||||
//#cgo windows CFLAGS: -DGLFW_DLL
|
||||
//#cgo linux LDFLAGS: -lglfw
|
||||
//#cgo darwin LDFLAGS: -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
|
||||
//#cgo freebsd LDFLAGS: -lglfw3 -lGL -lXrandr -lXxf86vm -lXi
|
||||
//#include <GLFW/glfw3.h>
|
||||
import "C"
|
||||
|
||||
const (
|
||||
VersionMajor = C.GLFW_VERSION_MAJOR //This is incremented when the API is changed in non-compatible ways.
|
||||
VersionMinor = C.GLFW_VERSION_MINOR //This is incremented when features are added to the API but it remains backward-compatible.
|
||||
VersionRevision = C.GLFW_VERSION_REVISION //This is incremented when a bug fix release is made that does not contain any API changes.
|
||||
)
|
||||
|
||||
//Init initializes the GLFW library. Before most GLFW functions can be used,
|
||||
//GLFW must be initialized, and before a program terminates GLFW should be
|
||||
//terminated in order to free any resources allocated during or after
|
||||
//initialization.
|
||||
//
|
||||
//If this function fails, it calls Terminate before returning. If it succeeds,
|
||||
//you should call Terminate before the program exits.
|
||||
//
|
||||
//Additional calls to this function after successful initialization but before
|
||||
//termination will succeed but will do nothing.
|
||||
//
|
||||
//This function may take several seconds to complete on some systems, while on
|
||||
//other systems it may take only a fraction of a second to complete.
|
||||
//
|
||||
//On Mac OS X, this function will change the current directory of the
|
||||
//application to the Contents/Resources subdirectory of the application's
|
||||
//bundle, if present.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func Init() bool {
|
||||
return glfwbool(C.glfwInit())
|
||||
}
|
||||
|
||||
//Terminate destroys all remaining windows, frees any allocated resources and
|
||||
//sets the library to an uninitialized state. Once this is called, you must
|
||||
//again call Init successfully before you will be able to use most GLFW
|
||||
//functions.
|
||||
//
|
||||
//If GLFW has been successfully initialized, this function should be called
|
||||
//before the program exits. If initialization fails, there is no need to call
|
||||
//this function, as it is called by Init before it returns failure.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func Terminate() {
|
||||
C.glfwTerminate()
|
||||
}
|
||||
|
||||
//GetVersion retrieves the major, minor and revision numbers of the GLFW
|
||||
//library. It is intended for when you are using GLFW as a shared library and
|
||||
//want to ensure that you are using the minimum required version.
|
||||
//
|
||||
//This function may be called before Init.
|
||||
func GetVersion() (major, minor, revision int) {
|
||||
var (
|
||||
maj C.int
|
||||
min C.int
|
||||
rev C.int
|
||||
)
|
||||
|
||||
C.glfwGetVersion(&maj, &min, &rev)
|
||||
return int(maj), int(min), int(rev)
|
||||
}
|
||||
|
||||
//GetVersionString returns a static string generated at compile-time according
|
||||
//to which configuration macros were defined. This is intended for use when
|
||||
//submitting bug reports, to allow developers to see which code paths are
|
||||
//enabled in a binary.
|
||||
//
|
||||
//This function may be called before Init.
|
||||
func GetVersionString() string {
|
||||
return C.GoString(C.glfwGetVersionString())
|
||||
}
|
57
vendor/github.com/go-gl/glfw/v3.0/glfw/input.c
generated
vendored
Normal file
57
vendor/github.com/go-gl/glfw/v3.0/glfw/input.c
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "_cgo_export.h"
|
||||
|
||||
void glfwMouseButtonCB(GLFWwindow* window, int button, int action, int mods) {
|
||||
goMouseButtonCB(window, button, action, mods);
|
||||
}
|
||||
|
||||
void glfwCursorPosCB(GLFWwindow* window, double xpos, double ypos) {
|
||||
goCursorPosCB(window, xpos, ypos);
|
||||
}
|
||||
|
||||
void glfwCursorEnterCB(GLFWwindow* window, int entered) {
|
||||
goCursorEnterCB(window, entered);
|
||||
}
|
||||
|
||||
void glfwScrollCB(GLFWwindow* window, double xoff, double yoff) {
|
||||
goScrollCB(window, xoff, yoff);
|
||||
}
|
||||
|
||||
void glfwKeyCB(GLFWwindow* window, int key, int scancode, int action, int mods) {
|
||||
goKeyCB(window, key, scancode, action, mods);
|
||||
}
|
||||
|
||||
void glfwCharCB(GLFWwindow* window, unsigned int character) {
|
||||
goCharCB(window, character);
|
||||
}
|
||||
|
||||
void glfwSetKeyCallbackCB(GLFWwindow *window) {
|
||||
glfwSetKeyCallback(window, glfwKeyCB);
|
||||
}
|
||||
|
||||
void glfwSetCharCallbackCB(GLFWwindow *window) {
|
||||
glfwSetCharCallback(window, glfwCharCB);
|
||||
}
|
||||
|
||||
void glfwSetMouseButtonCallbackCB(GLFWwindow *window) {
|
||||
glfwSetMouseButtonCallback(window, glfwMouseButtonCB);
|
||||
}
|
||||
|
||||
void glfwSetCursorPosCallbackCB(GLFWwindow *window) {
|
||||
glfwSetCursorPosCallback(window, glfwCursorPosCB);
|
||||
}
|
||||
|
||||
void glfwSetCursorEnterCallbackCB(GLFWwindow *window) {
|
||||
glfwSetCursorEnterCallback(window, glfwCursorEnterCB);
|
||||
}
|
||||
|
||||
void glfwSetScrollCallbackCB(GLFWwindow *window) {
|
||||
glfwSetScrollCallback(window, glfwScrollCB);
|
||||
}
|
||||
|
||||
float GetAxisAtIndex(float *axis, int i) {
|
||||
return axis[i];
|
||||
}
|
||||
|
||||
unsigned char GetButtonsAtIndex(unsigned char *buttons, int i) {
|
||||
return buttons[i];
|
||||
}
|
460
vendor/github.com/go-gl/glfw/v3.0/glfw/input.go
generated
vendored
Normal file
460
vendor/github.com/go-gl/glfw/v3.0/glfw/input.go
generated
vendored
Normal file
@@ -0,0 +1,460 @@
|
||||
package glfw
|
||||
|
||||
//#include <GLFW/glfw3.h>
|
||||
//void glfwSetKeyCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetCharCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetMouseButtonCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetCursorPosCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetCursorEnterCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetScrollCallbackCB(GLFWwindow *window);
|
||||
//float GetAxisAtIndex(float *axis, int i);
|
||||
//unsigned char GetButtonsAtIndex(unsigned char *buttons, int i);
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
//Joystick corresponds to a joystick.
|
||||
type Joystick int
|
||||
|
||||
//Joystick IDs
|
||||
const (
|
||||
Joystick1 Joystick = C.GLFW_JOYSTICK_1
|
||||
Joystick2 Joystick = C.GLFW_JOYSTICK_2
|
||||
Joystick3 Joystick = C.GLFW_JOYSTICK_3
|
||||
Joystick4 Joystick = C.GLFW_JOYSTICK_4
|
||||
Joystick5 Joystick = C.GLFW_JOYSTICK_5
|
||||
Joystick6 Joystick = C.GLFW_JOYSTICK_6
|
||||
Joystick7 Joystick = C.GLFW_JOYSTICK_7
|
||||
Joystick8 Joystick = C.GLFW_JOYSTICK_8
|
||||
Joystick9 Joystick = C.GLFW_JOYSTICK_9
|
||||
Joystick10 Joystick = C.GLFW_JOYSTICK_10
|
||||
Joystick11 Joystick = C.GLFW_JOYSTICK_11
|
||||
Joystick12 Joystick = C.GLFW_JOYSTICK_12
|
||||
Joystick13 Joystick = C.GLFW_JOYSTICK_13
|
||||
Joystick14 Joystick = C.GLFW_JOYSTICK_14
|
||||
Joystick15 Joystick = C.GLFW_JOYSTICK_15
|
||||
Joystick16 Joystick = C.GLFW_JOYSTICK_16
|
||||
JoystickLast Joystick = C.GLFW_JOYSTICK_LAST
|
||||
)
|
||||
|
||||
//Key corresponds to a keyboard key.
|
||||
type Key int
|
||||
|
||||
//These key codes are inspired by the USB HID Usage Tables v1.12 (p. 53-60),
|
||||
//but re-arranged to map to 7-bit ASCII for printable keys (function keys are
|
||||
//put in the 256+ range).
|
||||
const (
|
||||
KeyUnknown Key = C.GLFW_KEY_UNKNOWN
|
||||
KeySpace Key = C.GLFW_KEY_SPACE
|
||||
KeyApostrophe Key = C.GLFW_KEY_APOSTROPHE
|
||||
KeyComma Key = C.GLFW_KEY_COMMA
|
||||
KeyMinus Key = C.GLFW_KEY_MINUS
|
||||
KeyPeriod Key = C.GLFW_KEY_PERIOD
|
||||
KeySlash Key = C.GLFW_KEY_SLASH
|
||||
Key0 Key = C.GLFW_KEY_0
|
||||
Key1 Key = C.GLFW_KEY_1
|
||||
Key2 Key = C.GLFW_KEY_2
|
||||
Key3 Key = C.GLFW_KEY_3
|
||||
Key4 Key = C.GLFW_KEY_4
|
||||
Key5 Key = C.GLFW_KEY_5
|
||||
Key6 Key = C.GLFW_KEY_6
|
||||
Key7 Key = C.GLFW_KEY_7
|
||||
Key8 Key = C.GLFW_KEY_8
|
||||
Key9 Key = C.GLFW_KEY_9
|
||||
KeySemicolon Key = C.GLFW_KEY_SEMICOLON
|
||||
KeyEqual Key = C.GLFW_KEY_EQUAL
|
||||
KeyA Key = C.GLFW_KEY_A
|
||||
KeyB Key = C.GLFW_KEY_B
|
||||
KeyC Key = C.GLFW_KEY_C
|
||||
KeyD Key = C.GLFW_KEY_D
|
||||
KeyE Key = C.GLFW_KEY_E
|
||||
KeyF Key = C.GLFW_KEY_F
|
||||
KeyG Key = C.GLFW_KEY_G
|
||||
KeyH Key = C.GLFW_KEY_H
|
||||
KeyI Key = C.GLFW_KEY_I
|
||||
KeyJ Key = C.GLFW_KEY_J
|
||||
KeyK Key = C.GLFW_KEY_K
|
||||
KeyL Key = C.GLFW_KEY_L
|
||||
KeyM Key = C.GLFW_KEY_M
|
||||
KeyN Key = C.GLFW_KEY_N
|
||||
KeyO Key = C.GLFW_KEY_O
|
||||
KeyP Key = C.GLFW_KEY_P
|
||||
KeyQ Key = C.GLFW_KEY_Q
|
||||
KeyR Key = C.GLFW_KEY_R
|
||||
KeyS Key = C.GLFW_KEY_S
|
||||
KeyT Key = C.GLFW_KEY_T
|
||||
KeyU Key = C.GLFW_KEY_U
|
||||
KeyV Key = C.GLFW_KEY_V
|
||||
KeyW Key = C.GLFW_KEY_W
|
||||
KeyX Key = C.GLFW_KEY_X
|
||||
KeyY Key = C.GLFW_KEY_Y
|
||||
KeyZ Key = C.GLFW_KEY_Z
|
||||
KeyLeftBracket Key = C.GLFW_KEY_LEFT_BRACKET
|
||||
KeyBackslash Key = C.GLFW_KEY_BACKSLASH
|
||||
KeyBracket Key = C.GLFW_KEY_RIGHT_BRACKET //Kept for backward compatbility
|
||||
KeyRightBracket Key = C.GLFW_KEY_RIGHT_BRACKET
|
||||
KeyGraveAccent Key = C.GLFW_KEY_GRAVE_ACCENT
|
||||
KeyWorld1 Key = C.GLFW_KEY_WORLD_1
|
||||
KeyWorld2 Key = C.GLFW_KEY_WORLD_2
|
||||
KeyEscape Key = C.GLFW_KEY_ESCAPE
|
||||
KeyEnter Key = C.GLFW_KEY_ENTER
|
||||
KeyTab Key = C.GLFW_KEY_TAB
|
||||
KeyBackspace Key = C.GLFW_KEY_BACKSPACE
|
||||
KeyInsert Key = C.GLFW_KEY_INSERT
|
||||
KeyDelete Key = C.GLFW_KEY_DELETE
|
||||
KeyRight Key = C.GLFW_KEY_RIGHT
|
||||
KeyLeft Key = C.GLFW_KEY_LEFT
|
||||
KeyDown Key = C.GLFW_KEY_DOWN
|
||||
KeyUp Key = C.GLFW_KEY_UP
|
||||
KeyPageUp Key = C.GLFW_KEY_PAGE_UP
|
||||
KeyPageDown Key = C.GLFW_KEY_PAGE_DOWN
|
||||
KeyHome Key = C.GLFW_KEY_HOME
|
||||
KeyEnd Key = C.GLFW_KEY_END
|
||||
KeyCapsLock Key = C.GLFW_KEY_CAPS_LOCK
|
||||
KeyScrollLock Key = C.GLFW_KEY_SCROLL_LOCK
|
||||
KeyNumLock Key = C.GLFW_KEY_NUM_LOCK
|
||||
KeyPrintScreen Key = C.GLFW_KEY_PRINT_SCREEN
|
||||
KeyPause Key = C.GLFW_KEY_PAUSE
|
||||
KeyF1 Key = C.GLFW_KEY_F1
|
||||
KeyF2 Key = C.GLFW_KEY_F2
|
||||
KeyF3 Key = C.GLFW_KEY_F3
|
||||
KeyF4 Key = C.GLFW_KEY_F4
|
||||
KeyF5 Key = C.GLFW_KEY_F5
|
||||
KeyF6 Key = C.GLFW_KEY_F6
|
||||
KeyF7 Key = C.GLFW_KEY_F7
|
||||
KeyF8 Key = C.GLFW_KEY_F8
|
||||
KeyF9 Key = C.GLFW_KEY_F9
|
||||
KeyF10 Key = C.GLFW_KEY_F10
|
||||
KeyF11 Key = C.GLFW_KEY_F11
|
||||
KeyF12 Key = C.GLFW_KEY_F12
|
||||
KeyF13 Key = C.GLFW_KEY_F13
|
||||
KeyF14 Key = C.GLFW_KEY_F14
|
||||
KeyF15 Key = C.GLFW_KEY_F15
|
||||
KeyF16 Key = C.GLFW_KEY_F16
|
||||
KeyF17 Key = C.GLFW_KEY_F17
|
||||
KeyF18 Key = C.GLFW_KEY_F18
|
||||
KeyF19 Key = C.GLFW_KEY_F19
|
||||
KeyF20 Key = C.GLFW_KEY_F20
|
||||
KeyF21 Key = C.GLFW_KEY_F21
|
||||
KeyF22 Key = C.GLFW_KEY_F22
|
||||
KeyF23 Key = C.GLFW_KEY_F23
|
||||
KeyF24 Key = C.GLFW_KEY_F24
|
||||
KeyF25 Key = C.GLFW_KEY_F25
|
||||
KeyKp0 Key = C.GLFW_KEY_KP_0
|
||||
KeyKp1 Key = C.GLFW_KEY_KP_1
|
||||
KeyKp2 Key = C.GLFW_KEY_KP_2
|
||||
KeyKp3 Key = C.GLFW_KEY_KP_3
|
||||
KeyKp4 Key = C.GLFW_KEY_KP_4
|
||||
KeyKp5 Key = C.GLFW_KEY_KP_5
|
||||
KeyKp6 Key = C.GLFW_KEY_KP_6
|
||||
KeyKp7 Key = C.GLFW_KEY_KP_7
|
||||
KeyKp8 Key = C.GLFW_KEY_KP_8
|
||||
KeyKp9 Key = C.GLFW_KEY_KP_9
|
||||
KeyKpDecimal Key = C.GLFW_KEY_KP_DECIMAL
|
||||
KeyKpDivide Key = C.GLFW_KEY_KP_DIVIDE
|
||||
KeyKpMultiply Key = C.GLFW_KEY_KP_MULTIPLY
|
||||
KeyKpSubtract Key = C.GLFW_KEY_KP_SUBTRACT
|
||||
KeyKpAdd Key = C.GLFW_KEY_KP_ADD
|
||||
KeyKpEnter Key = C.GLFW_KEY_KP_ENTER
|
||||
KeyKpEqual Key = C.GLFW_KEY_KP_EQUAL
|
||||
KeyLeftShift Key = C.GLFW_KEY_LEFT_SHIFT
|
||||
KeyLeftControl Key = C.GLFW_KEY_LEFT_CONTROL
|
||||
KeyLeftAlt Key = C.GLFW_KEY_LEFT_ALT
|
||||
KeyLeftSuper Key = C.GLFW_KEY_LEFT_SUPER
|
||||
KeyRightShift Key = C.GLFW_KEY_RIGHT_SHIFT
|
||||
KeyRightControl Key = C.GLFW_KEY_RIGHT_CONTROL
|
||||
KeyRightAlt Key = C.GLFW_KEY_RIGHT_ALT
|
||||
KeyRightSuper Key = C.GLFW_KEY_RIGHT_SUPER
|
||||
KeyMenu Key = C.GLFW_KEY_MENU
|
||||
KeyLast Key = C.GLFW_KEY_LAST
|
||||
)
|
||||
|
||||
//ModifierKey corresponds to a modifier key.
|
||||
type ModifierKey int
|
||||
|
||||
//Modifier keys
|
||||
const (
|
||||
ModShift ModifierKey = C.GLFW_MOD_SHIFT
|
||||
ModControl ModifierKey = C.GLFW_MOD_CONTROL
|
||||
ModAlt ModifierKey = C.GLFW_MOD_ALT
|
||||
ModSuper ModifierKey = C.GLFW_MOD_SUPER
|
||||
)
|
||||
|
||||
//MouseButton corresponds to a mouse button.
|
||||
type MouseButton int
|
||||
|
||||
//Mouse buttons
|
||||
const (
|
||||
MouseButton1 MouseButton = C.GLFW_MOUSE_BUTTON_1
|
||||
MouseButton2 MouseButton = C.GLFW_MOUSE_BUTTON_2
|
||||
MouseButton3 MouseButton = C.GLFW_MOUSE_BUTTON_3
|
||||
MouseButton4 MouseButton = C.GLFW_MOUSE_BUTTON_4
|
||||
MouseButton5 MouseButton = C.GLFW_MOUSE_BUTTON_5
|
||||
MouseButton6 MouseButton = C.GLFW_MOUSE_BUTTON_6
|
||||
MouseButton7 MouseButton = C.GLFW_MOUSE_BUTTON_7
|
||||
MouseButton8 MouseButton = C.GLFW_MOUSE_BUTTON_8
|
||||
MouseButtonLast MouseButton = C.GLFW_MOUSE_BUTTON_LAST
|
||||
MouseButtonLeft MouseButton = C.GLFW_MOUSE_BUTTON_LEFT
|
||||
MouseButtonRight MouseButton = C.GLFW_MOUSE_BUTTON_RIGHT
|
||||
MouseButtonMiddle MouseButton = C.GLFW_MOUSE_BUTTON_MIDDLE
|
||||
)
|
||||
|
||||
//Action corresponds to a key or button action.
|
||||
type Action int
|
||||
|
||||
const (
|
||||
Release Action = C.GLFW_RELEASE //The key or button was released.
|
||||
Press Action = C.GLFW_PRESS //The key or button was pressed.
|
||||
Repeat Action = C.GLFW_REPEAT //The key was held down until it repeated.
|
||||
)
|
||||
|
||||
//InputMode corresponds to an input mode.
|
||||
type InputMode int
|
||||
|
||||
//Input modes
|
||||
const (
|
||||
Cursor InputMode = C.GLFW_CURSOR //See Cursor mode values
|
||||
StickyKeys InputMode = C.GLFW_STICKY_KEYS //Value can be either 1 or 0
|
||||
StickyMouseButtons InputMode = C.GLFW_STICKY_MOUSE_BUTTONS //Value can be either 1 or 0
|
||||
)
|
||||
|
||||
//Cursor mode values
|
||||
const (
|
||||
CursorNormal int = C.GLFW_CURSOR_NORMAL
|
||||
CursorHidden int = C.GLFW_CURSOR_HIDDEN
|
||||
CursorDisabled int = C.GLFW_CURSOR_DISABLED
|
||||
)
|
||||
|
||||
//export goMouseButtonCB
|
||||
func goMouseButtonCB(window unsafe.Pointer, button, action, mods C.int) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fMouseButtonHolder(w, MouseButton(button), Action(action), ModifierKey(mods))
|
||||
}
|
||||
|
||||
//export goCursorPosCB
|
||||
func goCursorPosCB(window unsafe.Pointer, xpos, ypos C.float) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fCursorPosHolder(w, float64(xpos), float64(ypos))
|
||||
}
|
||||
|
||||
//export goCursorEnterCB
|
||||
func goCursorEnterCB(window unsafe.Pointer, entered C.int) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
hasEntered := glfwbool(entered)
|
||||
w.fCursorEnterHolder(w, hasEntered)
|
||||
}
|
||||
|
||||
//export goScrollCB
|
||||
func goScrollCB(window unsafe.Pointer, xoff, yoff C.float) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fScrollHolder(w, float64(xoff), float64(yoff))
|
||||
}
|
||||
|
||||
//export goKeyCB
|
||||
func goKeyCB(window unsafe.Pointer, key, scancode, action, mods C.int) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fKeyHolder(w, Key(key), int(scancode), Action(action), ModifierKey(mods))
|
||||
}
|
||||
|
||||
//export goCharCB
|
||||
func goCharCB(window unsafe.Pointer, character C.uint) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fCharHolder(w, uint(character))
|
||||
}
|
||||
|
||||
//GetInputMode returns the value of an input option of the window.
|
||||
func (w *Window) GetInputMode(mode InputMode) int {
|
||||
return int(C.glfwGetInputMode(w.data, C.int(mode)))
|
||||
}
|
||||
|
||||
//Sets an input option for the window.
|
||||
func (w *Window) SetInputMode(mode InputMode, value int) {
|
||||
C.glfwSetInputMode(w.data, C.int(mode), C.int(value))
|
||||
}
|
||||
|
||||
//GetKey returns the last reported state of a keyboard key. The returned state
|
||||
//is one of Press or Release. The higher-level state Repeat is only reported to
|
||||
//the key callback.
|
||||
//
|
||||
//If the StickyKeys input mode is enabled, this function returns Press the first
|
||||
//time you call this function after a key has been pressed, even if the key has
|
||||
//already been released.
|
||||
//
|
||||
//The key functions deal with physical keys, with key tokens named after their
|
||||
//use on the standard US keyboard layout. If you want to input text, use the
|
||||
//Unicode character callback instead.
|
||||
func (w *Window) GetKey(key Key) Action {
|
||||
return Action(C.glfwGetKey(w.data, C.int(key)))
|
||||
}
|
||||
|
||||
//GetMouseButton returns the last state reported for the specified mouse button.
|
||||
//
|
||||
//If the StickyMouseButtons input mode is enabled, this function returns Press
|
||||
//the first time you call this function after a mouse button has been pressed,
|
||||
//even if the mouse button has already been released.
|
||||
func (w *Window) GetMouseButton(button MouseButton) Action {
|
||||
return Action(C.glfwGetMouseButton(w.data, C.int(button)))
|
||||
}
|
||||
|
||||
//GetCursorPosition returns the last reported position of the cursor.
|
||||
//
|
||||
//If the cursor is disabled (with CursorDisabled) then the cursor position is
|
||||
//unbounded and limited only by the minimum and maximum values of a double.
|
||||
//
|
||||
//The coordinate can be converted to their integer equivalents with the floor
|
||||
//function. Casting directly to an integer type works for positive coordinates,
|
||||
//but fails for negative ones.
|
||||
func (w *Window) GetCursorPosition() (x, y float64) {
|
||||
var xpos, ypos C.double
|
||||
|
||||
C.glfwGetCursorPos(w.data, &xpos, &ypos)
|
||||
return float64(xpos), float64(ypos)
|
||||
}
|
||||
|
||||
//SetCursorPosition sets the position of the cursor. The specified window must
|
||||
//be focused. If the window does not have focus when this function is called,
|
||||
//it fails silently.
|
||||
//
|
||||
//If the cursor is disabled (with CursorDisabled) then the cursor position is
|
||||
//unbounded and limited only by the minimum and maximum values of a double.
|
||||
func (w *Window) SetCursorPosition(xpos, ypos float64) {
|
||||
C.glfwSetCursorPos(w.data, C.double(xpos), C.double(ypos))
|
||||
}
|
||||
|
||||
//SetKeyCallback sets the key callback which is called when a key is pressed,
|
||||
//repeated or released.
|
||||
//
|
||||
//The key functions deal with physical keys, with layout independent key tokens
|
||||
//named after their values in the standard US keyboard layout. If you want to
|
||||
//input text, use the SetCharCallback instead.
|
||||
//
|
||||
//When a window loses focus, it will generate synthetic key release events for
|
||||
//all pressed keys. You can tell these events from user-generated events by the
|
||||
//fact that the synthetic ones are generated after the window has lost focus,
|
||||
//i.e. Focused will be false and the focus callback will have already been
|
||||
//called.
|
||||
func (w *Window) SetKeyCallback(cbfun func(w *Window, key Key, scancode int, action Action, mods ModifierKey)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetKeyCallback(w.data, nil)
|
||||
} else {
|
||||
w.fKeyHolder = cbfun
|
||||
C.glfwSetKeyCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetCharacterCallback sets the character callback which is called when a
|
||||
//Unicode character is input.
|
||||
//
|
||||
//The character callback is intended for text input. If you want to know whether
|
||||
//a specific key was pressed or released, use the key callback instead.
|
||||
func (w *Window) SetCharacterCallback(cbfun func(w *Window, char uint)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetCharCallback(w.data, nil)
|
||||
} else {
|
||||
w.fCharHolder = cbfun
|
||||
C.glfwSetCharCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetMouseButtonCallback sets the mouse button callback which is called when a
|
||||
//mouse button is pressed or released.
|
||||
//
|
||||
//When a window loses focus, it will generate synthetic mouse button release
|
||||
//events for all pressed mouse buttons. You can tell these events from
|
||||
//user-generated events by the fact that the synthetic ones are generated after
|
||||
//the window has lost focus, i.e. Focused will be false and the focus
|
||||
//callback will have already been called.
|
||||
func (w *Window) SetMouseButtonCallback(cbfun func(w *Window, button MouseButton, action Action, mod ModifierKey)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetMouseButtonCallback(w.data, nil)
|
||||
} else {
|
||||
w.fMouseButtonHolder = cbfun
|
||||
C.glfwSetMouseButtonCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetCursorPositionCallback sets the cursor position callback which is called
|
||||
//when the cursor is moved. The callback is provided with the position relative
|
||||
//to the upper-left corner of the client area of the window.
|
||||
func (w *Window) SetCursorPositionCallback(cbfun func(w *Window, xpos float64, ypos float64)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetCursorPosCallback(w.data, nil)
|
||||
} else {
|
||||
w.fCursorPosHolder = cbfun
|
||||
C.glfwSetCursorPosCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetCursorEnterCallback the cursor boundary crossing callback which is called
|
||||
//when the cursor enters or leaves the client area of the window.
|
||||
func (w *Window) SetCursorEnterCallback(cbfun func(w *Window, entered bool)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetCursorEnterCallback(w.data, nil)
|
||||
} else {
|
||||
w.fCursorEnterHolder = cbfun
|
||||
C.glfwSetCursorEnterCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetScrollCallback sets the scroll callback which is called when a scrolling
|
||||
//device is used, such as a mouse wheel or scrolling area of a touchpad.
|
||||
func (w *Window) SetScrollCallback(cbfun func(w *Window, xoff float64, yoff float64)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetScrollCallback(w.data, nil)
|
||||
} else {
|
||||
w.fScrollHolder = cbfun
|
||||
C.glfwSetScrollCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//GetJoystickPresent returns whether the specified joystick is present.
|
||||
func JoystickPresent(joy Joystick) bool {
|
||||
return glfwbool(C.glfwJoystickPresent(C.int(joy)))
|
||||
}
|
||||
|
||||
//GetJoystickAxes returns a slice of axis values.
|
||||
func GetJoystickAxes(joy Joystick) ([]float32, error) {
|
||||
var length int
|
||||
|
||||
axis := C.glfwGetJoystickAxes(C.int(joy), (*C.int)(unsafe.Pointer(&length)))
|
||||
if axis == nil {
|
||||
return nil, errors.New("Joystick is not present.")
|
||||
}
|
||||
|
||||
a := make([]float32, length)
|
||||
for i := 0; i < length; i++ {
|
||||
a[i] = float32(C.GetAxisAtIndex(axis, C.int(i)))
|
||||
}
|
||||
|
||||
return a, nil
|
||||
}
|
||||
|
||||
//GetJoystickButtons returns a slice of button values.
|
||||
func GetJoystickButtons(joy Joystick) ([]byte, error) {
|
||||
var length int
|
||||
|
||||
buttons := C.glfwGetJoystickButtons(C.int(joy), (*C.int)(unsafe.Pointer(&length)))
|
||||
if buttons == nil {
|
||||
return nil, errors.New("Joystick is not present.")
|
||||
}
|
||||
|
||||
b := make([]byte, length)
|
||||
for i := 0; i < length; i++ {
|
||||
b[i] = byte(C.GetButtonsAtIndex(buttons, C.int(i)))
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
//GetJoystickName returns the name, encoded as UTF-8, of the specified joystick.
|
||||
func GetJoystickName(joy Joystick) (string, error) {
|
||||
jn := C.glfwGetJoystickName(C.int(joy))
|
||||
if jn == nil {
|
||||
return "", errors.New("Joystick is not present.")
|
||||
}
|
||||
|
||||
return C.GoString(jn), nil
|
||||
}
|
25
vendor/github.com/go-gl/glfw/v3.0/glfw/monitor.c
generated
vendored
Normal file
25
vendor/github.com/go-gl/glfw/v3.0/glfw/monitor.c
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "_cgo_export.h"
|
||||
|
||||
GLFWmonitor *GetMonitorAtIndex(GLFWmonitor **monitors, int index) {
|
||||
return monitors[index];
|
||||
}
|
||||
|
||||
GLFWvidmode GetVidmodeAtIndex(GLFWvidmode *vidmodes, int index) {
|
||||
return vidmodes[index];
|
||||
}
|
||||
|
||||
void glfwMonitorCB(GLFWmonitor* monitor, int event) {
|
||||
goMonitorCB(monitor, event);
|
||||
}
|
||||
|
||||
void glfwSetMonitorCallbackCB() {
|
||||
glfwSetMonitorCallback(glfwMonitorCB);
|
||||
}
|
||||
|
||||
unsigned int GetGammaAtIndex(unsigned short *color, int i) {
|
||||
return color[i];
|
||||
}
|
||||
|
||||
void SetGammaAtIndex(unsigned short *color, int i, unsigned short value) {
|
||||
color[i] = value;
|
||||
}
|
203
vendor/github.com/go-gl/glfw/v3.0/glfw/monitor.go
generated
vendored
Normal file
203
vendor/github.com/go-gl/glfw/v3.0/glfw/monitor.go
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
package glfw
|
||||
|
||||
//#include <GLFW/glfw3.h>
|
||||
//GLFWmonitor* GetMonitorAtIndex(GLFWmonitor **monitors, int index);
|
||||
//GLFWvidmode GetVidmodeAtIndex(GLFWvidmode *vidmodes, int index);
|
||||
//void glfwSetMonitorCallbackCB();
|
||||
//unsigned int GetGammaAtIndex(unsigned short *color, int i);
|
||||
//void SetGammaAtIndex(unsigned short *color, int i, unsigned short value);
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type Monitor struct {
|
||||
data *C.GLFWmonitor
|
||||
}
|
||||
|
||||
//MonitorEvent corresponds to a monitor configuration event.
|
||||
type MonitorEvent int
|
||||
|
||||
//GammaRamp describes the gamma ramp for a monitor.
|
||||
type GammaRamp struct {
|
||||
Red []uint16 //A slice of value describing the response of the red channel.
|
||||
Green []uint16 //A slice of value describing the response of the green channel.
|
||||
Blue []uint16 //A slice of value describing the response of the blue channel.
|
||||
}
|
||||
|
||||
//Monitor events.
|
||||
const (
|
||||
Connected MonitorEvent = C.GLFW_CONNECTED
|
||||
Disconnected MonitorEvent = C.GLFW_DISCONNECTED
|
||||
)
|
||||
|
||||
//VideoMode describes a single video mode.
|
||||
type VideoMode struct {
|
||||
Width int //The width, in pixels, of the video mode.
|
||||
Height int //The height, in pixels, of the video mode.
|
||||
RedBits int //The bit depth of the red channel of the video mode.
|
||||
GreenBits int //The bit depth of the green channel of the video mode.
|
||||
BlueBits int //The bit depth of the blue channel of the video mode.
|
||||
RefreshRate int //The refresh rate, in Hz, of the video mode.
|
||||
}
|
||||
|
||||
var fMonitorHolder func(monitor *Monitor, event MonitorEvent)
|
||||
|
||||
//export goMonitorCB
|
||||
func goMonitorCB(monitor unsafe.Pointer, event C.int) {
|
||||
fMonitorHolder(&Monitor{(*C.GLFWmonitor)(monitor)}, MonitorEvent(event))
|
||||
}
|
||||
|
||||
//GetMonitors returns a slice of handles for all currently connected monitors.
|
||||
func GetMonitors() ([]*Monitor, error) {
|
||||
var length int
|
||||
|
||||
mC := C.glfwGetMonitors((*C.int)(unsafe.Pointer(&length)))
|
||||
|
||||
if mC == nil {
|
||||
return nil, errors.New("Can't get the monitor list.")
|
||||
}
|
||||
|
||||
m := make([]*Monitor, length)
|
||||
|
||||
for i := 0; i < length; i++ {
|
||||
m[i] = &Monitor{C.GetMonitorAtIndex(mC, C.int(i))}
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
//GetPrimaryMonitor returns the primary monitor. This is usually the monitor
|
||||
//where elements like the Windows task bar or the OS X menu bar is located.
|
||||
func GetPrimaryMonitor() (*Monitor, error) {
|
||||
m := C.glfwGetPrimaryMonitor()
|
||||
|
||||
if m == nil {
|
||||
return nil, errors.New("Can't get the primary monitor.")
|
||||
}
|
||||
return &Monitor{m}, nil
|
||||
}
|
||||
|
||||
//GetPosition returns the position, in screen coordinates, of the upper-left
|
||||
//corner of the monitor.
|
||||
func (m *Monitor) GetPosition() (x, y int) {
|
||||
var xpos, ypos C.int
|
||||
|
||||
C.glfwGetMonitorPos(m.data, &xpos, &ypos)
|
||||
return int(xpos), int(ypos)
|
||||
}
|
||||
|
||||
//GetPhysicalSize returns the size, in millimetres, of the display area of the
|
||||
//monitor.
|
||||
//
|
||||
//Note: Some operating systems do not provide accurate information, either
|
||||
//because the monitor's EDID data is incorrect, or because the driver does not
|
||||
//report it accurately.
|
||||
func (m *Monitor) GetPhysicalSize() (width, height int) {
|
||||
var wi, h C.int
|
||||
|
||||
C.glfwGetMonitorPhysicalSize(m.data, &wi, &h)
|
||||
return int(wi), int(h)
|
||||
}
|
||||
|
||||
//GetName returns a human-readable name of the monitor, encoded as UTF-8.
|
||||
func (m *Monitor) GetName() (string, error) {
|
||||
mn := C.glfwGetMonitorName(m.data)
|
||||
if mn == nil {
|
||||
return "", errors.New("Can't get monitor name.")
|
||||
}
|
||||
|
||||
return C.GoString(mn), nil
|
||||
}
|
||||
|
||||
//SetMonitorCallback sets the monitor configuration callback, or removes the
|
||||
//currently set callback. This is called when a monitor is connected to or
|
||||
//disconnected from the system.
|
||||
func SetMonitorCallback(cbfun func(monitor *Monitor, event MonitorEvent)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetMonitorCallback(nil)
|
||||
} else {
|
||||
fMonitorHolder = cbfun
|
||||
C.glfwSetMonitorCallbackCB()
|
||||
}
|
||||
}
|
||||
|
||||
//GetVideoModes returns an array of all video modes supported by the monitor.
|
||||
//The returned array is sorted in ascending order, first by color bit depth
|
||||
//(the sum of all channel depths) and then by resolution area (the product of
|
||||
//width and height).
|
||||
func (m *Monitor) GetVideoModes() ([]*VideoMode, error) {
|
||||
var length int
|
||||
|
||||
vC := C.glfwGetVideoModes(m.data, (*C.int)(unsafe.Pointer(&length)))
|
||||
if vC == nil {
|
||||
return nil, errors.New("Can't get the video mode list.")
|
||||
}
|
||||
|
||||
v := make([]*VideoMode, length)
|
||||
|
||||
for i := 0; i < length; i++ {
|
||||
t := C.GetVidmodeAtIndex(vC, C.int(i))
|
||||
v[i] = &VideoMode{int(t.width), int(t.height), int(t.redBits), int(t.greenBits), int(t.blueBits), int(t.refreshRate)}
|
||||
}
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
//GetVideoMode returns the current video mode of the monitor. If you
|
||||
//are using a full screen window, the return value will therefore depend on
|
||||
//whether it is focused.
|
||||
func (m *Monitor) GetVideoMode() (*VideoMode, error) {
|
||||
t := C.glfwGetVideoMode(m.data)
|
||||
|
||||
if t == nil {
|
||||
return nil, errors.New("Can't get the video mode.")
|
||||
}
|
||||
return &VideoMode{int(t.width), int(t.height), int(t.redBits), int(t.greenBits), int(t.blueBits), int(t.refreshRate)}, nil
|
||||
}
|
||||
|
||||
//SetGamma generates a 256-element gamma ramp from the specified exponent and then calls
|
||||
//SetGamma with it.
|
||||
func (m *Monitor) SetGamma(gamma float32) {
|
||||
C.glfwSetGamma(m.data, C.float(gamma))
|
||||
}
|
||||
|
||||
//GetGammaRamp retrieves the current gamma ramp of the monitor.
|
||||
func (m *Monitor) GetGammaRamp() (*GammaRamp, error) {
|
||||
var ramp GammaRamp
|
||||
|
||||
rampC := C.glfwGetGammaRamp(m.data)
|
||||
if rampC == nil {
|
||||
return nil, errors.New("Can't get the gamma ramp.")
|
||||
}
|
||||
|
||||
length := int(rampC.size)
|
||||
ramp.Red = make([]uint16, length)
|
||||
ramp.Green = make([]uint16, length)
|
||||
ramp.Blue = make([]uint16, length)
|
||||
|
||||
for i := 0; i < length; i++ {
|
||||
ramp.Red[i] = uint16(C.GetGammaAtIndex(rampC.red, C.int(i)))
|
||||
ramp.Green[i] = uint16(C.GetGammaAtIndex(rampC.green, C.int(i)))
|
||||
ramp.Blue[i] = uint16(C.GetGammaAtIndex(rampC.blue, C.int(i)))
|
||||
}
|
||||
|
||||
return &ramp, nil
|
||||
}
|
||||
|
||||
//SetGammaRamp sets the current gamma ramp for the monitor.
|
||||
func (m *Monitor) SetGammaRamp(ramp *GammaRamp) {
|
||||
var rampC C.GLFWgammaramp
|
||||
|
||||
length := len(ramp.Red)
|
||||
|
||||
for i := 0; i < length; i++ {
|
||||
C.SetGammaAtIndex(rampC.red, C.int(i), C.ushort(ramp.Red[i]))
|
||||
C.SetGammaAtIndex(rampC.green, C.int(i), C.ushort(ramp.Green[i]))
|
||||
C.SetGammaAtIndex(rampC.blue, C.int(i), C.ushort(ramp.Blue[i]))
|
||||
}
|
||||
|
||||
C.glfwSetGammaRamp(m.data, &rampC)
|
||||
}
|
15
vendor/github.com/go-gl/glfw/v3.0/glfw/native_darwin.go
generated
vendored
Normal file
15
vendor/github.com/go-gl/glfw/v3.0/glfw/native_darwin.go
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
package glfw
|
||||
|
||||
//#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
//#define GLFW_EXPOSE_NATIVE_NSGL
|
||||
//#include <GLFW/glfw3.h>
|
||||
//#include <GLFW/glfw3native.h>
|
||||
import "C"
|
||||
|
||||
func (w *Window) GetCocoaWindow() C.id {
|
||||
return C.glfwGetCocoaWindow(w.data)
|
||||
}
|
||||
|
||||
func (w *Window) GetNSGLContext() C.id {
|
||||
return C.glfwGetNSGLContext(w.data)
|
||||
}
|
22
vendor/github.com/go-gl/glfw/v3.0/glfw/native_linbsd.go
generated
vendored
Normal file
22
vendor/github.com/go-gl/glfw/v3.0/glfw/native_linbsd.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
//+build linux freebsd
|
||||
|
||||
package glfw
|
||||
|
||||
//#define GLFW_EXPOSE_NATIVE_X11
|
||||
//#define GLFW_EXPOSE_NATIVE_GLX
|
||||
//#include <X11/extensions/Xrandr.h>
|
||||
//#include <GLFW/glfw3.h>
|
||||
//#include <GLFW/glfw3native.h>
|
||||
import "C"
|
||||
|
||||
func (w *Window) GetX11Window() C.Window {
|
||||
return C.glfwGetX11Window(w.data)
|
||||
}
|
||||
|
||||
func (w *Window) GetGLXContext() C.GLXContext {
|
||||
return C.glfwGetGLXContext(w.data)
|
||||
}
|
||||
|
||||
func GetX11Display() *C.Display {
|
||||
return C.glfwGetX11Display()
|
||||
}
|
15
vendor/github.com/go-gl/glfw/v3.0/glfw/native_windows.go
generated
vendored
Normal file
15
vendor/github.com/go-gl/glfw/v3.0/glfw/native_windows.go
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
package glfw
|
||||
|
||||
//#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
//#define GLFW_EXPOSE_NATIVE_WGL
|
||||
//#include <GLFW/glfw3.h>
|
||||
//#include <GLFW/glfw3native.h>
|
||||
import "C"
|
||||
|
||||
func (w *Window) GetWin32Window() C.HWND {
|
||||
return C.glfwGetWin32Window(w.data)
|
||||
}
|
||||
|
||||
func (w *Window) GetWGLContext() C.HGLRC {
|
||||
return C.glfwGetWGLContext(w.data)
|
||||
}
|
24
vendor/github.com/go-gl/glfw/v3.0/glfw/time.go
generated
vendored
Normal file
24
vendor/github.com/go-gl/glfw/v3.0/glfw/time.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package glfw
|
||||
|
||||
//#include <GLFW/glfw3.h>
|
||||
import "C"
|
||||
|
||||
//GetTime returns the value of the GLFW timer. Unless the timer has been set
|
||||
//using SetTime, the timer measures time elapsed since GLFW was initialized.
|
||||
//
|
||||
//The resolution of the timer is system dependent, but is usually on the order
|
||||
//of a few micro- or nanoseconds. It uses the highest-resolution monotonic time
|
||||
//source on each supported platform.
|
||||
func GetTime() float64 {
|
||||
return float64(C.glfwGetTime())
|
||||
}
|
||||
|
||||
//SetTime sets the value of the GLFW timer. It then continues to count up from
|
||||
//that value.
|
||||
//
|
||||
//The resolution of the timer is system dependent, but is usually on the order
|
||||
//of a few micro- or nanoseconds. It uses the highest-resolution monotonic time
|
||||
//source on each supported platform.
|
||||
func SetTime(time float64) {
|
||||
C.glfwSetTime(C.double(time))
|
||||
}
|
11
vendor/github.com/go-gl/glfw/v3.0/glfw/util.go
generated
vendored
Normal file
11
vendor/github.com/go-gl/glfw/v3.0/glfw/util.go
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
package glfw
|
||||
|
||||
//#include <GLFW/glfw3.h>
|
||||
import "C"
|
||||
|
||||
func glfwbool(b C.int) bool {
|
||||
if b == C.GL_TRUE {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
57
vendor/github.com/go-gl/glfw/v3.0/glfw/window.c
generated
vendored
Normal file
57
vendor/github.com/go-gl/glfw/v3.0/glfw/window.c
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "_cgo_export.h"
|
||||
|
||||
void glfwWindowPosCB(GLFWwindow* window, int xpos, int ypos) {
|
||||
goWindowPosCB(window, xpos, ypos);
|
||||
}
|
||||
|
||||
void glfwWindowSizeCB(GLFWwindow* window, int width, int height) {
|
||||
goWindowSizeCB(window, width, height);
|
||||
}
|
||||
|
||||
void glfwFramebufferSizeCB(GLFWwindow* window, int width, int height) {
|
||||
goFramebufferSizeCB(window, width, height);
|
||||
}
|
||||
|
||||
void glfwWindowCloseCB(GLFWwindow* window) {
|
||||
goWindowCloseCB(window);
|
||||
}
|
||||
|
||||
void glfwWindowRefreshCB(GLFWwindow* window) {
|
||||
goWindowRefreshCB(window);
|
||||
}
|
||||
|
||||
void glfwWindowFocusCB(GLFWwindow* window, int focused) {
|
||||
goWindowFocusCB(window, focused);
|
||||
}
|
||||
|
||||
void glfwWindowIconifyCB(GLFWwindow* window, int iconified) {
|
||||
goWindowIconifyCB(window, iconified);
|
||||
}
|
||||
|
||||
void glfwSetWindowPosCallbackCB(GLFWwindow* window) {
|
||||
glfwSetWindowPosCallback(window, glfwWindowPosCB);
|
||||
}
|
||||
|
||||
void glfwSetWindowSizeCallbackCB(GLFWwindow* window) {
|
||||
glfwSetWindowSizeCallback(window, glfwWindowSizeCB);
|
||||
}
|
||||
|
||||
void glfwSetFramebufferSizeCallbackCB(GLFWwindow* window) {
|
||||
glfwSetFramebufferSizeCallback(window, glfwFramebufferSizeCB);
|
||||
}
|
||||
|
||||
void glfwSetWindowCloseCallbackCB(GLFWwindow* window) {
|
||||
glfwSetWindowCloseCallback(window, glfwWindowCloseCB);
|
||||
}
|
||||
|
||||
void glfwSetWindowRefreshCallbackCB(GLFWwindow* window) {
|
||||
glfwSetWindowRefreshCallback(window, glfwWindowRefreshCB);
|
||||
}
|
||||
|
||||
void glfwSetWindowFocusCallbackCB(GLFWwindow* window) {
|
||||
glfwSetWindowFocusCallback(window, glfwWindowFocusCB);
|
||||
}
|
||||
|
||||
void glfwSetWindowIconifyCallbackCB(GLFWwindow* window) {
|
||||
glfwSetWindowIconifyCallback(window, glfwWindowIconifyCB);
|
||||
}
|
549
vendor/github.com/go-gl/glfw/v3.0/glfw/window.go
generated
vendored
Normal file
549
vendor/github.com/go-gl/glfw/v3.0/glfw/window.go
generated
vendored
Normal file
@@ -0,0 +1,549 @@
|
||||
package glfw
|
||||
|
||||
//#include <stdlib.h>
|
||||
//#include <GLFW/glfw3.h>
|
||||
//void glfwSetWindowPosCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetWindowSizeCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetFramebufferSizeCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetWindowCloseCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetWindowRefreshCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetWindowFocusCallbackCB(GLFWwindow *window);
|
||||
//void glfwSetWindowIconifyCallbackCB(GLFWwindow *window);
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Internal window list stuff
|
||||
type windowList struct {
|
||||
l sync.Mutex
|
||||
m map[*C.GLFWwindow]*Window
|
||||
}
|
||||
|
||||
var windows = windowList{m: map[*C.GLFWwindow]*Window{}}
|
||||
|
||||
func (w *windowList) put(wnd *Window) {
|
||||
w.l.Lock()
|
||||
defer w.l.Unlock()
|
||||
w.m[wnd.data] = wnd
|
||||
}
|
||||
|
||||
func (w *windowList) remove(wnd *C.GLFWwindow) {
|
||||
w.l.Lock()
|
||||
defer w.l.Unlock()
|
||||
delete(w.m, wnd)
|
||||
}
|
||||
|
||||
func (w *windowList) get(wnd *C.GLFWwindow) *Window {
|
||||
w.l.Lock()
|
||||
defer w.l.Unlock()
|
||||
return w.m[wnd]
|
||||
}
|
||||
|
||||
//Hint corresponds to hints that can be set before creating a window.
|
||||
//
|
||||
//Hint also corresponds to the attributes of the window that can be get after
|
||||
//its creation.
|
||||
type Hint int
|
||||
|
||||
//Window related hints.
|
||||
const (
|
||||
Focused Hint = C.GLFW_FOCUSED //Specifies whether the window will be focused.
|
||||
Iconified Hint = C.GLFW_ICONIFIED //Specifies whether the window will be minimized.
|
||||
Visible Hint = C.GLFW_VISIBLE //Specifies whether the window will be initially visible.
|
||||
Resizable Hint = C.GLFW_RESIZABLE //Specifies whether the window will be resizable by the user.
|
||||
Decorated Hint = C.GLFW_DECORATED //Specifies whether the window will have window decorations such as a border, a close widget, etc.
|
||||
)
|
||||
|
||||
//Context related hints.
|
||||
const (
|
||||
ClientApi Hint = C.GLFW_CLIENT_API //Specifies which client API to create the context for. Hard constraint.
|
||||
ContextVersionMajor Hint = C.GLFW_CONTEXT_VERSION_MAJOR //Specifies the client API version that the created context must be compatible with.
|
||||
ContextVersionMinor Hint = C.GLFW_CONTEXT_VERSION_MINOR //Specifies the client API version that the created context must be compatible with.
|
||||
ContextRobustness Hint = C.GLFW_CONTEXT_ROBUSTNESS //Specifies the robustness strategy to be used by the context.
|
||||
OpenglForwardCompatible Hint = C.GLFW_OPENGL_FORWARD_COMPAT //Specifies whether the OpenGL context should be forward-compatible. Hard constraint.
|
||||
OpenglDebugContext Hint = C.GLFW_OPENGL_DEBUG_CONTEXT
|
||||
OpenglProfile Hint = C.GLFW_OPENGL_PROFILE //Specifies which OpenGL profile to create the context for. Hard constraint.
|
||||
)
|
||||
|
||||
//Framebuffer related hints.
|
||||
const (
|
||||
ContextRevision Hint = C.GLFW_CONTEXT_REVISION
|
||||
RedBits Hint = C.GLFW_RED_BITS //Specifies the desired bit depth of the default framebuffer.
|
||||
GreenBits Hint = C.GLFW_GREEN_BITS //Specifies the desired bit depth of the default framebuffer.
|
||||
BlueBits Hint = C.GLFW_BLUE_BITS //Specifies the desired bit depth of the default framebuffer.
|
||||
AlphaBits Hint = C.GLFW_ALPHA_BITS //Specifies the desired bit depth of the default framebuffer.
|
||||
DepthBits Hint = C.GLFW_DEPTH_BITS //Specifies the desired bit depth of the default framebuffer.
|
||||
StencilBits Hint = C.GLFW_STENCIL_BITS //Specifies the desired bit depth of the default framebuffer.
|
||||
AccumRedBits Hint = C.GLFW_ACCUM_RED_BITS //Specifies the desired bit depth of the accumulation buffer.
|
||||
AccumGreenBits Hint = C.GLFW_ACCUM_GREEN_BITS //Specifies the desired bit depth of the accumulation buffer.
|
||||
AccumBlueBits Hint = C.GLFW_ACCUM_BLUE_BITS //Specifies the desired bit depth of the accumulation buffer.
|
||||
AccumAlphaBits Hint = C.GLFW_ACCUM_ALPHA_BITS //Specifies the desired bit depth of the accumulation buffer.
|
||||
AuxBuffers Hint = C.GLFW_AUX_BUFFERS //Specifies the desired number of auxiliary buffers.
|
||||
Stereo Hint = C.GLFW_STEREO //Specifies whether to use stereoscopic rendering. Hard constraint.
|
||||
Samples Hint = C.GLFW_SAMPLES //Specifies the desired number of samples to use for multisampling. Zero disables multisampling.
|
||||
SrgbCapable Hint = C.GLFW_SRGB_CAPABLE //Specifies whether the framebuffer should be sRGB capable.
|
||||
RefreshRate Hint = C.GLFW_REFRESH_RATE //specifies the desired refresh rate for full screen windows. If set to zero, the highest available refresh rate will be used. This hint is ignored for windowed mode windows.
|
||||
)
|
||||
|
||||
//Values for the ClientApi hint.
|
||||
const (
|
||||
OpenglApi int = C.GLFW_OPENGL_API
|
||||
OpenglEsApi int = C.GLFW_OPENGL_ES_API
|
||||
)
|
||||
|
||||
//Values for the ContextRobustness hint.
|
||||
const (
|
||||
NoRobustness int = C.GLFW_NO_ROBUSTNESS
|
||||
NoResetNotification int = C.GLFW_NO_RESET_NOTIFICATION
|
||||
LoseContextOnReset int = C.GLFW_LOSE_CONTEXT_ON_RESET
|
||||
)
|
||||
|
||||
//Values for the OpenglProfile hint.
|
||||
const (
|
||||
OpenglAnyProfile int = C.GLFW_OPENGL_ANY_PROFILE
|
||||
OpenglCoreProfile int = C.GLFW_OPENGL_CORE_PROFILE
|
||||
OpenglCompatProfile int = C.GLFW_OPENGL_COMPAT_PROFILE
|
||||
)
|
||||
|
||||
//TRUE and FALSE values to use with hints.
|
||||
const (
|
||||
True int = C.GL_TRUE
|
||||
False int = C.GL_FALSE
|
||||
)
|
||||
|
||||
type Window struct {
|
||||
data *C.GLFWwindow
|
||||
|
||||
// Window
|
||||
fPosHolder func(w *Window, xpos int, ypos int)
|
||||
fSizeHolder func(w *Window, width int, height int)
|
||||
fFramebufferSizeHolder func(w *Window, width int, height int)
|
||||
fCloseHolder func(w *Window)
|
||||
fRefreshHolder func(w *Window)
|
||||
fFocusHolder func(w *Window, focused bool)
|
||||
fIconifyHolder func(w *Window, iconified bool)
|
||||
|
||||
// Input
|
||||
fMouseButtonHolder func(w *Window, button MouseButton, action Action, mod ModifierKey)
|
||||
fCursorPosHolder func(w *Window, xpos float64, ypos float64)
|
||||
fCursorEnterHolder func(w *Window, entered bool)
|
||||
fScrollHolder func(w *Window, xoff float64, yoff float64)
|
||||
fKeyHolder func(w *Window, key Key, scancode int, action Action, mods ModifierKey)
|
||||
fCharHolder func(w *Window, char uint)
|
||||
}
|
||||
|
||||
//export goWindowPosCB
|
||||
func goWindowPosCB(window unsafe.Pointer, xpos, ypos C.int) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fPosHolder(w, int(xpos), int(ypos))
|
||||
}
|
||||
|
||||
//export goWindowSizeCB
|
||||
func goWindowSizeCB(window unsafe.Pointer, width, height C.int) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fSizeHolder(w, int(width), int(height))
|
||||
}
|
||||
|
||||
//export goFramebufferSizeCB
|
||||
func goFramebufferSizeCB(window unsafe.Pointer, width, height C.int) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fFramebufferSizeHolder(w, int(width), int(height))
|
||||
}
|
||||
|
||||
//export goWindowCloseCB
|
||||
func goWindowCloseCB(window unsafe.Pointer) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fCloseHolder(w)
|
||||
}
|
||||
|
||||
//export goWindowRefreshCB
|
||||
func goWindowRefreshCB(window unsafe.Pointer) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fRefreshHolder(w)
|
||||
}
|
||||
|
||||
//export goWindowFocusCB
|
||||
func goWindowFocusCB(window unsafe.Pointer, focused C.int) {
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
isFocused := glfwbool(focused)
|
||||
w.fFocusHolder(w, isFocused)
|
||||
}
|
||||
|
||||
//export goWindowIconifyCB
|
||||
func goWindowIconifyCB(window unsafe.Pointer, iconified C.int) {
|
||||
isIconified := glfwbool(iconified)
|
||||
w := windows.get((*C.GLFWwindow)(window))
|
||||
w.fIconifyHolder(w, isIconified)
|
||||
}
|
||||
|
||||
//DefaultHints resets all window hints to their default values.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func DefaultWindowHints() {
|
||||
C.glfwDefaultWindowHints()
|
||||
}
|
||||
|
||||
//Hint function sets hints for the next call to CreateWindow. The hints,
|
||||
//once set, retain their values until changed by a call to Hint or
|
||||
//DefaultHints, or until the library is terminated with Terminate.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func WindowHint(target Hint, hint int) {
|
||||
C.glfwWindowHint(C.int(target), C.int(hint))
|
||||
}
|
||||
|
||||
//CreateWindow creates a window and its associated context. Most of the options
|
||||
//controlling how the window and its context should be created are specified
|
||||
//through Hint.
|
||||
//
|
||||
//Successful creation does not change which context is current. Before you can
|
||||
//use the newly created context, you need to make it current using
|
||||
//MakeContextCurrent.
|
||||
//
|
||||
//Note that the created window and context may differ from what you requested,
|
||||
//as not all parameters and hints are hard constraints. This includes the size
|
||||
//of the window, especially for full screen windows. To retrieve the actual
|
||||
//attributes of the created window and context, use queries like
|
||||
//GetWindowAttrib and GetWindowSize.
|
||||
//
|
||||
//To create the window at a specific position, make it initially invisible using
|
||||
//the Visible window hint, set its position and then show it.
|
||||
//
|
||||
//If a fullscreen window is active, the screensaver is prohibited from starting.
|
||||
//
|
||||
//Windows: If the executable has an icon resource named GLFW_ICON, it will be
|
||||
//set as the icon for the window. If no such icon is present, the IDI_WINLOGO
|
||||
//icon will be used instead.
|
||||
//
|
||||
//Mac OS X: The GLFW window has no icon, as it is not a document window, but the
|
||||
//dock icon will be the same as the application bundle's icon. Also, the first
|
||||
//time a window is opened the menu bar is populated with common commands like
|
||||
//Hide, Quit and About. The (minimal) about dialog uses information from the
|
||||
//application's bundle. For more information on bundles, see the Bundle
|
||||
//Programming Guide provided by Apple.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func CreateWindow(width, height int, title string, monitor *Monitor, share *Window) (*Window, error) {
|
||||
var (
|
||||
m *C.GLFWmonitor
|
||||
s *C.GLFWwindow
|
||||
)
|
||||
|
||||
t := C.CString(title)
|
||||
defer C.free(unsafe.Pointer(t))
|
||||
|
||||
if monitor != nil {
|
||||
m = monitor.data
|
||||
}
|
||||
|
||||
if share != nil {
|
||||
s = share.data
|
||||
}
|
||||
|
||||
w := C.glfwCreateWindow(C.int(width), C.int(height), t, m, s)
|
||||
|
||||
if w == nil {
|
||||
return nil, errors.New("Can't create window.")
|
||||
}
|
||||
wnd := &Window{data: w}
|
||||
windows.put(wnd)
|
||||
return wnd, nil
|
||||
}
|
||||
|
||||
//Destroy destroys the specified window and its context. On calling this
|
||||
//function, no further callbacks will be called for that window.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) Destroy() {
|
||||
windows.remove(w.data)
|
||||
C.glfwDestroyWindow(w.data)
|
||||
}
|
||||
|
||||
//ShouldClose returns the value of the close flag of the specified window.
|
||||
func (w *Window) ShouldClose() bool {
|
||||
return glfwbool(C.glfwWindowShouldClose(w.data))
|
||||
}
|
||||
|
||||
//SetShouldClose sets the value of the close flag of the window. This can be
|
||||
//used to override the user's attempt to close the window, or to signal that it
|
||||
//should be closed.
|
||||
func (w *Window) SetShouldClose(value bool) {
|
||||
if !value {
|
||||
C.glfwSetWindowShouldClose(w.data, C.GL_FALSE)
|
||||
} else {
|
||||
C.glfwSetWindowShouldClose(w.data, C.GL_TRUE)
|
||||
}
|
||||
}
|
||||
|
||||
//SetTitle sets the window title, encoded as UTF-8, of the window.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) SetTitle(title string) {
|
||||
t := C.CString(title)
|
||||
defer C.free(unsafe.Pointer(t))
|
||||
C.glfwSetWindowTitle(w.data, t)
|
||||
}
|
||||
|
||||
//GetPosition returns the position, in screen coordinates, of the upper-left
|
||||
//corner of the client area of the window.
|
||||
func (w *Window) GetPosition() (x, y int) {
|
||||
var xpos, ypos C.int
|
||||
|
||||
C.glfwGetWindowPos(w.data, &xpos, &ypos)
|
||||
return int(xpos), int(ypos)
|
||||
}
|
||||
|
||||
//SetPosition sets the position, in screen coordinates, of the upper-left corner
|
||||
//of the client area of the window.
|
||||
//
|
||||
//If it is a full screen window, this function does nothing.
|
||||
//
|
||||
//If you wish to set an initial window position you should create a hidden
|
||||
//window (using Hint and Visible), set its position and then show it.
|
||||
//
|
||||
//It is very rarely a good idea to move an already visible window, as it will
|
||||
//confuse and annoy the user.
|
||||
//
|
||||
//The window manager may put limits on what positions are allowed.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) SetPosition(xpos, ypos int) {
|
||||
C.glfwSetWindowPos(w.data, C.int(xpos), C.int(ypos))
|
||||
}
|
||||
|
||||
//GetSize returns the size, in screen coordinates, of the client area of the
|
||||
//specified window.
|
||||
func (w *Window) GetSize() (width, height int) {
|
||||
var wi, h C.int
|
||||
C.glfwGetWindowSize(w.data, &wi, &h)
|
||||
return int(wi), int(h)
|
||||
}
|
||||
|
||||
//SetSize sets the size, in screen coordinates, of the client area of the
|
||||
//window.
|
||||
//
|
||||
//For full screen windows, this function selects and switches to the resolution
|
||||
//closest to the specified size, without affecting the window's context. As the
|
||||
//context is unaffected, the bit depths of the framebuffer remain unchanged.
|
||||
//
|
||||
//The window manager may put limits on what window sizes are allowed.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) SetSize(width, height int) {
|
||||
C.glfwSetWindowSize(w.data, C.int(width), C.int(height))
|
||||
}
|
||||
|
||||
//GetFramebufferSize retrieves the size, in pixels, of the framebuffer of the
|
||||
//specified window.
|
||||
func (w *Window) GetFramebufferSize() (width, height int) {
|
||||
var wi, h C.int
|
||||
C.glfwGetFramebufferSize(w.data, &wi, &h)
|
||||
return int(wi), int(h)
|
||||
}
|
||||
|
||||
//Iconfiy iconifies/minimizes the window, if it was previously restored. If it
|
||||
//is a full screen window, the original monitor resolution is restored until the
|
||||
//window is restored. If the window is already iconified, this function does
|
||||
//nothing.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) Iconify() {
|
||||
C.glfwIconifyWindow(w.data)
|
||||
}
|
||||
|
||||
//Restore restores the window, if it was previously iconified/minimized. If it
|
||||
//is a full screen window, the resolution chosen for the window is restored on
|
||||
//the selected monitor. If the window is already restored, this function does
|
||||
//nothing.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) Restore() {
|
||||
C.glfwRestoreWindow(w.data)
|
||||
}
|
||||
|
||||
//Show makes the window visible, if it was previously hidden. If the window is
|
||||
//already visible or is in full screen mode, this function does nothing.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) Show() {
|
||||
C.glfwShowWindow(w.data)
|
||||
}
|
||||
|
||||
//Hide hides the window, if it was previously visible. If the window is already
|
||||
//hidden or is in full screen mode, this function does nothing.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func (w *Window) Hide() {
|
||||
C.glfwHideWindow(w.data)
|
||||
}
|
||||
|
||||
//GetMonitor returns the handle of the monitor that the window is in
|
||||
//fullscreen on.
|
||||
func (w *Window) GetMonitor() (*Monitor, error) {
|
||||
m := C.glfwGetWindowMonitor(w.data)
|
||||
|
||||
if m == nil {
|
||||
return nil, errors.New("Can't get the monitor.")
|
||||
}
|
||||
return &Monitor{m}, nil
|
||||
}
|
||||
|
||||
//GetAttribute returns an attribute of the window. There are many attributes,
|
||||
//some related to the window and others to its context.
|
||||
func (w *Window) GetAttribute(attrib Hint) int {
|
||||
return int(C.glfwGetWindowAttrib(w.data, C.int(attrib)))
|
||||
}
|
||||
|
||||
//SetUserPointer sets the user-defined pointer of the window. The current value
|
||||
//is retained until the window is destroyed. The initial value is nil.
|
||||
func (w *Window) SetUserPointer(pointer unsafe.Pointer) {
|
||||
C.glfwSetWindowUserPointer(w.data, pointer)
|
||||
}
|
||||
|
||||
//GetUserPointer returns the current value of the user-defined pointer of the
|
||||
//window. The initial value is nil.
|
||||
func (w *Window) GetUserPointer() unsafe.Pointer {
|
||||
return C.glfwGetWindowUserPointer(w.data)
|
||||
}
|
||||
|
||||
//SetPositionCallback sets the position callback of the window, which is called
|
||||
//when the window is moved. The callback is provided with the screen position
|
||||
//of the upper-left corner of the client area of the window.
|
||||
func (w *Window) SetPositionCallback(cbfun func(w *Window, xpos int, ypos int)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetWindowPosCallback(w.data, nil)
|
||||
} else {
|
||||
w.fPosHolder = cbfun
|
||||
C.glfwSetWindowPosCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetSizeCallback sets the size callback of the window, which is called when
|
||||
//the window is resized. The callback is provided with the size, in screen
|
||||
//coordinates, of the client area of the window.
|
||||
func (w *Window) SetSizeCallback(cbfun func(w *Window, width int, height int)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetWindowSizeCallback(w.data, nil)
|
||||
} else {
|
||||
w.fSizeHolder = cbfun
|
||||
C.glfwSetWindowSizeCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetFramebufferSizeCallback sets the framebuffer resize callback of the specified
|
||||
//window, which is called when the framebuffer of the specified window is resized.
|
||||
func (w *Window) SetFramebufferSizeCallback(cbfun func(w *Window, width int, height int)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetFramebufferSizeCallback(w.data, nil)
|
||||
} else {
|
||||
w.fFramebufferSizeHolder = cbfun
|
||||
C.glfwSetFramebufferSizeCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetCloseCallback sets the close callback of the window, which is called when
|
||||
//the user attempts to close the window, for example by clicking the close
|
||||
//widget in the title bar.
|
||||
//
|
||||
//The close flag is set before this callback is called, but you can modify it at
|
||||
//any time with SetShouldClose.
|
||||
//
|
||||
//Mac OS X: Selecting Quit from the application menu will trigger the close
|
||||
//callback for all windows.
|
||||
func (w *Window) SetCloseCallback(cbfun func(w *Window)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetWindowCloseCallback(w.data, nil)
|
||||
} else {
|
||||
w.fCloseHolder = cbfun
|
||||
C.glfwSetWindowCloseCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetRefreshCallback sets the refresh callback of the window, which
|
||||
//is called when the client area of the window needs to be redrawn, for example
|
||||
//if the window has been exposed after having been covered by another window.
|
||||
//
|
||||
//On compositing window systems such as Aero, Compiz or Aqua, where the window
|
||||
//contents are saved off-screen, this callback may be called only very
|
||||
//infrequently or never at all.
|
||||
func (w *Window) SetRefreshCallback(cbfun func(w *Window)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetWindowRefreshCallback(w.data, nil)
|
||||
} else {
|
||||
w.fRefreshHolder = cbfun
|
||||
C.glfwSetWindowRefreshCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetFocusCallback sets the focus callback of the window, which is called when
|
||||
//the window gains or loses focus.
|
||||
//
|
||||
//After the focus callback is called for a window that lost focus, synthetic key
|
||||
//and mouse button release events will be generated for all such that had been
|
||||
//pressed. For more information, see SetKeyCallback and SetMouseButtonCallback.
|
||||
func (w *Window) SetFocusCallback(cbfun func(w *Window, focused bool)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetWindowFocusCallback(w.data, nil)
|
||||
} else {
|
||||
w.fFocusHolder = cbfun
|
||||
C.glfwSetWindowFocusCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//SetIconifyCallback sets the iconification callback of the window, which is
|
||||
//called when the window is iconified or restored.
|
||||
func (w *Window) SetIconifyCallback(cbfun func(w *Window, iconified bool)) {
|
||||
if cbfun == nil {
|
||||
C.glfwSetWindowIconifyCallback(w.data, nil)
|
||||
} else {
|
||||
w.fIconifyHolder = cbfun
|
||||
C.glfwSetWindowIconifyCallbackCB(w.data)
|
||||
}
|
||||
}
|
||||
|
||||
//PollEvents processes only those events that have already been received and
|
||||
//then returns immediately. Processing events will cause the window and input
|
||||
//callbacks associated with those events to be called.
|
||||
//
|
||||
//This function is not required for joystick input to work.
|
||||
//
|
||||
//This function may not be called from a callback.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func PollEvents() {
|
||||
C.glfwPollEvents()
|
||||
}
|
||||
|
||||
//WaitEvents puts the calling thread to sleep until at least one event has been
|
||||
//received. Once one or more events have been recevied, it behaves as if
|
||||
//PollEvents was called, i.e. the events are processed and the function then
|
||||
//returns immediately. Processing events will cause the window and input
|
||||
//callbacks associated with those events to be called.
|
||||
//
|
||||
//Since not all events are associated with callbacks, this function may return
|
||||
//without a callback having been called even if you are monitoring all
|
||||
//callbacks.
|
||||
//
|
||||
//This function may not be called from a callback.
|
||||
//
|
||||
//This function may only be called from the main thread. See
|
||||
//https://code.google.com/p/go-wiki/wiki/LockOSThread
|
||||
func WaitEvents() {
|
||||
C.glfwWaitEvents()
|
||||
}
|
Reference in New Issue
Block a user