/** * Reads pixels using dual buffers. This function sends the reading request to GPU and returns the * result from the previous call. Thus, the first call always returns null. The pixelBuffer member * in the returned object maps to the internal buffer. This buffer cannot be overrode, and it * becomes invalid after next call to submitAndAcquire(). * * @param textureId the OpenGL texture Id. * @param textureWidth width of the texture in pixels. * @param textureHeight height of the texture in pixels. * @return a TextureReaderImage object that contains the pixels read from the texture. */ public TextureReaderImage submitAndAcquire(int textureId, int textureWidth, int textureHeight) { // Release previously used front buffer. if (frontIndex != -1) { releaseFrame(frontIndex); } // Move previous back buffer to front buffer. frontIndex = backIndex; // Submit new request on back buffer. backIndex = submitFrame(textureId, textureWidth, textureHeight); // Acquire frame from the new front buffer. if (frontIndex != -1) { return acquireFrame(frontIndex); } return null; }