### GLCanvas Initialization Events Source: https://github.com/husker-dev/openglfx/blob/master/README.md Set up event handlers for initialization, rendering, reshaping, and disposal of the GLCanvas. These events allow for one-time setup, per-frame rendering, viewport adjustments, and cleanup. ```kotlin canvas.addOnInitEvent { event -> // Init some gl properties only once } canvas.addOnRenderEvent { event -> // Render some content every frame } canvas.addOnReshapeEvent { event -> // Change viewport matrices at resizing } canvas.addOnDisposeEvent { event -> // Clear native data at disposing } ``` -------------------------------- ### LibGDX Integration with openglfx Source: https://github.com/husker-dev/openglfx/blob/master/README.md Example `build.gradle` configuration for integrating openglfx with a LibGDX project. It shows dependency setup for the openglfx-libgdx module. ```groovy plugins { id("org.jetbrains.kotlin.jvm") } sourceSets.main.resources.srcDirs += [ rootProject.file('assets').path ] dependencies { implementation project(':core') implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" // openglfx api("com.huskerdev:openglfx-libgdx:4.2.2") // implementation(/* JavaFX */) // implementation(/* LWJGL */) } ``` -------------------------------- ### Set OpenGL Pipeline via Launch Parameter Source: https://github.com/husker-dev/openglfx/wiki/About-JavaFX-pipelines Specify the OpenGL rendering pipeline using a Java Virtual Machine (JVM) launch parameter. ```shell -Dprism.order=es2 ``` -------------------------------- ### Set Multiple Pipelines via System Property Source: https://github.com/husker-dev/openglfx/wiki/About-JavaFX-pipelines Configure JavaFX to try multiple rendering pipelines (OpenGL, DirectX, Software) in a specified order. ```java System.setProperty("prism.order", "es2,d3d,sw"); ``` -------------------------------- ### Initialize GLCanvas with LWJGL Module Source: https://github.com/husker-dev/openglfx/blob/master/README.md Initializes a GLCanvas component using the LWJGL module. Ensure the LWJGL module is available. ```kotlin import com.huskerdev.openglfx.canvas.GLCanvas import com.huskerdev.openglfx.lwjgl.LWJGLExecutor.Companion.LWJGL_MODULE val canvas = GLCanvas(LWJGL_MODULE) ``` -------------------------------- ### Texture Sharing on Windows (ES2 Pipeline) Source: https://github.com/husker-dev/openglfx/blob/master/README.md Uses EXT_external_objects_win32 to create a shared texture chain (OpenGL ⟷ Vulkan ⟷ OpenGL) on Windows for the ES2 pipeline. ```kotlin ExternalObjectsCanvasES2.Win.kt ``` -------------------------------- ### Create GLCanvas with a Custom Executor Source: https://github.com/husker-dev/openglfx/blob/master/README.md To integrate a new OpenGL library, implement the GLExecutor interface and provide your custom instance to GLCanvas.create(). ```kotlin GLCanvas.create(YOUR_EXECUTOR_INSTANCE) ``` -------------------------------- ### Texture Sharing on Windows with WGL NV DX Interop Source: https://github.com/husker-dev/openglfx/blob/master/README.md Employs NV_DX_interop for synchronizing textures between DirectX 9 and OpenGL on Windows. ```kotlin WGLDXInteropCanvas.kt ``` -------------------------------- ### Texture Sharing on Windows with D3D Source: https://github.com/husker-dev/openglfx/blob/master/README.md Utilizes EXT_external_objects_win32 for shared DXGI textures between DirectX 9 and OpenGL on Windows. ```kotlin ExternalObjectsCanvasD3D.kt ``` -------------------------------- ### Texture Sharing on Linux (ES2 Pipeline) Source: https://github.com/husker-dev/openglfx/blob/master/README.md Leverages EXT_external_objects_fd for creating a shared texture chain (OpenGL ⟷ Vulkan ⟷ OpenGL) on Linux. ```kotlin ExternalObjectsCanvasES2.Linux.kt ``` -------------------------------- ### Texture Sharing on macOS with IOSurface Source: https://github.com/husker-dev/openglfx/blob/master/README.md Utilizes IOSurface to create a VRAM memory block accessible by different OpenGL contexts on macOS. ```kotlin IOSurfaceCanvas.kt ``` -------------------------------- ### Configure GLCanvas for RenderDoc/NSight Integration Source: https://github.com/husker-dev/openglfx/blob/master/README.md Set `externalWindow` to `true` in the GLCanvas constructor to enable integration with debugging tools like RenderDoc and NSight. This creates a separate window for the rendered image. ```kotlin GLCanvas(externalWindow = true) ``` -------------------------------- ### Configure Swap Buffers for GLCanvas Source: https://github.com/husker-dev/openglfx/blob/master/README.md Adjust the swap buffer setting to control UI performance and responsiveness to resizing. A value of 2 is default for performance, while 1 offers better responsiveness. ```kotlin GLCanvas(.., swapBuffers = 1) ``` -------------------------------- ### Initialize LibGDXCanvas for LibGDX Projects Source: https://github.com/husker-dev/openglfx/blob/master/README.md Use LibGDXCanvas instead of GLCanvas when integrating openglfx within a LibGDX project. Pass your main ApplicationAdapter class to the constructor. ```kotlin val canvas = LibGDXCanvas(Main()) // Main is ApplicationAdapter ``` -------------------------------- ### Set OpenGL Pipeline via System Property Source: https://github.com/husker-dev/openglfx/wiki/About-JavaFX-pipelines Use this system property to explicitly set the OpenGL (es2) rendering pipeline for JavaFX. ```java System.setProperty("prism.order", "es2"); ``` -------------------------------- ### Modify build.gradle for OpenGL Source: https://github.com/husker-dev/openglfx/wiki/How-to-enable-OpenGL-pipeline-on-Windows Change the INCLUDE_ES2 property in the build.gradle file to 'true' to enable OpenGL rendering on Windows. This is part of compiling OpenJFX sources. ```Groovy defineProperty("INCLUDE_ES2", IS_WINDOWS ? "false" : "true") ``` ```Groovy defineProperty("INCLUDE_ES2", "true") ``` -------------------------------- ### JVM Arguments for JPMS Exports Source: https://github.com/husker-dev/openglfx/blob/master/README.md Add these JVM arguments if you encounter issues with package access when using JPMS and openglfx. ```java -Dopenglfx.disable.exports=true --add-exports=javafx.graphics/com.sun.prism=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.javafx.scene.layout=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.scenario=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED --add-exports=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED ``` -------------------------------- ### Enable Antialiasing (MSAA) in GLCanvas Source: https://github.com/husker-dev/openglfx/blob/master/README.md Configure multi-sampling anti-aliasing for the GLCanvas. Specify the desired sample count, or -1 for the maximum possible level. ```kotlin GLCanvas(.., msaa = 4) ``` -------------------------------- ### Specify OpenGL Profile in GLCanvas Source: https://github.com/husker-dev/openglfx/blob/master/README.md Set the desired OpenGL profile, such as Core or Compatibility, during GLCanvas initialization. The Core profile is generally recommended. ```kotlin GLCanvas(.., profile = GLProfile.CORE) GLCanvas(.., profile = GLProfile.COMPATIBILITY) ``` -------------------------------- ### Control FPS in GLCanvas Source: https://github.com/husker-dev/openglfx/blob/master/README.md Set the desired frames per second (FPS) for content updates using the 'fps' property. A negative value uses the monitor's refresh rate, 0 disables automatic updates, and a positive value sets a specific FPS. ```kotlin // In constructor val canvas = GLCanvas(..., fps = 30) // Or at runtime canvas.fps = 40 ``` -------------------------------- ### Add OpenGLFX LWJGL Dependency Source: https://github.com/husker-dev/openglfx/blob/master/README.md Include this dependency in your Gradle build file to use the LWJGL backend for OpenGLFX. ```groovy dependencies { // implementation JavaFX // implementation LWJGL // implementation ... implementation 'com.huskerdev:openglfx-lwjgl:4.2.3' } ``` -------------------------------- ### Texture Sharing via ByteBuffer Copy Source: https://github.com/husker-dev/openglfx/blob/master/README.md As a fallback for other platforms, this method copies data from glReadPixels ByteBuffer to a JavaFX texture. ```kotlin BlitCanvas.kt ``` -------------------------------- ### Enable Y-Flipping for OpenGL Output Source: https://github.com/husker-dev/openglfx/blob/master/README.md Enable Y-flipping in GLCanvas to correct the default upside-down orientation of OpenGL rendering without performance loss. ```kotlin GLCanvas(.., flipY = true) ``` -------------------------------- ### Transfer Images Between JavaFX and OpenGL Source: https://github.com/husker-dev/openglfx/blob/master/README.md Utilize GLImageManager to convert JavaFX Images to OpenGL textures and vice versa. This facilitates data transfer between the two rendering systems. ```kotlin val fbo = GLImageManager.toGL(image) val image = GLImageManager.fromGL(fbo, width, height) ``` -------------------------------- ### Disable VSync for Higher FPS Source: https://github.com/husker-dev/openglfx/blob/master/README.md Disable VSync before JavaFX initialization to potentially achieve FPS rates higher than the monitor's refresh rate. ```kotlin System.setProperty("prism.vsync", "false") ``` -------------------------------- ### JPMS Module Declaration Source: https://github.com/husker-dev/openglfx/blob/master/README.md Declare the openglfx.lwjgl module in your module-info.java file if you are using JPMS (Java 9+ modules). ```java requires openglfx.lwjgl; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.