From ab48dac3f4419ceac51fdf059f310f0f0499c4d7 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Fri, 8 Apr 2011 14:51:22 +0200
Subject: FIX: Refactor GLArrayData and all it's implementations/sub-interfaces
 (VBO target, comments, names)

VBO target: Allowing ELEMENT_VERTEX_ARRAY w/o corresponding GLSL/Fixed attribute

Names: Clarified method named.

Comments: Added and fixed comments
---
 .../com/jogamp/opengl/util/GLDataArrayHandler.java | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 src/jogl/classes/com/jogamp/opengl/util/GLDataArrayHandler.java

(limited to 'src/jogl/classes/com/jogamp/opengl/util/GLDataArrayHandler.java')

diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDataArrayHandler.java b/src/jogl/classes/com/jogamp/opengl/util/GLDataArrayHandler.java
new file mode 100644
index 000000000..74d49aa6c
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLDataArrayHandler.java
@@ -0,0 +1,41 @@
+
+package com.jogamp.opengl.util;
+
+import javax.media.opengl.*;
+import javax.media.opengl.fixedfunc.*;
+import com.jogamp.opengl.util.*;
+import java.nio.*;
+
+public class GLDataArrayHandler implements GLArrayHandler {
+  private GLArrayDataEditable ad;
+
+  public GLDataArrayHandler(GLArrayDataEditable ad) {
+    this.ad = ad;
+  }
+
+  public void enableBuffer(GL gl, boolean enable) {
+    GLPointerFunc glp = gl.getGL2ES1();
+    if(enable) {
+        Buffer buffer = ad.getBuffer();
+
+        if(ad.isVBO()) {
+            // always bind and refresh the VBO mgr, 
+            // in case more than one gl*Pointer objects are in use
+            gl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
+            if(!ad.isVBOWritten()) {
+                if(null!=buffer) {
+                    gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getComponentSize(), buffer, ad.getVBOUsage());
+                }
+                ad.setVBOWritten(true);
+            }
+        } else if(null!=buffer) {
+            ad.setVBOWritten(true);
+        }
+    } else {
+        if(ad.isVBO()) {
+            gl.glBindBuffer(ad.getVBOTarget(), 0);
+        }
+    }
+  }
+}
+
-- 
cgit v1.2.3