Skip to content

Commit

Permalink
Improve GLES 3.x compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinRNDR committed Jul 10, 2024
1 parent 4448a5e commit 432de7c
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.openrndr.orsl.convention
import ScreenshotsHelper.collectScreenshots
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val libs = the<LibrariesForLibs>()
Expand Down Expand Up @@ -50,6 +51,10 @@ dependencies {
"demoImplementation"(libs.openrndr.extensions)
"demoRuntimeOnly"(libs.openrndr.gl3.core)
"demoRuntimeOnly"(libs.slf4j.simple)
if (DefaultNativePlatform.getCurrentOperatingSystem().isMacOsX) {
"demoRuntimeOnly"(libs.openrndr.gl3.natives.macos.arm64)
}

}


Expand Down Expand Up @@ -132,4 +137,8 @@ if (shouldPublish) {
setRequired({ isReleaseVersion && gradle.taskGraph.hasTask("publish") })
sign(publishing.publications)
}
}
}

java {
targetCompatibility = JavaVersion.valueOf("VERSION_${libs.versions.jvmTarget.get()}")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.openrndr.orsl.convention
import CollectScreenshotsTask
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import java.net.URI
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
Expand Down Expand Up @@ -96,6 +97,11 @@ kotlin {
implementation(libs.openrndr.extensions)
runtimeOnly(libs.openrndr.gl3.core)
runtimeOnly(libs.slf4j.simple)
dependencies {
if (DefaultNativePlatform.getCurrentOperatingSystem().isMacOsX) {
runtimeOnly(libs.openrndr.gl3.natives.macos.arm64)
}
}
}

// https://youtrack.jetbrains.com/issue/KTIJ-25644
Expand Down
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[versions]
ksp = "1.9.23-1.0.19"
kotlinPoet = "1.16.0"
kotlinPoet = "1.18.0"
kotlinApi = "1.9"
kotlinLanguage = "1.9"
kotlin = "1.9.23"
jvmTarget = "11"
jvmTarget = "17"
openrndr = { require = "[0.4.2, 0.5.0)" }
orx = { require = "[0.4.2, 0.5.0)" }
kotlinxCoroutines = "1.8.0"
kotlinLogging = "6.0.3"
kotlinxSerialization = "1.6.4"
kotlinxSerialization = "1.7.1"
dokka = "1.7.10"
nebulaRelease = "18.0.7"
gradleNexusPublish = "2.0.0"
Expand Down Expand Up @@ -49,6 +49,8 @@ openrndr-dialogs = { group = "org.openrndr", name = "openrndr-dialogs", version.
openrndr-ffmpeg = { group = "org.openrndr", name = "openrndr-ffmpeg", version.ref = "openrndr" }
openrndr-svg = { group = "org.openrndr", name = "openrndr-svg", version.ref = "openrndr" }
openrndr-gl3-core = { group = "org.openrndr", name = "openrndr-gl3", version.ref = "openrndr" }
openrndr-gl3-natives-macos-arm64 = { group = "org.openrndr", name = "openrndr-gl3-natives-macos-arm64", version.ref = "openrndr" }

orx-mesh-generators = { group = "org.openrndr.extra", name = "orx-mesh-generators", version.ref = "orx" }
orx-camera = { group = "org.openrndr.extra", name = "orx-camera", version.ref = "orx" }
orx-olive = { group = "org.openrndr.extra", name = "orx-olive", version.ref = "orx" }
Expand Down
1 change: 1 addition & 0 deletions orsl-demos/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
dependencies {
implementation(libs.openrndr.application)
implementation(libs.openrndr.gl3.core)
implementation("org.openrndr:openrndr-gl3-natives-macos-arm64:0.4.5-SNAPSHOT")
implementation(project(":orsl-shader-generator"))
implementation(project(":orsl-extension-color"))
implementation(project(":orsl-extension-easing"))
Expand Down
4 changes: 2 additions & 2 deletions orsl-demos/src/main/kotlin/DemoComputeStyle02.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fun main() {
)
}
}
updateBuffer.buffer("buffer", buffer1)
updateBuffer.buffer("buffer", buffer1.ssbo)

val style = shadeStyle {
vertexTransform {
Expand All @@ -70,7 +70,7 @@ fun main() {
)
}
}
style.buffer("buffer", buffer1)
style.buffer("buffer", buffer1.ssbo)

val sphere = sphereMesh(radius = 0.1)

Expand Down
8 changes: 3 additions & 5 deletions orsl-demos/src/main/kotlin/DemoVoxel01.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fun main() {
val filterSdf = computeStyle {
image("sdf", vt.imageBinding(0, ImageAccess.READ))

buffer("instances", instances)
buffer("instances", instances.ssbo)
workGroupSize = IntVector3(1, 1, 1)
computeTransform {
val b_instances by parameter<Voxel32>()
Expand Down Expand Up @@ -87,7 +87,7 @@ fun main() {
}

val ss = shadeStyle {
buffer("instances", instances)
buffer("instances", instances.ssbo)
vertexTransform {
val b_instances by parameter<Voxel32>()
x_position *= b_instances.position[c_instance].w
Expand All @@ -101,7 +101,7 @@ fun main() {
}

vt.imageBinding(0, ImageAccess.READ_WRITE)
filterSdf.buffer("instances", instances)
filterSdf.buffer("instances", instances.ssbo)
val box = boxMesh()
extend(Orbital())
extend {
Expand All @@ -114,8 +114,6 @@ fun main() {
drawer.vertexBufferInstances(listOf(box), emptyList(), DrawPrimitive.TRIANGLES, 32*32*32)

}


}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class FibonacciPhrases : ShaderBook {
vec4 sphericalDistribution( vec3 p, int n )
{
p = normalize(p);
float m = 1.0 - 1.0/n;
float m = 1.0 - 1.0 / float(n);
float phi = min(atan(p.y, p.x), PI), cosTheta = p.z;
float k = max(2.0, floor( log(n * PI * sqrt(5.0) * (1.0 - cosTheta*cosTheta))/ log(PHI+1.0)));
float k = max(2.0, floor( log(float(n) * PI * sqrt(5.0) * (1.0 - cosTheta*cosTheta))/ log(PHI+1.0)));
float Fk = pow(PHI, k)/sqrt(5.0);
vec2 F = vec2( floor(Fk + 0.5), floor(Fk * PHI + 0.5) ); // k, k+1
vec2 ka = 2.0*F/n;
vec2 ka = 2.0*F/float(n);
vec2 kb = 2.0*PI*( fract((F+1.0)*PHI) - (PHI-1.0) );
mat2 iB = mat2( ka.y, -ka.x,
Expand All @@ -42,7 +42,7 @@ vec4 sphericalDistribution( vec3 p, int n )
float i = dot(F, uv + c); // all quantities are ingeters (can take a round() for extra safety)
float phi = 2.0*PI*fract(i*PHI);
float cosTheta = m - 2.0*i/n;
float cosTheta = m - 2.0*i/float(n);
float sinTheta = sqrt(1.0 - cosTheta*cosTheta);
vec3 q = vec3( cos(phi)*sinTheta, sin(phi)*sinTheta, cosTheta );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ interface DoubleFunctions {
operator fun Double.plus(right: Symbol<Double>): Symbol<Double> = functionSymbol(this, right, "($0 + $1)")

@JvmName("plusSdSi")
operator fun Symbol<Double>.plus(right: Symbol<Int>): Symbol<Double> = functionSymbol(this, right, "($0 + $1)")
operator fun Symbol<Double>.plus(right: Symbol<Int>): Symbol<Double> = functionSymbol(this, right, "($0 + float($1))")

@JvmName("plusSdVd")
operator fun Symbol<Double>.plus(right: Double): Symbol<Double> = functionSymbol(this, right, "($0 + $1)")

@JvmName("plusSdVi")
operator fun Symbol<Double>.plus(right: Int): Symbol<Double> = functionSymbol(this, right, "($0 + $1)")
operator fun Symbol<Double>.plus(right: Int): Symbol<Double> = functionSymbol(this, right, "($0 + float($1))")

@JvmName("minusVdSd")
operator fun Double.minus(right: Symbol<Double>): Symbol<Double> = functionSymbol(this, right, "($0 - $1)")
Expand All @@ -194,7 +194,7 @@ interface DoubleFunctions {
operator fun Symbol<Double>.times(right: Double): Symbol<Double> = functionSymbol(this, right, "($0 * $1)")

@JvmName("timesSdVi")
operator fun Symbol<Double>.times(right: Int): Symbol<Double> = functionSymbol(this, right, "($0 * $1)")
operator fun Symbol<Double>.times(right: Int): Symbol<Double> = functionSymbol(this, right, "($0 * float($1))")

@JvmName("divSdSd")
operator fun Symbol<Double>.div(right: Symbol<Double>): Symbol<Double> = functionSymbol(this, right, "($0 / $1)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ interface IntFunctions {
operator fun Symbol<Int>.plus(right: Symbol<Int>): Symbol<Int> = functionSymbol(this, right, "($0 + $1)")

@JvmName("plusSiSd")
operator fun Symbol<Int>.plus(right: Symbol<Double>): Symbol<Double> = functionSymbol(this, right, "($0 + $1)")
operator fun Symbol<Int>.plus(right: Symbol<Double>): Symbol<Double> = functionSymbol(this, right, "(float($0) + $1)")

@JvmName("plusSiVi")
operator fun Symbol<Int>.plus(right: Int): Symbol<Int> = functionSymbol(this, right, "($0 + $1)")

@JvmName("plusSiVd")
operator fun Symbol<Int>.plus(right: Double): Symbol<Double> = functionSymbol(this, right, "($0 + $1)")
operator fun Symbol<Int>.plus(right: Double): Symbol<Double> = functionSymbol(this, right, "(float($0) + $1)")

@JvmName("minusSiSi")
operator fun Symbol<Int>.minus(right: Symbol<Int>): Symbol<Int> = functionSymbol(this, right, "($0 - $1)")
Expand All @@ -59,16 +59,16 @@ interface IntFunctions {
operator fun Symbol<Int>.times(right: Int): Symbol<Int> = functionSymbol(this, right, "($0 * $1)")

@JvmName("timesSiVd")
operator fun Symbol<Int>.times(right: Double): Symbol<Double> = functionSymbol(this, right, "($0 * $1)")
operator fun Symbol<Int>.times(right: Double): Symbol<Double> = functionSymbol(this, right, "(float($0) * $1)")

@JvmName("divSiSi")
operator fun Symbol<Int>.div(right: Symbol<Int>): Symbol<Int> = functionSymbol(this, right, "($0 / $1)")

@JvmName("divSiSd")
operator fun Symbol<Int>.div(right: Symbol<Double>): Symbol<Double> = functionSymbol(this, right, "($0 / $1)")
operator fun Symbol<Int>.div(right: Symbol<Double>): Symbol<Double> = functionSymbol(this, right, "(float($0) / $1)")

@JvmName("divSiVd")
operator fun Symbol<Int>.div(right: Double): Symbol<Double> = functionSymbol(this, right, "($0 / $1)")
operator fun Symbol<Int>.div(right: Double): Symbol<Double> = functionSymbol(this, right, "(float($0) / $1)")

@JvmName("eqSiSi")
infix fun Symbol<Int>.eq(right: Symbol<Int>): Symbol<Boolean> = functionSymbol(this, right, "($0 == $1)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ interface IntVector2Functions {
fun abs(x: Symbol<IntVector2>): Symbol<IntVector2> = functionSymbol(x, "abs($0)")

@JvmName("divVdSiv2")
operator fun Double.div(right: Symbol<IntVector2>): Symbol<Vector2> = functionSymbol(this, right, "($0 / $1)")
operator fun Double.div(right: Symbol<IntVector2>): Symbol<Vector2> = functionSymbol(this, right, "($0 / vec2($1))")


@JvmName("timesSiv2Vd")
operator fun Symbol<IntVector2>.times(right: Double): Symbol<Vector2> = functionSymbol(this, right, "($0 * $1)")
operator fun Symbol<IntVector2>.times(right: Double): Symbol<Vector2> = functionSymbol(this, right, "(vec2($0) * $1)")

@JvmName("timesSiv2Sd")
operator fun Symbol<IntVector2>.times(right: Symbol<Double>): Symbol<Vector2> =
functionSymbol(this, right, "($0 * $1)")
functionSymbol(this, right, "(vec2($0) * $1)")


val Symbol<IntVector2>.x: Symbol<Int>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import kotlin.jvm.JvmName
@Suppress("INAPPLICABLE_JVM_NAME")
interface UIntVector2Functions {
@JvmName("divVdSuiv2")
operator fun Double.div(right: Symbol<UIntVector2>): Symbol<Vector2> = functionSymbol(this, right, "($0 / $1)")
operator fun Double.div(right: Symbol<UIntVector2>): Symbol<Vector2> = functionSymbol(this, right, "($0 / vec2($1))")

@JvmName("timesSuiv2Vd")
operator fun Symbol<UIntVector2>.times(right: Double): Symbol<Vector2> = functionSymbol(this, right, "($0 * $1)")
operator fun Symbol<UIntVector2>.times(right: Double): Symbol<Vector2> = functionSymbol(this, right, "(vec2($0) * $1)")

@JvmName("timesSuiv2Sd")
operator fun Symbol<UIntVector2>.times(right: Symbol<Double>): Symbol<Vector2> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ open class ShadeStyleBuilder : ShaderBuilder(emptySet()), TransformPhrasesFuncti
): BufferProperty<T> {
return BufferProperty(staticType<T>()) { name ->
registerStructuredBuffer<T>(name, access, flags.toSet())
this@buffer.buffer(name, structuredBuffer)
this@buffer.buffer(name, structuredBuffer.ssbo)
}
}

Expand Down

0 comments on commit 432de7c

Please sign in to comment.