小编Nox*_*lus的帖子

无法将 Android WebView 渲染为 C++ 和 Java 代码之间共享的外部纹理

我目前正在尝试将 Android WebView 内容渲染为可在使用 JNI 和 NDK 的 C++ 应用程序中使用的纹理。我不明白为什么它不能按我的预期工作。

我在网上阅读了很多文档,以下是我现在所拥有的:

C++ 方面

// Create the texture
uint texture;
glGenTextures(1, &texture);

// Bind the texture with the proper external texture target
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture);

// Create the EGLImage object that maps the GraphicBuffer
int usage = GraphicBuffer::USAGE_HW_TEXTURE | GraphicBuffer::USAGE_SW_READ_OFTEN | GraphicBuffer::USAGE_SW_WRITE_OFTEN;
auto gralloc = new GraphicBuffer(width, height, PIXEL_FORMAT_RGBA_8888, usage);
EGLClientBuffer clientBuffer = (EGLClientBuffer) gralloc->getNativeBuffer();

EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
EGLint attrs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE };

auto eglImage = eglCreateImageKHR(display, …
Run Code Online (Sandbox Code Playgroud)

c++ java android webview android-ndk

2
推荐指数
1
解决办法
2576
查看次数

标签 统计

android ×1

android-ndk ×1

c++ ×1

java ×1

webview ×1