diff --git a/modules/core/src/main/java/org/lwjgl/opengl/GL.java b/modules/core/src/main/java/org/lwjgl/opengl/GL.java index d17c3e2b13..bb200f29fd 100644 --- a/modules/core/src/main/java/org/lwjgl/opengl/GL.java +++ b/modules/core/src/main/java/org/lwjgl/opengl/GL.java @@ -141,18 +141,19 @@ long getExtensionAddress(long name) { break; case LINUX: functionProvider = new FunctionProviderGL() { - private final long glXGetProcAddress = OPENGL.getFunctionAddress("glXGetProcAddress"); - private final long glXGetProcAddressARB = OPENGL.getFunctionAddress("glXGetProcAddressARB"); + private final long glXGetProcAddress; - @Override - long getExtensionAddress(long name) { - if ( glXGetProcAddress != NULL ) - return callPP(glXGetProcAddress, name); + { + long GetProcAddress = OPENGL.getFunctionAddress("glXGetProcAddress"); + if ( GetProcAddress == NULL ) + GetProcAddress = OPENGL.getFunctionAddress("glXGetProcAddressARB"); - if ( glXGetProcAddressARB != NULL ) - return callPP(glXGetProcAddressARB, name); + glXGetProcAddress = GetProcAddress; + } - return NULL; + @Override + long getExtensionAddress(long name) { + return glXGetProcAddress == NULL ? NULL : callPP(glXGetProcAddress, name); } }; break; diff --git a/modules/core/src/test/java/org/lwjgl/demo/system/jawt/LWJGLCanvas.java b/modules/core/src/test/java/org/lwjgl/demo/system/jawt/LWJGLCanvas.java index 5db6cb90a7..74cbd01a5f 100644 --- a/modules/core/src/test/java/org/lwjgl/demo/system/jawt/LWJGLCanvas.java +++ b/modules/core/src/test/java/org/lwjgl/demo/system/jawt/LWJGLCanvas.java @@ -15,7 +15,6 @@ import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.WGL.*; -import static org.lwjgl.system.JNI.*; import static org.lwjgl.system.MemoryUtil.*; import static org.lwjgl.system.jawt.JAWTFunctions.*; import static org.lwjgl.system.windows.GDI32.*; @@ -76,7 +75,7 @@ public void paint(Graphics g) { createContext(dsi_win); gears.initGLState(); } else { - if ( callPPI(caps.wglMakeCurrent, hdc, hglrc) == 0 ) + if ( wglMakeCurrent(hdc, hglrc) == 0 ) throw new IllegalStateException("wglMakeCurrent() failed"); GL.setCapabilities(caps); @@ -134,12 +133,12 @@ private void createContext(JAWTWin32DrawingSurfaceInfo dsi_win) { throw new IllegalStateException("SetPixelFormat() failed: " + WinBase.getLastError()); } - hglrc = callPP(caps.wglCreateContext, hdc); + hglrc = wglCreateContext(hdc); if ( hglrc == NULL ) throw new IllegalStateException("wglCreateContext() failed"); - if ( callPPI(caps.wglMakeCurrent, hdc, hglrc) == 0 ) + if ( wglMakeCurrent(hdc, hglrc) == 0 ) throw new IllegalStateException("wglMakeCurrent() failed"); caps = GL.createCapabilities(); @@ -152,7 +151,7 @@ public void destroy() { awt.free(); if ( hglrc != NULL ) - callPI(caps.wglDeleteContext, hglrc); + wglDeleteContext(hglrc); } } \ No newline at end of file diff --git a/modules/templates/src/main/kotlin/org/lwjgl/opengl/GLBinding.kt b/modules/templates/src/main/kotlin/org/lwjgl/opengl/GLBinding.kt index 6dab213652..5f077caab2 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/opengl/GLBinding.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/opengl/GLBinding.kt @@ -210,7 +210,6 @@ val GLBinding = Generator.register(object : APIBinding(OPENGL_PACKAGE, CAPABILIT fun String.nativeClassGL( templateName: String, - nativeSubPath: String = "", prefix: String = "GL", prefixMethod: String = prefix.toLowerCase(), postfix: String = "", @@ -218,7 +217,6 @@ fun String.nativeClassGL( ) = nativeClass( OPENGL_PACKAGE, templateName, - nativeSubPath = nativeSubPath, prefix = prefix, prefixMethod = prefixMethod, postfix = postfix, @@ -227,10 +225,10 @@ fun String.nativeClassGL( ) fun String.nativeClassWGL(templateName: String, postfix: String = "", init: (NativeClass.() -> Unit)? = null) = - nativeClassGL(templateName, "wgl", "WGL", postfix = postfix, init = init) + nativeClassGL(templateName, "WGL", postfix = postfix, init = init) fun String.nativeClassGLX(templateName: String, postfix: String = "", init: (NativeClass.() -> Unit)? = null) = - nativeClassGL(templateName, "glx", "GLX", "glX", postfix, init) + nativeClassGL(templateName, "GLX", "glX", postfix, init) private val REGISTRY_PATTERN = Pattern.compile("([A-Z]+)_(\\w+)") val NativeClass.registryLink: String get() { diff --git a/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/CGL.kt b/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/CGL.kt index 92af148c69..6e5113c124 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/CGL.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/CGL.kt @@ -8,7 +8,13 @@ import org.lwjgl.generator.* import org.lwjgl.opengl.* import org.lwjgl.system.macosx.* -val CGL = "CGL".nativeClass(OPENGL_PACKAGE, prefix = "CGL", prefixMethod = "CGL", prefixConstant = "kCGL", binding = GLBinding) { +val CGL = "CGL".nativeClass( + OPENGL_PACKAGE, + prefix = "CGL", + prefixConstant = "kCGL", + prefixMethod = "CGL", + binding = GLBinding.delegate("GL.getFunctionProvider()") +) { documentation = "Native bindings to CGL." // ----------------------------------------------- diff --git a/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/GLX.kt b/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/GLX.kt index 72e22de4ba..4cbf174db0 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/GLX.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/GLX.kt @@ -8,7 +8,7 @@ import org.lwjgl.generator.* import org.lwjgl.opengl.* import org.lwjgl.system.linux.* -val GLX = "GLX".nativeClassGLX("GLX") { +val GLX = "GLX".nativeClass(OPENGL_PACKAGE, prefix = "GLX", prefixMethod = "glX", binding = GLBinding.delegate("GL.getFunctionProvider()")) { javaImport( "org.lwjgl.system.linux.*" ) diff --git a/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/WGL.kt b/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/WGL.kt index 0b5656b110..ba8cdf2a72 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/WGL.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/WGL.kt @@ -8,7 +8,7 @@ import org.lwjgl.generator.* import org.lwjgl.opengl.* import org.lwjgl.system.windows.* -val WGL = "WGL".nativeClassWGL("WGL") { +val WGL = "WGL".nativeClass(OPENGL_PACKAGE, prefix = "WGL", binding = GLBinding.delegate("GL.getFunctionProvider()")) { javaImport( "org.lwjgl.system.windows.*" ) diff --git a/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/WGL_AMD_gpu_association.kt b/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/WGL_AMD_gpu_association.kt index 2499977780..cb662b271d 100644 --- a/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/WGL_AMD_gpu_association.kt +++ b/modules/templates/src/main/kotlin/org/lwjgl/opengl/templates/WGL_AMD_gpu_association.kt @@ -6,7 +6,6 @@ package org.lwjgl.opengl.templates import org.lwjgl.generator.* import org.lwjgl.opengl.* -import org.lwjgl.opengl.BufferType.* import org.lwjgl.system.windows.* val WGL_AMD_gpu_association = "WGLAMDGPUAssociation".nativeClassWGL("WGL_AMD_gpu_association", AMD) {