There's an image-gadget implementation from images.viewer, maybe you
should start from that and expand to get all the functionnality you
need ?

IN: scratchpad
"resource:./misc/icons/factor_48...@2x.png" <image-gadget> gadget.
"resource:./misc/icons/factor_48...@2x.png" <image-gadget> "image" open-window

Jon


On Sun, Nov 29, 2015 at 1:37 PM, Sankaranarayanan Viswanathan
<rationalrev...@gmail.com> wrote:
> Hi,
>
> Hi, i'm facing a problem drawing textures in a new window. when I
> create the gadget and add it to the listener using gadget. the image
> shows corretly, when I create the gadget and use open-window, the
> image does not show up on the new window.
>
> Sample code below:
>
> 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
>
> What could I be missing?
>
> Thanks,
> Sankar
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk

------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to