aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java')
-rw-r--r--src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java b/src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java
new file mode 100644
index 000000000..9882beb69
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java
@@ -0,0 +1,63 @@
+
+package com.sun.opengl.impl;
+
+import javax.media.opengl.*;
+import javax.media.opengl.glsl.ShaderState;
+import java.nio.*;
+
+public class GLFixedArrayHandler implements GLArrayHandler {
+ private GLArrayData ad;
+
+ public GLFixedArrayHandler(GLArrayData ad) {
+ this.ad = ad;
+ }
+
+ protected final void passArrayPointer(GL gl) {
+ switch(ad.getIndex()) {
+ case GL.GL_VERTEX_ARRAY:
+ gl.glVertexPointer(ad);
+ break;
+ case GL.GL_NORMAL_ARRAY:
+ gl.glNormalPointer(ad);
+ break;
+ case GL.GL_COLOR_ARRAY:
+ gl.glColorPointer(ad);
+ break;
+ case GL.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) {
+ if(enable) {
+ gl.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(gl);
+ } else if(null!=buffer) {
+ passArrayPointer(gl);
+ ad.setBufferWritten(true);
+ }
+ } else {
+ if(ad.isVBO()) {
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
+ }
+ gl.glDisableClientState(ad.getIndex());
+ }
+ }
+}
+