Make bunny load

db4
Slava Pestov 2008-12-17 20:28:26 -06:00
parent da38cd36dd
commit 128b52a24b
3 changed files with 8 additions and 10 deletions

View File

@ -23,7 +23,7 @@ IN: bunny.model
: n ( vs triple -- n ) : n ( vs triple -- n )
swap [ nth ] curry map 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 ; vneg normalize ;
: normal ( ns vs triple -- ) : normal ( ns vs triple -- )
@ -31,7 +31,7 @@ IN: bunny.model
: normals ( vs is -- ns ) : normals ( vs is -- ns )
over length { 0.0 0.0 0.0 } <array> -rot over length { 0.0 0.0 0.0 } <array> -rot
[ >r 2dup r> normal ] each drop [ [ 2dup ] dip normal ] each drop
[ normalize ] map ; [ normalize ] map ;
: read-model ( stream -- model ) : read-model ( stream -- model )

View File

@ -2,7 +2,7 @@ USING: arrays bunny.model bunny.cel-shaded continuations
destructors kernel math multiline opengl opengl.shaders destructors kernel math multiline opengl opengl.shaders
opengl.framebuffers opengl.gl opengl.demo-support fry opengl.framebuffers opengl.gl opengl.demo-support fry
opengl.capabilities sequences ui.gadgets combinators accessors opengl.capabilities sequences ui.gadgets combinators accessors
macros ; macros locals ;
IN: bunny.outlined IN: bunny.outlined
STRING: outlined-pass1-fragment-shader-main-source STRING: outlined-pass1-fragment-shader-main-source
@ -143,19 +143,17 @@ TUPLE: bunny-outlined
pass1-program pass2-program f f f f f bunny-outlined boa pass1-program pass2-program f f f f f bunny-outlined boa
] [ drop f ] if ; ] [ drop f ] if ;
: (framebuffer-texture) ( dim iformat xformat -- texture ) :: (framebuffer-texture) ( dim iformat xformat -- texture )
swapd >r >r >r
GL_TEXTURE0 glActiveTexture GL_TEXTURE0 glActiveTexture
gen-texture GL_TEXTURE_2D over glBindTexture gen-texture GL_TEXTURE_2D over glBindTexture
GL_TEXTURE_2D GL_TEXTURE_WRAP_S GL_CLAMP glTexParameteri 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_WRAP_T GL_CLAMP glTexParameteri
GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_NEAREST glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER GL_NEAREST glTexParameteri
GL_TEXTURE_2D GL_TEXTURE_MIN_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 -- ) :: (attach-framebuffer-texture) ( texture attachment -- )
swap >r >r GL_FRAMEBUFFER_EXT attachment GL_TEXTURE_2D texture 0 glFramebufferTexture2DEXT
GL_FRAMEBUFFER_EXT r> GL_TEXTURE_2D r> 0 glFramebufferTexture2DEXT
gl-error ; gl-error ;
: (make-framebuffer) ( color-texture normal-texture depth-texture -- framebuffer ) : (make-framebuffer) ( color-texture normal-texture depth-texture -- framebuffer )

View File

@ -60,7 +60,7 @@ M: demo-gadget pref-dim* ( gadget -- dim )
] [ ] [
GL_MODELVIEW glMatrixMode GL_MODELVIEW glMatrixMode
glLoadIdentity 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 ] [ pitch>> 1.0 0.0 0.0 glRotatef ]
[ yaw>> 0.0 1.0 0.0 glRotatef ] [ yaw>> 0.0 1.0 0.0 glRotatef ]
tri tri