 ui.gadgets accessors sequences ui.render ui math locals arrays
 generalizations combinators ui.gadgets.worlds
 literals ui.pixel-formats ;
-FROM: opengl.demo-support => rect-vertices ;
 IN: spheres
 
 STRING: plane-vertex-shader

    } cleave ] with-framebuffer ;

M: spheres-world draw-world*
    GL_DEPTH_TEST glEnable
    GL_SCISSOR_TEST glDisable
    0.15 0.15 1.0 1.0 glClearColor {
        [ (draw-reflection-texture) ]
        [ demo-world-set-matrix ]
        [ sphere-scene ]

        [ plane-program>> [ delete-gl-program ] when* ]
    } cleave ;

M: spheres-world pref-dim*
    drop { 640 480 } ;

:: (draw-sphere) ( program center radius -- )
    program "center" glGetAttribLocation center first3 glVertexAttrib3f
    program "radius" glGetAttribLocation radius glVertexAttrib1f
    { -1.0 -1.0 } { 2.0 2.0 } gl-fill-rect ;
    
:: (draw-colored-sphere) ( program center radius surfacecolor -- )
    program "surface_color" glGetAttribLocation surfacecolor first4 glVertexAttrib4f
