aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/sun/opengl/util/GLFixedArrayHandler.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-06-15 22:57:38 +0000
committerKenneth Russel <[email protected]>2009-06-15 22:57:38 +0000
commita959c53b7ac91e489bf0959391e892790b9ff248 (patch)
tree4664742a4f9f6daa694364292e376ad2e6ee97d1 /src/jogl/classes/com/sun/opengl/util/GLFixedArrayHandler.java
parent506b634b780dcd23aa61015c2ceba3e687196abf (diff)
Copied JOGL_2_SANDBOX r1957 on to trunk; JOGL_2_SANDBOX branch is now closed
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1959 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/jogl/classes/com/sun/opengl/util/GLFixedArrayHandler.java')
-rw-r--r--src/jogl/classes/com/sun/opengl/util/GLFixedArrayHandler.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/jogl/classes/com/sun/opengl/util/GLFixedArrayHandler.java b/src/jogl/classes/com/sun/opengl/util/GLFixedArrayHandler.java
new file mode 100644
index 000000000..f1e2502be
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/util/GLFixedArrayHandler.java
@@ -0,0 +1,65 @@
+
+package com.sun.opengl.util;
+
+import javax.media.opengl.*;
+import javax.media.opengl.fixedfunc.*;
+import com.sun.opengl.util.*;
+import java.nio.*;
+
+public class GLFixedArrayHandler implements GLArrayHandler {
+ private GLArrayDataEditable ad;
+
+ public GLFixedArrayHandler(GLArrayDataEditable ad) {
+ this.ad = ad;
+ }
+
+ protected final void passArrayPointer(GLPointerFunc gl) {
+ switch(ad.getIndex()) {
+ case GLPointerFunc.GL_VERTEX_ARRAY:
+ gl.glVertexPointer(ad);
+ break;
+ case GLPointerFunc.GL_NORMAL_ARRAY:
+ gl.glNormalPointer(ad);
+ break;
+ case GLPointerFunc.GL_COLOR_ARRAY:
+ gl.glColorPointer(ad);
+ break;
+ case GLPointerFunc.GL_TEXTURE_COORD_ARRAY:
+ gl.glTexCoordPointer(ad);
+ break;
+ default:
+ throw new GLException("invalid glArrayIndex: "+ad.getIndex()+":\n\t"+ad);
+ }
+ }
+
+ public void enableBuffer(GL gl, boolean enable) {
+ GLPointerFunc glp = gl.getGL2ES1();
+ if(enable) {
+ glp.glEnableClientState(ad.getIndex());
+
+ 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(GL.GL_ARRAY_BUFFER, ad.getVBOName());
+ if(!ad.isBufferWritten()) {
+ if(null!=buffer) {
+ gl.glBufferData(GL.GL_ARRAY_BUFFER, buffer.limit() * ad.getComponentSize(), buffer, ad.getBufferUsage());
+ }
+ ad.setBufferWritten(true);
+ }
+ passArrayPointer(glp);
+ } else if(null!=buffer) {
+ passArrayPointer(glp);
+ ad.setBufferWritten(true);
+ }
+ } else {
+ if(ad.isVBO()) {
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
+ }
+ glp.glDisableClientState(ad.getIndex());
+ }
+ }
+}
+