! See http://factorcode.org/license.txt for BSD license.
USING: kernel combinators namespaces quotations hashtables
sequences assocs arrays inference effects math math.ranges
- arrays.lib shuffle macros bake combinators.cleave ;
+ arrays.lib shuffle macros bake combinators.cleave
+ continuations ;
IN: combinators.lib
: and? ( obj quot1 quot2 -- ? )
>r keep r> rot [ call ] [ 2drop f ] if ; inline
+MACRO: multikeep ( word out-indexes -- ... )
+ [
+ dup >r [ \ npick \ >r 3array % ] each
+ %
+ r> [ drop \ r> , ] each
+ ] [ ] make ;
++
+ : retry ( quot n -- )
+ [ drop ] rot compose attempt-all ; inline
alien>char-string
] with-malloc ;
- : check-gl-shader ( shader -- shader* )
+ : check-gl-shader ( shader -- shader )
dup gl-shader-ok? [ dup gl-shader-info-log throw ] unless ;
: delete-gl-shader ( shader -- ) glDeleteShader ; inline
alien>char-string
] with-malloc ;
- : check-gl-program ( program -- program* )
+ : check-gl-program ( program -- program )
dup gl-program-ok? [ dup gl-program-info-log throw ] unless ;
: gl-program-shaders-length ( program -- shaders-length )
GL_ATTACHED_SHADERS gl-program-get-int ; inline
: gl-program-shaders ( program -- shaders )
- dup gl-program-shaders-length [
- dup "GLuint" <c-array>
- [ 0 <int> swap glGetAttachedShaders ] keep
- ] keep c-uint-array> ;
+ dup gl-program-shaders-length
+ dup "GLuint" <c-array>
+ 0 <int> swap
+ [ glGetAttachedShaders ] { 3 1 } multikeep
+ c-uint-array> ;
: delete-gl-program-only ( program -- )
glDeleteProgram ; inline