From 1992d24671f8d99abccb671b8f9d5a7cd474fd00 Mon Sep 17 00:00:00 2001
From: Sven Gothel
Date: Fri, 12 Oct 2012 21:38:36 +0200
Subject: GLArrayData* VBO binding: Properly document and impl. bindBuffer(..)
in detail w/ data sync within GLArrayHandle, which also removed redundant
code (VBO data sync and binding).
Refines commit 8582ece7dc7f65271b3184261697a542766d9864
and f49f8e22953ed2426fd4264ee407e2dc3fc07cfc
---
.../com/jogamp/opengl/util/GLArrayDataClient.java | 26 ++++++++++++++++---
.../jogamp/opengl/util/GLArrayDataEditable.java | 30 ++++++++++++++--------
2 files changed, 42 insertions(+), 14 deletions(-)
(limited to 'src/jogl/classes/com')
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
index 30fc0012b..af091d52b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
@@ -124,33 +124,41 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
// Data read access
//
+ @Override
public final boolean isVBOWritten() { return bufferWritten; }
+ @Override
public final boolean sealed() { return sealed; }
+ @Override
public final boolean enabled() { return bufferEnabled; }
//
// Data and GL state modification ..
//
+ @Override
public final void setVBOWritten(boolean written) { bufferWritten=written; }
+ @Override
public void destroy(GL gl) {
reset(gl);
super.destroy(gl);
}
+ @Override
public void reset(GL gl) {
enableBuffer(gl, false);
reset();
}
+ @Override
public void seal(GL gl, boolean seal) {
seal(seal);
enableBuffer(gl, seal);
}
+ @Override
public void enableBuffer(GL gl, boolean enable) {
if( enableBufferAlways || bufferEnabled != enable ) {
if(enable) {
@@ -172,12 +180,12 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
}
- public void bindBuffer(GL gl, boolean bind) {
- if(isVBO()) {
- gl.glBindBuffer(getVBOTarget(), bind ? getVBOName() : 0);
- }
+ @Override
+ public boolean bindBuffer(GL gl, boolean bind) {
+ return glArrayHandler.bindBuffer(gl, bind);
}
+ @Override
public void setEnableAlways(boolean always) {
enableBufferAlways = always;
}
@@ -186,6 +194,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
// Data modification ..
//
+ @Override
public void reset() {
if(buffer!=null) {
buffer.clear();
@@ -195,6 +204,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
this.bufferWritten=false;
}
+ @Override
public void seal(boolean seal)
{
if(sealed==seal) return;
@@ -211,12 +221,14 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
}
+ @Override
public void rewind() {
if(buffer!=null) {
buffer.rewind();
}
}
+ @Override
public void padding(int doneInByteSize) {
if ( buffer==null || sealed ) return;
while(doneInByteSize
* Enables the buffer if enable
is true
,
* and transfers the data if required.
- * In case {@link #isVBO() VBO is used}, it is bound accordingly for the data transfer and data association.
+ * In case {@link #isVBO() VBO is used}, it is bound accordingly for the data transfer and association,
+ * i.e. it issued {@link #bindBuffer(GL, boolean)}.
* The VBO buffer is unbound when the method returns.
- *
*
* Disables the buffer if enable
is false
.
*
@@ -67,15 +66,26 @@ public interface GLArrayDataEditable extends GLArrayData {
* @see #setEnableAlways(boolean)
*/
public void enableBuffer(GL gl, boolean enable);
-
+
/**
- * In case {@link #isVBO() VBO is used}, the buffer is bound
- * if bind
is true
, otherwise the buffer is unbound.
+ * if bind
is true and the data uses {@link #isVBO() VBO},
+ * the latter will be bound and data written to the GPU if required.
+ *
+ * If bind
is false and the data uses {@link #isVBO() VBO},
+ * the latter will be unbound.
+ *
+ *
+ * This method is exposed to allow data VBO arrays, i.e. {@link GL#GL_ELEMENT_ARRAY_BUFFER},
+ * to be bounded and written while keeping the VBO bound. The latter is in contrast to {@link #enableBuffer(GL, boolean)},
+ * which leaves the VBO unbound, since it's not required for vertex attributes or pointers.
+ *
*
- * @param gl
- * @param bind
+ * @param gl current GL object
+ * @param bind true if VBO shall be bound and data written,
+ * otherwise clear VBO binding.
+ * @return true if data uses VBO and action was performed, otherwise false
*/
- public void bindBuffer(GL gl, boolean bind);
+ public boolean bindBuffer(GL gl, boolean bind);
/**
* Affects the behavior of 'enableBuffer'.
--
cgit v1.2.3