-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs cache colors.constants destructors
-kernel opengl opengl.gl opengl.capabilities combinators images
-images.tesselation grouping sequences math math.vectors
-math.matrices generalizations fry arrays namespaces system
-locals literals specialized-arrays ;
+USING: accessors alien.data assocs cache colors.constants
+destructors kernel opengl opengl.gl opengl.capabilities
+combinators images images.tesselation grouping sequences math
+math.vectors generalizations fry arrays namespaces system locals
+literals specialized-arrays ;
+FROM: alien.c-types => int float ;
SPECIALIZED-ARRAY: float
IN: opengl.textures
] unless ;
:: tex-image ( image bitmap -- )
- image image-format :> type :> format :> internal-format
+ image image-format :> ( internal-format format type )
GL_TEXTURE_2D 0 internal-format
image dim>> adjust-texture-dim first2 0
format type bitmap glTexImage2D ;
: image-locs ( image-grid -- loc-grid )
[ first [ dim>> first ] map ] [ [ first dim>> second ] map ] bi
[ 0 [ + ] accumulate nip ] bi@
- cross-zip flip ;
+ cartesian-product flip ;
: <texture-grid> ( image-grid loc -- grid )
[ dup image-locs ] dip
over dim>> max-texture-size [ <= ] 2all?
[ <single-texture> ]
[ [ max-texture-size tesselate ] dip <multi-texture> ] if ;
+
+: get-texture-float ( target level enum -- value )
+ { float } [ glGetTexLevelParameterfv ] [ ] with-out-parameters ; inline
+
+: get-texture-int ( target level enum -- value )
+ { int } [ glGetTexLevelParameteriv ] [ ] with-out-parameters ; inline