【发布时间】:2014-06-09 07:28:04
【问题描述】:
我是参考How to improve opengl es display performance in android 的问题的答案来问这个问题的。我试图构建使用带有 ndk-r9d 的 GraphicBuffer 的代码。但它是说 GraphicBuffer 没有在这个范围内声明。 eglCreateImageKHR 和 glEGLImageTargetTexture2DOES 的 cmets 相同。
我添加了 EGL/eglext.h 和 GLES2/gl2ext.h 。我试图包含 ui/GraphicBuffer.h 但它没有接受它。还有头文件要加吗?
我添加了下面给出的代码以避免使用 glTexSubImage2D()。
GraphicBuffer * pGraphicBuffer = new GraphicBuffer(frame_width, frame_height, PIXEL_FORMAT_RGB_565, GraphicBuffer::USAGE_SW_WRITE_OFTEN | GraphicBuffer::USAGE_HW_TEXTURE);
// Lock the buffer to get a pointer
unsigned char * pBitmap = NULL;
pGraphicBuffer->lock(GraphicBuffer::USAGE_SW_WRITE_OFTEN,(void **)&pBitmap);
// Write 2D image to pBitmap
memcpy(pBitmap, frame_buffer, frame_width * frame_height * 3);
// Unlock to allow OpenGL ES to use it
pGraphicBuffer->unlock();
EGLClientBuffer ClientBufferAddress = pGraphicBuffer->getNativeBuffer();
EGLint SurfaceType = EGL_NATIVE_BUFFER_ANDROID;
// Make an EGL Image at the same address of the native client buffer
EGLDisplay eglDisplayHandle = eglGetDisplay(EGL_DEFAULT_DISPLAY);
// Create an EGL Image with these attributes
EGLint eglImageAttributes[] = {EGL_WIDTH, frame_width, EGL_HEIGHT, frame_height, EGL_MATCH_FORMAT_KHR, EGL_FORMAT_RGB_565_KHR, EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
EGLImageKHR eglImageHandle = eglCreateImageKHR(eglDisplayHandle, EGL_NO_CONTEXT, SurfaceType, ClientBufferAddress, eglImageAttributes);
// Create a texture and bind it to GL_TEXTURE_2D
/* EGLint TextureHandle;
glGenTextures(1, &TextureHandle);
glBindTexture(GL_TEXTURE_2D, TextureHandle);
*/
// Attach the EGL Image to the same texture
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImageHandle);
我该怎么做才能让它运行......
提前谢谢..
【问题讨论】:
-
GraphicBuffer.h 不是 NDK 的一部分。您需要从 AOSP 源中提取标头,并在了解这是一个内部 API 的情况下使用它,在不同版本之间可能会发生变化。 FWIW,stackoverflow.com/questions/21151259 可能是相关的。
-
@fadden 感谢您的回复.. 我已经问过这个问题来加快我的视频帧显示速度,就像我在stackoverflow.com/questions/23131472/… 的问题一样。除了graphicBuffer,你还有其他解决方案吗?以及如何从 AOSP 源中提取标头
-
@fadden 如何从 AOSP 源中提取标头
-
@Gorilla.Maguila 你能给我一个建议吗..
标签: android opengl-es android-ndk egl