Add orx readme generator, update readmes

This commit is contained in:
Abe Pazos
2020-05-18 11:54:18 +02:00
committed by Edwin Jakobs
parent 274af989c3
commit 540e8b0498
39 changed files with 206 additions and 84 deletions

View File

@@ -0,0 +1,47 @@
# orx-shader-phrases
A library that provides a `#pragma import` statement for shaders by using the JVM class loader.
## Usage
Given a shader source:
````glsl
#version 330
// -- this imports all phrases in Dummy
#pragma import org.openrndr.extra.shaderphrases.phrases.Dummy.*
void main() {
float a = dummy();
}
````
We can use the `preprocessShader()` function to resolve `#pragma import` statements.
```kotlin
val preprocessedSource = preprocessShader(originalSource)
```
Alternatively loading and preprocessing can be combined in a single function call.
```kotlin
val preprocessedSource = preprocessShaderFromUrl(resourceUrl("/some-shader.frag"))
```
To create importable shader phrases one creates a Kotlin class and adds the `ShaderPhrases` annotation.
For example the `dummy` phrase in our example is made available as follows:
```kotlin
// -- force the class name to be Dummy on the JVM
@file:JvmName("Dummy")
@file:ShaderPhrases
package org.openrndr.extra.shaderphrases.phrases
import org.openrndr.extra.shaderphrases.annotations.ShaderPhrases
// -- the shader phrase
const val dummy = """
float dummy() {
return 0.0;
}
"""
```