aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xetc/profile.jogl4
-rw-r--r--make/build.xml13
-rw-r--r--make/gl-if-CustomJavaCode-gl.java1
-rw-r--r--make/gl-impl-CustomJavaCode-common.java4
-rw-r--r--make/gl-impl-CustomJavaCode-gl2es12.java2
-rw-r--r--src/classes/com/sun/javafx/newt/GLWindow.java4
-rw-r--r--src/classes/com/sun/opengl/impl/GLArrayHandler.java11
-rw-r--r--src/classes/com/sun/opengl/impl/GLFixedArrayHandler.java63
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java67
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/GLSLArrayHandler.java63
-rw-r--r--src/classes/javax/media/opengl/GLArrayData.java10
-rw-r--r--src/classes/javax/media/opengl/GLArrayDataClient.java95
-rw-r--r--src/classes/javax/media/opengl/GLArrayDataServer.java45
-rw-r--r--src/classes/javax/media/opengl/util/ImmModeSink.java7
14 files changed, 239 insertions, 150 deletions
diff --git a/etc/profile.jogl b/etc/profile.jogl
index a52aed371..f4c0de3a3 100755
--- a/etc/profile.jogl
+++ b/etc/profile.jogl
@@ -69,18 +69,22 @@ if [ ! -z "$1" ] ; then
JOGL_ES1_MIN)
JOGL_CLASSPATH=$(concat_jogl_list $JOGL_JAR_DIR $JOGL_JAR_ES1_MIN)
JOGL_LIBS=$(concat_jogl_list $JOGL_LIB_DIR $JOGL_LIB_ES1_MIN)
+ JOGL_VBO_BUG=true ; export JOGL_VBO_BUG # ES emulation has buggy VBO impl.
;;
JOGL_ES1_MAX)
JOGL_CLASSPATH=$(concat_jogl_list $JOGL_JAR_DIR $JOGL_JAR_ES1_MAX)
JOGL_LIBS=$(concat_jogl_list $JOGL_LIB_DIR $JOGL_LIB_ES1_MAX)
+ JOGL_VBO_BUG=true ; export JOGL_VBO_BUG # ES emulation has buggy VBO impl.
;;
JOGL_ES2_MIN)
JOGL_CLASSPATH=$(concat_jogl_list $JOGL_JAR_DIR $JOGL_JAR_ES2_MIN)
JOGL_LIBS=$(concat_jogl_list $JOGL_LIB_DIR $JOGL_LIB_ES2_MIN)
+ JOGL_VBO_BUG=true ; export JOGL_VBO_BUG # ES emulation has buggy VBO impl.
;;
JOGL_ES2_MAX)
JOGL_CLASSPATH=$(concat_jogl_list $JOGL_JAR_DIR $JOGL_JAR_ES2_MAX)
JOGL_LIBS=$(concat_jogl_list $JOGL_LIB_DIR $JOGL_LIB_ES2_MAX)
+ JOGL_VBO_BUG=true ; export JOGL_VBO_BUG # ES emulation has buggy VBO impl.
;;
JOGL_GL2ES12_MIN)
JOGL_CLASSPATH=$(concat_jogl_list $JOGL_JAR_DIR $JOGL_JAR_GL2ES12_MIN)
diff --git a/make/build.xml b/make/build.xml
index 92e4188a8..9b7f41eb6 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -770,6 +770,17 @@
</gluegen>
</target>
+ <target name="java.generate.SystemUtil.javame_cdc_fp" if="jogl.cdcfp">
+ <copy file="../src/classes/com/sun/opengl/impl/SystemUtil.java.javame_cdc_fp" tofile="../build/gensrc/classes/com/sun/opengl/impl/SystemUtil.java" />
+ </target>
+
+ <target name="java.generate.SystemUtil.javase" unless="jogl.cdcfp">
+ <copy file="../src/classes/com/sun/opengl/impl/SystemUtil.java.javase" tofile="../build/gensrc/classes/com/sun/opengl/impl/SystemUtil.java" />
+ </target>
+
+ <!-- Generate the SystemUtil class for this particular profile -->
+ <target name="java.generate.SystemUtil" depends="java.generate.SystemUtil.javase, java.generate.SystemUtil.javame_cdc_fp" />
+
<target name="java.generate.BufferUtil.javame_cdc_fp" if="jogl.cdcfp">
<copy file="../src/classes/javax/media/opengl/util/BufferUtil.java.javame_cdc_fp" tofile="../build/gensrc/classes/javax/media/opengl/util/BufferUtil.java" />
</target>
@@ -810,7 +821,7 @@
- from the C GL headers. This involves setting the taskdef and creating
- the classpath reference id then running the task on each header.
-->
- <target name="java.generate" depends="build.gluegen, java.generate.BufferUtil, java.generate.TextureIO, java.generate.check" unless="java.generate.skip">
+ <target name="java.generate" depends="build.gluegen, java.generate.SystemUtil, java.generate.BufferUtil, java.generate.TextureIO, java.generate.check" unless="java.generate.skip">
<!-- Add the GlueGen and BuildStaticGLInfo tasks to ANT -->
<taskdef name="gluegen" classname="com.sun.gluegen.ant.GlueGenTask"
diff --git a/make/gl-if-CustomJavaCode-gl.java b/make/gl-if-CustomJavaCode-gl.java
index 20cfe864c..acb3f10f5 100644
--- a/make/gl-if-CustomJavaCode-gl.java
+++ b/make/gl-if-CustomJavaCode-gl.java
@@ -121,3 +121,4 @@
public void glShadeModel(int mode);
+ public int glGetBoundBuffer(int target);
diff --git a/make/gl-impl-CustomJavaCode-common.java b/make/gl-impl-CustomJavaCode-common.java
index 866fbc7ae..930f976ce 100644
--- a/make/gl-impl-CustomJavaCode-common.java
+++ b/make/gl-impl-CustomJavaCode-common.java
@@ -18,3 +18,7 @@
return false;
}
+ public int glGetBoundBuffer(int target) {
+ return bufferStateTracker.getBoundBufferObject(target, this);
+ }
+
diff --git a/make/gl-impl-CustomJavaCode-gl2es12.java b/make/gl-impl-CustomJavaCode-gl2es12.java
index 643443b91..0eff40f08 100644
--- a/make/gl-impl-CustomJavaCode-gl2es12.java
+++ b/make/gl-impl-CustomJavaCode-gl2es12.java
@@ -430,3 +430,5 @@ native private long dispatch_glMapBuffer(int target, int access, long glProcAddr
glTexCoordPointer(array.getComponentNumber(), array.getComponentType(), array.getStride(), array.getBuffer());
}
}
+
+
diff --git a/src/classes/com/sun/javafx/newt/GLWindow.java b/src/classes/com/sun/javafx/newt/GLWindow.java
index baabd25a6..7f7d8d077 100644
--- a/src/classes/com/sun/javafx/newt/GLWindow.java
+++ b/src/classes/com/sun/javafx/newt/GLWindow.java
@@ -403,8 +403,8 @@ public class GLWindow extends Window implements GLAutoDrawable {
dt0 = curTime-lastCheck;
if ( dt0 > 5000 ) {
dt1 = curTime-startTime;
- System.out.println(dt1/1000+"s, 5s: "+ (lastFrames*1000)/dt0 + " fps, "+
- "total: "+ (totalFrames*1000)/dt1 + " fps");
+ System.out.println(dt0/1000 +"s: "+ lastFrames + "f, " + (lastFrames*1000)/dt0 + " fps, "+dt0/lastFrames+" ms/f; "+
+ "total: "+ dt1/1000+"s, "+(totalFrames*1000)/dt1 + " fps, "+dt1/totalFrames+" ms/f");
lastCheck=curTime;
lastFrames=0;
}
diff --git a/src/classes/com/sun/opengl/impl/GLArrayHandler.java b/src/classes/com/sun/opengl/impl/GLArrayHandler.java
new file mode 100644
index 000000000..bba190835
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/GLArrayHandler.java
@@ -0,0 +1,11 @@
+
+package com.sun.opengl.impl;
+
+import javax.media.opengl.*;
+
+public interface GLArrayHandler {
+
+ public void enableBuffer(GL gl, boolean enable);
+
+}
+
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());
+ }
+ }
+}
+
diff --git a/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java b/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java
deleted file mode 100644
index 14613227e..000000000
--- a/src/classes/com/sun/opengl/impl/glsl/GLSLArrayDataServer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-
-package com.sun.opengl.impl.glsl;
-
-import javax.media.opengl.*;
-import javax.media.opengl.glsl.ShaderState;
-import java.nio.*;
-
-public class GLSLArrayDataServer extends GLArrayDataServer {
-
- public GLSLArrayDataServer(String name, int comps, int dataType, boolean normalized,
- int stride, Buffer buffer, int glBufferUsage) {
- init(name, -1, comps, dataType, normalized, stride, buffer, 0, buffer.limit(), glBufferUsage, true);
- }
-
- public GLSLArrayDataServer(String name, int comps, int dataType, boolean normalized,
- int stride, long bufferOffset) {
- init(name, -1, comps, dataType, normalized, stride, null, bufferOffset, 0, -1, true);
- }
-
- public GLSLArrayDataServer(String name, int comps, int dataType, boolean normalized,
- int initialSize, int glBufferUsage) {
- init(name, -1, comps, dataType, normalized, 0, null, 0, initialSize, glBufferUsage, true);
- }
-
- protected final void passVertexAttribPointer(GL2ES2 gl, ShaderState st) {
- if ( ! st.glVertexAttribPointer(gl, this) ) {
- throw new RuntimeException("Internal Error");
- }
- }
-
- protected void enableBufferGLImpl(GL gl, boolean enable) {
- GL2ES2 glsl = gl.getGL2ES2();
- ShaderState st = ShaderState.getCurrent();
- if(null==st) {
- throw new GLException("No ShaderState current");
- }
-
- if(enable) {
- if(!st.glEnableVertexAttribArray(glsl, name)) {
- throw new RuntimeException("Internal Error");
- }
-
- if(vboUsage) {
- gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboName);
- if(!bufferWritten) {
- if(null!=buffer) {
- gl.glBufferData(GL.GL_ARRAY_BUFFER, buffer.limit() * getComponentSize(), buffer, glBufferUsage);
- }
- bufferWritten=true;
- }
- passVertexAttribPointer(glsl, st);
- } else if(null!=buffer) {
- passVertexAttribPointer(glsl, st);
- bufferWritten=true;
- }
- } else {
- if(vboUsage) {
- gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
- }
- if(!st.glDisableVertexAttribArray(glsl, name)) {
- throw new RuntimeException("Internal Error");
- }
- }
- }
-
-}
-
diff --git a/src/classes/com/sun/opengl/impl/glsl/GLSLArrayHandler.java b/src/classes/com/sun/opengl/impl/glsl/GLSLArrayHandler.java
new file mode 100644
index 000000000..2910e67bd
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/glsl/GLSLArrayHandler.java
@@ -0,0 +1,63 @@
+
+package com.sun.opengl.impl.glsl;
+
+import com.sun.opengl.impl.*;
+
+import javax.media.opengl.*;
+import javax.media.opengl.glsl.ShaderState;
+import java.nio.*;
+
+public class GLSLArrayHandler implements GLArrayHandler {
+ private GLArrayData ad;
+
+ public GLSLArrayHandler(GLArrayData ad) {
+ this.ad = ad;
+ }
+
+ protected final void passVertexAttribPointer(GL2ES2 gl, ShaderState st) {
+ if ( ! st.glVertexAttribPointer(gl, ad) ) {
+ throw new RuntimeException("Internal Error");
+ }
+ }
+
+ public void enableBuffer(GL gl, boolean enable) {
+ GL2ES2 glsl = gl.getGL2ES2();
+ ShaderState st = ShaderState.getCurrent();
+ if(null==st) {
+ throw new GLException("No ShaderState current");
+ }
+
+ if(enable) {
+ if(!st.glEnableVertexAttribArray(glsl, ad.getName())) {
+ throw new RuntimeException("Internal Error");
+ }
+
+ 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);
+ }
+ passVertexAttribPointer(glsl, st);
+ } else if(null!=buffer) {
+ passVertexAttribPointer(glsl, st);
+ ad.setBufferWritten(true);
+ }
+ } else {
+ if(ad.isVBO()) {
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
+ }
+ if(!st.glDisableVertexAttribArray(glsl, ad.getName())) {
+ throw new RuntimeException("Internal Error");
+ }
+ }
+ }
+
+}
+
diff --git a/src/classes/javax/media/opengl/GLArrayData.java b/src/classes/javax/media/opengl/GLArrayData.java
index 096506242..bdffa3c44 100644
--- a/src/classes/javax/media/opengl/GLArrayData.java
+++ b/src/classes/javax/media/opengl/GLArrayData.java
@@ -83,6 +83,16 @@ public interface GLArrayData {
public Buffer getBuffer();
/**
+ * Is the buffer written to the GPU ?
+ */
+ public boolean isBufferWritten();
+
+ /**
+ * Marks the buffer written to the GPU
+ */
+ public void setBufferWritten(boolean written);
+
+ /**
* The number of components per element
*/
public int getComponentNumber();
diff --git a/src/classes/javax/media/opengl/GLArrayDataClient.java b/src/classes/javax/media/opengl/GLArrayDataClient.java
index a8da6c0a1..2a5b48506 100644
--- a/src/classes/javax/media/opengl/GLArrayDataClient.java
+++ b/src/classes/javax/media/opengl/GLArrayDataClient.java
@@ -2,13 +2,23 @@
package javax.media.opengl;
import javax.media.opengl.util.*;
-import com.sun.opengl.impl.GLReflection;
+import com.sun.opengl.impl.*;
+import com.sun.opengl.impl.glsl.*;
import java.nio.*;
public class GLArrayDataClient implements GLArrayData {
/**
+ * The OpenGL ES emulation on the PC probably has a buggy VBO implementation,
+ * where we have to 'refresh' the VertexPointer or VertexAttribArray after each
+ * BindBuffer !
+ *
+ * This should not be necessary on proper native implementations.
+ */
+ public static final boolean hasVBOBug = (SystemUtil.getenv("JOGL_VBO_BUG") != null);
+
+ /**
* @arg index The GL array index
* @arg name The optional custom name for the GL array index, maybe null.
* If null, the default name mapping will be used, see 'getPredefinedArrayIndexName(int)'.
@@ -25,7 +35,8 @@ public class GLArrayDataClient implements GLArrayData {
{
GLProfile.isValidateArrayDataType(index, comps, dataType, false, true);
GLArrayDataClient adc = new GLArrayDataClient();
- adc.init(name, index, comps, dataType, normalized, 0, null, initialSize, false);
+ GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
+ adc.init(name, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler);
return adc;
}
@@ -35,27 +46,36 @@ public class GLArrayDataClient implements GLArrayData {
{
GLProfile.isValidateArrayDataType(index, comps, dataType, false, true);
GLArrayDataClient adc = new GLArrayDataClient();
- adc.init(name, index, comps, dataType, normalized, stride, buffer, comps*comps, false);
+ GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
+ adc.init(name, index, comps, dataType, normalized, stride, buffer, comps*comps, false, glArrayHandler);
return adc;
}
- public static GLArrayDataClient createGLSL(int index, String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataClient createGLSL(String name, int comps, int dataType, boolean normalized,
int initialSize)
throws GLException
{
- GLProfile.isValidateArrayDataType(index, comps, dataType, true, true);
+ if(!GLProfile.isGL2ES2()) {
+ throw new GLException("GLArrayDataServer not supported for profile: "+GLProfile.getProfile());
+ }
+
GLArrayDataClient adc = new GLArrayDataClient();
- adc.init(name, index, comps, dataType, normalized, 0, null, initialSize, true);
+ GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc);
+ adc.init(name, -1, comps, dataType, normalized, 0, null, initialSize, true, glArrayHandler);
return adc;
}
- public static GLArrayDataClient createGLSL(int index, String name, int comps, int dataType, boolean normalized,
+ public static GLArrayDataClient createGLSL(String name, int comps, int dataType, boolean normalized,
int stride, Buffer buffer)
throws GLException
{
- GLProfile.isValidateArrayDataType(index, comps, dataType, true, true);
+ if(!GLProfile.isGL2ES2()) {
+ throw new GLException("GLArrayDataServer not supported for profile: "+GLProfile.getProfile());
+ }
+
GLArrayDataClient adc = new GLArrayDataClient();
- adc.init(name, index, comps, dataType, normalized, stride, buffer, comps*comps, true);
+ GLArrayHandler glArrayHandler = new GLSLArrayHandler(adc);
+ adc.init(name, -1, comps, dataType, normalized, stride, buffer, comps*comps, true, glArrayHandler);
return adc;
}
@@ -75,7 +95,7 @@ public class GLArrayDataClient implements GLArrayData {
public long getOffset() { return -1; }
- public final Buffer getBuffer() { return buffer; }
+ public final boolean isBufferWritten() { return bufferWritten; }
public boolean isVBO() { return false; }
@@ -120,6 +140,10 @@ public class GLArrayDataClient implements GLArrayData {
// Data and GL state modification ..
//
+ public final Buffer getBuffer() { return buffer; }
+
+ public final void setBufferWritten(boolean written) { bufferWritten=written; }
+
public void setName(String newName) {
location = -1;
name = newName;
@@ -159,7 +183,7 @@ public class GLArrayDataClient implements GLArrayData {
buffer.rewind();
}
}
- enableBufferGLImpl(gl, enable);
+ glArrayHandler.enableBuffer(gl, enable);
bufferEnabled = enable;
}
}
@@ -410,9 +434,10 @@ public class GLArrayDataClient implements GLArrayData {
}
protected void init(String name, int index, int comps, int dataType, boolean normalized, int stride, Buffer data,
- int initialSize, boolean isVertexAttribute)
+ int initialSize, boolean isVertexAttribute, GLArrayHandler handler)
throws GLException
{
+ this.glArrayHandler = handler;
this.isVertexAttribute = isVertexAttribute;
this.index = index;
this.location = -1;
@@ -457,50 +482,6 @@ public class GLArrayDataClient implements GLArrayData {
}
}
- protected final void passArrayPointer(GL gl) {
- switch(index) {
- case GL.GL_VERTEX_ARRAY:
- gl.glVertexPointer(this);
- break;
- case GL.GL_NORMAL_ARRAY:
- gl.glNormalPointer(this);
- break;
- case GL.GL_COLOR_ARRAY:
- gl.glColorPointer(this);
- break;
- case GL.GL_TEXTURE_COORD_ARRAY:
- gl.glTexCoordPointer(this);
- break;
- default:
- throw new GLException("invalid glArrayIndex: "+index+":\n\t"+this);
- }
- }
-
- protected void enableBufferGLImpl(GL gl, boolean enable) {
- if(enable) {
- gl.glEnableClientState(index);
-
- if(isVBO()) {
- gl.glBindBuffer(GL.GL_ARRAY_BUFFER, getVBOName());
- if(!bufferWritten) {
- if(null!=buffer) {
- gl.glBufferData(GL.GL_ARRAY_BUFFER, buffer.limit() * getComponentSize(), buffer, getBufferUsage());
- }
- bufferWritten=true;
- }
- passArrayPointer(gl);
- } else if(null!=buffer) {
- passArrayPointer(gl);
- bufferWritten=true;
- }
- } else {
- if(isVBO()) {
- gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
- }
- gl.glDisableClientState(index);
- }
- }
-
protected void init_vbo(GL gl) {}
protected GLArrayDataClient() { }
@@ -522,5 +503,7 @@ public class GLArrayDataClient implements GLArrayData {
protected boolean bufferEnabled;
protected boolean bufferWritten;
protected boolean enableBufferAlways;
+
+ protected GLArrayHandler glArrayHandler;
}
diff --git a/src/classes/javax/media/opengl/GLArrayDataServer.java b/src/classes/javax/media/opengl/GLArrayDataServer.java
index 44d4a2ff7..032e0a6f1 100644
--- a/src/classes/javax/media/opengl/GLArrayDataServer.java
+++ b/src/classes/javax/media/opengl/GLArrayDataServer.java
@@ -4,6 +4,7 @@ package javax.media.opengl;
import javax.media.opengl.*;
import java.nio.*;
import com.sun.opengl.impl.*;
+import com.sun.opengl.impl.glsl.*;
public class GLArrayDataServer extends GLArrayDataClient implements GLArrayData {
@@ -37,7 +38,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayData
GLProfile.isValidateArrayDataType(index, comps, dataType, false, true);
GLArrayDataServer ads = new GLArrayDataServer();
- ads.init(name, index, comps, dataType, normalized, stride, buffer, 0, buffer.limit(), glBufferUsage, false);
+ GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
+ ads.init(name, index, comps, dataType, normalized, stride, buffer, 0, buffer.limit(), glBufferUsage, false, glArrayHandler);
return ads;
}
@@ -59,7 +61,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayData
GLProfile.isValidateArrayDataType(index, comps, dataType, false, true);
GLArrayDataServer ads = new GLArrayDataServer();
- ads.init(name, index, comps, dataType, normalized, 0, null, 0, initialSize, glBufferUsage, false);
+ GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
+ ads.init(name, index, comps, dataType, normalized, 0, null, 0, initialSize, glBufferUsage, false, glArrayHandler);
return ads;
}
@@ -82,7 +85,8 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayData
GLProfile.isValidateArrayDataType(index, comps, dataType, false, true);
GLArrayDataServer ads = new GLArrayDataServer();
- ads.init(name, index, comps, dataType, normalized, stride, null, bufferOffset, 0, -1, false);
+ GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
+ ads.init(name, index, comps, dataType, normalized, stride, null, bufferOffset, 0, -1, false, glArrayHandler);
ads.vboName = vboName;
ads.bufferWritten = true;
ads.sealed = true;
@@ -99,15 +103,14 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayData
int initialSize, int glBufferUsage)
throws GLException
{
- GLProfile.isValidateArrayDataType(-1, comps, dataType, true, true);
- Class[] types = new Class[]{ String.class, int.class, int.class, boolean.class, int.class, int.class };
- Object[] args = new Object[]{ name, new Integer(comps), new Integer(dataType),
- new Boolean(normalized), new Integer(initialSize), new Integer(glBufferUsage) } ;
-
- if(GLProfile.isGL2ES2()) {
- return (GLArrayDataServer) GLReflection.createInstance("com.sun.opengl.impl.glsl.GLSLArrayDataServer", types, args);
+ if(!GLProfile.isGL2ES2()) {
+ throw new GLException("GLArrayDataServer not supported for profile: "+GLProfile.getProfile());
}
- throw new GLException("GLArrayDataServer not supported for profile: "+GLProfile.getProfile());
+
+ GLArrayDataServer ads = new GLArrayDataServer();
+ GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
+ ads.init(name, -1, comps, dataType, normalized, 0, null, 0, initialSize, glBufferUsage, true, glArrayHandler);
+ return ads;
}
/**
@@ -120,15 +123,14 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayData
int stride, Buffer buffer, int glBufferUsage)
throws GLException
{
- GLProfile.isValidateArrayDataType(-1, comps, dataType, true, true);
- Class[] types = new Class[]{ String.class, int.class, int.class, boolean.class, int.class, Buffer.class, int.class };
- Object[] args = new Object[]{ name, new Integer(comps), new Integer(dataType),
- new Boolean(normalized), new Integer(stride), buffer, new Integer(glBufferUsage) } ;
-
- if(GLProfile.isGL2ES2()) {
- return (GLArrayDataServer) GLReflection.createInstance("com.sun.opengl.impl.glsl.GLSLArrayDataServer", types, args);
+ if(!GLProfile.isGL2ES2()) {
+ throw new GLException("GLArrayDataServer not supported for profile: "+GLProfile.getProfile());
}
- throw new GLException("GLArrayDataServer not supported for profile: "+GLProfile.getProfile());
+
+ GLArrayDataServer ads = new GLArrayDataServer();
+ GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads);
+ ads.init(name, -1, comps, dataType, normalized, stride, buffer, 0, buffer.limit(), glBufferUsage, true, glArrayHandler);
+ return ads;
}
//
@@ -200,10 +202,11 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayData
//
protected void init(String name, int index, int comps, int dataType, boolean normalized,
- int stride, Buffer data, long offset, int initialSize, int glBufferUsage, boolean isVertexAttribute)
+ int stride, Buffer data, long offset, int initialSize, int glBufferUsage, boolean isVertexAttribute,
+ GLArrayHandler glArrayHandler)
throws GLException
{
- super.init(name, index, comps, dataType, normalized, stride, data, initialSize, isVertexAttribute);
+ super.init(name, index, comps, dataType, normalized, stride, data, initialSize, isVertexAttribute, glArrayHandler);
vboUsage=true;
diff --git a/src/classes/javax/media/opengl/util/ImmModeSink.java b/src/classes/javax/media/opengl/util/ImmModeSink.java
index 04173cb6f..4ef8cacf7 100644
--- a/src/classes/javax/media/opengl/util/ImmModeSink.java
+++ b/src/classes/javax/media/opengl/util/ImmModeSink.java
@@ -399,10 +399,10 @@ public class ImmModeSink {
Exception e = new Exception("ImmModeSink.draw["+i+"](disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this);
e.printStackTrace();
}
- vertexVBO.enableBuffer(gl, true);
normalVBO.enableBuffer(gl, true);
colorVBO.enableBuffer(gl, true);
texcoordVBO.enableBuffer(gl, true);
+ vertexVBO.enableBuffer(gl, true);
if (vertexVBO.getBuffer()!=null) {
if(null==indices) {
@@ -419,14 +419,15 @@ public class ImmModeSink {
throw new GLException("Given Buffer Class not supported: "+clazz+", should be ubyte or ushort:\n\t"+this);
}
gl.glDrawElements(mode, indices.remaining(), type, indices);
+ // GL2: gl.glDrawRangeElements(mode, 0, indices.remaining()-1, indices.remaining(), type, indices);
}
}
if(disableBufferAfterDraw) {
vertexVBO.enableBuffer(gl, false);
- normalVBO.enableBuffer(gl, false);
- colorVBO.enableBuffer(gl, false);
texcoordVBO.enableBuffer(gl, false);
+ colorVBO.enableBuffer(gl, false);
+ normalVBO.enableBuffer(gl, false);
}
}