-
Notifications
You must be signed in to change notification settings - Fork 25
/
gl_window.go
57 lines (52 loc) · 1.37 KB
/
gl_window.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
package fltk
/*
#include "gl_window.h"
*/
import "C"
import (
"unsafe"
)
type GlWindow struct {
Window
deletionHandlerId uintptr
drawFunId uintptr
}
func NewGlWindow(x, y, w, h int, drawFun func()) *GlWindow {
win := &GlWindow{}
win.drawFunId = globalCallbackMap.register(drawFun)
initWidget(win, unsafe.Pointer(C.go_fltk_new_GlWindow(C.int(x), C.int(y), C.int(w), C.int(h), C.uintptr_t(win.drawFunId))))
win.deletionHandlerId = win.addDeletionHandler(win.onDelete)
return win
}
func (w *GlWindow) MakeCurrent() {
C.go_fltk_Gl_Window_make_current((*C.Fl_Gl_Window)(w.ptr()))
}
func (w *GlWindow) onDelete() {
if w.deletionHandlerId > 0 {
globalCallbackMap.unregister(w.deletionHandlerId)
}
w.deletionHandlerId = 0
if w.drawFunId > 0 {
globalCallbackMap.unregister(w.drawFunId)
}
w.drawFunId = 0
}
func (w *GlWindow) Destroy() {
if w.drawFunId > 0 {
globalCallbackMap.unregister(w.drawFunId)
}
w.drawFunId = 0
w.Window.Destroy()
}
func (w *GlWindow) ContextValid() bool {
return C.go_fltk_Gl_Window_context_valid((*C.Fl_Gl_Window)(w.ptr())) != 0
}
func (w *GlWindow) Valid() bool {
return C.go_fltk_Gl_Window_valid((*C.Fl_Gl_Window)(w.ptr())) != 0
}
func (w *GlWindow) CanDo() bool {
return C.go_fltk_Gl_Window_can_do((*C.Fl_Gl_Window)(w.ptr())) != 0
}
func (w *GlWindow) SetMode(mode int) {
C.go_fltk_Gl_Window_set_mode((*C.Fl_Gl_Window)(w.ptr()), C.int(mode))
}