offscreen-world widgets and offscreen pixel format fixes
parent
4307234550
commit
ec98a6c83d
|
@ -58,8 +58,6 @@ PRIVATE>
|
||||||
: <PixelFormat> ( attributes -- pixelfmt )
|
: <PixelFormat> ( attributes -- pixelfmt )
|
||||||
NSOpenGLPixelFormat -> alloc swap [
|
NSOpenGLPixelFormat -> alloc swap [
|
||||||
%
|
%
|
||||||
NSOpenGLPFAWindow ,
|
|
||||||
NSOpenGLPFADoubleBuffer ,
|
|
||||||
NSOpenGLPFADepthSize , 16 ,
|
NSOpenGLPFADepthSize , 16 ,
|
||||||
+software-renderer+ get [
|
+software-renderer+ get [
|
||||||
NSOpenGLPFARendererID , kCGLRendererGenericFloatID ,
|
NSOpenGLPFARendererID , kCGLRendererGenericFloatID ,
|
||||||
|
@ -75,7 +73,8 @@ PRIVATE>
|
||||||
-> autorelease ;
|
-> autorelease ;
|
||||||
|
|
||||||
: <GLView> ( class dim -- view )
|
: <GLView> ( class dim -- view )
|
||||||
[ -> alloc 0 0 ] dip first2 <NSRect> { } <PixelFormat>
|
[ -> alloc 0 0 ] dip first2 <NSRect>
|
||||||
|
NSOpenGLPFAWindow NSOpenGLPFADoubleBuffer 2array <PixelFormat>
|
||||||
-> initWithFrame:pixelFormat:
|
-> initWithFrame:pixelFormat:
|
||||||
dup 1 -> setPostsBoundsChangedNotifications:
|
dup 1 -> setPostsBoundsChangedNotifications:
|
||||||
dup 1 -> setPostsFrameChangedNotifications: ;
|
dup 1 -> setPostsFrameChangedNotifications: ;
|
||||||
|
|
|
@ -16,6 +16,7 @@ TUPLE: offscreen-handle < handle context buffer ;
|
||||||
C: <window-handle> window-handle
|
C: <window-handle> window-handle
|
||||||
C: <offscreen-handle> offscreen-handle
|
C: <offscreen-handle> offscreen-handle
|
||||||
|
|
||||||
|
! XXX gross!
|
||||||
M: offscreen-handle window>> drop f ;
|
M: offscreen-handle window>> drop f ;
|
||||||
M: offscreen-handle view>> drop f ;
|
M: offscreen-handle view>> drop f ;
|
||||||
|
|
||||||
|
@ -104,9 +105,9 @@ M: cocoa-ui-backend raise-window* ( world -- )
|
||||||
{ [ * * malloc ] [ 2drop ] [ drop nip ] [ nip * ] } 3cleave ;
|
{ [ * * malloc ] [ 2drop ] [ drop nip ] [ nip * ] } 3cleave ;
|
||||||
|
|
||||||
: gadget-offscreen-context ( world -- context buffer )
|
: gadget-offscreen-context ( world -- context buffer )
|
||||||
{ NSOpenGLPFAOffScreen } <PixelFormat>
|
NSOpenGLPFAOffScreen 1array <PixelFormat>
|
||||||
[ NSOpenGLContext -> alloc swap f -> initWithFormat:shareContext: dup ]
|
[ nip NSOpenGLContext -> alloc swap f -> initWithFormat:shareContext: dup ]
|
||||||
[ offscreen-buffer ] bi
|
[ offscreen-buffer ] 2bi
|
||||||
4 npick [ -> setOffScreen:width:height:rowbytes: ] dip ;
|
4 npick [ -> setOffScreen:width:height:rowbytes: ] dip ;
|
||||||
|
|
||||||
M: cocoa-ui-backend (open-offscreen-buffer) ( world -- )
|
M: cocoa-ui-backend (open-offscreen-buffer) ( world -- )
|
||||||
|
|
|
@ -13,6 +13,8 @@ title status
|
||||||
fonts handle
|
fonts handle
|
||||||
window-loc ;
|
window-loc ;
|
||||||
|
|
||||||
|
TUPLE: offscreen-world < world ;
|
||||||
|
|
||||||
: find-world ( gadget -- world/f ) [ world? ] find-parent ;
|
: find-world ( gadget -- world/f ) [ world? ] find-parent ;
|
||||||
|
|
||||||
: show-status ( string/f gadget -- )
|
: show-status ( string/f gadget -- )
|
||||||
|
@ -38,8 +40,8 @@ M: world request-focus-on ( child gadget -- )
|
||||||
2dup eq?
|
2dup eq?
|
||||||
[ 2drop ] [ dup focused?>> (request-focus) ] if ;
|
[ 2drop ] [ dup focused?>> (request-focus) ] if ;
|
||||||
|
|
||||||
: <world> ( gadget title status -- world )
|
: new-world ( gadget title status class -- world )
|
||||||
{ 0 1 } world new-track
|
{ 0 1 } swap new-track
|
||||||
t >>root?
|
t >>root?
|
||||||
t >>active?
|
t >>active?
|
||||||
H{ } clone >>fonts
|
H{ } clone >>fonts
|
||||||
|
@ -49,6 +51,11 @@ M: world request-focus-on ( child gadget -- )
|
||||||
swap 1 track-add
|
swap 1 track-add
|
||||||
dup request-focus ;
|
dup request-focus ;
|
||||||
|
|
||||||
|
: <world> ( gadget title status -- world )
|
||||||
|
world new-world ;
|
||||||
|
: <offscreen-world> ( gadget title status -- world )
|
||||||
|
offscreen-world new-world ;
|
||||||
|
|
||||||
M: world layout*
|
M: world layout*
|
||||||
dup call-next-method
|
dup call-next-method
|
||||||
dup glass>> [
|
dup glass>> [
|
||||||
|
|
|
@ -60,23 +60,34 @@ SYMBOL: stop-after-last-window?
|
||||||
focus-path f swap focus-gestures ;
|
focus-path f swap focus-gestures ;
|
||||||
|
|
||||||
M: world graft*
|
M: world graft*
|
||||||
dup (open-window)
|
[ (open-window) ]
|
||||||
dup title>> over set-title
|
[ [ title>> ] keep set-title ]
|
||||||
request-focus ;
|
[ request-focus ] tri ;
|
||||||
|
|
||||||
: reset-world ( world -- )
|
: reset-world ( world -- )
|
||||||
#! This is used when a window is being closed, but also
|
#! This is used when a window is being closed, but also
|
||||||
#! when restoring saved worlds on image startup.
|
#! when restoring saved worlds on image startup.
|
||||||
dup fonts>> clear-assoc
|
[ fonts>> clear-assoc ]
|
||||||
dup unfocus-world
|
[ unfocus-world ]
|
||||||
f >>handle drop ;
|
[ f >>handle drop ] tri ;
|
||||||
|
|
||||||
|
: (ungraft-world) ( world -- )
|
||||||
|
[ free-fonts ]
|
||||||
|
[ hand-clicked close-global ]
|
||||||
|
[ hand-gadget close-global ] tri ;
|
||||||
|
|
||||||
M: world ungraft*
|
M: world ungraft*
|
||||||
dup free-fonts
|
[ (ungraft-world) ]
|
||||||
dup hand-clicked close-global
|
[ handle>> (close-window) ]
|
||||||
dup hand-gadget close-global
|
[ reset-world ] tri ;
|
||||||
dup handle>> (close-window)
|
|
||||||
reset-world ;
|
M: offscreen-world graft*
|
||||||
|
(open-offscreen-buffer) ;
|
||||||
|
|
||||||
|
M: offscreen-world ungraft*
|
||||||
|
[ (ungraft-world) ]
|
||||||
|
[ handle>> (close-offscreen-buffer) ]
|
||||||
|
[ reset-world ] tri ;
|
||||||
|
|
||||||
: find-window ( quot -- world )
|
: find-window ( quot -- world )
|
||||||
windows get values
|
windows get values
|
||||||
|
|
|
@ -23,6 +23,14 @@ TUPLE: bitmap magic size reserved offset header-length width
|
||||||
swap [ >>array ] [ >>color-index ] bi
|
swap [ >>array ] [ >>color-index ] bi
|
||||||
24 >>bit-count ;
|
24 >>bit-count ;
|
||||||
|
|
||||||
|
: bgra>bitmap ( array height width -- bitmap )
|
||||||
|
bitmap new
|
||||||
|
2over * 4 * >>size-image
|
||||||
|
swap >>height
|
||||||
|
swap >>width
|
||||||
|
swap [ >>array ] [ >>color-index ] bi
|
||||||
|
32 >>bit-count ;
|
||||||
|
|
||||||
: 8bit>array ( bitmap -- array )
|
: 8bit>array ( bitmap -- array )
|
||||||
[ rgb-quads>> 4 <sliced-groups> [ 3 head-slice ] map ]
|
[ rgb-quads>> 4 <sliced-groups> [ 3 head-slice ] map ]
|
||||||
[ color-index>> >array ] bi [ swap nth ] with map concat ;
|
[ color-index>> >array ] bi [ swap nth ] with map concat ;
|
||||||
|
|
Loading…
Reference in New Issue