Fix bug where font sprites would be freed in the wrong context
parent
c94ba8665b
commit
36635a9b13
|
@ -6,8 +6,8 @@ DEFER: FactorView
|
|||
USING: arrays cocoa errors freetype gadgets gadgets-launchpad
|
||||
gadgets-layouts gadgets-listener gadgets-panes hashtables kernel
|
||||
lists math namespaces objc objc-NSApplication objc-NSEvent
|
||||
objc-NSObject objc-NSOpenGLView objc-NSView objc-NSWindow
|
||||
sequences threads ;
|
||||
objc-NSObject objc-NSOpenGLContext objc-NSOpenGLView objc-NSView
|
||||
objc-NSWindow sequences threads ;
|
||||
|
||||
! Cocoa backend for Factor UI
|
||||
|
||||
|
@ -75,7 +75,7 @@ H{ } clone views set-global
|
|||
|
||||
"NSOpenGLView" "FactorView" {
|
||||
{ "drawRect:" "void" { "id" "SEL" "NSRect" }
|
||||
[ 2drop [ view draw-world ] with-gl-view ]
|
||||
[ 2drop view draw-world ]
|
||||
}
|
||||
|
||||
{ "mouseMoved:" "void" { "id" "SEL" "id" }
|
||||
|
@ -171,6 +171,12 @@ IN: gadgets
|
|||
: in-window ( gadget status dim title -- )
|
||||
>r <world> r> <FactorWindow> drop ;
|
||||
|
||||
: select-gl-context ( handle -- )
|
||||
[openGLContext] [makeCurrentContext] ;
|
||||
|
||||
: flush-gl-context ( handle -- )
|
||||
[openGLContext] [flushBuffer] ;
|
||||
|
||||
IN: shells
|
||||
|
||||
: ui
|
||||
|
|
|
@ -11,14 +11,6 @@ objc-NSOpenGLView objc-NSView opengl sequences ;
|
|||
dup 1 [setPostsBoundsChangedNotifications:]
|
||||
dup 1 [setPostsFrameChangedNotifications:] ;
|
||||
|
||||
: with-gl-context ( context quot -- )
|
||||
swap
|
||||
[ [makeCurrentContext] call glFlush ] keep
|
||||
[flushBuffer] ; inline
|
||||
|
||||
: with-gl-view ( view quot -- | quot: view -- )
|
||||
>r dup [openGLContext] r> with-gl-context ; inline
|
||||
|
||||
: view-dim [bounds] dup NSRect-w swap NSRect-h 0 3array ;
|
||||
|
||||
: NSViewFrameDidChangeNotification
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
IN: gadgets
|
||||
USING: kernel opengl ;
|
||||
|
||||
DEFER: repaint-handle ( handle -- )
|
||||
|
||||
DEFER: in-window ( gadget status dim title -- )
|
||||
|
||||
DEFER: select-gl-context ( handle -- )
|
||||
|
||||
DEFER: flush-gl-context ( handle -- )
|
||||
|
||||
: with-gl-context ( handle quot -- )
|
||||
swap [ select-gl-context call ] keep
|
||||
glFlush flush-gl-context gl-error ; inline
|
||||
|
|
|
@ -65,7 +65,9 @@ DEFER: draw-gadget
|
|||
|
||||
: draw-world ( world -- )
|
||||
[
|
||||
dup rect-dim init-gl dup world set draw-gadget gl-error
|
||||
dup world-handle [
|
||||
dup rect-dim init-gl dup world set draw-gadget
|
||||
] with-gl-context
|
||||
] with-scope ;
|
||||
|
||||
! Pen paint properties
|
||||
|
|
|
@ -19,6 +19,7 @@ TUPLE: world glass status focus fonts handle ;
|
|||
world-fonts [ drop V{ } clone ] cache ;
|
||||
|
||||
: close-world ( world -- )
|
||||
dup world-handle select-gl-context
|
||||
f over request-focus*
|
||||
dup remove-notify
|
||||
dup free-fonts
|
||||
|
|
Loading…
Reference in New Issue