Bug 179

Summary: Add documentation on importance of byte ordering
Product: [JogAmp] Jogl Reporter: Sven Gothel <sgothel>
Component: coreAssignee: Sven Gothel <sgothel>
Status: VERIFIED FIXED    
Severity: normal    
Priority: P3    
Version: 1   
Hardware: All   
OS: all   
Type: FEATURE SCM Refs:
Workaround: ---

Description Sven Gothel 2010-03-24 07:48:05 CET


---- Reported by pepijnve 2005-10-28 03:04:09 ----

Some documentation should be added to the package documentation explaining the
importance of byte ordering when using Buffer objects.
A Buffer orders the bytes of multibyte values based on its ByteOrder. Jogl does
not look at the byte order of Buffer parameters and simply passes them on to the
underlying OpenGL implementation. If users are not using native byte ordering,
this could cause issues when developing cross-platform, since the default
ordering is big endian which may or may not corresponds with the underlying
platforms byte ordering. This issue does not occur when using primitive arrays,
since JNI takes care of properly converting primitive values.



---- Additional Comments From pepijnve 2005-10-28 03:08:25 ----

This issue does not occur when using primitive arrays, since JNI takes care of
properly converting primitive values.

This sentence is not accurate, so it should be disregarded.



---- Additional Comments From kbr 2006-01-22 08:51:46 ----

Added text to the spec overview regarding setting byte order of newly-allocated
ByteBuffers to native order.

<h4>Byte ordering of Buffers</h4>
 When allocating a New I/O Buffer (in particular, a direct ByteBuffer)
to be passed to the APIs in these packages, it is essential to set the
<em>byte ordering</em> of the newly-allocated ByteBuffer to the
<em>native</em> byte ordering of the platform:
e.g. <code>ByteBuffer.allocateDirect(...).order(ByteOrder.nativeOrder());</code>.
The byte order of the ByteBuffer indicates how multi-byte values such
as int and float are stored in the Buffer either using methods like
putInt and putFloat or views such as IntBuffer or FloatBuffer. The
Java bindings perform no conversion or byte swapping on the outgoing
data to OpenGL, and the native OpenGL implementation expects data in
the host CPU's byte order, so it is essential to always match the byte
order of the underlying platform when filling Buffers with data. <br>




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

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