diff --git a/VERSION b/VERSION index 75274d8..1f77169 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.12 +0.4.13 diff --git a/example/lwjgl3-opengl/src/main/java/com/labymedia/ultralight/lwjgl3/opengl/ExampleMain.java b/example/lwjgl3-opengl/src/main/java/com/labymedia/ultralight/lwjgl3/opengl/ExampleMain.java index 572c80e..a4af9df 100644 --- a/example/lwjgl3-opengl/src/main/java/com/labymedia/ultralight/lwjgl3/opengl/ExampleMain.java +++ b/example/lwjgl3-opengl/src/main/java/com/labymedia/ultralight/lwjgl3/opengl/ExampleMain.java @@ -64,8 +64,10 @@ public static void main(String[] args) throws UltralightLoadException { // Load the native libraries from the given directory. This method makes sure everything is loaded in the // correct order. If you want to manually load all natives, either don't use this function or pass 'false' as // the second parameter. - UltralightGPUDriverNativeUtil.load(nativesDir); - UltralightJava.load(nativesDir); + // Note that this order matters, as the libraries needed for the GPU Driver in the Ultralight SDK + // need to be loaded before the GPU driver. + UltralightJava.load(nativesDir); + UltralightGPUDriverNativeUtil.load(nativesDir); // Create and run a simple test application ExampleApplication application = new ExampleApplication(); diff --git a/ultralight-java-base/src/main/java/com/labymedia/ultralight/plugin/render/UltralightGPUDriverNative.java b/ultralight-java-base/src/main/java/com/labymedia/ultralight/plugin/render/UltralightGPUDriverNative.java index d793132..3c2750b 100644 --- a/ultralight-java-base/src/main/java/com/labymedia/ultralight/plugin/render/UltralightGPUDriverNative.java +++ b/ultralight-java-base/src/main/java/com/labymedia/ultralight/plugin/render/UltralightGPUDriverNative.java @@ -33,5 +33,7 @@ public interface UltralightGPUDriverNative { void bindTexture(long textureId, long texture); + int getGlTextureId(long texture); + void setActiveWindow(long window); } diff --git a/ultralight-java-gpu-native/include/ultralight_java/gpudriver/com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil.h b/ultralight-java-gpu-native/include/ultralight_java/gpudriver/com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil.h index dd2a11a..eadc518 100644 --- a/ultralight-java-gpu-native/include/ultralight_java/gpudriver/com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil.h +++ b/ultralight-java-gpu-native/include/ultralight_java/gpudriver/com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil.h @@ -79,6 +79,14 @@ JNIEXPORT void JNICALL Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNati JNIEXPORT void JNICALL Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil_bindTexture( JNIEnv *, jobject, jlong handle, jlong textureId, jlong texture); +/* + * Class: com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil + * Method: getGlTextureId + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil_getGlTextureId(JNIEnv *, jobject, jlong handle, jlong texture); + # ifdef __cplusplus } # endif diff --git a/ultralight-java-gpu-native/include/ultralight_java/gpudriver/gl/GPUDriverGL.h b/ultralight-java-gpu-native/include/ultralight_java/gpudriver/gl/GPUDriverGL.h index 88e4029..7df200f 100644 --- a/ultralight-java-gpu-native/include/ultralight_java/gpudriver/gl/GPUDriverGL.h +++ b/ultralight-java-gpu-native/include/ultralight_java/gpudriver/gl/GPUDriverGL.h @@ -99,6 +99,7 @@ namespace ultralight { virtual void DrawCommandList() override; void BindUltralightTexture(uint32_t ultralight_texture_id); + uint32_t GetGlTextureId(uint32_t ultralight_texture_id); void LoadPrograms(); void DestroyPrograms(); diff --git a/ultralight-java-gpu-native/src/gpudriver/gl/GPUDriverGL.cpp b/ultralight-java-gpu-native/src/gpudriver/gl/GPUDriverGL.cpp index d374138..2fa7804 100644 --- a/ultralight-java-gpu-native/src/gpudriver/gl/GPUDriverGL.cpp +++ b/ultralight-java-gpu-native/src/gpudriver/gl/GPUDriverGL.cpp @@ -320,6 +320,12 @@ namespace ultralight { CHECK_GL(); } + uint32_t GPUDriverGL::GetGlTextureId(uint32_t ultralight_texture_id) { + TextureEntry &entry = texture_map[ultralight_texture_id]; + ResolveIfNeeded(entry.render_buffer_id); + return entry.tex_id; + } + void GPUDriverGL::DestroyTexture(uint32_t texture_id) { TextureEntry &entry = texture_map[texture_id]; glDeleteTextures(1, &entry.tex_id); diff --git a/ultralight-java-gpu-native/src/gpudriver/ultralight_java_gpu.cpp b/ultralight-java-gpu-native/src/gpudriver/ultralight_java_gpu.cpp index b08fabe..d7c18cf 100644 --- a/ultralight-java-gpu-native/src/gpudriver/ultralight_java_gpu.cpp +++ b/ultralight-java-gpu-native/src/gpudriver/ultralight_java_gpu.cpp @@ -91,3 +91,8 @@ JNIEXPORT void JNICALL Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNati auto *driver = (ultralight::GPUDriverGL *) handle; driver->BindTexture(textureId, texture); } + +JNIEXPORT jint JNICALL Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil_getGlTextureId (JNIEnv *, jobject, jlong handle, jlong texture) { + auto *driver = (ultralight::GPUDriverGL *) handle; + return (jint) driver->GetGlTextureId(texture); +} diff --git a/ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightGPUDriverNativeUtil.java b/ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightGPUDriverNativeUtil.java index 79c9550..5eaefda 100644 --- a/ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightGPUDriverNativeUtil.java +++ b/ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightGPUDriverNativeUtil.java @@ -210,6 +210,16 @@ public static UltralightGPUDriverNativeUtil getInstance() { */ public native void bindTexture(long handle, long textureId, long texture); + /** + * Get the OpenGL texture id for a given driver-specific texture index. + * + * @param handle OpenGL context handle + * @param texture Ultralight renderTarget texture id + * + * @return OpenGL texture id + */ + public native int getGlTextureId(long handle, long texture); + /** * Set which GLFW context should be active. * diff --git a/ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightOpenGLGPUDriverNative.java b/ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightOpenGLGPUDriverNative.java index 679beda..57440d6 100644 --- a/ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightOpenGLGPUDriverNative.java +++ b/ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightOpenGLGPUDriverNative.java @@ -94,6 +94,11 @@ public void bindTexture(long textureId, long texture) { this.util.bindTexture(this.driverHandle, textureId, texture); } + @Override + public int getGlTextureId(long texture) { + return this.util.getGlTextureId(this.driverHandle, texture); + } + /** * Set which GLFW context should be active. *