X11 backend for pixel formats
parent
95f1ca3d9f
commit
623b16d048
|
@ -22,8 +22,6 @@ C: <offscreen-handle> offscreen-handle
|
||||||
|
|
||||||
SINGLETON: cocoa-ui-backend
|
SINGLETON: cocoa-ui-backend
|
||||||
|
|
||||||
<PRIVATE
|
|
||||||
|
|
||||||
PIXEL-FORMAT-ATTRIBUTE-TABLE: NSOpenGLPFA { } H{
|
PIXEL-FORMAT-ATTRIBUTE-TABLE: NSOpenGLPFA { } H{
|
||||||
{ double-buffered { $ NSOpenGLPFADoubleBuffer } }
|
{ double-buffered { $ NSOpenGLPFADoubleBuffer } }
|
||||||
{ stereo { $ NSOpenGLPFAStereo } }
|
{ stereo { $ NSOpenGLPFAStereo } }
|
||||||
|
@ -48,8 +46,6 @@ PIXEL-FORMAT-ATTRIBUTE-TABLE: NSOpenGLPFA { } H{
|
||||||
{ samples { $ NSOpenGLPFASamples } }
|
{ samples { $ NSOpenGLPFASamples } }
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIVATE>
|
|
||||||
|
|
||||||
M: cocoa-ui-backend (make-pixel-format)
|
M: cocoa-ui-backend (make-pixel-format)
|
||||||
nip >NSOpenGLPFA-int-array
|
nip >NSOpenGLPFA-int-array
|
||||||
NSOpenGLPixelFormat -> alloc swap -> initWithAttributes: ;
|
NSOpenGLPixelFormat -> alloc swap -> initWithAttributes: ;
|
||||||
|
|
|
@ -7,7 +7,8 @@ namespaces opengl sequences strings x11 x11.xlib x11.events x11.xim
|
||||||
x11.glx x11.clipboard x11.constants x11.windows x11.io
|
x11.glx x11.clipboard x11.constants x11.windows x11.io
|
||||||
io.encodings.string io.encodings.ascii io.encodings.utf8 combinators
|
io.encodings.string io.encodings.ascii io.encodings.utf8 combinators
|
||||||
command-line math.vectors classes.tuple opengl.gl threads
|
command-line math.vectors classes.tuple opengl.gl threads
|
||||||
math.rectangles environment ascii ;
|
math.rectangles environment ascii
|
||||||
|
ui.pixel-formats ui.pixel-formats.private ;
|
||||||
IN: ui.backend.x11
|
IN: ui.backend.x11
|
||||||
|
|
||||||
SINGLETON: x11-ui-backend
|
SINGLETON: x11-ui-backend
|
||||||
|
@ -29,6 +30,40 @@ M: world configure-event
|
||||||
! In case dimensions didn't change
|
! In case dimensions didn't change
|
||||||
relayout-1 ;
|
relayout-1 ;
|
||||||
|
|
||||||
|
PIXEL-FORMAT-ATTRIBUTE-TABLE: glx-visual { $ GLX_USE_GL $ GLX_RGBA } H{
|
||||||
|
{ double-buffered { $ GLX_DOUBLEBUFFER } }
|
||||||
|
{ stereo { $ GLX_STEREO } }
|
||||||
|
{ color-bits { $ GLX_BUFFER_SIZE } }
|
||||||
|
{ red-bits { $ GLX_RED_SIZE } }
|
||||||
|
{ green-bits { $ GLX_GREEN_SIZE } }
|
||||||
|
{ blue-bits { $ GLX_BLUE_SIZE } }
|
||||||
|
{ alpha-bits { $ GLX_ALPHA_SIZE } }
|
||||||
|
{ accum-red-bits { $ GLX_ACCUM_RED_SIZE } }
|
||||||
|
{ accum-green-bits { $ GLX_ACCUM_GREEN_SIZE } }
|
||||||
|
{ accum-blue-bits { $ GLX_ACCUM_BLUE_SIZE } }
|
||||||
|
{ accum-alpha-bits { $ GLX_ACCUM_ALPHA_SIZE } }
|
||||||
|
{ depth-bits { $ GLX_DEPTH_SIZE } }
|
||||||
|
{ stencil-bits { $ GLX_STENCIL_SIZE } }
|
||||||
|
{ aux-buffers { $ GLX_AUX_BUFFERS } }
|
||||||
|
{ sample-buffers { $ GLX_SAMPLE_BUFFERS } }
|
||||||
|
{ samples { $ GLX_SAMPLES } }
|
||||||
|
}
|
||||||
|
|
||||||
|
M: x11-ui-backend (make-pixel-format)
|
||||||
|
[ drop dpy get scr get ] dip
|
||||||
|
>glx-visual-int-array glXChooseVisual ;
|
||||||
|
|
||||||
|
M: x11-ui-backend (free-pixel-format)
|
||||||
|
handle>> XFree ;
|
||||||
|
|
||||||
|
M: x11-ui-backend (pixel-format-attribute)
|
||||||
|
[ dpy get ] 2dip
|
||||||
|
[ handle>> ] [ >glx-visual ] bi*
|
||||||
|
[ drop f ] [
|
||||||
|
first [ dpy get ] 2dip
|
||||||
|
0 <int> [ glXGetConfig drop ] keep *int
|
||||||
|
] if-empty ;
|
||||||
|
|
||||||
CONSTANT: modifiers
|
CONSTANT: modifiers
|
||||||
{
|
{
|
||||||
{ S+ HEX: 1 }
|
{ S+ HEX: 1 }
|
||||||
|
@ -187,7 +222,8 @@ M: world client-event
|
||||||
|
|
||||||
: gadget-window ( world -- )
|
: gadget-window ( world -- )
|
||||||
dup
|
dup
|
||||||
[ window-loc>> ] [ dim>> ] bi glx-window swap
|
[ [ [ window-loc>> ] [ dim>> ] bi ] dip handle>> glx-window ]
|
||||||
|
with-world-pixel-format swap
|
||||||
dup "Factor" create-xic
|
dup "Factor" create-xic
|
||||||
<x11-handle>
|
<x11-handle>
|
||||||
[ window>> register-window ] [ >>handle drop ] 2bi ;
|
[ window>> register-window ] [ >>handle drop ] 2bi ;
|
||||||
|
@ -274,7 +310,9 @@ M: x11-pixmap-handle flush-gl-context ( handle -- )
|
||||||
drop ;
|
drop ;
|
||||||
|
|
||||||
M: x11-ui-backend (open-offscreen-buffer) ( world -- )
|
M: x11-ui-backend (open-offscreen-buffer) ( world -- )
|
||||||
dup dim>> glx-pixmap <x11-pixmap-handle> >>handle drop ;
|
dup [ [ dim>> ] [ handle>> ] bi* glx-pixmap ]
|
||||||
|
with-world-pixel-format
|
||||||
|
<x11-pixmap-handle> >>handle drop ;
|
||||||
M: x11-ui-backend (close-offscreen-buffer) ( handle -- )
|
M: x11-ui-backend (close-offscreen-buffer) ( handle -- )
|
||||||
dpy get swap
|
dpy get swap
|
||||||
[ glx-pixmap>> glXDestroyGLXPixmap ]
|
[ glx-pixmap>> glXDestroyGLXPixmap ]
|
||||||
|
|
|
@ -95,17 +95,6 @@ CONSTANT: GLX_RGBA_FLOAT_BIT HEX: 0004
|
||||||
! GLX Events
|
! GLX Events
|
||||||
! (also skipped for now. only has GLXPbufferClobberEvent, the rest is handled by xlib methinks)
|
! (also skipped for now. only has GLXPbufferClobberEvent, the rest is handled by xlib methinks)
|
||||||
|
|
||||||
: choose-visual ( flags -- XVisualInfo* )
|
|
||||||
[ dpy get scr get ] dip
|
|
||||||
[
|
|
||||||
%
|
|
||||||
GLX_RGBA ,
|
|
||||||
GLX_DEPTH_SIZE , 16 ,
|
|
||||||
0 ,
|
|
||||||
] int-array{ } make
|
|
||||||
glXChooseVisual
|
|
||||||
[ "Could not get a double-buffered GLX RGBA visual" throw ] unless* ;
|
|
||||||
|
|
||||||
: create-glx ( XVisualInfo* -- GLXContext )
|
: create-glx ( XVisualInfo* -- GLXContext )
|
||||||
[ dpy get ] dip f 1 glXCreateContext
|
[ dpy get ] dip f 1 glXCreateContext
|
||||||
[ "Failed to create GLX context" throw ] unless* ;
|
[ "Failed to create GLX context" throw ] unless* ;
|
||||||
|
|
|
@ -53,11 +53,8 @@ IN: x11.windows
|
||||||
dup
|
dup
|
||||||
] dip auto-position ;
|
] dip auto-position ;
|
||||||
|
|
||||||
: glx-window ( loc dim -- window glx )
|
: glx-window ( loc dim visual -- window glx )
|
||||||
GLX_DOUBLEBUFFER 1array choose-visual
|
[ create-window ] [ create-glx ] bi ;
|
||||||
[ create-window ] keep
|
|
||||||
[ create-glx ] keep
|
|
||||||
XFree ;
|
|
||||||
|
|
||||||
: create-pixmap ( dim visual -- pixmap )
|
: create-pixmap ( dim visual -- pixmap )
|
||||||
[ [ { 0 0 } swap ] dip create-window ] [
|
[ [ { 0 0 } swap ] dip create-window ] [
|
||||||
|
@ -74,9 +71,8 @@ IN: x11.windows
|
||||||
: create-glx-pixmap ( dim visual -- pixmap glx-pixmap )
|
: create-glx-pixmap ( dim visual -- pixmap glx-pixmap )
|
||||||
[ create-pixmap ] [ (create-glx-pixmap) ] bi ;
|
[ create-pixmap ] [ (create-glx-pixmap) ] bi ;
|
||||||
|
|
||||||
: glx-pixmap ( dim -- glx pixmap glx-pixmap )
|
: glx-pixmap ( dim visual -- glx pixmap glx-pixmap )
|
||||||
{ } choose-visual
|
[ nip create-glx ] [ create-glx-pixmap ] 2bi ;
|
||||||
[ nip create-glx ] [ create-glx-pixmap ] [ nip XFree ] 2tri ;
|
|
||||||
|
|
||||||
: destroy-window ( win -- )
|
: destroy-window ( win -- )
|
||||||
dpy get swap XDestroyWindow drop ;
|
dpy get swap XDestroyWindow drop ;
|
||||||
|
|
Loading…
Reference in New Issue