Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions v3.4/glfw/GLFW_C_REVISION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e2c92645460f680fd272fd2eed591efb2be7dc31
53 changes: 53 additions & 0 deletions v3.4/glfw/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package glfw

/*
// Windows Build Tags
// ----------------
// GLFW Options:
#cgo windows CFLAGS: -D_GLFW_WIN32 -Iglfw/deps/mingw

// Linker Options:
#cgo windows LDFLAGS: -lgdi32

#cgo !gles2,windows LDFLAGS: -lopengl32
#cgo gles2,windows LDFLAGS: -lGLESv2

// Darwin Build Tags
// ----------------
// GLFW Options:
#cgo darwin CFLAGS: -D_GLFW_COCOA -Wno-deprecated-declarations

// Linker Options:
#cgo darwin LDFLAGS: -framework Cocoa -framework IOKit -framework CoreVideo

#cgo !gles2,darwin LDFLAGS: -framework OpenGL
#cgo gles2,darwin LDFLAGS: -lGLESv2

// Linux Build Tags
// ----------------
// GLFW Options:
#cgo linux,!wayland CFLAGS: -D_GLFW_X11
#cgo linux,wayland CFLAGS: -D_GLFW_WAYLAND

// Linker Options:
#cgo linux,!gles1,!gles2,!gles3,!vulkan LDFLAGS: -lGL
#cgo linux,gles1 LDFLAGS: -lGLESv1
#cgo linux,gles2 LDFLAGS: -lGLESv2
#cgo linux,gles3 LDFLAGS: -lGLESv3
#cgo linux,vulkan LDFLAGS: -lvulkan
#cgo linux,!wayland LDFLAGS: -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -lm -lXinerama -ldl -lrt
#cgo linux,wayland LDFLAGS: -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon -lm -ldl -lrt

// BSD Build Tags
// ----------------
// GLFW Options:
#cgo freebsd,!wayland netbsd,!wayland openbsd pkg-config: x11 xau xcb xdmcp
#cgo freebsd,wayland netbsd,wayland pkg-config: wayland-client wayland-cursor wayland-egl epoll-shim
#cgo freebsd netbsd openbsd CFLAGS: -D_GLFW_HAS_DLOPEN
#cgo freebsd,!wayland netbsd,!wayland openbsd CFLAGS: -D_GLFW_X11 -D_GLFW_HAS_GLXGETPROCADDRESSARB
#cgo freebsd,wayland netbsd,wayland CFLAGS: -D_GLFW_WAYLAND

// Linker Options:
#cgo freebsd netbsd openbsd LDFLAGS: -lm
*/
import "C"
19 changes: 19 additions & 0 deletions v3.4/glfw/build_cgo_hack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//go:build required
// +build required

package glfw

// This file exists purely to prevent the golang toolchain from stripping
// away the c source directories and files when `go mod vendor` is used
// to populate a `vendor/` directory of a project depending on `go-gl/glfw`.
//
// How it works:
// - every directory which only includes c source files receives a dummy.go file.
// - every directory we want to preserve is included here as a _ import.
// - this file is given a build to exclude it from the regular build.
import (
// Prevent go tooling from stripping out the c source files.
_ "github.com/go-gl/glfw/v3.3/glfw/glfw/deps"
_ "github.com/go-gl/glfw/v3.3/glfw/glfw/include/GLFW"
_ "github.com/go-gl/glfw/v3.3/glfw/glfw/src"
)
12 changes: 12 additions & 0 deletions v3.4/glfw/c_glfw.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package glfw

/*
#include "glfw/src/context.c"
#include "glfw/src/init.c"
#include "glfw/src/input.c"
#include "glfw/src/monitor.c"
#include "glfw/src/vulkan.c"
#include "glfw/src/window.c"
#include "glfw/src/osmesa_context.c"
*/
import "C"
30 changes: 30 additions & 0 deletions v3.4/glfw/c_glfw_bsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//go:build freebsd || netbsd || openbsd
// +build freebsd netbsd openbsd

package glfw

/*
#ifdef _GLFW_WAYLAND
#include "glfw/src/wl_init.c"
#include "glfw/src/wl_monitor.c"
#include "glfw/src/wl_window.c"
#include "glfw/src/wayland-idle-inhibit-unstable-v1-client-protocol.c"
#include "glfw/src/wayland-pointer-constraints-unstable-v1-client-protocol.c"
#include "glfw/src/wayland-relative-pointer-unstable-v1-client-protocol.c"
#include "glfw/src/wayland-viewporter-client-protocol.c"
#include "glfw/src/wayland-xdg-decoration-unstable-v1-client-protocol.c"
#include "glfw/src/wayland-xdg-shell-client-protocol.c"
#endif
#ifdef _GLFW_X11
#include "glfw/src/x11_init.c"
#include "glfw/src/x11_monitor.c"
#include "glfw/src/x11_window.c"
#include "glfw/src/glx_context.c"
#endif
#include "glfw/src/null_joystick.c"
#include "glfw/src/posix_time.c"
#include "glfw/src/posix_thread.c"
#include "glfw/src/xkb_unicode.c"
#include "glfw/src/egl_context.c"
*/
import "C"
20 changes: 20 additions & 0 deletions v3.4/glfw/c_glfw_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package glfw

