- Joined
- Jan 2, 2020
- Messages
- 1,414
I'm learning OO and 3d graphics but before continouning with that I want to go through with seeing if I can make an experiment I said I would try with readpixels because it seems doable actually. I know it's old GLES2.0 but I won't try too hard. And if I need to make too much changes in the sourcecode that might induce problems then I guess I will just quit trying.
Do you have a preference about what option to plump for in Cerberus?
Pseudo/C++ code :
Do you have a preference about what option to plump for in Cerberus?
Pseudo/C++ code :
Code:
' Improves GLES 2.0 readpixels from 100ms to 5ms on Android
' INIT
EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, ' any valid display
EGLContext ctx, ' EGL_NO_CONTEXT
EGLenum target, ' EGL_NATIVE_BUFFER_ANDROID
EGLClientBuffer buffer, ' ANativeWindowBuffer
const EGLint *attrib_list)
' Allocate ANativeWindowBuffer using the wrapper Graphicbuffer
GraphicBuffer *window = new GraphicBuffer(width, height, PIXEL_FORMAT_RGBA_8888, GraphicBuffer::USAGE_SW_READ_OFTEN | GraphicBuffer::USAGE_HW_TEXTURE);
struct ANativeWindowBuffer *buffer = window->getNativeBuffer();
EGLImageKHR *image = eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, *attribs);
' USAGE :
' FBO OPTION 1
void EGLImageTargetTexture2DOES(enum target, eglImageOES image)
uint8_t *ptr;
glBindTexture(GL_TEXTURE_2D, texture_id);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
' FBO OPTION 2
void EGLImageTargetRenderbufferStorageOES(enum target, eglImageOES image)
window->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, &ptr);
memcpy(pixels, ptr, width * height * 4);
window->unlock();
Last edited: