From 3a168b887f5015265f8a727512529c8229a388a7 Mon Sep 17 00:00:00 2001 From: zani Date: Fri, 18 Oct 2024 16:54:13 -0600 Subject: [PATCH] fix: allow requesting of opengl functions via GLContext --- .../src/main/kotlin/org/lwjgl/opengl/GLContext.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/lwjgl/src/main/kotlin/org/lwjgl/opengl/GLContext.kt b/modules/lwjgl/src/main/kotlin/org/lwjgl/opengl/GLContext.kt index d7952db..bf7450c 100644 --- a/modules/lwjgl/src/main/kotlin/org/lwjgl/opengl/GLContext.kt +++ b/modules/lwjgl/src/main/kotlin/org/lwjgl/opengl/GLContext.kt @@ -1,12 +1,18 @@ package org.lwjgl.opengl +import kotlin.concurrent.getOrSet + object GLContext { - private val capabilities = mutableMapOf() + private val capabilities = ThreadLocal() @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 }