Package com.victorvalentim.zividomelive
Class SceneAssets
java.lang.Object
com.victorvalentim.zividomelive.SceneAssets
Processing-friendly, typed assets scoped to one scene activation.
Images, shaders, and shapes are created only on the bound render thread. The default loaders keep borrowed Processing objects and release their Java references at scene disposal.
Use these synchronous asset operations during Scene.setupScene() or another known
render-thread callback, not inside background tasks or recurring hot paths.
API stability: Advanced Stable.
- Since:
- 2.0.0
-
Method Summary
Modifier and TypeMethodDescriptionprocessing.core.PShapecacheShape(String key, processing.core.PShape shape) Stores or replaces one borrowed retained shape.processing.core.PShapegetOrCreateShape(String key, Supplier<? extends processing.core.PShape> factory) Creates a retained shape once on the render thread.processing.core.PImageLoads an image once using a sketch-relative or absolute Processing image path.processing.opengl.PShaderloadShader(String fragmentPath) Loads a fragment shader once.processing.opengl.PShaderloadShader(String key, String fragmentPath, String vertexPath) Loads a fragment/vertex shader pair once.intremoveShapesByPrefix(String prefix) Invalidates retained shapes whose keys start with the supplied prefix.
-
Method Details
-
loadImage
Loads an image once using a sketch-relative or absolute Processing image path.- Parameters:
path- non-blank Processing image path, also used as the activation cache key- Returns:
- loaded image, or null when Processing cannot load it
-
loadShader
Loads a fragment shader once.- Parameters:
fragmentPath- non-blank Processing fragment shader path and cache key- Returns:
- loaded shader, or null when Processing cannot load it
-
loadShader
Loads a fragment/vertex shader pair once.- Parameters:
key- non-blank activation cache keyfragmentPath- Processing fragment shader pathvertexPath- Processing vertex shader path- Returns:
- loaded shader, or null when Processing cannot load it
-
getOrCreateShape
public processing.core.PShape getOrCreateShape(String key, Supplier<? extends processing.core.PShape> factory) Creates a retained shape once on the render thread.- Parameters:
key- non-blank activation cache keyfactory- retained shape factory invoked only when the key is absent- Returns:
- cached or newly created shape
-
cacheShape
Stores or replaces one borrowed retained shape.- Parameters:
key- non-blank activation cache keyshape- borrowed retained Processing shape- Returns:
- the supplied shape
-
removeShapesByPrefix
Invalidates retained shapes whose keys start with the supplied prefix.- Parameters:
prefix- key prefix used to select retained shapes; an empty prefix removes all- Returns:
- number of removed shapes
-