! Copyright (C) 2008 Joe Groff.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel opengl.gl alien.c-types continuations namespaces
-assocs alien alien.data alien.strings libc opengl math sequences combinators
-macros arrays io.encodings.ascii fry specialized-arrays
-destructors accessors ;
+assocs alien alien.data alien.strings libc opengl math sequences
+combinators macros arrays io.encodings.ascii fry
+specialized-arrays destructors accessors ;
SPECIALIZED-ARRAY: uint
IN: opengl.shaders
: with-gl-shader-source-ptr ( string quot -- )
- swap ascii malloc-string [ <void*> swap call ] keep free ; inline
+ swap ascii malloc-string [ void* <ref> swap call ] keep free ; inline
: <gl-shader> ( source kind -- shader )
glCreateShader dup rot
dup integer? [ glIsShader c-bool> ] [ drop f ] if ;
: gl-shader-get-int ( shader enum -- value )
- 0 <int> [ glGetShaderiv ] keep *int ;
+ { int } [ glGetShaderiv ] with-out-parameters ;
: gl-shader-ok? ( shader -- ? )
GL_COMPILE_STATUS gl-shader-get-int c-bool> ;
: gl-shader-info-log ( shader -- log )
dup gl-shader-info-log-length dup [
1 calloc &free
- [ 0 <int> swap glGetShaderInfoLog ] keep
+ [ 0 int <ref> swap glGetShaderInfoLog ] keep
ascii alien>string
] with-destructors ;
dup integer? [ glIsProgram c-bool> ] [ drop f ] if ;
: gl-program-get-int ( program enum -- value )
- 0 <int> [ glGetProgramiv ] keep *int ;
+ { int } [ glGetProgramiv ] with-out-parameters ;
: gl-program-ok? ( program -- ? )
GL_LINK_STATUS gl-program-get-int c-bool> ;
: gl-program-info-log ( program -- log )
dup gl-program-info-log-length dup [
1 calloc &free
- [ 0 <int> swap glGetProgramInfoLog ] keep
+ [ 0 int <ref> swap glGetProgramInfoLog ] keep
ascii alien>string
] with-destructors ;
: gl-program-shaders ( program -- shaders )
dup gl-program-shaders-length 2 *
- 0 <int>
- over <uint-array>
- [ glGetAttachedShaders ] keep [ zero? not ] filter ;
+ 0 int <ref>
+ over uint <c-array>
+ [ glGetAttachedShaders ] keep [ zero? ] reject ;
: delete-gl-program-only ( program -- )
glDeleteProgram ; inline