Paste: opengl + cairo

Author: hsuh
Mode: factor
Date: Tue, 6 Oct 2009 01:21:59
Plain Text |
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>
: <test-gadget> (  -- 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
        <image-surface> &cairo_surface_destroy
        [ <cairo> &cairo_destroy { 0 0 } { 255 255 } <rect> fill-rect ]
        [ '[ width height GL_BGRA GL_UNSIGNED_BYTE _ cairo_image_surface_get_data glDrawPixels ] ] bi
        drop drop
    ] with-destructors ;

: cairo-gadget-test ( -- )
    <test-gadget> "cairogl" open-window ;

MAIN: cairo-gadget-test

New Annotation

Summary:
Author:
Mode:
Body: