-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow requesting of opengl functions via GLContext
- Loading branch information
Showing
1 changed file
with
8 additions
and
2 deletions.
There are no files selected for viewing
10 changes: 8 additions & 2 deletions
10
modules/lwjgl/src/main/kotlin/org/lwjgl/opengl/GLContext.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
package org.lwjgl.opengl | ||
|
||
import kotlin.concurrent.getOrSet | ||
|
||
object GLContext { | ||
private val capabilities = mutableMapOf<Thread, ContextCapabilities>() | ||
private val capabilities = ThreadLocal<ContextCapabilities>() | ||
|
||
@JvmStatic | ||
fun getCapabilities(): ContextCapabilities { | ||
return capabilities.computeIfAbsent(Thread.currentThread()) { thread -> | ||
return capabilities.getOrSet { | ||
ContextCapabilities() | ||
} | ||
} | ||
|
||
@JvmStatic | ||
fun getFunctionAddress(function: String): Long = | ||
GL.getFunctionProvider()?.getFunctionAddress(function) ?: 0 | ||
} |