-
Notifications
You must be signed in to change notification settings - Fork 3
/
context.go
92 lines (83 loc) · 2.86 KB
/
context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package glfw
import (
"fmt"
"unsafe"
)
func (w *Window) initContext() {
if ctx, err := w.callbacks.D.NewContext(); err != nil {
panic(err)
} else {
w.ctx = ctx
theApp.Ctx = ctx
}
w.ctx.Refresh()
panicError()
}
func (w *Window) MakeContextCurrent() {
if err := w.ctx.Lock(); err != nil {
panic(err)
}
panicError()
}
// DetachCurrentContext detaches the current context.
func DetachCurrentContext() {
theApp.Ctx.Unlock()
panicError()
}
// GetCurrentContext returns the window whose context is current.
func GetCurrentContext() *Window {
return theApp.MainWindow
}
// 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() {
if err := w.ctx.SwapBuffers(); err != nil {
panic(err)
}
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) {
theApp.Ctx.SwapInterval(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 {
fmt.Println("not implemented")
panicError()
return false
}
// 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 {
fmt.Println("not implemented")
panicError()
return nil
}