https://github.com/husker-dev/grapl
Java\Kotlin tool for managing OpenGL contexts and windows
https://github.com/husker-dev/grapl
Last synced: 3 months ago
JSON representation
Java\Kotlin tool for managing OpenGL contexts and windows
- Host: GitHub
- URL: https://github.com/husker-dev/grapl
- Owner: husker-dev
- License: apache-2.0
- Created: 2022-05-29T13:36:52.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2026-01-10T11:30:56.000Z (4 months ago)
- Last Synced: 2026-01-11T03:34:25.348Z (4 months ago)
- Language: Kotlin
- Homepage:
- Size: 1.09 MB
- Stars: 8
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# About
Java\Kotlin tool for managing OpenGL contexts and windows.
- [Dependency](#dependency)
- [Usage](#usage)
- [Contexts](#contexts)
- [Windows](#windows)
# Dependency
```groovy
dependencies {
implementation 'com.huskerdev:grapl-gl:2.3.14'
}
```
Available modules:
- ```grapl``` - core library
- grapl-native-core-win
- grapl-native-core-macos
- grapl-native-core-linux
- ```grapl-gl``` - OpenGL module
- grapl-native-gl-win
- grapl-native-gl-macos
- grapl-native-gl-linux
- ```grapl-ext-display``` - Display extension
# Usage
Grapl can oparate OpenGL contexts separatly from window
## Contexts
- ```kotlin
val context = GLContext.create(..)
```
Creates new opengl context with requesterd parameters (doesn't make current)
- ```shareWith``` - Shared context handle
- ***type***: GLContext/Long
- **default**: 0L
- ```coreProfile``` - Core/Compatibility profile
- ***type***: GLProfile
- **default**: GLProfile.CORE
- ```majorVersion``` - Requested major version
- ***type***: Int
- **default**: -1
- ```minorVersion``` - Requested minor version
- ***type***: Int
- **default**: -1
- ```kotlin
context.makeCurrent()
```
Makes context current in running thread
- ```kotlin
context.delete()
```
Deletes context (does not require to be current)
## Windows
Example usage:
```kotlin
GLWindow().apply {
title = "My application"
size = 100 x 100
alignToCenter()
eventConsumer = windowEventConsumer {
onInit {
swapInterval = 1
GL.createCapabilities()
glClearColor(1f, 0f, 1f, 1f)
}
onUpdate {
glClear(GL_COLOR_BUFFER_BIT)
swapBuffers()
}
}
keyTypedListeners += { e ->
println("key typed: ${e.key.char}")
}
visible = true
}
```
To take control of window event handling:
```kotlin
// Disable built-in message handling
BackgroundMessageHandler.useHandler = false
val window = GLWindow().apply {
size = 100 x 100
alignToCenter()
visible = true
}
// Handle events
while(!window.shouldClose)
Window.waitMessages() // or peekMessages
```