refresh-program ( program: program -- )
GPU-accelerated rendering ยป Shader objects

Prev:<program-instance> ( program: program -- instance: program-instance )
Next:vertex-array


Vocabulary
gpu.shaders

Inputs
programa program


Outputs
None

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.

Definition


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
new-shader-instance
become-shader-instance
] each
] with-destructors
] with-gl-context
] when
] assoc-each reset-memos ;