aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2001-11-11 23:17:43 +0000
committerKenneth Russel <[email protected]>2001-11-11 23:17:43 +0000
commit78429f3bb42a4fdf68711191d042523a08e57fcb (patch)
treedbd2e610ef51911ea72c2afe115e51d45807f404
parent9926109230d7fc43033550baa29d92175e90fed5 (diff)
Clarification on unsafety of glVertexPointer taking float array as arg
-rw-r--r--demos/NVidia/VertexArrayRange.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/demos/NVidia/VertexArrayRange.java b/demos/NVidia/VertexArrayRange.java
index f4d0d2f..0da54bf 100644
--- a/demos/NVidia/VertexArrayRange.java
+++ b/demos/NVidia/VertexArrayRange.java
@@ -632,9 +632,18 @@ public class VertexArrayRange {
loX.reset();
hiX.reset();
- // NOTE: we don't make the glVertexPointer/glNormalPointer
- // call until this point because the semantics in the
- // "fixed" implementation are that they copy data.
+ // NOTE: these calls are not safe because the OpenGL for
+ // Java implementation uses the JNI
+ // GetPrimitiveArrayCritical routine to fetch the arrays'
+ // storage. If a garbage collection occurs between or during
+ // the glVertexPointer and glDrawElements calls, the arrays
+ // may move, leading to incorrect data being drawn or
+ // possibly a crash. Future applications should always use
+ // java.nio direct buffers for the storage passed down to
+ // glVertexPointer and similar routines taking persistent
+ // pointers, regardless of whether an extension like
+ // NVidia's vertex array range is used. Direct buffers can
+ // be created with ByteBuffer.allocateDirect().
gl.glVertexPointer(3, GL_FLOAT, 3 * SIZEOF_FLOAT, v);
gl.glNormalPointer(GL_FLOAT, 3 * SIZEOF_FLOAT, n);