2009-02-11 05:55:33 -05:00
|
|
|
! Copyright (C) 2009 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-02-15 05:33:43 -05:00
|
|
|
USING: namespaces cache images images.loader accessors assocs
|
2009-02-15 07:01:46 -05:00
|
|
|
kernel opengl opengl.gl opengl.textures ui.gadgets.worlds
|
2009-09-28 18:16:16 -04:00
|
|
|
memoize images.png images.tiff ;
|
2009-02-11 05:55:33 -05:00
|
|
|
IN: ui.images
|
|
|
|
|
|
|
|
TUPLE: image-name path ;
|
|
|
|
|
|
|
|
C: <image-name> image-name
|
|
|
|
|
2009-02-15 07:01:46 -05:00
|
|
|
MEMO: cached-image ( image-name -- image ) path>> load-image ;
|
2009-02-11 05:55:33 -05:00
|
|
|
|
|
|
|
<PRIVATE
|
|
|
|
|
|
|
|
: image-texture-cache ( world -- texture-cache )
|
2009-02-15 05:33:43 -05:00
|
|
|
[ [ <cache-assoc> ] unless* ] change-images images>> ;
|
2009-02-11 05:55:33 -05:00
|
|
|
|
|
|
|
PRIVATE>
|
|
|
|
|
|
|
|
: rendered-image ( path -- texture )
|
2009-02-20 21:53:51 -05:00
|
|
|
world get image-texture-cache
|
|
|
|
[ cached-image { 0 0 } <texture> ] cache ;
|
2009-02-11 05:55:33 -05:00
|
|
|
|
|
|
|
: draw-image ( image-name -- )
|
2009-02-19 05:06:57 -05:00
|
|
|
rendered-image draw-texture ;
|
2009-02-11 05:55:33 -05:00
|
|
|
|
2009-02-12 02:39:03 -05:00
|
|
|
: draw-scaled-image ( dim image-name -- )
|
2009-02-19 05:06:57 -05:00
|
|
|
rendered-image draw-scaled-texture ;
|
2009-02-12 02:39:03 -05:00
|
|
|
|
2009-02-11 05:55:33 -05:00
|
|
|
: image-dim ( image-name -- dim )
|
2009-06-02 21:39:51 -04:00
|
|
|
cached-image dim>> ;
|