/*
#cgo CFLAGS: -x objective-c
#include "glfw/src/cocoa_init.m"
#include "glfw/src/cocoa_joystick.m"
#include "glfw/src/cocoa_monitor.m"
#include "glfw/src/cocoa_window.m"
#include "glfw/src/cocoa_time.c"
#include "glfw/src/posix_thread.c"
#include "glfw/src/nsgl_context.m"
#include "glfw/src/egl_context.c"
#include "glfw/src/posix_module.c"
#include "glfw/src/platform.c"
#include "glfw/src/null_init.c"
#include "glfw/src/null_joystick.c"
#include "glfw/src/null_monitor.c"
#include "glfw/src/null_window.c"
*/
import "C"
31 changes: 31 additions & 0 deletions v3.4/glfw/c_glfw_lin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//go:build linux
// +build linux

package glfw

/*
#ifdef _GLFW_WAYLAND
#include "glfw/src/wl_init.c"
#include "glfw/src/wl_monitor.c"
#include "glfw/src/wl_window.c"
#endif
#ifdef _GLFW_X11
#include "glfw/src/x11_window.c"
#include "glfw/src/x11_init.c"
#include "glfw/src/x11_monitor.c"
#include "glfw/src/glx_context.c"
#endif
#include "glfw/src/linux_joystick.c"
#include "glfw/src/posix_module.c"
#include "glfw/src/posix_poll.c"
#include "glfw/src/posix_time.c"
#include "glfw/src/posix_thread.c"
#include "glfw/src/xkb_unicode.c"
#include "glfw/src/egl_context.c"
#include "glfw/src/platform.c"
#include "glfw/src/null_init.c"
#include "glfw/src/null_joystick.c"
#include "glfw/src/null_monitor.c"
#include "glfw/src/null_window.c"
*/
import "C"
19 changes: 19 additions & 0 deletions v3.4/glfw/c_glfw_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package glfw

/*
#include "glfw/src/win32_init.c"
#include "glfw/src/win32_joystick.c"
#include "glfw/src/win32_monitor.c"
#include "glfw/src/win32_time.c"
#include "glfw/src/win32_thread.c"
#include "glfw/src/win32_window.c"
#include "glfw/src/win32_module.c"
#include "glfw/src/wgl_context.c"
#include "glfw/src/egl_context.c"
#include "glfw/src/platform.c"
#include "glfw/src/null_init.c"
#include "glfw/src/null_monitor.c"
#include "glfw/src/null_window.c"
#include "glfw/src/null_joystick.c"
*/
import "C"
94 changes: 94 additions & 0 deletions v3.4/glfw/context.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package glfw

//#include <stdlib.h>
//#define GLFW_INCLUDE_NONE
//#include "glfw/include/GLFW/glfw3.h"
import "C"

import (
"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)
panicError()
}

// DetachCurrentContext detaches the current context.
func DetachCurrentContext() {
C.glfwMakeContextCurrent(nil)
panicError()
}

// GetCurrentContext returns the window whose context is current.
func GetCurrentContext() *Window {
w := C.glfwGetCurrentContext()
panicError()
if w == nil {
return nil
}
return windows.get(w)
}

// 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)
panicError()
}

// 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))
panicError()
}

// ExtensionSupported reports 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))
ret := glfwbool(C.glfwExtensionSupported(e))
panicError()
return ret
}

// GetProcAddress returns the address of the specified OpenGL or OpenGL ES core
// or extension function, if it is supported by the current context.
//
// A context must be current on the calling thread. Calling this function
// without a current context will cause a GLFW_NO_CURRENT_CONTEXT error.
//
// This function is used to provide GL proc resolving capabilities to an
// external C library.
func GetProcAddress(procname string) unsafe.Pointer {
p := C.CString(procname)
defer C.free(unsafe.Pointer(p))
ret := unsafe.Pointer(C.glfwGetProcAddress(p))
panicError()
return ret
}
3 changes: 3 additions & 0 deletions v3.4/glfw/error.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "_cgo_export.h"

void glfwSetErrorCallbackCB() { glfwSetErrorCallback((GLFWerrorfun)goErrorCB); }
Loading