Bug 84

Summary: glReadPixels does not commit results
Product: [JogAmp] Jogl Reporter: Sven Gothel <sgothel>
Component: coreAssignee: Sven Gothel <sgothel>
Status: VERIFIED FIXED    
Severity: normal    
Priority: P5    
Version: 1   
Hardware: All   
OS: all   
Type: DEFECT SCM Refs:
Workaround: ---

Description Sven Gothel 2010-03-24 07:46:35 CET


---- Reported by petermantell 2004-05-07 05:44:57 ----

The native code for glReadPixels contains the following lines at the end of the 
function:

if (pixels != NULL)
{
  (*env)->ReleasePrimitiveArrayCritical(env, pixels, _ptr6, JNI_ABORT);
}

The use of JNI_ABORT signifies that the buffer will be freed but changes are 
not written back into the Java array. So the data that glReadPixels returns 
never ends up back in the Java array.

0 should be used instead of JNI_ABORT. See 
http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/functions.html#wp17440.



---- Additional Comments From kbr 2005-02-03 15:21:05 ----

While the submitter is correct, this is not a problem on Sun's JDK
implementation or any other JDK that I am aware of. GetPrimitiveArrayCritical
tends to return a pointer to the actual storage of the array rather than a copy.
I'm lowering the priority of this bug. For complete correctness, GlueGen would
probably use JNI_ABORT for outgoing const pointers and 0 for outgoing non-const
pointers.




---- Additional Comments From petermantell 2005-02-04 01:10:35 ----

With respect, it was a Sun JDK implementation that I was using at the time. 
This bug caused us lots of problems because it makes it almost impossible to 
get any data back from the buffer.



---- Additional Comments From kbr 2005-02-04 08:27:04 ----

What operating system, JDK version, and graphics card? Did you change the native
code, recompile, and see the problem disappear? Do you have a test case?

We are using glReadPixels in the core JOGL implementation with no problems. Is
it possible you were making the glReadPixels call while your GLEventListener was
not active?




---- Additional Comments From petermantell 2005-02-07 00:53:13 ----

Not sure of the answers to your questions - it was almost a year ago. I do 
remember trying it on different machines though, so can't have been a card 
specific issue.



---- Additional Comments From kbr 2006-01-11 00:05:08 ----

Changed use of JNI_ABORT to 0 in ReleasePrimitiveArrayCritical calls. This
should not change the behavior of the generated glue code in any way, at least
on the HotSpot JVM, but is being done for completeness of the GlueGen tool.




--- Bug imported by sgothel@jausoft.com 2010-03-24 07:46 EDT  ---

This bug was previously known as _bug_ 84 at https://jogl.dev.java.net/bugs/show_bug.cgi?id=84