Re: Why glReadPixels' buffer is too small?
Posted by
Wade Walker on
Apr 18, 2012; 3:34pm
URL: https://forum.jogamp.org/Why-glReadPixels-buffer-is-too-small-tp3916912p3920378.html
If you look at the source code at
https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java, you can see it's doing some complex calculations with GL.GL_PACK* and GL.GL_UNPACK* to figure out the required buffer size -- it's not as simple as just multiplying x and y size and the depth bytes together

Those GLBuffers.sizeof() methods are invoked by Buffers.rangeCheckBytes(), which is invoked by GL4bcImpl.glReadPixels(). All this checking is apparently to prevent inadvertently aksing OpenGL to write outside allocated memory by passing it a buffer that's too small.