--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleExecutable</key>
+ <string>gpu.demos.raytrace</string>
+ <key>CFBundleIconFile</key>
+ <string>Icon.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.factor.gpu.demos.raytrace</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>Raytrace.app</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+</dict>
+</plist>
! (c)2010 Joe Groff bsd license
USING: accessors alien.data cocoa cocoa.classes cocoa.messages
combinators core-foundation.data core-graphics.types fry images
-images.loader io io.streams.limited kernel literals ;
+images.loader io io.streams.limited kernel literals math
+sequences ;
IN: images.cocoa
SINGLETON: ns-image
: image-rep>image ( image-rep -- image )
image new swap {
- [ -> size CGSize>dim >>dim ]
+ [ -> size CGSize>dim [ >integer ] map >>dim ]
[ -> bitmapData ]
[ -> bytesPerPlane memory>byte-array >>bitmap ]
} cleave
RGBA >>component-order
ubyte-components >>component-type
+ t >>premultiplied-alpha?
f >>upside-down? ;
M: ns-image stream>image
UNION: alpha-channel-precedes-colors ABGR ARGB XBGR XRGB ;
-TUPLE: image dim component-order component-type upside-down? bitmap ;
+TUPLE: image
+ dim component-order component-type
+ upside-down? premultiplied-alpha?
+ bitmap ;
: <image> ( -- image ) image new ; inline
[ init-texture texture-coords>> gl-texture-coord-pointer ] tri
swap gl-fill-rect ;
+: set-blend-mode ( texture -- )
+ image>> dup has-alpha?
+ [ premultiplied-alpha?>> [ GL_ONE GL_ONE_MINUS_SRC_ALPHA glBlendFunc ] when ]
+ [ drop GL_BLEND glDisable ] if ;
+
+: reset-blend-mode ( texture -- )
+ image>> dup has-alpha?
+ [ premultiplied-alpha?>> [ GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA glBlendFunc ] when ]
+ [ drop GL_BLEND glEnable ] if ;
+
: draw-textured-rect ( dim texture -- )
[
- [ image>> has-alpha? [ GL_BLEND glDisable ] unless ]
+ [ set-blend-mode ]
[ (draw-textured-rect) GL_TEXTURE_2D 0 glBindTexture ]
- [ image>> has-alpha? [ GL_BLEND glEnable ] unless ]
- tri
+ [ reset-blend-mode ] tri
] with-texturing ;
: texture-coords ( texture -- coords )
: read-texture-image ( tdt level -- image )
[ texture-dim ]
- [ drop texture-object [ component-order>> ] [ component-type>> ] bi f ]
+ [ drop texture-object [ component-order>> ] [ component-type>> ] bi f f ]
[ read-texture ] 2tri
image boa ; inline