@@ -5,60 +5,52 @@ Render OpenGL content onto a Compose Canvas.
55## Supported platforms
66
77- JVM + Linux
8-
9- ## Dependencies
10-
11- This library works with the default skiko and skia builds,
12- but also supports a custom skiko+skia build using EGL and GLES instead of GLX and Desktop GL on Linux:
13-
14- - Skiko: https://github.com/silenium-dev/skiko
15- - Skia: https://github.com/silenium-dev/skia-pack
8+ - JVM + Windows
169
1710## Usage
1811
1912You can add the dependency to your project as follows:
2013
2114``` kotlin
2215repositories {
23- maven(" https://reposilite .silenium.dev/releases" ) {
24- name = " silenium-releases"
16+ maven(" https://repo .silenium.dev/releases" ) {
17+ name = " silenium-dev- releases"
2518 }
2619}
2720dependencies {
28- implementation(" dev.silenium.compose.gl:compose-gl:0.6.0 " )
21+ implementation(" dev.silenium.compose.gl:compose-gl:0.7.4 " )
2922}
3023```
3124
25+ ### Development Snapshots
26+
27+ Snapshots are available from [ silenium-dev-snapshots] ( https://repo.silenium.dev/snapshots ) .
28+ Versions don't follow semantic versioning, but are based on the commit hash: ` <short-sha>-dev ` (e.g. ` c6d653e-dev ` )
29+
3230### Example
3331
32+ This is a simple example of how to use the library.
33+ For a more complex example, see [ src/test/kotlin/direct/Main.kt] ( src/test/kotlin/direct/Main.kt ) .
34+
3435``` kotlin
3536@Composable
3637fun App () {
37- Box (contentAlignment = Alignment .TopStart ) {
38- // Button behind the GLSurfaceView -> Alpha works, clicks will be passed through, as long as the GLSurfaceView is not clickable
38+ Box (modifier = Modifier .fillMaxSize(), contentAlignment = Alignment .TopStart ) {
39+ // Button behind the GLCanvas -> Alpha works. Clicks will be passed through, as long as the GLCanvas is not clickable
3940 Button (onClick = {}) {
4041 Text (" Click me!" )
4142 }
42- // Size needs to be specified, as the default size is 0x0
43+ // Size needs to be specified, as the default size of a Compose Canvas is 0x0
4344 // Internally uses a Compose Canvas, so it can be used like any other Composable
44- GLSurfaceView (
45- modifier = Modifier .size(100 .dp),
46- presentMode = GLSurfaceView .PresentMode .MAILBOX , // Present mode is based on the Vulkan present modes
47- swapChainSize = 2 ,
48- ) {
49- // Translucent grey
50- // Use GLES or GL, depending on the skiko variant you are using
51- GL30 .glClearColor(0.5f , 0.5f , 0.5f , 0.5f )
52- GL30 .glClear(GL_COLOR_BUFFER_BIT )
53- // Render with 30 FPS, this should be the time from start of frame n to frame n+1, the internal logic subtracts render time and other delays
54- // Defaults to 60 FPS
55- // Will be replaced with a better solution in the future
56- redrawAfter((1000.0 / 30 ).milliseconds)
45+ GLCanvas (modifier = Modifier .size(100 .dp)) {
46+ // Translucent blue
47+ // Use LWJGL GL, other GL libraries may work but are not tested
48+ GL30 .glClearColor(0f , 0f , 0.5f , 0.5f )
49+ GL30 .glClear(GL30 .GL_COLOR_BUFFER_BIT )
5750 }
5851 }
5952}
6053
61- // awaitApplication{} is required for now. For some reason, the JVM gets stuck on shutdown, when using application{}.
6254fun main () = application {
6355 Window (onCloseRequest = ::exitApplication) {
6456 App ()
0 commit comments