: n ( vs triple -- n )
swap [ nth ] curry map
- dup third over first v- >r dup second swap first v- r> cross
+ [ [ second ] [ first ] bi v- ] [ [ third ] [ first ] bi v- ] bi cross
vneg normalize ;
: normal ( ns vs triple -- )
: normals ( vs is -- ns )
over length { 0.0 0.0 0.0 } <array> -rot
- [ >r 2dup r> normal ] each drop
+ [ [ 2dup ] dip normal ] each drop
[ normalize ] map ;
: read-model ( stream -- model )
destructors kernel math multiline opengl opengl.shaders
opengl.framebuffers opengl.gl opengl.demo-support fry
opengl.capabilities sequences ui.gadgets combinators accessors
-macros ;
+macros locals ;
IN: bunny.outlined
STRING: outlined-pass1-fragment-shader-main-source
pass1-program pass2-program f f f f f bunny-outlined boa
] [ drop f ] if ;
-: (framebuffer-texture) ( dim iformat xformat -- texture )
- swapd >r >r >r
+:: (framebuffer-texture) ( dim iformat xformat -- texture )
GL_TEXTURE0 glActiveTexture
gen-texture GL_TEXTURE_2D over glBindTexture
GL_TEXTURE_2D GL_TEXTURE_WRAP_S GL_CLAMP glTexParameteri
GL_TEXTURE_2D GL_TEXTURE_WRAP_T GL_CLAMP glTexParameteri
GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_NEAREST glTexParameteri
GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER GL_NEAREST glTexParameteri
- GL_TEXTURE_2D 0 r> r> first2 0 r> GL_UNSIGNED_BYTE f glTexImage2D ;
+ GL_TEXTURE_2D 0 iformat dim first2 0 xformat GL_UNSIGNED_BYTE f glTexImage2D ;
-: (attach-framebuffer-texture) ( texture attachment -- )
- swap >r >r
- GL_FRAMEBUFFER_EXT r> GL_TEXTURE_2D r> 0 glFramebufferTexture2DEXT
+:: (attach-framebuffer-texture) ( texture attachment -- )
+ GL_FRAMEBUFFER_EXT attachment GL_TEXTURE_2D texture 0 glFramebufferTexture2DEXT
gl-error ;
: (make-framebuffer) ( color-texture normal-texture depth-texture -- framebuffer )
] [
GL_MODELVIEW glMatrixMode
glLoadIdentity
- [ >r 0.0 0.0 r> distance>> neg glTranslatef ]
+ [ [ 0.0 0.0 ] dip distance>> neg glTranslatef ]
[ pitch>> 1.0 0.0 0.0 glRotatef ]
[ yaw>> 0.0 1.0 0.0 glRotatef ]
tri