eglCreateImageKHR on Raspberry Pi
Posted by strator on Aug 02, 2013; 1:40pm
URL: https://forum.jogamp.org/eglCreateImageKHR-on-Raspberry-Pi-tp4029712.html
I'm currently working to implement some off-screen image processing using shaders with the help of JogAmp and
framebufffer objects.
This works great the the performance and the memory consumption of Java on the RPi is impressive.
Since I need the processed data back in the CPU I used glReadPixels for the transfer.
However, it turned out that glReadPixes is really slow (no surprise) and so I looked for other approaches
for the transfer. I figured out that eglCreateImageKHR could be a solution for my problem (correct me, if I'm wrong).
I tried now for several days to get eglCreateImageKHR to work but wasn't successfull. All I get is EGL_BAD_PARAMETER
no matter what configuration I use.
Here is a stripped down version of my code:
ByteBuffer bb = ByteBuffer.allocateDirect(640*480*3);
IntBuffer ib = Buffers.newDirectIntBuffer(1);
gl.glGenTextures(1, ib);
gl.glBindTexture(GL_TEXTURE_2D, ib.get(0));
System.out.println("texture id: " + ib.get(0));
gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 640, 480, 0, GL_RGB, GL_UNSIGNED_BYTE, null);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gl.glGenerateMipmap(GL_TEXTURE_2D);
gl.glBindTexture(GL_TEXTURE_2D, 0);
IntBuffer attribList = Buffers.newDirectIntBuffer(new int[] {
EGLExt.EGL_MATCH_FORMAT_KHR, EGLExt.EGL_FORMAT_RGBA_8888_KHR,
EGLExt.EGL_GL_TEXTURE_LEVEL_KHR, 0,
EGLExt.EGL_IMAGE_PRESERVED_KHR, EGL.EGL_TRUE,
EGL.EGL_TEXTURE_FORMAT, EGL.EGL_TEXTURE_RGB,
EGL.EGL_TEXTURE_TARGET, EGL.EGL_TEXTURE_2D,
EGL.EGL_NONE
});
long eglImage = eglExt.eglCreateImageKHR(display, context.getHandle(), EGLExt.EGL_GL_TEXTURE_2D_KHR, ib.get(0), attribList);
System.out.println("got EGLimage: " + (eglImage));
gl.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage);
Everythink works fine until I try to create the EGLImage. I have tried all possible configuration and attributes but
could not figure out the problem.
Any help would be greatly appreciated!
Torsten