diff options
author | Kenneth Russel <[email protected]> | 2009-03-19 06:39:36 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2009-03-19 06:39:36 +0000 |
commit | 45eac4e00b9b9dd935265c2ab25a61a2cf3cbf63 (patch) | |
tree | 3f1b3f3c0bee714b01acccdff54c29b378b0eb45 /src/jogl/classes/com/sun/opengl/util/GLFixedArrayHandler.java | |
parent | 0da2cacaab3c6862df6ca05abdbf0a7d9e9e5451 (diff) |
Moved remaining portions of fixed function emulation out of core JOGL
public and implementation packages and into
com.sun.opengl.util.glsl.fixed.* and other subpackages of
com.sun.opengl.util. Renamed javax.media.opengl.sub.GLObject to
javax.media.opengl.GLBase. Moved interfaces in
javax.media.opengl.sub.fixed to javax.media.opengl.fixedfunc and
changed naming convention. Moved all classes in
javax.media.opengl.util to com.sun.opengl.util. Moved
com.sun.opengl.impl.packrect to com.sun.opengl.util.packrect. Renamed
InternalBufferUtils to InternalBufferUtil to match naming convention
and copied in needed routines for GLU and other classes. Fixed build
breakage when specifying rootrel.build property; reintroduced
build-temp directory. Updated demos.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1886 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.java | 65 |
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()); + } + } +} + |