USING: accessors assocs cache colors.constants destructors fry kernel
opengl opengl.gl combinators images images.tesselation grouping
specialized-arrays.float sequences math math.vectors
-math.matrices generalizations fry arrays ;
+math.matrices generalizations fry arrays namespaces ;
IN: opengl.textures
+SYMBOL: non-power-of-2-textures?
+
: gen-texture ( -- id ) [ glGenTextures ] (gen-gl-object) ;
: delete-texture ( id -- ) [ glDeleteTextures ] (delete-gl-object) ;
TUPLE: single-texture image dim loc texture-coords texture display-list disposed ;
+: adjust-texture-dim ( dim -- dim' )
+ non-power-of-2-textures? get [
+ [ next-power-of-2 ] map
+ ] unless ;
+
: (tex-image) ( image -- )
[ GL_TEXTURE_2D 0 GL_RGBA ] dip
- [ dim>> first2 [ next-power-of-2 ] bi@ 0 ]
+ [ dim>> adjust-texture-dim first2 0 ]
[ component-order>> component-order>format f ] bi
glTexImage2D ;
] with-texturing ;
: texture-coords ( texture -- coords )
- [ [ dim>> ] [ image>> dim>> [ next-power-of-2 ] map ] bi v/ ]
+ [ [ dim>> ] [ image>> dim>> adjust-texture-dim ] bi v/ ]
[
image>> upside-down?>>
{ { 0 1 } { 1 1 } { 1 0 } { 0 0 } }
-! Copyright (C) 2006, 2007 Slava Pestov.
+! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces opengl opengl.gl ;
+USING: kernel namespaces opengl opengl.gl fry ;
IN: ui.backend
SYMBOL: ui-backend
HOOK: offscreen-pixels ui-backend ( world -- alien w h )
: with-gl-context ( handle quot -- )
- swap [ select-gl-context call ] keep
- flush-gl-context gl-error ; inline
+ '[ select-gl-context @ ]
+ [ flush-gl-context gl-error ] bi ; inline
HOOK: (with-ui) ui-backend ( quot -- )
\ No newline at end of file
! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs continuations kernel math models
-namespaces opengl sequences io combinators combinators.short-circuit
-fry math.vectors math.rectangles cache ui.gadgets ui.gestures
-ui.render ui.backend ui.gadgets.tracks ui.commands ;
+namespaces opengl opengl.capabilities opengl.textures sequences io
+combinators combinators.short-circuit fry math.vectors math.rectangles
+cache ui.gadgets ui.gestures ui.render ui.backend ui.gadgets.tracks
+ui.commands ;
IN: ui.gadgets.worlds
TUPLE: world < track
flush-layout-cache-hook [ [ ] ] initialize
+: check-extensions ( -- )
+ "2.0" { "GL_ARB_texture_non_power_of_two" } has-gl-version-or-extensions?
+ non-power-of-2-textures? set ;
+
: (draw-world) ( world -- )
dup handle>> [
+ check-extensions
{
[ init-gl ]
[ draw-gadget ]