From 7bccfbd60938e5f63e887f3ae53701336e16d003 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Fri, 24 Jan 2020 11:03:10 +0100 Subject: [PATCH] Update orx-olive/README.md --- orx-olive/README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/orx-olive/README.md b/orx-olive/README.md index 97920eec..5a9c85fb 100644 --- a/orx-olive/README.md +++ b/orx-olive/README.md @@ -60,7 +60,35 @@ import org.openrndr.draw.* } } ``` -The Reloadable store can be cleared using the `clearReloadables` function + +The Reloadable store can be cleared using the `clearReloadables` function. + +### Reloadable GPU resources + +To store GPU resources or objects that use GPU resources (a.o. `ColorBuffer`, `VertexBuffer`, `Shader`, `BufferTexture`) in a `Reloadable` object one uses OPENRNDR's +`persistent {}` builder function. + +```!kotlin +@file:Suppress("UNUSED_LAMBDA_EXPRESSION") +import org.openrndr.color.ColorRGBa +import org.openrndr.draw.* + +{ program: PersistentProgram -> + program.apply { + val a = object : Reloadable() { + var image = persistent { loadImage("data/images/pm5544.png" ) } + } + a.reload() + + extend { + drawer.image(a.image) + } + } +} +``` + + + Keep in mind that `Reloadable` should only be used for singleton classes.