我在参考如何提高 android 中的 opengl es 显示性能的问题的答案来问这个问题。我试图构建使用带有 ndk-r9d 的 GraphicBuffer 的代码。但它是说 GraphicBuffer 没有在这个范围内声明。eglCreateImageKHR 和 glEGLImageTargetTexture2DOES 的注释相同。
我添加了 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);
我该怎么做才能让它运行......
提前致谢..