refresh-program ( program: program -- )
GPU-accelerated rendering > Shader objects

Prev:<program-instance> ( program: program -- instance: program-instance )


Inputs and outputs
programa program

Word description
Rereads the source code for every shader in program and attempts to refresh all the existing shader-instances and program-instances for those shaders. If any of the new source code fails to compile or link, the existing valid shader and program instances will remain untouched. However, subsequent attempts to compile new shader or program instances will still attempt to use the new source code. If the compilation and linking succeed, the existing shader and program instances will be updated on the fly to reference the newly compiled code.


TYPED:: refresh-program ( program: program -- )
program shaders>> [ refresh-shader-source ] each
program instances>> [| world old-instance |
old-instance valid-handle? [
world [
program shaders>>
[ compile-shader |dispose ] map
:> new-shader-instances program
new-shader-instances (link-program)
|dispose :> new-program-instance
old-instance new-program-instance
become-program-instance new-shader-instances
[| new-shader-instance |
world new-shader-instance shader>>
instances>> at
] each
] with-destructors
] with-gl-context
] when
] assoc-each reset-memos ;