Bump to OPENRNDR 0.3.44-rc.2
This commit is contained in:
18
openrndr-demos/src/demo/kotlin/DemoCircleBatch01.kt
Normal file
18
openrndr-demos/src/demo/kotlin/DemoCircleBatch01.kt
Normal file
@@ -0,0 +1,18 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
|
||||
/*
|
||||
This demo just verifies that drawing a single circle still works with revamped circle drawing code
|
||||
*/
|
||||
fun main() = application {
|
||||
program {
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.GRAY)
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.stroke = ColorRGBa.WHITE
|
||||
drawer.strokeWeight = 2.0
|
||||
drawer.circle(100.0, 100.0, 50.0)
|
||||
drawer.rectangle(100.0, 100.0, 50.0, 50.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
28
openrndr-demos/src/demo/kotlin/DemoCircleBatch02.kt
Normal file
28
openrndr-demos/src/demo/kotlin/DemoCircleBatch02.kt
Normal file
@@ -0,0 +1,28 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.circleBatch
|
||||
|
||||
/*
|
||||
This program demonstrates creating "pre-baked" batches of circles. Batches can have varying fill, stroke and
|
||||
strokeWeight settings.
|
||||
|
||||
Batches are (currently) static but stored in GPU memory. Batches are fast to draw.
|
||||
*/
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
|
||||
val batch = drawer.circleBatch {
|
||||
this.fill = ColorRGBa.PINK
|
||||
for (i in 0 until 100) {
|
||||
this.strokeWeight = Math.random() * 5.0
|
||||
this.circle(Math.random() * width, Math.random() * height, 50.0 * Math.random() + 50.0 )
|
||||
}
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.GRAY)
|
||||
drawer.circles(batch)
|
||||
}
|
||||
}
|
||||
}
|
||||
15
openrndr-demos/src/demo/kotlin/DemoColorBufferCopy01.kt
Normal file
15
openrndr-demos/src/demo/kotlin/DemoColorBufferCopy01.kt
Normal file
@@ -0,0 +1,15 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.extras.meshgenerators.boxMesh
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val cb0 = loadImage("demo-data/images/image-001.png")
|
||||
val cb1 = cb0.createEquivalent()
|
||||
extend {
|
||||
cb0.copyTo(cb1)
|
||||
drawer.image(cb1)
|
||||
}
|
||||
}
|
||||
}
|
||||
37
openrndr-demos/src/demo/kotlin/DemoGeometryShader01.kt
Normal file
37
openrndr-demos/src/demo/kotlin/DemoGeometryShader01.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.DrawPrimitive
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.draw.shadeStyle
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.extras.meshgenerators.boxMesh
|
||||
import org.openrndr.resourceUrl
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val vb = boxMesh()
|
||||
val shader = Shader.Companion.createFromUrls(
|
||||
vsUrl = resourceUrl("/shaders/gs-01.vert"),
|
||||
gsUrl = resourceUrl("/shaders/gs-01.geom"),
|
||||
fsUrl = resourceUrl("/shaders/gs-01.frag")
|
||||
)
|
||||
extend(Orbital())
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.TRIANGLES, 0, vb.vertexCount)
|
||||
shader.end()
|
||||
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
vertexPreamble = "krak"
|
||||
}
|
||||
//drawer.vertexBuffer(vb, DrawPrimitive.TRIANGLES, 0, vb.vertexCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
openrndr-demos/src/demo/kotlin/DemoImageLoadStore01.kt
Normal file
51
openrndr-demos/src/demo/kotlin/DemoImageLoadStore01.kt
Normal file
@@ -0,0 +1,51 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extras.meshgenerators.planeMesh
|
||||
import org.openrndr.internal.Driver
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
|
||||
val shader = Shader.createFromCode(vsCode =
|
||||
"""
|
||||
#version 430
|
||||
in vec3 a_position;
|
||||
in vec2 a_texCoord0;
|
||||
in vec3 a_normal;
|
||||
uniform mat4 projMatrix;
|
||||
uniform mat4 viewMatrix;
|
||||
|
||||
void main() {
|
||||
gl_Position = projMatrix * vec4(a_position, 1.0);
|
||||
}
|
||||
""",
|
||||
fsCode = """
|
||||
#version 430
|
||||
out vec4 o_color;
|
||||
layout(rgba8) uniform image2D bla;
|
||||
void main() {
|
||||
imageStore(bla, ivec2(30,30), vec4(1.0, 0.0, 0.0, 1.0));
|
||||
o_color = vec4(1.0);
|
||||
}
|
||||
""", name = "ils")
|
||||
val cb = colorBuffer(128, 128)
|
||||
val mesh = planeMesh(Vector3.ZERO, Vector3.UNIT_X, Vector3.UNIT_Y, -Vector3.UNIT_Z, 100.0, 100.0)
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.image("bla", 0, cb.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
shader.uniform("viewMatrix", drawer.view)
|
||||
shader.uniform("projMatrix", drawer.projection)
|
||||
|
||||
Driver.instance.drawVertexBuffer(shader, listOf(mesh), DrawPrimitive.TRIANGLES, 0, mesh.vertexCount)
|
||||
shader.end()
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.image(cb)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
26
openrndr-demos/src/demo/kotlin/DemoImageLoadStore02.kt
Normal file
26
openrndr-demos/src/demo/kotlin/DemoImageLoadStore02.kt
Normal file
@@ -0,0 +1,26 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extras.meshgenerators.planeMesh
|
||||
import org.openrndr.internal.Driver
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val cb = colorBuffer(128, 128)
|
||||
extend {
|
||||
val ss = shadeStyle {
|
||||
fragmentTransform = """
|
||||
imageStore(p_image, ivec2(30.0, 30.0), vec4(1.0, 0.0, 0.0, 1.0));
|
||||
""".trimIndent()
|
||||
|
||||
parameter("image", cb.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
}
|
||||
drawer.shadeStyle = ss
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.rectangle(0.0, 0.0, 100.0, 100.0)
|
||||
drawer.image(cb, 0.0, 200.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
openrndr-demos/src/demo/kotlin/DemoImageLoadStore03.kt
Normal file
29
openrndr-demos/src/demo/kotlin/DemoImageLoadStore03.kt
Normal file
@@ -0,0 +1,29 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val cb = colorBuffer(128, 128)
|
||||
val at = arrayTexture(128, 128, 32)
|
||||
val vt = volumeTexture(32, 32, 32)
|
||||
extend {
|
||||
val ss = shadeStyle {
|
||||
fragmentTransform = """
|
||||
imageStore(p_image, ivec2(30.0, 30.0), vec4(1.0, 0.0, 0.0, 1.0));
|
||||
imageStore(p_vt, ivec3(2, 2, 2), vec4(1.0, 0.0, 0.0, 1.0));
|
||||
imageStore(p_at, ivec3(2, 2, 2), vec4(1.0, 0.0, 0.0, 1.0));
|
||||
""".trimIndent()
|
||||
|
||||
parameter("at", at.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
parameter("image", cb.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
parameter("vt", vt.imageBinding(0, ImageAccess.READ_WRITE))
|
||||
}
|
||||
drawer.shadeStyle = ss
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.rectangle(0.0, 0.0, 100.0, 100.0)
|
||||
drawer.image(cb, 0.0, 200.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
33
openrndr-demos/src/demo/kotlin/DemoLineDash01.kt
Normal file
33
openrndr-demos/src/demo/kotlin/DemoLineDash01.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.shadeStyle
|
||||
import org.openrndr.extensions.Screenshots
|
||||
import org.openrndr.math.Polar
|
||||
import org.openrndr.shape.contour
|
||||
fun main() = application {
|
||||
program {
|
||||
val style = shadeStyle {
|
||||
//fragmentTransform = "x_stroke.a *= step(0.5, fract(c_contourPosition / p_dashLen));"
|
||||
fragmentTransform = "x_stroke.a *= smoothstep(0.0, 1.0, mod(c_contourPosition, p_dashLen)) * smoothstep(p_dashLen, p_dashLen-1.0, mod(c_contourPosition, p_dashLen));"
|
||||
parameter("dashLen", 20.0)
|
||||
}
|
||||
extend {
|
||||
drawer.run {
|
||||
clear(ColorRGBa.WHITE)
|
||||
stroke = ColorRGBa.BLACK.opacify(0.5)
|
||||
val c = contour {
|
||||
moveTo(100.0, 100.0)
|
||||
continueTo(100.0, 300.0)
|
||||
continueTo(bounds.center + Polar(seconds * 30, 100.0).cartesian)
|
||||
continueTo(500.0, 100.0)
|
||||
continueTo(600.0, 100.0)
|
||||
}
|
||||
shadeStyle = style
|
||||
contour(c)
|
||||
|
||||
drawer.lineSegment(0.0, 0.0, width*1.0, height*1.0)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
53
openrndr-demos/src/demo/kotlin/DemoTessShader01.kt
Normal file
53
openrndr-demos/src/demo/kotlin/DemoTessShader01.kt
Normal file
@@ -0,0 +1,53 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.extras.meshgenerators.boxMesh
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.resourceUrl
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, 12)
|
||||
val shader = Shader.Companion.createFromUrls(
|
||||
vsUrl = resourceUrl("/shaders/ts-01.vert"),
|
||||
tcsUrl = resourceUrl("/shaders/ts-01.tesc"),
|
||||
tesUrl = resourceUrl("/shaders/ts-01.tese"),
|
||||
fsUrl = resourceUrl("/shaders/ts-01.frag")
|
||||
)
|
||||
|
||||
vb.put {
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 300.0, 0.0))
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 400.0, 0.0))
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 500.0, 0.0))
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
|
||||
|
||||
|
||||
shader.end()
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
openrndr-demos/src/demo/kotlin/DemoTessShader02.kt
Normal file
51
openrndr-demos/src/demo/kotlin/DemoTessShader02.kt
Normal file
@@ -0,0 +1,51 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.extras.meshgenerators.boxMesh
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.resourceUrl
|
||||
|
||||
fun main() {
|
||||
application {
|
||||
program {
|
||||
val vb = vertexBuffer(vertexFormat {
|
||||
position(3)
|
||||
}, 12)
|
||||
|
||||
val shader = Shader.createFromUrls(
|
||||
vsUrl = resourceUrl("/shaders/ts-02.vert"),
|
||||
tcsUrl = resourceUrl("/shaders/ts-02.tesc"),
|
||||
tesUrl = resourceUrl("/shaders/ts-02.tese"),
|
||||
gsUrl = resourceUrl("/shaders/ts-02.geom"),
|
||||
fsUrl = resourceUrl("/shaders/ts-02.frag")
|
||||
)
|
||||
|
||||
vb.put {
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 300.0, 0.0))
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 400.0, 0.0))
|
||||
write(Vector3(0.0, 0.0, 0.0))
|
||||
write(Vector3(100.0, 0.0, 0.0))
|
||||
write(Vector3(140.0, 200.0, 0.0))
|
||||
write(Vector3(200.0, 500.0, 0.0))
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
shader.begin()
|
||||
shader.uniform("offset", mouse.position.xy0)
|
||||
shader.uniform("view", drawer.view)
|
||||
shader.uniform("proj", drawer.projection)
|
||||
shader.uniform("model", drawer.model)
|
||||
driver.drawVertexBuffer(shader, listOf(vb), DrawPrimitive.PATCHES, 0, vb.vertexCount)
|
||||
shader.end()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
openrndr-demos/src/demo/kotlin/DemoVolumeTexture01.kt
Normal file
33
openrndr-demos/src/demo/kotlin/DemoVolumeTexture01.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extensions.Screenshots
|
||||
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
|
||||
val screenshots = extend(Screenshots()) {
|
||||
|
||||
}
|
||||
|
||||
val volumeTexture = VolumeTexture.create(128,128,32)
|
||||
val rt = renderTarget(128, 128) {
|
||||
volumeTexture(volumeTexture, 0)
|
||||
}
|
||||
|
||||
val cb = colorBuffer(128, 128)
|
||||
extend {
|
||||
|
||||
screenshots.afterScreenshot
|
||||
|
||||
drawer.isolatedWithTarget(rt) {
|
||||
drawer.ortho(rt)
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
}
|
||||
volumeTexture.copyTo(cb, 0)
|
||||
drawer.image(cb)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user