Paste: texture graft

Author: rationalrevolt
Mode: factor
Date: Sun, 29 Nov 2015 12:21:10
Plain Text |
TUPLE: i-gadget < gadget
    image texture ;

: <i-gadget> ( path -- gadget )
    [ i-gadget new ] dip load-image >>image ;    

M: i-gadget pref-dim*
    image>> dim>> [ 20 + ] map ;

M: i-gadget graft*
    dup find-gl-context
    dup image>> { 0 0 } <texture> >>texture drop ;

M: i-gadget ungraft*
    dup find-gl-context
    dup texture>> dispose
    f >>texture drop ;

M: i-gadget draw-gadget*
    [ { 10 10 } ] dip texture>> [ draw-texture ] curry with-translation ;

! In the listener

"vocab:images/sprites/game_drop.png" <i-gadget> gadget.

! the above works and shows the image in the listener

"vocab:images/sprites/game_drop.png" <i-gadget> "i-gadget" open-window

! the above opens a new window but the image does not show

New Annotation

Summary:
Author:
Mode:
Body: