Processing 3 Kotlin project-template with gradle

Hi :slight_smile:

I recently started using Processing and wanted to use it from my familiar IDE (IntelliJ) and with my preferred language (Kotlin).

I stumbled upon some interesting reads ([1], [2], [3]) and created a project template upon that basis.

You can find it here: Moritz Lindner / Processing Kotlin Gradle Template · GitLab

With this, you no longer need to have processing installed and manually add it as a project dependency since its present as a Gradle dependency. Therefore, it should be much easier to share your project via git.

A version using the Processing 4 library will come soon.

Important Infos:

  • Please make sure to use a Java 8 JDK

Please share your thoughts and give me feedback :slight_smile:

Known Issues:

  • The P2D and P3D renderers don’t work on apple m1 chips:

This is because of an error in the macOS arm build of the used java OpenGL binding library (jogl) which is used by Processing. (I think a fix is available [4] but the best solution would be a fix in the processing library)

If you are trying to run the application on apple silicon with one of those renderers the following error will occur:

java.lang.UnsatisfiedLinkError: /private/var/folders/kv/drx4695s5p91vm8chh27scv00000gn/T/jogamp_0000/file_cache/jln3913932672952410849/jln113904259977141220/natives/macosx-universal/libgluegen-rt.jnilib: dlopen(/private/var/folders/kv/drx4695s5p91vm8chh27scv00000gn/T/jogamp_0000/file_cache/jln3913932672952410849/jln113904259977141220/natives/macosx-universal/libgluegen-rt.jnilib, 0x0001): tried: '/private/var/folders/kv/drx4695s5p91vm8chh27scv00000gn/T/jogamp_0000/file_cache/jln3913932672952410849/jln113904259977141220/natives/macosx-universal/libgluegen-rt.jnilib' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64e')), '/usr/lib/libgluegen-rt.jnilib' (no such file)

I tried solving the issue by excluding the jogl dependency with the error and using the in [4] discussed dependency. But this only resulted in this runtime error:

`java.lang.UnsatisfiedLinkError: Can't load library: /Users/.../ProcessingProject/natives/macosx-universal//gluegen-rt`

If you have any ideas let me know.

Resources:

(Links coming soon because new users can only have 2 links in a post. So just google it if you are interested :))

[1] Writing Processing in Kotlin
[2] How To Write Processing Code In Kotlin
[3] Using P2D and P3D Renderers In Kotlin Processing Sketches
[4] JOGL for Mac ARM Silicon (make sure to read page 2. The forum is pretty ugly)

2 Likes

Hey there I’m also running into this rendering error with P3D sadly (I am using a fresh version of Processing: 4b6c, and OpenJDK 17.0.2). Recently attempted to convert all my sketches from old pde files to Kotlin. They all work except the few using P3D (the rest use the default Java PGraphics 2D renderer, P2D fails similarly).

However, those sketches still work inside the Processing’s IDE using P2D/P3D but not using Kotlin/Gradle. I feel like there is a solution close by if the Processing IDE runs OpenGL renderers fine.

Curious if anyone else has also found a solution. I really want to continue using Processing in the Kotlin/JVM ecosystem, and continue building on some older sketches. It has truly made me that much more productive on medium to larger projects.

We have a project called libp5x, that is a modularized version of Processing 3.5.3 (will update to 4 soon) and uses LWJGL for rendering. It’s what is used in PraxisLIVE. There are some example projects using Gradle at GitHub - codelerity/libp5x-examples: Examples using libp5x - Java not Kotlin, but should be easy to migrate

These should also work on Mac ARM Silicon with an x86-64 JVM (11 or 17) at least (PraxisLIVE works on that). I’m working on native Mac ARM Silicon support, having just got hold of a Mac Mini for testing on.

1 Like

Thanks! Incorporating those libraries got things going. I did have to reference the jar files from LWJGL - Lightweight Java Game Library in order to get all the things working, but it is indeed working!

Great! Yes, you do need to configure LWJGL as you can see in the Gradle build scripts for each example - eg. libp5x-examples/build.gradle at main · codelerity/libp5x-examples · GitHub And also note the default JVM arguments, which are most important if you want to support macOS.