Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

Commit f1da8c1

Browse files
authored
Merge pull request #74 from UpcraftLP/develop
expose GL texure id
2 parents 243daa2 + 318b851 commit f1da8c1

File tree

7 files changed

+37
-0
lines changed

7 files changed

+37
-0
lines changed

ultralight-java-base/src/main/java/com/labymedia/ultralight/plugin/render/UltralightGPUDriverNative.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ public interface UltralightGPUDriverNative {
3333

3434
void bindTexture(long textureId, long texture);
3535

36+
int getGlTextureId(long texture);
37+
3638
void setActiveWindow(long window);
3739
}

ultralight-java-gpu-native/include/ultralight_java/gpudriver/com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ JNIEXPORT void JNICALL Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNati
7979
JNIEXPORT void JNICALL Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil_bindTexture(
8080
JNIEnv *, jobject, jlong handle, jlong textureId, jlong texture);
8181

82+
/*
83+
* Class: com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil
84+
* Method: getGlTextureId
85+
* Signature: (JJ)I
86+
*/
87+
JNIEXPORT jint JNICALL
88+
Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil_getGlTextureId(JNIEnv *, jobject, jlong handle, jlong texture);
89+
8290
# ifdef __cplusplus
8391
}
8492
# endif

ultralight-java-gpu-native/include/ultralight_java/gpudriver/gl/GPUDriverGL.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ namespace ultralight {
9999
virtual void DrawCommandList() override;
100100

101101
void BindUltralightTexture(uint32_t ultralight_texture_id);
102+
uint32_t GetGlTextureId(uint32_t ultralight_texture_id);
102103

103104
void LoadPrograms();
104105
void DestroyPrograms();

ultralight-java-gpu-native/src/gpudriver/gl/GPUDriverGL.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ namespace ultralight {
320320
CHECK_GL();
321321
}
322322

323+
uint32_t GPUDriverGL::GetGlTextureId(uint32_t ultralight_texture_id) {
324+
TextureEntry &entry = texture_map[ultralight_texture_id];
325+
ResolveIfNeeded(entry.render_buffer_id);
326+
return entry.tex_id;
327+
}
328+
323329
void GPUDriverGL::DestroyTexture(uint32_t texture_id) {
324330
TextureEntry &entry = texture_map[texture_id];
325331
glDeleteTextures(1, &entry.tex_id);

ultralight-java-gpu-native/src/gpudriver/ultralight_java_gpu.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,8 @@ JNIEXPORT void JNICALL Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNati
9191
auto *driver = (ultralight::GPUDriverGL *) handle;
9292
driver->BindTexture(textureId, texture);
9393
}
94+
95+
JNIEXPORT jint JNICALL Java_com_labymedia_ultralight_gpu_UltralightGPUDriverNativeUtil_getGlTextureId (JNIEnv *, jobject, jlong handle, jlong texture) {
96+
auto *driver = (ultralight::GPUDriverGL *) handle;
97+
return (jint) driver->GetGlTextureId(texture);
98+
}

ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightGPUDriverNativeUtil.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ public static UltralightGPUDriverNativeUtil getInstance() {
210210
*/
211211
public native void bindTexture(long handle, long textureId, long texture);
212212

213+
/**
214+
* Get the OpenGL texture id for a given driver-specific texture index.
215+
*
216+
* @param handle OpenGL context handle
217+
* @param texture Ultralight renderTarget texture id
218+
*
219+
* @return OpenGL texture id
220+
*/
221+
public native int getGlTextureId(long handle, long texture);
222+
213223
/**
214224
* Set which GLFW context should be active.
215225
*

ultralight-java-gpu/src/main/java/com/labymedia/ultralight/gpu/UltralightOpenGLGPUDriverNative.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ public void bindTexture(long textureId, long texture) {
9494
this.util.bindTexture(this.driverHandle, textureId, texture);
9595
}
9696

97+
@Override
98+
public int getGlTextureId(long texture) {
99+
return this.util.getGlTextureId(this.driverHandle, texture);
100+
}
101+
97102
/**
98103
* Set which GLFW context should be active.
99104
*

0 commit comments

Comments
 (0)