USING: accessors arrays cairo cairo.ffi cairo.gadgets destructors images.memory.private kernel libc math math.rectangles namespaces opengl opengl.demo-support opengl.gl opengl.glu sequences ui ui.gadgets ui.render fry ; IN: cairo.gadgets TUPLE: test-gadget < gadget ; CONSTANT: width 256 CONSTANT: height 256 PRIVATE> : ( -- gadget ) test-gadget new ; M: test-gadget pref-dim* ( gadget -- dim ) drop width height 2array ; M: test-gadget draw-gadget* ( gadget -- ) 0 0 glRasterPos2i 1.0 -1.0 glPixelZoom [ width height 2array [ malloc-bitmap-data ] keep &cairo_surface_destroy [ &cairo_destroy { 0 0 } { 255 255 } fill-rect ] [ '[ width height GL_BGRA GL_UNSIGNED_BYTE _ cairo_image_surface_get_data glDrawPixels ] ] bi drop drop ] with-destructors ; : cairo-gadget-test ( -- ) "cairogl" open-window ; MAIN: cairo-gadget-test