summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-08-22 01:59:00 +0200
committerSven Gothel <[email protected]>2011-08-22 01:59:00 +0200
commit6c346d98f04e2355210960fe9ffde47432f04d62 (patch)
tree938536365abee309d5acf9ada1ac75bc1a49e939 /src
parent47b0d317df3c860b6cf3ea10196dfee82b3b3dc1 (diff)
Misc Rename/Reloc; GLArrayData*/PMVMatrix enhancments; Test fixes/adds (GearsES1/ES2)
rename/reloc: - javax.media.nativewindow.util: DimensionReadOnly -> DimensionImmutable PointReadOnly -> PointImmutable RectangleReadOnly -> RectangleImmutable unified 'immutable' name as used within jogamp already - remove array handler from public API com.jogamp.opengl.util.GL*ArrayHandler -> jogamp.opengl.util.GL*ArrayHandler - GLArrayData: Clarify method names getComponentNumber() -> getComponentCount() getComponentSize() -> getComponentSizeInBytes() getElementNumber() -> getElementCount() getByteSize() -> getSizeInBytes() - FixedFuncPipeline: Moved def. array names to GLPointerFuncUtil enhancement: - GLArrayDataServer: Add support for interleaved arrays/VBO - GLArrayData*.createFixed(..) remove 'name' argument (non sense for fixed function) - PMVMatrix: - one nio buffer - removed 'Pmv' multiplied matrix - removed 2x2 cut down 'Mvi' normal matrix (use 4x4 Mvi) - tests: - RedSquare -> RedSquareES1/RedSquareES2 - Gears ES1 fixed + ES2 added. Both work properly and share common Gears VBO construction - Added TestMapBuffer01NEWT, testing glMapBuffer
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java55
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java89
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java41
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayHandler.java21
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLDataArrayHandler.java41
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLFixedArrayHandler.java65
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java168
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java10
-rw-r--r--src/jogl/classes/javax/media/opengl/GLArrayData.java17
-rw-r--r--src/jogl/classes/javax/media/opengl/GLUniformData.java14
-rw-r--r--src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java29
-rw-r--r--src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java25
-rw-r--r--src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java27
-rw-r--r--src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java55
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java4
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java73
-rw-r--r--src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java99
-rw-r--r--src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java82
-rw-r--r--src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerInterleaved.java87
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java (renamed from src/jogl/classes/com/jogamp/opengl/util/glsl/GLSLArrayHandler.java)31
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java66
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java96
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java27
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java65
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorLight.vp4
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_attribute.glsl2
-rw-r--r--src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_uniform.glsl3
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/DimensionReadOnly.java)2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Point.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/PointReadOnly.java)2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java (renamed from src/nativewindow/classes/javax/media/nativewindow/util/RectangleReadOnly.java)2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java8
-rw-r--r--src/newt/classes/com/jogamp/newt/ScreenMode.java4
-rw-r--r--src/newt/classes/com/jogamp/newt/util/MonitorMode.java8
-rw-r--r--src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java20
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java4
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/test/GearsGL2ES1.java422
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java71
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java111
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java232
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java224
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java75
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquare.java)6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/newt/TestGearsGL2ES1NEWT.java)16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java222
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java93
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquare0.java)38
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp50
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.vp48
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/GearsGL2ES1.java441
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java4
73 files changed, 2147 insertions, 1396 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
index 4296ebee2..13c61766e 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java
@@ -1,33 +1,26 @@
package com.jogamp.opengl.util;
-import com.jogamp.common.nio.Buffers;
-import java.security.*;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
-import javax.media.opengl.*;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLException;
+import javax.media.opengl.fixedfunc.GLPointerFuncUtil;
-import com.jogamp.opengl.util.glsl.*;
+import jogamp.opengl.util.GLFixedArrayHandler;
+import jogamp.opengl.util.glsl.GLSLArrayHandler;
-import jogamp.opengl.SystemUtil;
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.opengl.util.glsl.ShaderState;
-import java.nio.*;
public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayDataEditable {
/**
- * 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 = AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return SystemUtil.getenv("JOGL_VBO_BUG");
- }
- }) != null;
-
- /**
* Create a client side buffer object, using a predefined fixed function array index
* and starting with a new created Buffer object with initialSize size
*
@@ -36,10 +29,10 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
* EnableVertexAttribArray and VertexAttribPointer calls,
* and a predefined vertex attribute variable name will be chosen.
*
+ * The default name mapping will be used,
+ * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}.
+ *
* @param index The GL array index
- * @param name The optional custom name for the GL array index, maybe null.
- * If null, the default name mapping will be used, see 'getPredefinedArrayIndexName(int)'.
- * This name might be used as the shader attribute name.
* @param comps The array component number
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
@@ -47,12 +40,12 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataClient createFixed(int index, String name, int comps, int dataType, boolean normalized, int initialSize)
+ public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int initialSize)
throws GLException
{
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
- adc.init(name, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler, 0, 0, 0, 0);
+ adc.init(null, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler, 0, 0, 0, 0);
return adc;
}
@@ -65,10 +58,10 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
* EnableVertexAttribArray and VertexAttribPointer calls,
* and a predefined vertex attribute variable name will be chosen.
*
+ * The default name mapping will be used,
+ * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}.
+ *
* @param index The GL array index
- * @param name The optional custom name for the GL array index, maybe null.
- * If null, the default name mapping will be used, see 'getPredefinedArrayIndexName(int)'.
- * This name might be used as the shader attribute name.
* @param comps The array component number
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
@@ -77,13 +70,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataClient createFixed(int index, String name, int comps, int dataType, boolean normalized, int stride,
+ public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int stride,
Buffer buffer)
throws GLException
{
GLArrayDataClient adc = new GLArrayDataClient();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(adc);
- adc.init(name, index, comps, dataType, normalized, stride, buffer, comps*comps, false, glArrayHandler, 0, 0, 0, 0);
+ adc.init(null, index, comps, dataType, normalized, stride, buffer, comps*comps, false, glArrayHandler, 0, 0, 0, 0);
return adc;
}
@@ -271,9 +264,9 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData
", isVertexAttribute "+isVertexAttribute+
", dataType "+componentType+
", bufferClazz "+componentClazz+
- ", elements "+getElementNumber()+
+ ", elements "+getElementCount()+
", components "+components+
- ", stride "+stride+"u "+strideB+"b "+strideL+"c"+
+ ", stride "+strideB+"b "+strideL+"c"+
", initialSize "+initialSize+
", sealed "+sealed+
", bufferEnabled "+bufferEnabled+
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
index b244184b0..38207cd2d 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
@@ -1,11 +1,22 @@
package com.jogamp.opengl.util;
-import javax.media.opengl.*;
+import java.nio.Buffer;
-import java.nio.*;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLArrayData;
+import javax.media.opengl.GLException;
+import javax.media.opengl.fixedfunc.GLPointerFuncUtil;
-import com.jogamp.opengl.util.glsl.*;
+import jogamp.opengl.util.GLDataArrayHandler;
+import jogamp.opengl.util.GLFixedArrayHandler;
+import jogamp.opengl.util.GLFixedArrayHandlerFlat;
+import jogamp.opengl.util.GLFixedArrayHandlerInterleaved;
+import jogamp.opengl.util.glsl.GLSLArrayHandler;
+import jogamp.opengl.util.glsl.GLSLArrayHandlerFlat;
+
+import com.jogamp.opengl.util.glsl.ShaderState;
public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataEditable {
@@ -22,6 +33,9 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* EnableVertexAttribArray and VertexAttribPointer calls,
* and a predefined vertex attribute variable name will be chosen.
*
+ * The default name mapping will be used,
+ * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}.
+ *
* @param index The GL array index
* @param name The optional custom name for the GL array index, maybe null.
* If null, the default name mapping will be used, see 'getPredefinedArrayIndexName(int)'.
@@ -35,13 +49,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataServer createFixed(int index, String name, int comps, int dataType, boolean normalized, int stride,
+ public static GLArrayDataServer createFixed(int index, int comps, int dataType, boolean normalized, int stride,
Buffer buffer, int vboUsage)
throws GLException
{
GLArrayDataServer ads = new GLArrayDataServer();
GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
- ads.init(name, index, comps, dataType, normalized, stride, buffer, buffer.limit(), false, glArrayHandler,
+ ads.init(null, index, comps, dataType, normalized, stride, buffer, buffer.limit(), false, glArrayHandler,
0, 0, vboUsage, GL.GL_ARRAY_BUFFER);
return ads;
}
@@ -55,10 +69,10 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
* EnableVertexAttribArray and VertexAttribPointer calls,
* and a predefined vertex attribute variable name will be chosen.
*
+ * The default name mapping will be used,
+ * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}.
+ *
* @param index The GL array index
- * @param name The optional custom name for the GL array index, maybe null.
- * If null, the default name mapping will be used, see 'getPredefinedArrayIndexName(int)'.
- * This name might be used as the shader attribute name.
* @param comps The array component number
* @param dataType The array index GL data type
* @param normalized Whether the data shall be normalized
@@ -67,14 +81,14 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
*
* @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int)
*/
- public static GLArrayDataServer createFixed(int index, String name, int comps, int dataType, boolean normalized, int initialSize,
+ public static GLArrayDataServer createFixed(int index, int comps, int dataType, boolean normalized, int initialSize,
int vboUsage)
throws GLException
{
- GLArrayDataServer ads = new GLArrayDataServer();
- GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
- ads.init(name, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler,
- 0, 0, vboUsage, GL.GL_ARRAY_BUFFER);
+ GLArrayDataServer ads = new GLArrayDataServer();
+ GLArrayHandler glArrayHandler = new GLFixedArrayHandler(ads);
+ ads.init(null, index, comps, dataType, normalized, 0, null, initialSize, false, glArrayHandler,
+ 0, 0, vboUsage, GL.GL_ARRAY_BUFFER);
return ads;
}
@@ -174,6 +188,51 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
}
+ public static GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize,
+ int vboUsage)
+ throws GLException
+ {
+ GLArrayDataServer ads = new GLArrayDataServer();
+ GLArrayHandler glArrayHandler = new GLFixedArrayHandlerInterleaved(ads);
+ ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, false, 0, null, initialSize, false, glArrayHandler,
+ 0, 0, vboUsage, GL.GL_ARRAY_BUFFER);
+ return ads;
+ }
+
+ int interleavedOffset = 0;
+
+ public GLArrayData addFixedSubArray(int index, int comps) {
+ if(interleavedOffset >= getComponentCount() * getComponentSizeInBytes()) {
+ final int iOffC = interleavedOffset / getComponentSizeInBytes();
+ throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")");
+ }
+ GLArrayDataWrapper ad = GLArrayDataWrapper.createFixed(
+ index, comps, getComponentType(),
+ getNormalized(), getStride(), getBuffer(),
+ getVBOName(), interleavedOffset, getVBOUsage());
+ ad.setVBOEnabled(isVBO());
+ interleavedOffset += comps * getComponentSizeInBytes();
+ GLArrayHandler handler = new GLFixedArrayHandlerFlat(ad);
+ glArrayHandler.addSubHandler(handler);
+ return ad;
+ }
+
+ public GLArrayData addGLSLSubArray(ShaderState st, String name, int comps) {
+ if(interleavedOffset >= getComponentCount() * getComponentSizeInBytes()) {
+ final int iOffC = interleavedOffset / getComponentSizeInBytes();
+ throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")");
+ }
+ GLArrayDataWrapper ad = GLArrayDataWrapper.createGLSL(
+ name, comps, getComponentType(),
+ getNormalized(), getStride(), getBuffer(),
+ getVBOName(), interleavedOffset, getVBOUsage());
+ ad.setVBOEnabled(isVBO());
+ interleavedOffset += comps * getComponentSizeInBytes();
+ GLArrayHandler handler = new GLSLArrayHandlerFlat(st, ad);
+ glArrayHandler.addSubHandler(handler);
+ return ad;
+ }
+
//
// Data matters GLArrayData
//
@@ -213,9 +272,9 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
", isVertexAttribute "+isVertexAttribute+
", dataType "+componentType+
", bufferClazz "+componentClazz+
- ", elements "+getElementNumber()+
+ ", elements "+getElementCount()+
", components "+components+
- ", stride "+stride+"u "+strideB+"b "+strideL+"c"+
+ ", stride "+strideB+"b "+strideL+"c"+
", initialSize "+initialSize+
", vboEnabled "+vboEnabled+
", vboName "+vboName+
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
index e3b250934..da841afca 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java
@@ -2,6 +2,7 @@
package com.jogamp.opengl.util;
import javax.media.opengl.*;
+import javax.media.opengl.fixedfunc.GLPointerFuncUtil;
import jogamp.opengl.util.glsl.fixedfunc.*;
@@ -85,7 +86,7 @@ public class GLArrayDataWrapper implements GLArrayData {
}
return false;
}
- return glp.isValidArrayDataType(getIndex(), getComponentNumber(), getComponentType(), isVertexAttribute(), throwException);
+ return glp.isValidArrayDataType(getIndex(), getComponentCount(), getComponentType(), isVertexAttribute(), throwException);
}
//
@@ -114,24 +115,24 @@ public class GLArrayDataWrapper implements GLArrayData {
public final Buffer getBuffer() { return buffer; }
- public final int getComponentNumber() { return components; }
+ public final int getComponentCount() { return components; }
public final int getComponentType() { return componentType; }
- public final int getComponentSize() { return componentSize; }
+ public final int getComponentSizeInBytes() { return componentByteSize; }
- public final int getElementNumber() {
+ public final int getElementCount() {
if(null==buffer) return 0;
return ( buffer.position()==0 ) ? ( buffer.limit() / components ) : ( buffer.position() / components ) ;
}
- public final int getByteSize() {
+ public final int getSizeInBytes() {
if(null==buffer) return 0;
- return ( buffer.position()==0 ) ? ( buffer.limit() * componentSize ) : ( buffer.position() * componentSize ) ;
+ return ( buffer.position()==0 ) ? ( buffer.limit() * componentByteSize ) : ( buffer.position() * componentByteSize ) ;
}
public final boolean getNormalized() { return normalized; }
- public final int getStride() { return stride; }
+ public final int getStride() { return strideB; }
public final Class getBufferClass() { return componentClazz; }
@@ -150,9 +151,9 @@ public class GLArrayDataWrapper implements GLArrayData {
", isVertexAttribute "+isVertexAttribute+
", dataType "+componentType+
", bufferClazz "+componentClazz+
- ", elements "+getElementNumber()+
+ ", elements "+getElementCount()+
", components "+components+
- ", stride "+stride+"u "+strideB+"b "+strideL+"c"+
+ ", stride "+strideB+"b "+strideL+"c"+
", buffer "+buffer+
", vboEnabled "+vboEnabled+
", vboName "+vboName+
@@ -234,7 +235,7 @@ public class GLArrayDataWrapper implements GLArrayData {
// ok ..
} else if( GL.GL_ARRAY_BUFFER == vboTarget ) {
// check name ..
- this.name = ( null == name ) ? FixedFuncPipeline.getPredefinedArrayIndexName(index) : name ;
+ this.name = ( null == name ) ? GLPointerFuncUtil.getPredefinedArrayIndexName(index) : name ;
if(null == this.name ) {
throw new GLException("Not a valid array buffer index: "+index);
}
@@ -255,8 +256,8 @@ public class GLArrayDataWrapper implements GLArrayData {
default:
this.normalized = false;
}
- componentSize = GLBuffers.sizeOfGLType(componentType);
- if(0 > componentSize) {
+ componentByteSize = GLBuffers.sizeOfGLType(componentType);
+ if(0 > componentByteSize) {
throw new GLException("Given componentType not supported: "+componentType+":\n\t"+this);
}
if(0 >= components) {
@@ -264,16 +265,15 @@ public class GLArrayDataWrapper implements GLArrayData {
}
this.components = components;
- if(0<stride && stride<components*componentSize) {
- throw new GLException("stride ("+stride+") lower than component bytes, "+components+" * "+componentSize);
+ if(0<stride && stride<components*componentByteSize) {
+ throw new GLException("stride ("+stride+") lower than component bytes, "+components+" * "+componentByteSize);
}
- if(0<stride && stride%componentSize!=0) {
- throw new GLException("stride ("+stride+") not a multiple of bpc "+componentSize);
+ if(0<stride && stride%componentByteSize!=0) {
+ throw new GLException("stride ("+stride+") not a multiple of bpc "+componentByteSize);
}
this.buffer = data;
- this.stride=stride;
- this.strideB=(0==stride)?components*componentSize:stride;
- this.strideL=(0==stride)?components:strideB/componentSize;
+ this.strideB=(0==stride)?components*componentByteSize:stride;
+ this.strideL=strideB/componentByteSize;
this.vboName= vboName;
this.vboEnabled= 0 != vboName ;
this.vboOffset=vboOffset;
@@ -309,9 +309,8 @@ public class GLArrayDataWrapper implements GLArrayData {
protected int components;
protected int componentType;
protected Class componentClazz;
- protected int componentSize;
+ protected int componentByteSize;
protected boolean normalized;
- protected int stride; // user given stride
protected int strideB; // stride in bytes
protected int strideL; // stride in logical components
protected Buffer buffer;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayHandler.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayHandler.java
index bfabb5b01..ee80c4299 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayHandler.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayHandler.java
@@ -3,9 +3,30 @@ package com.jogamp.opengl.util;
import javax.media.opengl.*;
+/**
+ * Handles consistency of buffer data and array state.
+ * Implementations shall consider buffer types (VBO, ..), interleaved, etc.
+ * They also need to consider array state types, i.e. fixed function or GLSL.
+ */
public interface GLArrayHandler {
+ /**
+ * Implementation shall ensure the buffers data is synchronized to the GPU
+ * and the array state is enabled.
+ *
+ * @param gl current GL object
+ * @param enable true if array shall be enabled, otherwise false.
+ */
public void enableBuffer(GL gl, boolean enable);
+
+ /**
+ * Supporting interleaved arrays, where sub handlers may handle
+ * the array state and the <i>master</i> handler the buffer consistency.
+ *
+ * @param handler the sub handler
+ * @throws UnsupportedOperationException if this array handler does not support interleaved arrays
+ */
+ public void addSubHandler(GLArrayHandler handler) throws UnsupportedOperationException;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDataArrayHandler.java b/src/jogl/classes/com/jogamp/opengl/util/GLDataArrayHandler.java
deleted file mode 100644
index 74d49aa6c..000000000
--- a/src/jogl/classes/com/jogamp/opengl/util/GLDataArrayHandler.java
+++ /dev/null
@@ -1,41 +0,0 @@
-
-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);
- }
- }
- }
-}
-
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLFixedArrayHandler.java b/src/jogl/classes/com/jogamp/opengl/util/GLFixedArrayHandler.java
deleted file mode 100644
index a825ca690..000000000
--- a/src/jogl/classes/com/jogamp/opengl/util/GLFixedArrayHandler.java
+++ /dev/null
@@ -1,65 +0,0 @@
-
-package com.jogamp.opengl.util;
-
-import javax.media.opengl.*;
-import javax.media.opengl.fixedfunc.*;
-import com.jogamp.opengl.util.*;
-import java.nio.*;
-
-public class GLFixedArrayHandler implements GLArrayHandler {
- private GLArrayDataEditable ad;
-
- public GLFixedArrayHandler(GLArrayDataEditable ad) {
- this.ad = ad;
- }
-
- private 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(ad.getVBOTarget(), ad.getVBOName());
- if(!ad.isVBOWritten()) {
- if(null!=buffer) {
- gl.glBufferData(ad.getVBOTarget(), buffer.limit() * ad.getComponentSize(), buffer, ad.getVBOUsage());
- }
- ad.setVBOWritten(true);
- }
- passArrayPointer(glp);
- } else if(null!=buffer) {
- passArrayPointer(glp);
- ad.setVBOWritten(true);
- }
- } else {
- if(ad.isVBO()) {
- gl.glBindBuffer(ad.getVBOTarget(), 0);
- }
- glp.glDisableClientState(ad.getIndex());
- }
- }
-}
-
diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
index 0e1b7926e..bf6e8c025 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java
@@ -48,49 +48,36 @@ public class PMVMatrix implements GLMatrixFunc {
public PMVMatrix() {
projectFloat = new ProjectFloat();
- matrixIdent = Buffers.newDirectFloatBuffer(1*16);
- projectFloat.gluMakeIdentityf(matrixIdent);
- matrixIdent.rewind();
-
+ // I Identity
// T Texture
// P Projection
// Mv ModelView
// Mvi Modelview-Inverse
// Mvit Modelview-Inverse-Transpose
- // Pmv P * Mv
- matrixTPMvMvitPmv = Buffers.newDirectFloatBuffer(6*16); // grouping T + P + Mv + Mvi + Mvit + Pmv
- matrixPMvMvitPmv = slice(matrixTPMvMvitPmv, 1*16, 5*16); // grouping P + Mv + Mvi + Mvit + Pmv
- matrixT = slice(matrixTPMvMvitPmv, 0*16, 1*16); // T
- matrixPMvMvit = slice(matrixTPMvMvitPmv, 1*16, 4*16); // grouping P + Mv + Mvi + Mvit
- matrixPMvMvi = slice(matrixTPMvMvitPmv, 1*16, 3*16); // grouping P + Mv + Mvi
- matrixPMv = slice(matrixTPMvMvitPmv, 1*16, 2*16); // grouping P + Mv
- matrixP = slice(matrixTPMvMvitPmv, 1*16, 1*16); // P
- matrixMv = slice(matrixTPMvMvitPmv, 2*16, 1*16); // Mv
- matrixMvi = slice(matrixTPMvMvitPmv, 3*16, 1*16); // Mvi
- matrixMvit = slice(matrixTPMvMvitPmv, 4*16, 1*16); // Mvit
- matrixPmv = slice(matrixTPMvMvitPmv, 5*16, 1*16); // Pmv
- matrixTPMvMvitPmv.rewind();
-
- matrixMvit3 = Buffers.newDirectFloatBuffer(3*3);
-
- localBuf = Buffers.newDirectFloatBuffer(6*16);
-
- matrixMult=slice(localBuf, 0*16, 16);
-
- matrixTrans=slice(localBuf, 1*16, 16);
- projectFloat.gluMakeIdentityf(matrixTrans);
-
- matrixRot=slice(localBuf, 2*16, 16);
- projectFloat.gluMakeIdentityf(matrixRot);
-
- matrixScale=slice(localBuf, 3*16, 16);
- projectFloat.gluMakeIdentityf(matrixScale);
-
- matrixOrtho=slice(localBuf, 4*16, 16);
- projectFloat.gluMakeIdentityf(matrixOrtho);
-
- matrixFrustum=slice(localBuf, 5*16, 16);
- projectFloat.gluMakeZero(matrixFrustum);
+ matrixITPMvMvitL = Buffers.newDirectFloatBuffer(12*16); // I + T + P + Mv + Mvi + Mvit + Local
+ matrixIdent = slice(matrixITPMvMvitL, 0*16, 1*16); // I
+ matrixTex = slice(matrixITPMvMvitL, 1*16, 1*16); // T
+ matrixPMvMvit = slice(matrixITPMvMvitL, 2*16, 4*16); // P + Mv + Mvi + Mvit
+ matrixPMvMvi = slice(matrixITPMvMvitL, 2*16, 3*16); // P + Mv + Mvi
+ matrixPMv = slice(matrixITPMvMvitL, 2*16, 2*16); // P + Mv
+ matrixP = slice(matrixITPMvMvitL, 2*16, 1*16); // P
+ matrixMv = slice(matrixITPMvMvitL, 3*16, 1*16); // Mv
+ matrixMvi = slice(matrixITPMvMvitL, 4*16, 1*16); // Mvi
+ matrixMvit = slice(matrixITPMvMvitL, 5*16, 1*16); // Mvit
+ matrixMult = slice(matrixITPMvMvitL, 6*16, 1*16);
+ matrixTrans = slice(matrixITPMvMvitL, 7*16, 1*16);
+ matrixRot = slice(matrixITPMvMvitL, 8*16, 1*16);
+ matrixScale = slice(matrixITPMvMvitL, 9*16, 1*16);
+ matrixOrtho = slice(matrixITPMvMvitL, 10*16, 1*16);
+ matrixFrustum = slice(matrixITPMvMvitL, 11*16, 1*16);
+ matrixITPMvMvitL.rewind();
+
+ ProjectFloat.gluMakeIdentityf(matrixIdent);
+ ProjectFloat.gluMakeIdentityf(matrixTrans);
+ ProjectFloat.gluMakeIdentityf(matrixRot);
+ ProjectFloat.gluMakeIdentityf(matrixScale);
+ ProjectFloat.gluMakeIdentityf(matrixOrtho);
+ ProjectFloat.gluMakeZero(matrixFrustum);
vec3f=new float[3];
@@ -105,6 +92,7 @@ public class PMVMatrix implements GLMatrixFunc {
glMatrixMode(GL.GL_TEXTURE);
glLoadIdentity();
setDirty();
+ update();
}
public void destroy() {
@@ -112,17 +100,8 @@ public class PMVMatrix implements GLMatrixFunc {
projectFloat.destroy(); projectFloat=null;
}
- if(null!=matrixIdent) {
- matrixIdent.clear(); matrixIdent=null;
- }
- if(null!=matrixTPMvMvitPmv) {
- matrixTPMvMvitPmv.clear(); matrixTPMvMvitPmv=null;
- }
- if(null!=matrixMvit3) {
- matrixMvit3.clear(); matrixMvit3=null;
- }
- if(null!=localBuf) {
- localBuf.clear(); localBuf=null;
+ if(null!=matrixITPMvMvitL) {
+ matrixITPMvMvitL.clear(); matrixITPMvMvitL=null;
}
if(null!=matrixPStack) {
@@ -139,8 +118,8 @@ public class PMVMatrix implements GLMatrixFunc {
matrixTStack.clear(); matrixTStack=null;
}
- matrixTPMvMvitPmv=null; matrixPMvMvit=null; matrixPMvMvitPmv=null; matrixPMvMvi=null; matrixPMv=null;
- matrixP=null; matrixT=null; matrixMv=null; matrixMvi=null; matrixMvit=null; matrixPmv=null;
+ matrixITPMvMvitL=null; matrixPMvMvit=null; matrixPMvMvi=null; matrixPMv=null;
+ matrixP=null; matrixTex=null; matrixMv=null; matrixMvi=null; matrixMvit=null;
matrixMult=null; matrixTrans=null; matrixRot=null; matrixScale=null; matrixOrtho=null; matrixFrustum=null;
}
@@ -228,17 +207,20 @@ public class PMVMatrix implements GLMatrixFunc {
return modified!=0;
}
+ /**
+ * Update the derived Mvi, Mvit and Pmv matrices
+ * in case Mv or P has changed.
+ *
+ * @return
+ */
public boolean update() {
- // if(0==modified) return false;
+ if(0==modified) return false;
- // int res = modified;
- int res = DIRTY_MODELVIEW | DIRTY_PROJECTION ;
+ final int res = modified;
+ // int res = DIRTY_MODELVIEW | DIRTY_PROJECTION ;
if( (res&DIRTY_MODELVIEW)!=0 ) {
setMviMvit();
}
- if( (res&DIRTY_MODELVIEW)!=0 || (res&DIRTY_PROJECTION)!=0 ) {
- glMultMatrixf(matrixP, matrixMv, matrixPmv);
- }
modified=0;
return res!=0;
}
@@ -248,7 +230,7 @@ public class PMVMatrix implements GLMatrixFunc {
}
public final FloatBuffer glGetTMatrixf() {
- return matrixT;
+ return matrixTex;
}
public final FloatBuffer glGetPMatrixf() {
@@ -259,10 +241,6 @@ public class PMVMatrix implements GLMatrixFunc {
return matrixMv;
}
- public final FloatBuffer glGetPMvMvitPmvMatrixf() {
- return matrixPMvMvitPmv;
- }
-
public final FloatBuffer glGetPMvMvitMatrixf() {
return matrixPMvMvit;
}
@@ -279,14 +257,6 @@ public class PMVMatrix implements GLMatrixFunc {
return matrixMvi;
}
- public final FloatBuffer glGetPmvMatrixf() {
- return matrixPmv;
- }
-
- public final FloatBuffer glGetNormalMatrixf() {
- return matrixMvit3;
- }
-
/*
* @return the current matrix
*/
@@ -304,7 +274,7 @@ public class PMVMatrix implements GLMatrixFunc {
} else if(matrixName==GL_PROJECTION) {
return matrixP;
} else if(matrixName==GL.GL_TEXTURE) {
- return matrixT;
+ return matrixTex;
} else {
throw new GLException("unsupported matrixName: "+matrixName);
}
@@ -403,9 +373,9 @@ public class PMVMatrix implements GLMatrixFunc {
matrixP.rewind();
modified |= DIRTY_PROJECTION ;
} else if(matrixMode==GL.GL_TEXTURE) {
- matrixT.clear();
- matrixT.put(values, offset, len);
- matrixT.rewind();
+ matrixTex.clear();
+ matrixTex.put(values, offset, len);
+ matrixTex.rewind();
modified |= DIRTY_TEXTURE ;
}
}
@@ -423,9 +393,9 @@ public class PMVMatrix implements GLMatrixFunc {
matrixP.rewind();
modified |= DIRTY_PROJECTION ;
} else if(matrixMode==GL.GL_TEXTURE) {
- matrixT.clear();
- matrixT.put(m);
- matrixT.rewind();
+ matrixTex.clear();
+ matrixTex.put(m);
+ matrixTex.rewind();
modified |= DIRTY_TEXTURE ;
}
m.position(spos);
@@ -454,8 +424,8 @@ public class PMVMatrix implements GLMatrixFunc {
matrixP.rewind();
matrixPStack.add(0, stackEntry);
} else if(matrixMode==GL.GL_TEXTURE) {
- matrixT.get(stackEntry);
- matrixT.rewind();
+ matrixTex.get(stackEntry);
+ matrixTex.rewind();
matrixTStack.add(0, stackEntry);
}
}
@@ -474,9 +444,9 @@ public class PMVMatrix implements GLMatrixFunc {
matrixIdent.rewind();
modified |= DIRTY_PROJECTION ;
} else if(matrixMode==GL.GL_TEXTURE) {
- matrixT.clear();
- matrixT.put(matrixIdent);
- matrixT.rewind();
+ matrixTex.clear();
+ matrixTex.put(matrixIdent);
+ matrixTex.rewind();
matrixIdent.rewind();
modified |= DIRTY_TEXTURE ;
}
@@ -496,10 +466,10 @@ public class PMVMatrix implements GLMatrixFunc {
matrixP.rewind();
modified |= DIRTY_PROJECTION ;
} else if(matrixMode==GL.GL_TEXTURE) {
- glMultMatrixf(matrixT, m, matrixMult);
- matrixT.clear();
- matrixT.put(matrixMult);
- matrixT.rewind();
+ glMultMatrixf(matrixTex, m, matrixMult);
+ matrixTex.clear();
+ matrixTex.put(matrixMult);
+ matrixTex.rewind();
modified |= DIRTY_TEXTURE ;
}
matrixMult.rewind();
@@ -519,10 +489,10 @@ public class PMVMatrix implements GLMatrixFunc {
matrixP.rewind();
modified |= DIRTY_PROJECTION ;
} else if(matrixMode==GL.GL_TEXTURE) {
- glMultMatrixf(matrixT, m, m_offset, matrixMult);
- matrixT.clear();
- matrixT.put(matrixMult);
- matrixT.rewind();
+ glMultMatrixf(matrixTex, m, m_offset, matrixMult);
+ matrixTex.clear();
+ matrixTex.put(matrixMult);
+ matrixTex.rewind();
modified |= DIRTY_TEXTURE ;
}
matrixMult.rewind();
@@ -541,13 +511,13 @@ public class PMVMatrix implements GLMatrixFunc {
}
public final void glRotatef(final float angdeg, float x, float y, float z) {
- float angrad = angdeg * (float) Math.PI / 180;
+ float angrad = angdeg * (float) Math.PI / 180.0f;
float c = (float)Math.cos(angrad);
float ic= 1.0f - c;
float s = (float)Math.sin(angrad);
vec3f[0]=x; vec3f[1]=y; vec3f[2]=z;
- projectFloat.normalize(vec3f);
+ ProjectFloat.normalize(vec3f);
x = vec3f[0]; y = vec3f[1]; z = vec3f[2];
// Rotation matrix:
@@ -661,19 +631,11 @@ public class PMVMatrix implements GLMatrixFunc {
matrixMvit.put(j+i*4, matrixMvi.get(i+j*4));
}
}
-
- // fetch 3x3
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- matrixMvit3.put(i+j*3, matrixMvit.get(i+j*4));
- }
- }
}
- protected FloatBuffer matrixIdent;
- protected FloatBuffer matrixTPMvMvitPmv, matrixPMvMvit, matrixPMvMvitPmv, matrixPMvMvi, matrixPMv, matrixP, matrixT, matrixMv, matrixMvi, matrixMvit, matrixPmv;
- protected FloatBuffer matrixMvit3;
- protected FloatBuffer localBuf, matrixMult, matrixTrans, matrixRot, matrixScale, matrixOrtho, matrixFrustum;
+ protected FloatBuffer matrixITPMvMvitL;
+ protected FloatBuffer matrixIdent, matrixPMvMvit, matrixPMvMvi, matrixPMv, matrixP, matrixTex, matrixMv, matrixMvi, matrixMvit;
+ protected FloatBuffer matrixMult, matrixTrans, matrixRot, matrixScale, matrixOrtho, matrixFrustum;
protected float[] vec3f;
protected List/*FloatBuffer*/ matrixTStack, matrixPStack, matrixMvStack;
protected int matrixMode = GL_MODELVIEW;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
index 565b5ab1c..8dd09ffab 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
@@ -229,7 +229,7 @@ public class ShaderProgram {
*
* @param gl
* @param verboseOut
- * @return
+ * @return true if program was successfully linked and is valid, otherwise false
*
* @see #init(GL2ES2)
*/
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
index c2b3308db..d92a7aa22 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
@@ -63,30 +63,30 @@ public class FixedFuncUtil {
* @see javax.media.opengl.fixedfunc.GLPointerFunc#glTexCoordPointer
*/
public static String getPredefinedArrayIndexName(int glArrayIndex) {
- return FixedFuncPipeline.getPredefinedArrayIndexName(glArrayIndex);
+ return GLPointerFuncUtil.getPredefinedArrayIndexName(glArrayIndex);
}
/**
* String name for
* @see javax.media.opengl.GL2#GL_VERTEX_ARRAY
*/
- public static final String mgl_Vertex = FixedFuncPipeline.mgl_Vertex;
+ public static final String mgl_Vertex = GLPointerFuncUtil.mgl_Vertex;
/**
* String name for
* @see javax.media.opengl.GL2#GL_NORMAL_ARRAY
*/
- public static final String mgl_Normal = FixedFuncPipeline.mgl_Normal;
+ public static final String mgl_Normal = GLPointerFuncUtil.mgl_Normal;
/**
* String name for
* @see javax.media.opengl.GL2#GL_COLOR_ARRAY
*/
- public static final String mgl_Color = FixedFuncPipeline.mgl_Color;
+ public static final String mgl_Color = GLPointerFuncUtil.mgl_Color;
/**
* String name for
* @see javax.media.opengl.GL2#GL_TEXTURE_COORD_ARRAY
*/
- public static final String mgl_MultiTexCoord = FixedFuncPipeline.mgl_MultiTexCoord;
+ public static final String mgl_MultiTexCoord = GLPointerFuncUtil.mgl_MultiTexCoord;
}
diff --git a/src/jogl/classes/javax/media/opengl/GLArrayData.java b/src/jogl/classes/javax/media/opengl/GLArrayData.java
index 4562c1c0b..26f0f6be2 100644
--- a/src/jogl/classes/javax/media/opengl/GLArrayData.java
+++ b/src/jogl/classes/javax/media/opengl/GLArrayData.java
@@ -116,7 +116,7 @@ public interface GLArrayData {
/**
* The number of components per element
*/
- public int getComponentNumber();
+ public int getComponentCount();
/**
* The component's GL data type, ie. GL_FLOAT
@@ -126,19 +126,19 @@ public interface GLArrayData {
/**
* The component's size in bytes
*/
- public int getComponentSize();
+ public int getComponentSizeInBytes();
/**
* The current number of used elements.<br>
* In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
*/
- public int getElementNumber();
+ public int getElementCount();
/**
- * The current number of used bytes.<br>
+ * The currently used size in bytes.<br>
* In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
*/
- public int getByteSize();
+ public int getSizeInBytes();
/**
* True, if GL shall normalize fixed point data while converting
@@ -146,10 +146,9 @@ public interface GLArrayData {
*/
public boolean getNormalized();
- /**
- * The distance to the next payload,
- * allowing interleaved arrays.
- */
+ /**
+ * @return the byte offset between consecutive components
+ */
public int getStride();
public String toString();
diff --git a/src/jogl/classes/javax/media/opengl/GLUniformData.java b/src/jogl/classes/javax/media/opengl/GLUniformData.java
index 9b0d5f151..5c9388be2 100644
--- a/src/jogl/classes/javax/media/opengl/GLUniformData.java
+++ b/src/jogl/classes/javax/media/opengl/GLUniformData.java
@@ -59,10 +59,10 @@ public class GLUniformData {
init(name, rows, columns, data);
}
- public void setData(int data) { init(new Integer(data)); }
- public void setData(float data) { init(new Float(data)); }
- public void setData(IntBuffer data) { init(data); }
- public void setData(FloatBuffer data) { init(data); }
+ public GLUniformData setData(int data) { init(new Integer(data)); return this; }
+ public GLUniformData setData(float data) { init(new Float(data)); return this; }
+ public GLUniformData setData(IntBuffer data) { init(data); return this; }
+ public GLUniformData setData(FloatBuffer data) { init(data); return this; }
public int intValue() { return ((Integer)data).intValue(); };
public float floatValue() { return ((Float)data).floatValue(); };
@@ -105,8 +105,8 @@ public class GLUniformData {
private void init(Object data) {
if(data instanceof Buffer) {
- int sz = rows*columns;
- Buffer buffer = (Buffer)data;
+ final int sz = rows*columns;
+ final Buffer buffer = (Buffer)data;
if(buffer.limit()<sz || 0!=buffer.limit()%sz) {
throw new GLException("data buffer size invalid: new buffer limit: "+buffer.limit()+"\n\t"+this);
}
@@ -127,7 +127,7 @@ public class GLUniformData {
/**
* Sets the determined location of the shader uniform.
*/
- public void setLocation(int location) { this.location=location; }
+ public GLUniformData setLocation(int location) { this.location=location; return this; }
public Object getObject() {
return data;
diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java
index 5563ea9c8..001f4f05b 100644
--- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java
+++ b/src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java
@@ -1,13 +1,34 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
*/
package javax.media.opengl.fixedfunc;
-import java.nio.*;
-
-import javax.media.opengl.*;
-
public interface GLLightingFunc {
public static final int GL_LIGHT0 = 0x4000;
public static final int GL_LIGHT1 = 0x4001;
diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java
index b899f3c0a..a34d490c0 100644
--- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java
+++ b/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java
@@ -1,5 +1,30 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
*/
package javax.media.opengl.fixedfunc;
diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java
index ed7bef5d4..786835f4d 100644
--- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java
+++ b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java
@@ -1,11 +1,34 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
*/
package javax.media.opengl.fixedfunc;
-import java.nio.*;
-
import javax.media.opengl.*;
public interface GLPointerFunc {
diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java
new file mode 100644
index 000000000..e52154c7d
--- /dev/null
+++ b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package javax.media.opengl.fixedfunc;
+
+public class GLPointerFuncUtil {
+ public static final String mgl_Vertex = "mgl_Vertex";
+ public static final String mgl_Normal = "mgl_Normal";
+ public static final String mgl_Color = "mgl_Color";
+ public static final String mgl_MultiTexCoord = "mgl_MultiTexCoord" ;
+ public static final String mgl_InterleaveArray = "mgl_InterleaveArray" ; // magic name for interleaved arrays w/ sub-arrays
+
+ /**
+ * @param glArrayIndex the fixed function array index
+ * @return default fixed function array name
+ */
+ public static String getPredefinedArrayIndexName(int glArrayIndex) {
+ switch(glArrayIndex) {
+ case GLPointerFunc.GL_VERTEX_ARRAY:
+ return mgl_Vertex;
+ case GLPointerFunc.GL_NORMAL_ARRAY:
+ return mgl_Normal;
+ case GLPointerFunc.GL_COLOR_ARRAY:
+ return mgl_Color;
+ case GLPointerFunc.GL_TEXTURE_COORD_ARRAY:
+ return mgl_MultiTexCoord;
+ }
+ return null;
+ }
+}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
index 6427bcd48..2d13f5ba0 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
@@ -212,7 +212,7 @@ public class VBORegion2PES2 extends GLRegion {
texCoordFboAttr.enableBuffer(gl, true);
indicesFbo.enableBuffer(gl, true);
- gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesFbo.getElementNumber() * indicesFbo.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesFbo.getElementCount() * indicesFbo.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0);
verticeFboAttr.enableBuffer(gl, false);
texCoordFboAttr.enableBuffer(gl, false);
@@ -278,7 +278,7 @@ public class VBORegion2PES2 extends GLRegion {
texCoordTxtAttr.enableBuffer(gl, true);
indicesTxt.enableBuffer(gl, true);
- gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesTxt.getElementNumber() * indicesTxt.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesTxt.getElementCount() * indicesTxt.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0);
verticeTxtAttr.enableBuffer(gl, false);
texCoordTxtAttr.enableBuffer(gl, false);
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index dc4e3a6e0..83cd6fab9 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -130,7 +130,7 @@ public class VBORegionSPES2 extends GLRegion {
texCoordAttr.enableBuffer(gl, true);
indices.enableBuffer(gl, true);
- gl.glDrawElements(GL2ES2.GL_TRIANGLES, indices.getElementNumber() * indices.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, indices.getElementCount() * indices.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0);
verticeAttr.enableBuffer(gl, false);
texCoordAttr.enableBuffer(gl, false);
diff --git a/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java
new file mode 100644
index 000000000..718b63822
--- /dev/null
+++ b/src/jogl/classes/jogamp/opengl/util/GLDataArrayHandler.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.opengl.util;
+
+import javax.media.opengl.*;
+import com.jogamp.opengl.util.*;
+
+import java.nio.*;
+
+/**
+ * Used for pure VBO data arrays, i.e. where the buffer data
+ * does not represents a specific array name.
+ */
+public class GLDataArrayHandler implements GLArrayHandler {
+ private GLArrayDataEditable ad;
+
+ public GLDataArrayHandler(GLArrayDataEditable ad) {
+ this.ad = ad;
+ if(!ad.isVBO()) {
+ // makes no sense otherwise
+ throw new GLException("GLDataArrayHandler can only handle VBOs.");
+ }
+ }
+
+ public final void addSubHandler(GLArrayHandler handler) {
+ throw new UnsupportedOperationException();
+ }
+
+ public final void enableBuffer(GL gl, boolean enable) {
+ if(enable) {
+ Buffer buffer = ad.getBuffer();
+
+ // 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.getComponentSizeInBytes(), buffer, ad.getVBOUsage());
+ }
+ ad.setVBOWritten(true);
+ }
+ } else {
+ gl.glBindBuffer(ad.getVBOTarget(), 0);
+ }
+ }
+}
+
diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java
new file mode 100644
index 000000000..e365f0f4b
--- /dev/null
+++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandler.java
@@ -0,0 +1,99 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.opengl.util;
+
+import javax.media.opengl.*;
+import javax.media.opengl.fixedfunc.*;
+
+import com.jogamp.opengl.util.GLArrayDataEditable;
+import com.jogamp.opengl.util.GLArrayHandler;
+
+import java.nio.*;
+
+/**
+ * Used for 1:1 fixed function arrays, i.e. where the buffer data
+ * represents this array only.
+ */
+public class GLFixedArrayHandler implements GLArrayHandler {
+ private GLArrayDataEditable ad;
+
+ public GLFixedArrayHandler(GLArrayDataEditable ad) {
+ this.ad = ad;
+ }
+
+ public final void addSubHandler(GLArrayHandler handler) {
+ throw new UnsupportedOperationException();
+ }
+
+ private 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 final 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.getComponentSizeInBytes(), buffer, ad.getVBOUsage());
+ }
+ ad.setVBOWritten(true);
+ }
+ }
+ passArrayPointer(glp);
+ glp.glEnableClientState(ad.getIndex());
+ } else {
+ glp.glDisableClientState(ad.getIndex());
+ if(ad.isVBO()) {
+ gl.glBindBuffer(ad.getVBOTarget(), 0);
+ }
+ }
+ }
+}
+
diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java
new file mode 100644
index 000000000..e1cf5d572
--- /dev/null
+++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerFlat.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.opengl.util;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GLArrayData;
+import javax.media.opengl.GLException;
+import javax.media.opengl.fixedfunc.GLPointerFunc;
+
+import com.jogamp.opengl.util.GLArrayHandler;
+
+/**
+ * Used for interleaved fixed function arrays, i.e. where the buffer data itself is handled
+ * separately and interleaves many arrays.
+ */
+public class GLFixedArrayHandlerFlat implements GLArrayHandler {
+ private GLArrayData ad;
+
+ public GLFixedArrayHandlerFlat(GLArrayData ad) {
+ this.ad = ad;
+ }
+
+ public final void addSubHandler(GLArrayHandler handler) {
+ throw new UnsupportedOperationException();
+ }
+
+ private 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 final void enableBuffer(GL gl, boolean enable) {
+ GLPointerFunc glp = gl.getGL2ES1();
+ if(enable) {
+ passArrayPointer(glp);
+ glp.glEnableClientState(ad.getIndex());
+ } else {
+ glp.glDisableClientState(ad.getIndex());
+ }
+ }
+}
+
diff --git a/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerInterleaved.java
new file mode 100644
index 000000000..838032646
--- /dev/null
+++ b/src/jogl/classes/jogamp/opengl/util/GLFixedArrayHandlerInterleaved.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.opengl.util;
+
+import javax.media.opengl.*;
+import javax.media.opengl.fixedfunc.*;
+
+import com.jogamp.opengl.util.GLArrayDataEditable;
+import com.jogamp.opengl.util.GLArrayHandler;
+
+import java.nio.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Interleaved fixed function arrays, i.e. where this buffer data
+ * represents many arrays.
+ */
+public class GLFixedArrayHandlerInterleaved implements GLArrayHandler {
+ private GLArrayDataEditable ad;
+ private List<GLArrayHandler> subArrays = new ArrayList<GLArrayHandler>();
+
+ public GLFixedArrayHandlerInterleaved(GLArrayDataEditable ad) {
+ this.ad = ad;
+ }
+
+ public final void addSubHandler(GLArrayHandler handler) {
+ subArrays.add(handler);
+ }
+
+ private final void enableSubBuffer(GL gl, boolean enable) {
+ for(int i=0; i<subArrays.size(); i++) {
+ subArrays.get(i).enableBuffer(gl, enable);
+ }
+ }
+
+ public final void enableBuffer(GL gl, boolean enable) {
+ 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.getComponentSizeInBytes(), buffer, ad.getVBOUsage());
+ }
+ ad.setVBOWritten(true);
+ }
+ }
+ enableSubBuffer(gl, true);
+ } else {
+ enableSubBuffer(gl, false);
+ if(ad.isVBO()) {
+ gl.glBindBuffer(ad.getVBOTarget(), 0);
+ }
+ }
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
index cc9be681c..b4b7b5ace 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/GLSLArrayHandler.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.util.glsl;
+package jogamp.opengl.util.glsl;
import java.nio.Buffer;
@@ -35,9 +35,13 @@ import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLException;
import com.jogamp.opengl.util.GLArrayDataEditable;
import com.jogamp.opengl.util.GLArrayHandler;
+import com.jogamp.opengl.util.glsl.ShaderState;
+/**
+ * Used for 1:1 GLSL arrays, i.e. where the buffer data
+ * represents this array only.
+ */
public class GLSLArrayHandler implements GLArrayHandler {
- private static final boolean DEBUG = ShaderState.DEBUG;
private GLArrayDataEditable ad;
private ShaderState st;
@@ -46,26 +50,22 @@ public class GLSLArrayHandler implements GLArrayHandler {
this.ad = ad;
}
- public void enableBuffer(GL gl, boolean enable) {
- if(!gl.isGL2ES2()) {
- throw new GLException("GLSLArrayHandler expects a GL2ES2 implementation");
- }
+ public final void addSubHandler(GLArrayHandler handler) {
+ throw new UnsupportedOperationException();
+ }
+
+ public final void enableBuffer(GL gl, boolean enable) {
GL2ES2 glsl = gl.getGL2ES2();
if(enable) {
- st.enableVertexAttribArray(glsl, ad);
-
Buffer buffer = ad.getBuffer();
if(ad.isVBO()) {
// bind and refresh the VBO / vertex-attr only if necessary
if(!ad.isVBOWritten()) {
- if(DEBUG) {
- System.err.println("XXX VA "+ad.getName()+" VBO write: "+ad.getVBOName());
- }
glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
if(null!=buffer) {
- glsl.glBufferData(ad.getVBOTarget(), ad.getByteSize(), buffer, ad.getVBOUsage());
+ glsl.glBufferData(ad.getVBOTarget(), ad.getSizeInBytes(), buffer, ad.getVBOUsage());
}
ad.setVBOWritten(true);
st.vertexAttribPointer(glsl, ad);
@@ -74,22 +74,19 @@ public class GLSLArrayHandler implements GLArrayHandler {
final int[] qi = new int[1];
glsl.glGetVertexAttribiv(ad.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0);
if(ad.getVBOName() != qi[0]) {
- if(DEBUG) {
- System.err.println("XXX VA "+ad.getName()+" VBO rebind: "+qi[0]+" -> "+ad.getVBOName());
- }
glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
st.vertexAttribPointer(glsl, ad);
}
}
} else if(null!=buffer) {
st.vertexAttribPointer(glsl, ad);
- ad.setVBOWritten(true);
}
+ st.enableVertexAttribArray(glsl, ad);
} else {
+ st.disableVertexAttribArray(glsl, ad);
if(ad.isVBO()) {
glsl.glBindBuffer(ad.getVBOTarget(), 0);
}
- st.disableVertexAttribArray(glsl, ad);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
new file mode 100644
index 000000000..38379877f
--- /dev/null
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.opengl.util.glsl;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLArrayData;
+import com.jogamp.opengl.util.GLArrayHandler;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+/**
+ * Used for interleaved GLSL arrays, i.e. where the buffer data itself is handled
+ * separately and interleaves many arrays.
+ */
+public class GLSLArrayHandlerFlat implements GLArrayHandler {
+ private ShaderState st;
+ private GLArrayData ad;
+
+ public GLSLArrayHandlerFlat(ShaderState st, GLArrayData ad) {
+ this.st = st;
+ this.ad = ad;
+ }
+
+ public final void addSubHandler(GLArrayHandler handler) {
+ throw new UnsupportedOperationException();
+ }
+
+ public final void enableBuffer(GL gl, boolean enable) {
+ GL2ES2 glsl = gl.getGL2ES2();
+
+ if(enable) {
+ st.vertexAttribPointer(glsl, ad);
+ st.enableVertexAttribArray(glsl, ad);
+ } else {
+ st.disableVertexAttribArray(glsl, ad);
+ }
+ }
+
+}
+
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java
new file mode 100644
index 000000000..ba5814a09
--- /dev/null
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java
@@ -0,0 +1,96 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.opengl.util.glsl;
+
+import java.nio.Buffer;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLException;
+
+import jogamp.opengl.util.GLFixedArrayHandlerFlat;
+
+import com.jogamp.opengl.util.GLArrayDataEditable;
+import com.jogamp.opengl.util.GLArrayHandler;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+/**
+ * Interleaved GLSL arrays, i.e. where this buffer data
+ * represents many arrays.
+ */
+public class GLSLArrayHandlerInterleaved implements GLArrayHandler {
+ private GLArrayDataEditable ad;
+ private ShaderState st;
+ private List<GLArrayHandler> subArrays = new ArrayList<GLArrayHandler>();
+
+ public GLSLArrayHandlerInterleaved(ShaderState st, GLArrayDataEditable ad) {
+ this.st = st;
+ this.ad = ad;
+ }
+
+ public final void addSubHandler(GLArrayHandler handler) {
+ subArrays.add(handler);
+ }
+
+ private final void enableSubBuffer(GL gl, boolean enable) {
+ for(int i=0; i<subArrays.size(); i++) {
+ subArrays.get(i).enableBuffer(gl, enable);
+ }
+ }
+
+ public final void enableBuffer(GL gl, boolean enable) {
+ GL2ES2 glsl = gl.getGL2ES2();
+
+ if(enable) {
+ Buffer buffer = ad.getBuffer();
+
+ if(ad.isVBO()) {
+ // always bind and refresh the VBO mgr,
+ // in case more than one attributes are in use
+ glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
+ if(!ad.isVBOWritten()) {
+ if(null!=buffer) {
+ glsl.glBufferData(ad.getVBOTarget(), ad.getSizeInBytes(), buffer, ad.getVBOUsage());
+ }
+ ad.setVBOWritten(true);
+ }
+ }
+ enableSubBuffer(gl, true);
+ } else {
+ enableSubBuffer(gl, false);
+ if(ad.isVBO()) {
+ glsl.glBindBuffer(ad.getVBOTarget(), 0);
+ }
+ }
+ }
+
+}
+
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
index 984439031..2d18ba248 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java
@@ -1,5 +1,30 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
*/
package jogamp.opengl.util.glsl.fixedfunc;
@@ -254,7 +279,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
}
public void glNormalPointer(GLArrayData array) {
- if(array.getComponentNumber()!=3) {
+ if(array.getComponentCount()!=3) {
throw new GLException("Only 3 components per normal allowed");
}
if(array.isVBO()) {
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
index 2218c2d73..7bc0c5468 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
@@ -1,3 +1,31 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
package jogamp.opengl.util.glsl.fixedfunc;
@@ -12,26 +40,6 @@ public class FixedFuncPipeline {
public static final int MAX_TEXTURE_UNITS = 8;
public static final int MAX_LIGHTS = 8;
- // We can't have any dependencies on the FixedFuncUtil class for build bootstrapping reasons
- public static final String mgl_Vertex = "mgl_Vertex";
- public static final String mgl_Normal = "mgl_Normal";
- public static final String mgl_Color = "mgl_Color";
- public static final String mgl_MultiTexCoord = "mgl_MultiTexCoord" ;
-
- public static String getPredefinedArrayIndexName(int glArrayIndex) {
- switch(glArrayIndex) {
- case GLPointerFunc.GL_VERTEX_ARRAY:
- return mgl_Vertex;
- case GLPointerFunc.GL_NORMAL_ARRAY:
- return mgl_Normal;
- case GLPointerFunc.GL_COLOR_ARRAY:
- return mgl_Color;
- case GLPointerFunc.GL_TEXTURE_COORD_ARRAY:
- return mgl_MultiTexCoord;
- }
- return null;
- }
-
public FixedFuncPipeline(GL2ES2 gl, PMVMatrix pmvMatrix) {
init(gl, pmvMatrix, FixedFuncPipeline.class, shaderSrcRootDef, shaderBinRootDef,
vertexColorFileDef, vertexColorLightFileDef, fragmentColorFileDef, fragmentColorTextureFileDef);
@@ -62,7 +70,7 @@ public class FixedFuncPipeline {
}
public String getArrayIndexName(int glArrayIndex) {
- String name = getPredefinedArrayIndexName(glArrayIndex);
+ String name = GLPointerFuncUtil.getPredefinedArrayIndexName(glArrayIndex);
switch(glArrayIndex) {
case GLPointerFunc.GL_VERTEX_ARRAY:
case GLPointerFunc.GL_NORMAL_ARRAY:
@@ -320,15 +328,10 @@ public class FixedFuncPipeline {
} else {
throw new GLException("Failed to update: mgl_PMVMatrix");
}
- ud = shaderState.getUniform(mgl_NormalMatrix);
- if(null!=ud) {
- // same data object ..
- shaderState.uniform(gl, ud);
- }
}
ud = shaderState.getUniform(mgl_ColorEnabled);
if(null!=ud) {
- int ca = (shaderState.isVertexAttribArrayEnabled(mgl_Color)==true)?1:0;
+ int ca = (shaderState.isVertexAttribArrayEnabled(GLPointerFuncUtil.mgl_Color)==true)?1:0;
if(ca!=ud.intValue()) {
ud.setData(ca);
shaderState.uniform(gl, ud);
@@ -450,13 +453,10 @@ public class FixedFuncPipeline {
shaderState.useProgram(gl, true);
// mandatory ..
- if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMviMatrixf()))) {
+ if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMvitMatrixf()))) {
throw new GLException("Error setting PMVMatrix in shader: "+this);
}
- // optional parameter ..
- shaderState.uniform(gl, new GLUniformData(mgl_NormalMatrix, 3, 3, pmvMatrix.glGetNormalMatrixf()));
-
shaderState.uniform(gl, new GLUniformData(mgl_ColorEnabled, 0));
shaderState.uniform(gl, new GLUniformData(mgl_ColorStatic, 4, zero4f));
shaderState.uniform(gl, new GLUniformData(mgl_TexCoordEnabled, 1, textureCoordsEnabled));
@@ -508,8 +508,7 @@ public class FixedFuncPipeline {
protected ShaderProgram shaderProgramColorTextureLight;
// uniforms ..
- protected static final String mgl_PMVMatrix = "mgl_PMVMatrix"; // m4fv[3]
- protected static final String mgl_NormalMatrix = "mgl_NormalMatrix"; // m4fv
+ protected static final String mgl_PMVMatrix = "mgl_PMVMatrix"; // m4fv[4] - P, Mv, Mvi and Mvit
protected static final String mgl_ColorEnabled = "mgl_ColorEnabled"; // 1i
protected static final String mgl_ColorStatic = "mgl_ColorStatic"; // 4fv
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorLight.vp b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorLight.vp
index ce203cfb9..7ce1eedcf 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorLight.vp
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorLight.vp
@@ -19,7 +19,7 @@ void main(void)
position = mgl_PMVMatrix[1] * mgl_Vertex; // vertex eye position
- normal = normalize(mgl_NormalMatrix * mgl_Normal);
+ normal = normalize(mgl_PMVMatrix[3] * mgl_Normal).xyz;
// cameraPosition: (mgl_PMVMatrix[2] * vec4(0,0,0,1.0)).xyz
cameraDir = normalize( (mgl_PMVMatrix[2] * vec4(0,0,0,1.0)).xyz - mgl_Vertex.xyz );
@@ -50,7 +50,7 @@ void main(void)
}
}
}
- ambient += mgl_FrontMaterial.ambient;
+ ambient *= mgl_FrontMaterial.ambient;
diffuse *= mgl_FrontMaterial.diffuse;
specular *= mgl_FrontMaterial.specular;
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_attribute.glsl b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_attribute.glsl
index b09bdb05a..09a11ec95 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_attribute.glsl
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_attribute.glsl
@@ -5,7 +5,7 @@
#include es_precision.glsl
attribute HIGHP vec4 mgl_Vertex;
-attribute HIGHP vec3 mgl_Normal;
+attribute HIGHP vec4 mgl_Normal;
attribute HIGHP vec4 mgl_Color;
attribute HIGHP vec4 mgl_MultiTexCoord0;
attribute HIGHP vec4 mgl_MultiTexCoord1;
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_uniform.glsl b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_uniform.glsl
index d8b3c7f95..4c4000dfa 100644
--- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_uniform.glsl
+++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_uniform.glsl
@@ -6,8 +6,7 @@
#include mgl_const.glsl
-uniform HIGHP mat4 mgl_PMVMatrix[3]; // P, Mv, and Mvi
-uniform HIGHP mat3 mgl_NormalMatrix; // transpose(inverse(ModelView)).3x3
+uniform HIGHP mat4 mgl_PMVMatrix[4]; // P, Mv, Mvi and Mvit (transpose(inverse(ModelView)) == normalMatrix)
uniform LOWP int mgl_ColorEnabled;
uniform HIGHP vec4 mgl_ColorStatic;
uniform LOWP int mgl_TexCoordEnabled[MAX_TEXTURE_UNITS];
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
index 4151c1537..ebf5b9e81 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
@@ -29,7 +29,7 @@
package javax.media.nativewindow.util;
-public class Dimension implements Cloneable, DimensionReadOnly {
+public class Dimension implements Cloneable, DimensionImmutable {
int width;
int height;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionReadOnly.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java
index 442afd4ba..262086ba3 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionReadOnly.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java
@@ -35,7 +35,7 @@ package javax.media.nativewindow.util;
* <li><code>height</code></li>
* </ul>
*/
-public interface DimensionReadOnly extends Cloneable {
+public interface DimensionImmutable extends Cloneable {
int getHeight();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
index 6db0ecfe2..89a87541e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
@@ -29,7 +29,7 @@
package javax.media.nativewindow.util;
-public class Point implements Cloneable, PointReadOnly {
+public class Point implements Cloneable, PointImmutable {
int x;
int y;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointReadOnly.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java
index 9caaf7fee..7f42138eb 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PointReadOnly.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java
@@ -30,7 +30,7 @@
package javax.media.nativewindow.util;
/** Immutable Point interface */
-public interface PointReadOnly extends Cloneable {
+public interface PointImmutable extends Cloneable {
int getX();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
index ba24bc64e..67bdcbfc7 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
@@ -28,7 +28,7 @@
package javax.media.nativewindow.util;
-public class Rectangle implements Cloneable, RectangleReadOnly {
+public class Rectangle implements Cloneable, RectangleImmutable {
int x;
int y;
int width;
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleReadOnly.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java
index 81a5a9f86..ede8ba9c5 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleReadOnly.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java
@@ -29,7 +29,7 @@
package javax.media.nativewindow.util;
/** Immutable Rectangle interface */
-public interface RectangleReadOnly extends Cloneable {
+public interface RectangleImmutable extends Cloneable {
int getHeight();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
index ea098b967..19786af2a 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
@@ -31,15 +31,15 @@ package javax.media.nativewindow.util;
/** Immutable SurfaceSize Class, consisting of it's read only components:<br>
* <ul>
- * <li>{@link javax.media.nativewindow.util.DimensionReadOnly} size in pixels</li>
+ * <li>{@link javax.media.nativewindow.util.DimensionImmutable} size in pixels</li>
* <li><code>bits per pixel</code></li>
* </ul>
*/
public class SurfaceSize implements Cloneable {
- DimensionReadOnly resolution;
+ DimensionImmutable resolution;
int bitsPerPixel;
- public SurfaceSize(DimensionReadOnly resolution, int bitsPerPixel) {
+ public SurfaceSize(DimensionImmutable resolution, int bitsPerPixel) {
if(null==resolution || bitsPerPixel<=0) {
throw new IllegalArgumentException("resolution must be set and bitsPerPixel greater 0");
}
@@ -55,7 +55,7 @@ public class SurfaceSize implements Cloneable {
}
}
- public final DimensionReadOnly getResolution() {
+ public final DimensionImmutable getResolution() {
return resolution;
}
diff --git a/src/newt/classes/com/jogamp/newt/ScreenMode.java b/src/newt/classes/com/jogamp/newt/ScreenMode.java
index 2a05d842e..414e2fb9c 100644
--- a/src/newt/classes/com/jogamp/newt/ScreenMode.java
+++ b/src/newt/classes/com/jogamp/newt/ScreenMode.java
@@ -28,7 +28,7 @@
package com.jogamp.newt;
-import javax.media.nativewindow.util.DimensionReadOnly;
+import javax.media.nativewindow.util.DimensionImmutable;
import com.jogamp.newt.util.MonitorMode;
@@ -206,7 +206,7 @@ public class ScreenMode implements Cloneable {
}
private final int getRotatedWH(boolean width) {
- final DimensionReadOnly d = getMonitorMode().getSurfaceSize().getResolution();
+ final DimensionImmutable d = getMonitorMode().getSurfaceSize().getResolution();
final boolean swap = ScreenMode.ROTATE_90 == rotation || ScreenMode.ROTATE_270 == rotation ;
if ( ( width && swap ) || ( !width && !swap ) ) {
return d.getHeight();
diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorMode.java b/src/newt/classes/com/jogamp/newt/util/MonitorMode.java
index fb2d0ceb5..69dc584d3 100644
--- a/src/newt/classes/com/jogamp/newt/util/MonitorMode.java
+++ b/src/newt/classes/com/jogamp/newt/util/MonitorMode.java
@@ -33,16 +33,16 @@ import javax.media.nativewindow.util.*;
/** Immutable MonitorMode Class, consisting of it's read only components:<br>
* <ul>
* <li>{@link javax.media.nativewindow.util.SurfaceSize} surface memory size</li>
- * <li>{@link javax.media.nativewindow.util.DimensionReadOnly} size in [mm]</li>
+ * <li>{@link javax.media.nativewindow.util.DimensionImmutable} size in [mm]</li>
* <li><code>refresh rate</code></li>
* </ul>
*/
public class MonitorMode implements Cloneable {
SurfaceSize surfaceSize;
- DimensionReadOnly screenSizeMM; // in [mm]
+ DimensionImmutable screenSizeMM; // in [mm]
int refreshRate;
- public MonitorMode(SurfaceSize surfaceSize, DimensionReadOnly screenSizeMM, int refreshRate) {
+ public MonitorMode(SurfaceSize surfaceSize, DimensionImmutable screenSizeMM, int refreshRate) {
if(null==surfaceSize || refreshRate<=0) {
throw new IllegalArgumentException("surfaceSize must be set and refreshRate greater 0");
}
@@ -63,7 +63,7 @@ public class MonitorMode implements Cloneable {
return surfaceSize;
}
- public final DimensionReadOnly getScreenSizeMM() {
+ public final DimensionImmutable getScreenSizeMM() {
return screenSizeMM;
}
diff --git a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java
index 9c4993f1d..6986e3657 100644
--- a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java
+++ b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java
@@ -33,7 +33,7 @@ import com.jogamp.newt.ScreenMode;
import java.util.ArrayList;
import java.util.List;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionReadOnly;
+import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.SurfaceSize;
/**
@@ -84,7 +84,7 @@ public class ScreenModeUtil {
* @param resolution
* @return modes with nearest resolution, or matching ones
*/
- public static List/*<ScreenMode>*/ filterByResolution(List/*<ScreenMode>*/ screenModes, DimensionReadOnly resolution) {
+ public static List/*<ScreenMode>*/ filterByResolution(List/*<ScreenMode>*/ screenModes, DimensionImmutable resolution) {
if(null==screenModes || screenModes.size()==0) {
return null;
}
@@ -94,7 +94,7 @@ public class ScreenModeUtil {
for (int i=0; null!=screenModes && i<screenModes.size(); i++) {
ScreenMode sm = (ScreenMode)screenModes.get(i);
- DimensionReadOnly res = sm.getMonitorMode().getSurfaceSize().getResolution();
+ DimensionImmutable res = sm.getMonitorMode().getSurfaceSize().getResolution();
int dsq = Math.abs(resolution_sq - res.getHeight()*res.getWidth());
if(dsq<sm_dsq) {
sm_dsq = dsq;
@@ -216,19 +216,19 @@ public class ScreenModeUtil {
}
/** WARNING: must be synchronized with ScreenMode.h, native implementation */
- public static DimensionReadOnly streamInResolution(int[] resolutionProperties, int offset) {
+ public static DimensionImmutable streamInResolution(int[] resolutionProperties, int offset) {
Dimension resolution = new Dimension(resolutionProperties[offset++], resolutionProperties[offset++]);
return resolution;
}
/** WARNING: must be synchronized with ScreenMode.h, native implementation */
- public static SurfaceSize streamInSurfaceSize(DimensionReadOnly resolution, int[] sizeProperties, int offset) {
+ public static SurfaceSize streamInSurfaceSize(DimensionImmutable resolution, int[] sizeProperties, int offset) {
SurfaceSize surfaceSize = new SurfaceSize(resolution, sizeProperties[offset++]);
return surfaceSize;
}
/** WARNING: must be synchronized with ScreenMode.h, native implementation */
- public static MonitorMode streamInMonitorMode(SurfaceSize surfaceSize, DimensionReadOnly screenSizeMM, int[] monitorProperties, int offset) {
+ public static MonitorMode streamInMonitorMode(SurfaceSize surfaceSize, DimensionImmutable screenSizeMM, int[] monitorProperties, int offset) {
int refreshRate = monitorProperties[offset++];
return new MonitorMode(surfaceSize, screenSizeMM, refreshRate);
}
@@ -288,10 +288,10 @@ public class ScreenModeUtil {
throw new RuntimeException("properties array too short, should be >= "+NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+(modeProperties.length-offset));
}
offset++;
- DimensionReadOnly resolution = ScreenModeUtil.streamInResolution(modeProperties, offset);
+ DimensionImmutable resolution = ScreenModeUtil.streamInResolution(modeProperties, offset);
offset += ScreenModeUtil.NUM_RESOLUTION_PROPERTIES;
if(null!=resolutionPool) {
- resolution = (DimensionReadOnly) resolutionPool.getOrAdd(resolution);
+ resolution = (DimensionImmutable) resolutionPool.getOrAdd(resolution);
}
SurfaceSize surfaceSize = ScreenModeUtil.streamInSurfaceSize(resolution, modeProperties, offset);
@@ -300,10 +300,10 @@ public class ScreenModeUtil {
surfaceSize = (SurfaceSize) surfaceSizePool.getOrAdd(surfaceSize);
}
- DimensionReadOnly screenSizeMM = ScreenModeUtil.streamInResolution(modeProperties, offset);
+ DimensionImmutable screenSizeMM = ScreenModeUtil.streamInResolution(modeProperties, offset);
offset += ScreenModeUtil.NUM_RESOLUTION_PROPERTIES;
if(null!=screenSizeMMPool) {
- screenSizeMM = (DimensionReadOnly) screenSizeMMPool.getOrAdd(screenSizeMM);
+ screenSizeMM = (DimensionImmutable) screenSizeMMPool.getOrAdd(screenSizeMM);
}
MonitorMode monitorMode = ScreenModeUtil.streamInMonitorMode(surfaceSize, screenSizeMM, modeProperties, offset);
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index e03c4553e..54a8c2bb8 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -64,7 +64,7 @@ import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.SurfaceUpdatedListener;
-import javax.media.nativewindow.util.DimensionReadOnly;
+import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.Point;
import javax.media.nativewindow.util.Rectangle;
@@ -1527,7 +1527,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
if(success) {
- DimensionReadOnly screenSize = sm.getMonitorMode().getSurfaceSize().getResolution();
+ DimensionImmutable screenSize = sm.getMonitorMode().getSurfaceSize().getResolution();
if ( getHeight() > screenSize.getHeight() ||
getWidth() > screenSize.getWidth() ) {
setSize(screenSize.getWidth(), screenSize.getHeight());
diff --git a/src/newt/classes/jogamp/newt/driver/android/test/GearsGL2ES1.java b/src/newt/classes/jogamp/newt/driver/android/test/GearsGL2ES1.java
deleted file mode 100644
index 1a4e16112..000000000
--- a/src/newt/classes/jogamp/newt/driver/android/test/GearsGL2ES1.java
+++ /dev/null
@@ -1,422 +0,0 @@
-
-package jogamp.newt.driver.android.test;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES1;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLProfile;
-import com.jogamp.opengl.util.ImmModeSink;
-
-import com.jogamp.newt.Window;
-import com.jogamp.newt.event.KeyAdapter;
-import com.jogamp.newt.event.KeyEvent;
-import com.jogamp.newt.event.KeyListener;
-import com.jogamp.newt.event.MouseAdapter;
-import com.jogamp.newt.event.MouseEvent;
-import com.jogamp.newt.event.MouseListener;
-
-/**
- * Gears.java <BR>
- * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P>
- *
- * This version is equal to Brian Paul's version 1.2 1999/10/21
- */
-
-public class GearsGL2ES1 implements GLEventListener {
- private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
- private final float red[] = { 0.8f, 0.1f, 0.0f, 0.7f };
- private final float green[] = { 0.0f, 0.8f, 0.2f, 0.7f };
- private final float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f };
-
- private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
- private GearBuffers gear1=null, gear2=null, gear3=null;
- private float angle = 0.0f;
- private int swapInterval;
-
- private int prevMouseX, prevMouseY;
-
- public GearsGL2ES1(int swapInterval) {
- this.swapInterval = swapInterval;
- }
-
- public GearsGL2ES1() {
- this.swapInterval = 1;
- }
-
- public void init(GLAutoDrawable drawable) {
- System.err.println("Gears: Init: "+drawable);
- // Use debug pipeline
- // drawable.setGL(new DebugGL(drawable.getGL()));
-
- GL _gl = drawable.getGL();
- // GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/);
- GL2ES1 gl = _gl.getGL2ES1();
-
- System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
- System.err.println("INIT GL IS: " + gl.getClass().getName());
- System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
- System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
- System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
-
- gl.glLightfv(GL2ES1.GL_LIGHT0, GL2ES1.GL_POSITION, pos, 0);
- gl.glEnable(GL.GL_CULL_FACE);
- gl.glEnable(GL2ES1.GL_LIGHTING);
- gl.glEnable(GL2ES1.GL_LIGHT0);
- gl.glEnable(GL2ES1.GL_DEPTH_TEST);
-
- /* make the gears */
- if(null == gear1) {
- gear1 = gear(gl, 1.0f, 4.0f, 1.0f, 20, 0.7f);
- System.err.println("gear1 created: "+gear1);
- } else {
- System.err.println("gear1 reused: "+gear1);
- }
-
- if(null == gear2) {
- gear2 = gear(gl, 0.5f, 2.0f, 2.0f, 10, 0.7f);
- System.err.println("gear2 created: "+gear2);
- } else {
- System.err.println("gear2 reused: "+gear2);
- }
-
- if(null == gear3) {
- gear3 = gear(gl, 1.3f, 2.0f, 0.5f, 10, 0.7f);
- System.err.println("gear3 created: "+gear3);
- } else {
- System.err.println("gear3 reused: "+gear3);
- }
-
- gl.glEnable(GL2ES1.GL_NORMALIZE);
-
- // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
- MouseListener gearsMouse = new GearsMouseAdapter();
- KeyListener gearsKeys = new GearsKeyAdapter();
-
- if (drawable instanceof Window) {
- Window window = (Window) drawable;
- window.addMouseListener(gearsMouse);
- window.addKeyListener(gearsKeys);
- } /* else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) {
- java.awt.Component comp = (java.awt.Component) drawable;
- new AWTMouseAdapter(gearsMouse).addTo(comp);
- new AWTKeyAdapter(gearsKeys).addTo(comp);
- } */
- }
-
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height);
- GL2ES1 gl = drawable.getGL().getGL2ES1();
-
- gl.setSwapInterval(swapInterval);
-
- float h = (float)height / (float)width;
-
- gl.glMatrixMode(GL2ES1.GL_PROJECTION);
-
- gl.glLoadIdentity();
- gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
- gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
- gl.glLoadIdentity();
- gl.glTranslatef(0.0f, 0.0f, -40.0f);
- }
-
- public void dispose(GLAutoDrawable drawable) {
- System.err.println("Gears: Dispose");
- }
-
- public void display(GLAutoDrawable drawable) {
- // Turn the gears' teeth
- angle += 2.0f;
-
- // Get the GL corresponding to the drawable we are animating
- GL2ES1 gl = drawable.getGL().getGL2ES1();
-
- gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
- gl.glClear(GL2ES1.GL_COLOR_BUFFER_BIT | GL2ES1.GL_DEPTH_BUFFER_BIT);
-
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
-
- // Rotate the entire assembly of gears based on how the user
- // dragged the mouse around
- gl.glPushMatrix();
- gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
- gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
- gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
-
- final boolean disableBufferAfterDraw = true;
-
- // Place the first gear and call its display list
- gl.glPushMatrix();
- gl.glTranslatef(-3.0f, -2.0f, 0.0f);
- gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
- gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, red, 0);
- gear1.draw(gl, disableBufferAfterDraw);
- gl.glPopMatrix();
-
- // Place the second gear and call its display list
- gl.glPushMatrix();
- gl.glTranslatef(3.1f, -2.0f, 0.0f);
- gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
- gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, green, 0);
- gear2.draw(gl, disableBufferAfterDraw);
- gl.glPopMatrix();
-
- // Place the third gear and call its display list
- gl.glPushMatrix();
- gl.glTranslatef(-3.1f, 4.2f, 0.0f);
- gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
- gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, blue, 0);
- gear3.draw(gl, disableBufferAfterDraw);
- gl.glPopMatrix();
-
- // Remember that every push needs a pop; this one is paired with
- // rotating the entire gear assembly
- gl.glPopMatrix();
- }
-
- static class GearBuffers {
- public final ImmModeSink frontFace;
- public final ImmModeSink frontSide;
- public final ImmModeSink backFace;
- public final ImmModeSink backSide;
- public final ImmModeSink outwardFace;
- public final ImmModeSink insideRadiusCyl;
-
- public GearBuffers(
- ImmModeSink frontFace,
- ImmModeSink frontSide,
- ImmModeSink backFace,
- ImmModeSink backSide,
- ImmModeSink outwardFace,
- ImmModeSink insideRadiusCyl) {
- this.frontFace = frontFace;
- this.frontSide = frontSide;
- this.backFace = backFace;
- this.backSide = backSide;
- this.outwardFace = outwardFace;
- this.insideRadiusCyl = insideRadiusCyl;
- }
-
- public void draw(GL2ES1 gl, boolean disableBufferAfterDraw) {
- gl.glShadeModel(GL2ES1.GL_FLAT);
- frontFace.draw(gl, disableBufferAfterDraw);
- frontSide.draw(gl, disableBufferAfterDraw);
- backFace.draw(gl, disableBufferAfterDraw);
- backSide.draw(gl, disableBufferAfterDraw);
- outwardFace.draw(gl, disableBufferAfterDraw);
- gl.glShadeModel(GL2ES1.GL_SMOOTH);
- insideRadiusCyl.draw(gl, disableBufferAfterDraw);
- }
- }
-
- public static GearBuffers gear(GL2ES1 gl,
- float inner_radius,
- float outer_radius,
- float width,
- int teeth,
- float tooth_depth)
- {
- final float dz = width * 0.5f;
- int i;
- float r0, r1, r2;
- float angle, da;
- float u, v, len;
-
- r0 = inner_radius;
- r1 = outer_radius - tooth_depth / 2.0f;
- r2 = outer_radius + tooth_depth / 2.0f;
-
- da = 2.0f * (float) Math.PI / teeth / 4.0f;
-
- /* draw front face */
- ImmModeSink vboFrontFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*teeth+2,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 0, GL.GL_BYTE, /* texture */ 0, GL.GL_FLOAT);
- vboFrontFace.glBegin(GL.GL_TRIANGLE_STRIP);
- for (i = 0; i < teeth; i++) {
- angle = i * 2.0f * (float) Math.PI / teeth;
- vboFrontFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz);
- vboFrontFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- vboFrontFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz);
- vboFrontFace.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), dz);
- }
- vboFrontFace.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), dz);
- vboFrontFace.glVertex3f(r1 * (float)Math.cos(0f), r1 * (float)Math.sin(0f), dz);
- vboFrontFace.glEnd(gl, false /* immediate */);
-
- /* draw front sides of teeth */
- ImmModeSink vboFrontSide = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 6*teeth,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboFrontSide.glBegin(GL.GL_TRIANGLES);
- for (i = 0; i < teeth; i++) {
- // QUAD [s0..s3] -> 2x TRIs
- angle = i * 2.0f * (float) Math.PI / teeth;
- // s0
- vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- // s1
- vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), dz);
- // s2
- vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), dz);
-
- // s0
- vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- // s2
- vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), dz);
- // s3
- vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), dz);
- }
- vboFrontSide.glEnd(gl, false /* immediate */);
-
- /* draw back face */
- ImmModeSink vboBackFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*teeth+2,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboBackFace.glBegin(GL.GL_TRIANGLE_STRIP);
- for (i = 0; i < teeth; i++) {
- angle = i * 2.0f * (float) Math.PI / teeth;
- vboBackFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
- vboBackFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz);
- vboBackFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
- vboBackFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz);
- }
- vboBackFace.glVertex3f(r1 * (float)Math.cos(0f), r1 * (float)Math.sin(0f), -dz);
- vboBackFace.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), -dz);
- vboBackFace.glEnd(gl, false /* immediate */);
-
- /* draw back sides of teeth */
- ImmModeSink vboBackSide = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 6*teeth,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboBackSide.glBegin(GL.GL_TRIANGLES);
- for (i = 0; i < teeth; i++) {
- // QUAD [s0..s3] -> 2x TRIs
- angle = i * 2.0f * (float) Math.PI / teeth;
- // s0
- vboBackSide.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
- // s1
- vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz);
- // s2
- vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -dz);
-
- // s0
- vboBackSide.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
- // s2
- vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -dz);
- // s3
- vboBackSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
- }
- vboBackSide.glEnd(gl, false /* immediate */);
-
- /* draw outward faces of teeth */
- ImmModeSink vboOutwardFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*4*teeth,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 3, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboOutwardFace.glBegin(GL.GL_TRIANGLE_STRIP);
- for (i = 0; i < teeth; i++) {
- angle = i * 2.0f * (float) Math.PI / teeth;
- u = r2 * (float)Math.cos(angle + da) - r1 * (float)Math.cos(angle);
- v = r2 * (float)Math.sin(angle + da) - r1 * (float)Math.sin(angle);
- len = (float)Math.sqrt(u * u + v * v);
- u /= len;
- v /= len;
-
- vboOutwardFace.glNormal3f(v, -u, 0.0f);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), -dz);
-
- vboOutwardFace.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), -dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz);
-
- u = r1 * (float)Math.cos(angle + 3 * da) - r2 * (float)Math.cos(angle + 2 * da);
- v = r1 * (float)Math.sin(angle + 3 * da) - r2 * (float)Math.sin(angle + 2 * da);
- vboOutwardFace.glNormal3f(v, -u, 0.0f);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
-
- vboOutwardFace.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
- }
- vboOutwardFace.glEnd(gl, false /* immediate */);
-
- /* draw inside radius cylinder */
- ImmModeSink vboInsideRadiusCyl = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 2*teeth+2,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 3, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboInsideRadiusCyl.glBegin(GL.GL_TRIANGLE_STRIP);
- for (i = 0; i < teeth; i++) {
- angle = i * 2.0f * (float) Math.PI / teeth;
- vboInsideRadiusCyl.glNormal3f(-(float)Math.cos(angle), -(float)Math.sin(angle), 0.0f);
- vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz);
- vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz);
- }
- vboInsideRadiusCyl.glNormal3f(-(float)Math.cos(0f), -(float)Math.sin(0f), 0.0f);
- vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), -dz);
- vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), dz);
- vboInsideRadiusCyl.glEnd(gl, false /* immediate */);
- return new GearBuffers(vboFrontFace, vboFrontSide, vboBackFace, vboBackSide, vboOutwardFace, vboInsideRadiusCyl);
- }
-
- class GearsKeyAdapter extends KeyAdapter {
- public void keyPressed(KeyEvent e) {
- int kc = e.getKeyCode();
- if(KeyEvent.VK_LEFT == kc) {
- view_roty -= 1;
- } else if(KeyEvent.VK_RIGHT == kc) {
- view_roty += 1;
- } else if(KeyEvent.VK_UP == kc) {
- view_rotx -= 1;
- } else if(KeyEvent.VK_DOWN == kc) {
- view_rotx += 1;
- }
- }
- }
-
- class GearsMouseAdapter extends MouseAdapter {
- public void mousePressed(MouseEvent e) {
- prevMouseX = e.getX();
- prevMouseY = e.getY();
- }
-
- public void mouseReleased(MouseEvent e) {
- }
-
- public void mouseDragged(MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
- int width=0, height=0;
- Object source = e.getSource();
- if(source instanceof Window) {
- Window window = (Window) source;
- width=window.getWidth();
- height=window.getHeight();
- } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
- java.awt.Component comp = (java.awt.Component) source;
- width=comp.getWidth();
- height=comp.getHeight();
- } else {
- throw new RuntimeException("Event source neither Window nor Component: "+source);
- }
- float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
- float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
-
- prevMouseX = x;
- prevMouseY = y;
-
- view_rotx += thetaX;
- view_roty += thetaY;
- }
- }
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
index a328a2bac..a369f542f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
@@ -36,7 +36,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL2GL3;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLException;
@@ -58,15 +57,13 @@ public class TestGPUMemSec01NEWT extends UITestCase {
static NEWTGLContext.WindowContext createCurrentGLOffscreenWindow(int width, int height) throws GLException, InterruptedException {
final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(GLProfile.getGL2ES2(), width, height, true);
- final GL _gl = winctx.context.getGL();
- Assert.assertTrue(_gl.isGL2GL3());
- final GL2GL3 gl = _gl.getGL2GL3();
+ final GL gl = winctx.context.getGL();
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// misc GL setup
gl.glClearColor(1, 1, 1, 1);
- gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+ gl.glEnable(GL.GL_DEPTH_TEST);
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
gl.glViewport(0, 0, width, height);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
@@ -232,36 +229,38 @@ public class TestGPUMemSec01NEWT extends UITestCase {
}
@Test
- public void testReadPixels_640x480xREDxUB() throws InterruptedException {
+ public void testReadPixels_640x480xRGBxUB() throws InterruptedException {
final int width = 640;
final int height= 480;
-
+
// preset ..
final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(width, height);
final GLDrawable drawable = winctx.context.getGLDrawable();
- final GL2GL3 gl = winctx.context.getGL().getGL2GL3();
+ final GL gl = winctx.context.getGL();
// 2 x too small - 0 x alignment
- Assert.assertEquals(2, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, width, height));
+ Assert.assertEquals(2, readPixelsCheck(gl, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, width, height));
drawable.swapBuffers();
Thread.sleep(50);
NEWTGLContext.destroyWindow(winctx);
}
-
+
@Test
- public void testReadPixels_640x480xRGBxUB() throws InterruptedException {
- final int width = 640;
- final int height= 480;
+ public void testReadPixels_102x100xRGBxUB() throws InterruptedException {
+ final int wwidth = 640;
+ final int wheight= 480;
+ final int rwidth = 102;
+ final int rheight= 100;
// preset ..
- final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(width, height);
+ final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(wwidth, wheight);
final GLDrawable drawable = winctx.context.getGLDrawable();
- final GL2GL3 gl = winctx.context.getGL().getGL2GL3();
+ final GL gl = winctx.context.getGL();
- // 2 x too small - 0 x alignment
- Assert.assertEquals(2, readPixelsCheck(gl, GL2GL3.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, width, height));
+ // 2 x too small - 2 x alignment
+ Assert.assertEquals(4, readPixelsCheck(gl, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, rwidth, rheight));
drawable.swapBuffers();
Thread.sleep(50);
@@ -270,40 +269,46 @@ public class TestGPUMemSec01NEWT extends UITestCase {
}
@Test
- public void testReadPixels_102x100xREDxUB() throws InterruptedException {
- int wwidth = 640;
- int wheight= 480;
- int rwidth = 102;
- int rheight= 100;
+ public void testReadPixelsGL2GL3_640x480xREDxUB() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
+ System.err.println("GL2GL3 n/a skip test");
+ return;
+ }
+ final int width = 640;
+ final int height= 480;
// preset ..
- final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(wwidth, wheight);
+ final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(width, height);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2GL3 gl = winctx.context.getGL().getGL2GL3();
- // 2 x too small - 2 x alignment
- Assert.assertEquals(4, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, rwidth, rheight));
+ // 2 x too small - 0 x alignment
+ Assert.assertEquals(2, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, width, height));
drawable.swapBuffers();
Thread.sleep(50);
NEWTGLContext.destroyWindow(winctx);
}
-
+
@Test
- public void testReadPixels_102x100xRGBxUB() throws InterruptedException {
- final int wwidth = 640;
- final int wheight= 480;
- final int rwidth = 102;
- final int rheight= 100;
-
+ public void testReadPixelsGL2GL3_102x100xREDxUB() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
+ System.err.println("GL2GL3 n/a skip test");
+ return;
+ }
+ int wwidth = 640;
+ int wheight= 480;
+ int rwidth = 102;
+ int rheight= 100;
+
// preset ..
final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(wwidth, wheight);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2GL3 gl = winctx.context.getGL().getGL2GL3();
// 2 x too small - 2 x alignment
- Assert.assertEquals(4, readPixelsCheck(gl, GL2GL3.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, rwidth, rheight));
+ Assert.assertEquals(4, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, rwidth, rheight));
drawable.swapBuffers();
Thread.sleep(50);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java
new file mode 100644
index 000000000..bad04addc
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java
@@ -0,0 +1,111 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.opengl.test.junit.util.NEWTGLContext;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Luz, et.al.
+ */
+public class TestMapBuffer01NEWT extends UITestCase {
+ static final boolean DEBUG = false;
+
+ @Test
+ public void testWriteRead01a() throws InterruptedException {
+ ByteBuffer verticiesBB = ByteBuffer.allocate(4*9);
+ verticiesBB.order(ByteOrder.nativeOrder());
+ testWriteRead01(verticiesBB);
+ }
+ @Test
+ public void testWriteRead01b() throws InterruptedException {
+ ByteBuffer verticiesBB = Buffers.newDirectByteBuffer(4*9);
+ testWriteRead01(verticiesBB);
+ }
+
+ private void testWriteRead01(ByteBuffer verticiesBB) throws InterruptedException {
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(GLProfile.getDefault(), 800, 600, true);
+ final GL gl = winctx.context.getGL();
+
+ int[] vertexBuffer = new int[1];
+
+ verticiesBB.putFloat(0);
+ verticiesBB.putFloat(0.5f);
+ verticiesBB.putFloat(0);
+
+ verticiesBB.putFloat(0.5f);
+ verticiesBB.putFloat(-0.5f);
+ verticiesBB.putFloat(0);
+
+ verticiesBB.putFloat(-0.5f);
+ verticiesBB.putFloat(-0.5f);
+ verticiesBB.putFloat(0);
+ verticiesBB.rewind();
+ if(DEBUG) {
+ for(int i=0; i < verticiesBB.capacity(); i+=4) {
+ System.out.println("java "+i+": "+verticiesBB.getFloat(i));
+ }
+ }
+
+ gl.glGenBuffers(1, vertexBuffer, 0);
+
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vertexBuffer[0]);
+
+ // gl.glBufferData(GL3.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL3.GL_STATIC_READ);
+ gl.glBufferData(GL.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL.GL_STATIC_DRAW);
+
+ ByteBuffer bb = gl.glMapBuffer(GL.GL_ARRAY_BUFFER, GL2GL3.GL_READ_ONLY);
+ // gl.glUnmapBuffer(GL3.GL_ARRAY_BUFFER);
+ if(DEBUG) {
+ for(int i=0; i < bb.capacity(); i+=4) {
+ System.out.println("gpu "+i+": "+bb.getFloat(i));
+ }
+ }
+ for(int i=0; i < bb.capacity(); i+=4) {
+ Assert.assertEquals(verticiesBB.getFloat(i), bb.getFloat(i), 0.0);
+ }
+ NEWTGLContext.destroyWindow(winctx);
+ }
+ public static void main(String args[]) throws IOException {
+ String tstname = TestMapBuffer01NEWT.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java
new file mode 100644
index 000000000..19c207f80
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java
@@ -0,0 +1,232 @@
+/**
+ * Copyright (C) 2011 JogAmp Community. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos;
+
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.opengl.util.GLArrayDataServer;
+
+/**
+ * GearsObject.java <BR>
+ * author: Brian Paul (converted to Java by Sven Gothel) <P>
+ */
+public abstract class GearsObject {
+ public static final FloatBuffer red = Buffers.newDirectFloatBuffer( new float[] { 0.8f, 0.1f, 0.0f, 0.7f } );
+ public static final FloatBuffer green = Buffers.newDirectFloatBuffer( new float[] { 0.0f, 0.8f, 0.2f, 0.7f } );
+ public static final FloatBuffer blue = Buffers.newDirectFloatBuffer( new float[] { 0.2f, 0.2f, 1.0f, 0.7f } );
+ public static final float M_PI = (float)Math.PI;
+
+ public final GLArrayDataServer frontFace;
+ public final GLArrayDataServer frontSide;
+ public final GLArrayDataServer backFace;
+ public final GLArrayDataServer backSide;
+ public final GLArrayDataServer outwardFace;
+ public final GLArrayDataServer insideRadiusCyl;
+
+ public abstract void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components);
+ public abstract void draw(GL gl, float x, float y, float angle, FloatBuffer color);
+
+ public GearsObject (
+ float inner_radius,
+ float outer_radius,
+ float width,
+ int teeth,
+ float tooth_depth)
+ {
+ final float dz = width * 0.5f;
+ int i;
+ float r0, r1, r2;
+ float angle, da;
+ float u, v, len;
+ float s[] = new float[5];
+ float c[] = new float[5];
+ float normal[] = new float[3];
+ // final int tris_per_tooth = 32;
+
+ r0 = inner_radius;
+ r1 = outer_radius - tooth_depth / 2.0f;
+ r2 = outer_radius + tooth_depth / 2.0f;
+
+ da = 2.0f * (float) Math.PI / teeth / 4.0f;
+
+ s[4] = 0; // sin(0f)
+ c[4] = 1; // cos(0f)
+
+ System.err.println("teeth: "+teeth);
+
+ frontFace = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 4*teeth+2, GL.GL_STATIC_DRAW);
+ addInterleavedVertexAndNormalArrays(frontFace, 3);
+ backFace = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 4*teeth+2, GL.GL_STATIC_DRAW);
+ addInterleavedVertexAndNormalArrays(backFace, 3);
+ frontSide = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 6*teeth, GL.GL_STATIC_DRAW);
+ addInterleavedVertexAndNormalArrays(frontSide, 3);
+ backSide = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 6*teeth, GL.GL_STATIC_DRAW);
+ addInterleavedVertexAndNormalArrays(backSide, 3);
+ outwardFace = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 4*4*teeth+2, GL.GL_STATIC_DRAW);
+ addInterleavedVertexAndNormalArrays(outwardFace, 3);
+ insideRadiusCyl = GLArrayDataServer.createInterleaved(6, GL.GL_FLOAT, false, 2*teeth+2, GL.GL_STATIC_DRAW);
+ addInterleavedVertexAndNormalArrays(insideRadiusCyl, 3);
+
+ for (i = 0; i < teeth; i++) {
+ angle = i * 2.0f * M_PI / teeth;
+ sincos(angle + da * 0f, s, 0, c, 0);
+ sincos(angle + da * 1f, s, 1, c, 1);
+ sincos(angle + da * 2f, s, 2, c, 2);
+ sincos(angle + da * 3f, s, 3, c, 3);
+
+ /* front */
+ normal[0] = 0.0f;
+ normal[1] = 0.0f;
+ normal[2] = 1.0f;
+
+ /* front face - GL.GL_TRIANGLE_STRIP */
+ vert(frontFace, r0 * c[0], r0 * s[0], dz, normal);
+ vert(frontFace, r1 * c[0], r1 * s[0], dz, normal);
+ vert(frontFace, r0 * c[0], r0 * s[0], dz, normal);
+ vert(frontFace, r1 * c[3], r1 * s[3], dz, normal);
+
+ /* front sides of teeth - GL.GL_TRIANGLES */
+ vert(frontSide, r1 * c[0], r1 * s[0], dz, normal);
+ vert(frontSide, r2 * c[1], r2 * s[1], dz, normal);
+ vert(frontSide, r2 * c[2], r2 * s[2], dz, normal);
+ vert(frontSide, r1 * c[0], r1 * s[0], dz, normal);
+ vert(frontSide, r2 * c[2], r2 * s[2], dz, normal);
+ vert(frontSide, r1 * c[3], r1 * s[3], dz, normal);
+
+ /* back */
+ normal[0] = 0.0f;
+ normal[1] = 0.0f;
+ normal[2] = -1.0f;
+
+ /* back face - GL.GL_TRIANGLE_STRIP */
+ vert(backFace, r1 * c[0], r1 * s[0], -dz, normal);
+ vert(backFace, r0 * c[0], r0 * s[0], -dz, normal);
+ vert(backFace, r1 * c[3], r1 * s[3], -dz, normal);
+ vert(backFace, r0 * c[0], r0 * s[0], -dz, normal);
+
+ /* back sides of teeth - GL.GL_TRIANGLES*/
+ vert(backSide, r1 * c[3], r1 * s[3], -dz, normal);
+ vert(backSide, r2 * c[2], r2 * s[2], -dz, normal);
+ vert(backSide, r2 * c[1], r2 * s[1], -dz, normal);
+ vert(backSide, r1 * c[3], r1 * s[3], -dz, normal);
+ vert(backSide, r2 * c[1], r2 * s[1], -dz, normal);
+ vert(backSide, r1 * c[0], r1 * s[0], -dz, normal);
+
+ /* outward faces of teeth */
+ u = r2 * c[1] - r1 * c[0];
+ v = r2 * s[1] - r1 * s[0];
+ len = (float)Math.sqrt(u * u + v * v);
+ u /= len;
+ v /= len;
+ normal[0] = v;
+ normal[1] = -u;
+ normal[2] = 0.0f;
+
+ vert(outwardFace, r1 * c[0], r1 * s[0], dz, normal);
+ vert(outwardFace, r1 * c[0], r1 * s[0], -dz, normal);
+ vert(outwardFace, r2 * c[1], r2 * s[1], dz, normal);
+ vert(outwardFace, r2 * c[1], r2 * s[1], -dz, normal);
+
+ normal[0] = c[0];
+ normal[1] = s[0];
+ vert(outwardFace, r2 * c[1], r2 * s[1], dz, normal);
+ vert(outwardFace, r2 * c[1], r2 * s[1], -dz, normal);
+ vert(outwardFace, r2 * c[2], r2 * s[2], dz, normal);
+ vert(outwardFace, r2 * c[2], r2 * s[2], -dz, normal);
+
+ normal[0] = ( r1 * s[3] - r2 * s[2] );
+ normal[1] = ( r1 * c[3] - r2 * c[2] ) * -1.0f ;
+ vert(outwardFace, r2 * c[2], r2 * s[2], dz, normal);
+ vert(outwardFace, r2 * c[2], r2 * s[2], -dz, normal);
+ vert(outwardFace, r1 * c[3], r1 * s[3], dz, normal);
+ vert(outwardFace, r1 * c[3], r1 * s[3], -dz, normal);
+
+ normal[0] = c[0];
+ normal[1] = s[0];
+ vert(outwardFace, r1 * c[3], r1 * s[3], dz, normal);
+ vert(outwardFace, r1 * c[3], r1 * s[3], -dz, normal);
+ vert(outwardFace, r1 * c[0], r1 * s[0], dz, normal);
+ vert(outwardFace, r1 * c[0], r1 * s[0], -dz, normal);
+
+ /* inside radius cylinder */
+ normal[0] = c[0] * -1.0f;
+ normal[1] = s[0] * -1.0f;
+ normal[2] = 0.0f;
+ vert(insideRadiusCyl, r0 * c[0], r0 * s[0], -dz, normal);
+ vert(insideRadiusCyl, r0 * c[0], r0 * s[0], dz, normal);
+ }
+ /* finish front face */
+ normal[0] = 0.0f;
+ normal[1] = 0.0f;
+ normal[2] = 1.0f;
+ vert(frontFace, r0 * c[4], r0 * s[4], dz, normal);
+ vert(frontFace, r1 * c[4], r1 * s[4], dz, normal);
+ frontFace.seal(true);
+
+ /* finish back face */
+ normal[2] = -1.0f;
+ vert(backFace, r1 * c[4], r1 * s[4], -dz, normal);
+ vert(backFace, r0 * c[4], r0 * s[4], -dz, normal);
+ backFace.seal(true);
+
+ backSide.seal(true);
+ frontSide.seal(true);
+
+ /* finish outward face */
+ sincos(da * 1f, s, 1, c, 1);
+ u = r2 * c[1] - r1 * c[4];
+ v = r2 * s[1] - r1 * s[4];
+ len = (float)Math.sqrt(u * u + v * v);
+ u /= len;
+ v /= len;
+ normal[0] = v;
+ normal[1] = -u;
+ normal[2] = 0.0f;
+ vert(outwardFace, r1 * c[4], r1 * s[4], dz, normal);
+ vert(outwardFace, r1 * c[4], r1 * s[4], -dz, normal);
+ outwardFace.seal(true);
+
+ /* finish inside radius cylinder */
+ normal[0] = c[4] * -1.0f;
+ normal[1] = s[4] * -1.0f;
+ normal[2] = 0.0f;
+ vert(insideRadiusCyl, r0 * c[4], r0 * s[4], -dz, normal);
+ vert(insideRadiusCyl, r0 * c[4], r0 * s[4], dz, normal);
+ insideRadiusCyl.seal(true);
+ }
+
+ static void vert(GLArrayDataServer array, float x, float y, float z, float n[]) {
+ array.putf(x);
+ array.putf(y);
+ array.putf(z);
+ array.putf(n[0]);
+ array.putf(n[1]);
+ array.putf(n[2]);
+ }
+
+ static void sincos(float x, float sin[], int sinIdx, float cos[], int cosIdx) {
+ sin[sinIdx] = (float) Math.sin(x);
+ cos[cosIdx] = (float) Math.cos(x);
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
new file mode 100644
index 000000000..dfac46482
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -0,0 +1,224 @@
+/**
+ * Copyright (C) 2011 JogAmp Community. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.demos.es1;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import com.jogamp.newt.Window;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.KeyListener;
+import com.jogamp.newt.event.MouseAdapter;
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.event.MouseListener;
+import com.jogamp.newt.event.awt.AWTKeyAdapter;
+import com.jogamp.newt.event.awt.AWTMouseAdapter;
+import com.jogamp.opengl.test.junit.jogl.demos.GearsObject;
+
+/**
+ * GearsES1.java <BR>
+ * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P>
+ */
+public class GearsES1 implements GLEventListener {
+ private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
+
+ private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
+ private GearsObject gear1=null, gear2=null, gear3=null;
+ private float angle = 0.0f;
+ private int swapInterval;
+
+ private int prevMouseX, prevMouseY;
+
+ public GearsES1(int swapInterval) {
+ this.swapInterval = swapInterval;
+ }
+
+ public GearsES1() {
+ this.swapInterval = 1;
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ System.err.println("Gears: Init: "+drawable);
+ // Use debug pipeline
+ // drawable.setGL(new DebugGL(drawable.getGL()));
+
+ GL _gl = drawable.getGL();
+ // GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/);
+ GL2ES1 gl = _gl.getGL2ES1();
+
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
+ System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
+ System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
+
+ gl.glLightfv(GL2ES1.GL_LIGHT0, GL2ES1.GL_POSITION, pos, 0);
+ gl.glEnable(GL.GL_CULL_FACE);
+ gl.glEnable(GL2ES1.GL_LIGHTING);
+ gl.glEnable(GL2ES1.GL_LIGHT0);
+ gl.glEnable(GL2ES1.GL_DEPTH_TEST);
+
+ /* make the gears */
+ if(null == gear1) {
+ gear1 = new GearsObjectES1(1.0f, 4.0f, 1.0f, 20, 0.7f);
+ System.err.println("gear1 created: "+gear1);
+ } else {
+ System.err.println("gear1 reused: "+gear1);
+ }
+
+ if(null == gear2) {
+ gear2 = new GearsObjectES1(0.5f, 2.0f, 2.0f, 10, 0.7f);
+ System.err.println("gear2 created: "+gear2);
+ } else {
+ System.err.println("gear2 reused: "+gear2);
+ }
+
+ if(null == gear3) {
+ gear3 = new GearsObjectES1(1.3f, 2.0f, 0.5f, 10, 0.7f);
+ System.err.println("gear3 created: "+gear3);
+ } else {
+ System.err.println("gear3 reused: "+gear3);
+ }
+
+ gl.glEnable(GL2ES1.GL_NORMALIZE);
+
+ // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
+ MouseListener gearsMouse = new GearsMouseAdapter();
+ KeyListener gearsKeys = new GearsKeyAdapter();
+
+ if (drawable instanceof Window) {
+ Window window = (Window) drawable;
+ window.addMouseListener(gearsMouse);
+ window.addKeyListener(gearsKeys);
+ } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) {
+ java.awt.Component comp = (java.awt.Component) drawable;
+ new AWTMouseAdapter(gearsMouse).addTo(comp);
+ new AWTKeyAdapter(gearsKeys).addTo(comp);
+ }
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height);
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ gl.setSwapInterval(swapInterval);
+
+ float h = (float)height / (float)width;
+
+ gl.glMatrixMode(GL2ES1.GL_PROJECTION);
+
+ gl.glLoadIdentity();
+ gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
+ gl.glLoadIdentity();
+ gl.glTranslatef(0.0f, 0.0f, -40.0f);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ System.err.println("Gears: Dispose");
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ // Turn the gears' teeth
+ angle += 2.0f;
+
+ // Get the GL corresponding to the drawable we are animating
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ gl.glClear(GL2ES1.GL_COLOR_BUFFER_BIT | GL2ES1.GL_DEPTH_BUFFER_BIT);
+
+ gl.glNormal3f(0.0f, 0.0f, 1.0f);
+
+ // Rotate the entire assembly of gears based on how the user
+ // dragged the mouse around
+ gl.glPushMatrix();
+ gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
+ gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
+ gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
+
+ gear1.draw(gl, -3.0f, -2.0f, angle, GearsObject.red);
+ gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f, GearsObject.green);
+ gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f, GearsObject.blue);
+
+ // Remember that every push needs a pop; this one is paired with
+ // rotating the entire gear assembly
+ gl.glPopMatrix();
+ }
+
+
+ class GearsKeyAdapter extends KeyAdapter {
+ public void keyPressed(KeyEvent e) {
+ int kc = e.getKeyCode();
+ if(KeyEvent.VK_LEFT == kc) {
+ view_roty -= 1;
+ } else if(KeyEvent.VK_RIGHT == kc) {
+ view_roty += 1;
+ } else if(KeyEvent.VK_UP == kc) {
+ view_rotx -= 1;
+ } else if(KeyEvent.VK_DOWN == kc) {
+ view_rotx += 1;
+ }
+ }
+ }
+
+ class GearsMouseAdapter extends MouseAdapter {
+ public void mousePressed(MouseEvent e) {
+ prevMouseX = e.getX();
+ prevMouseY = e.getY();
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ public void mouseDragged(MouseEvent e) {
+ int x = e.getX();
+ int y = e.getY();
+ int width=0, height=0;
+ Object source = e.getSource();
+ if(source instanceof Window) {
+ Window window = (Window) source;
+ width=window.getWidth();
+ height=window.getHeight();
+ } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
+ java.awt.Component comp = (java.awt.Component) source;
+ width=comp.getWidth();
+ height=comp.getHeight();
+ } else {
+ throw new RuntimeException("Event source neither Window nor Component: "+source);
+ }
+ float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
+ float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
+
+ prevMouseX = x;
+ prevMouseY = y;
+
+ view_rotx += thetaX;
+ view_roty += thetaY;
+ }
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java
new file mode 100644
index 000000000..0da2b5496
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java
@@ -0,0 +1,75 @@
+/**
+ * Copyright (C) 2011 JogAmp Community. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.es1;
+
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.fixedfunc.GLPointerFunc;
+
+
+import com.jogamp.opengl.test.junit.jogl.demos.GearsObject;
+import com.jogamp.opengl.util.GLArrayDataServer;
+
+/**
+ * GearsObjectES1.java <BR>
+ * author: Brian Paul (converted to Java by Sven Gothel) <P>
+ */
+public class GearsObjectES1 extends GearsObject {
+
+ public GearsObjectES1(float inner_radius, float outer_radius, float width,
+ int teeth, float tooth_depth) {
+ super(inner_radius, outer_radius, width, teeth, tooth_depth);
+ }
+
+ @Override
+ public void addInterleavedVertexAndNormalArrays(GLArrayDataServer array,
+ int components) {
+ array.addFixedSubArray(GLPointerFunc.GL_VERTEX_ARRAY, 3);
+ array.addFixedSubArray(GLPointerFunc.GL_NORMAL_ARRAY, 3);
+ }
+
+ private void draw(GL2ES1 gl, GLArrayDataServer array, int mode) {
+ array.enableBuffer(gl, true);
+ gl.glDrawArrays(mode, 0, array.getElementCount());
+ array.enableBuffer(gl, false);
+ }
+
+ @Override
+ public void draw(GL _gl, float x, float y, float angle, FloatBuffer color) {
+ GL2ES1 gl = _gl.getGL2ES1();
+ gl.glPushMatrix();
+ gl.glTranslatef(x, y, 0f);
+ gl.glRotatef(angle, 0f, 0f, 1f);
+ gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, color);
+
+ gl.glShadeModel(GL2ES1.GL_FLAT);
+ draw(gl, frontFace, GL.GL_TRIANGLE_STRIP);
+ draw(gl, frontSide, GL.GL_TRIANGLES);
+ draw(gl, backFace, GL.GL_TRIANGLE_STRIP);
+ draw(gl, backSide, GL.GL_TRIANGLES);
+ draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP);
+ gl.glShadeModel(GL2ES1.GL_SMOOTH);
+ draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP);
+ gl.glPopMatrix();
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquare.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
index 5b7f1d12a..9c74ddce0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquare.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
@@ -10,7 +10,7 @@ import javax.media.nativewindow.*;
import com.jogamp.opengl.util.*;
import com.jogamp.opengl.util.glsl.fixedfunc.*;
-public class RedSquare implements GLEventListener {
+public class RedSquareES1 implements GLEventListener {
public static boolean glDebugEmu = false;
public static boolean glDebug = false ;
@@ -25,11 +25,11 @@ public class RedSquare implements GLEventListener {
GLU glu = null;
- public RedSquare() {
+ public RedSquareES1() {
this(false);
}
- public RedSquare(boolean debug) {
+ public RedSquareES1(boolean debug) {
this.debug = debug;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/newt/TestGearsGL2ES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
index ffba7c050..86f63cb2d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/newt/TestGearsGL2ES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2011 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears.newt;
+package com.jogamp.opengl.test.junit.jogl.demos.es1.newt;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
@@ -36,7 +36,7 @@ import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears.GearsGL2ES1;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
@@ -46,17 +46,17 @@ import org.junit.BeforeClass;
import org.junit.AfterClass;
import org.junit.Test;
-public class TestGearsGL2ES1NEWT extends UITestCase {
+public class TestGearsES1NEWT extends UITestCase {
static GLProfile glp;
static int width, height;
@BeforeClass
public static void initClass() {
GLProfile.initSingleton(true);
- if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) {
+ /* if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) {
// exact match
glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1);
- } else {
+ } else */ {
// default device, somehow ES1 compatible
glp = GLProfile.getGL2ES1();
}
@@ -74,7 +74,7 @@ public class TestGearsGL2ES1NEWT extends UITestCase {
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test");
- glWindow.addGLEventListener(new GearsGL2ES1());
+ glWindow.addGLEventListener(new GearsES1());
Animator animator = new Animator(glWindow);
QuitAdapter quitAdapter = new QuitAdapter();
@@ -131,6 +131,6 @@ public class TestGearsGL2ES1NEWT extends UITestCase {
} catch (Exception ex) { ex.printStackTrace(); }
}
}
- org.junit.runner.JUnitCore.main(TestGearsGL2ES1NEWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestGearsES1NEWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
new file mode 100644
index 000000000..6d551144e
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -0,0 +1,222 @@
+/**
+ * Copyright (C) 2011 JogAmp Community. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.es2;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.newt.Window;
+import com.jogamp.newt.event.KeyAdapter;
+import com.jogamp.newt.event.KeyEvent;
+import com.jogamp.newt.event.KeyListener;
+import com.jogamp.newt.event.MouseAdapter;
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.event.MouseListener;
+import com.jogamp.opengl.test.junit.jogl.demos.GearsObject;
+import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+import com.jogamp.opengl.util.glsl.ShaderState;
+import java.nio.FloatBuffer;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLUniformData;
+
+/**
+ * GearsES2.java <BR>
+ * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P>
+ */
+public class GearsES2 implements GLEventListener {
+ private final FloatBuffer lightPos = Buffers.newDirectFloatBuffer( new float[] { 5.0f, 5.0f, 10.0f } );
+
+ private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
+ private GearsObject gear1=null, gear2=null, gear3=null;
+ private float angle = 0.0f;
+ private int swapInterval;
+
+ private int prevMouseX, prevMouseY;
+
+ public GearsES2(int swapInterval) {
+ this.swapInterval = swapInterval;
+ }
+
+ public GearsES2() {
+ this.swapInterval = 1;
+ }
+
+ ShaderState st;
+ PMVMatrix pmvMatrix;
+ GLUniformData pmvMatrixUniform;
+ GLUniformData colorU;
+
+ public void init(GLAutoDrawable drawable) {
+ System.err.println("Gears: Init: "+drawable);
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
+ System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
+ System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
+
+ gl.glEnable(GL.GL_CULL_FACE);
+ gl.glEnable(GL.GL_DEPTH_TEST);
+
+ st = new ShaderState();
+ st.setVerbose(true);
+ final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, this.getClass(),
+ "shader", "shader/bin", "gears");
+ final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, this.getClass(),
+ "shader", "shader/bin", "gears");
+ final ShaderProgram sp0 = new ShaderProgram();
+ sp0.add(gl, vp0, System.err);
+ sp0.add(gl, fp0, System.err);
+ st.attachShaderProgram(gl, sp0);
+ st.useProgram(gl, true);
+ // Use debug pipeline
+ // drawable.setGL(new DebugGL(drawable.getGL()));
+
+ pmvMatrix = new PMVMatrix();
+ pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.glGetPMvMvitMatrixf()); // P, Mv, Mvi and Mvit
+ st.ownUniform(pmvMatrixUniform);
+ st.uniform(gl, pmvMatrixUniform);
+
+ GLUniformData lightU = new GLUniformData("lightPos", 3, lightPos);
+ st.ownUniform(lightU);
+ st.uniform(gl, lightU);
+
+ colorU = new GLUniformData("color", 4, GearsObject.red);
+ st.ownUniform(colorU);
+ st.uniform(gl, colorU);
+ gear1 = new GearsObjectES2(1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ gear2 = new GearsObjectES2(0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+ gear3 = new GearsObjectES2(1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU);
+
+ // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
+ MouseListener gearsMouse = new GearsMouseAdapter();
+ KeyListener gearsKeys = new GearsKeyAdapter();
+
+ if (drawable instanceof Window) {
+ Window window = (Window) drawable;
+ window.addMouseListener(gearsMouse);
+ window.addKeyListener(gearsKeys);
+ } /* else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) {
+ java.awt.Component comp = (java.awt.Component) drawable;
+ new AWTMouseAdapter(gearsMouse).addTo(comp);
+ new AWTKeyAdapter(gearsKeys).addTo(comp);
+ } */
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height);
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.setSwapInterval(swapInterval);
+
+ float h = (float)height / (float)width;
+
+ pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glFrustumf(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0.0f, 0.0f, -40.0f);
+ st.uniform(gl, pmvMatrixUniform);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ System.err.println("Gears: Dispose");
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ // Turn the gears' teeth
+ angle += 2.0f;
+
+ // Get the GL corresponding to the drawable we are animating
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+
+ gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
+
+ pmvMatrix.glPushMatrix();
+ pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
+ pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
+ pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
+
+ gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f, GearsObject.red);
+ gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f, GearsObject.green);
+ gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f, GearsObject.blue);
+ pmvMatrix.glPopMatrix();
+ }
+
+ class GearsKeyAdapter extends KeyAdapter {
+ public void keyPressed(KeyEvent e) {
+ int kc = e.getKeyCode();
+ if(KeyEvent.VK_LEFT == kc) {
+ view_roty -= 1;
+ } else if(KeyEvent.VK_RIGHT == kc) {
+ view_roty += 1;
+ } else if(KeyEvent.VK_UP == kc) {
+ view_rotx -= 1;
+ } else if(KeyEvent.VK_DOWN == kc) {
+ view_rotx += 1;
+ }
+ }
+ }
+
+ class GearsMouseAdapter extends MouseAdapter {
+ public void mousePressed(MouseEvent e) {
+ prevMouseX = e.getX();
+ prevMouseY = e.getY();
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ public void mouseDragged(MouseEvent e) {
+ int x = e.getX();
+ int y = e.getY();
+ int width=0, height=0;
+ Object source = e.getSource();
+ if(source instanceof Window) {
+ Window window = (Window) source;
+ width=window.getWidth();
+ height=window.getHeight();
+ } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
+ java.awt.Component comp = (java.awt.Component) source;
+ width=comp.getWidth();
+ height=comp.getHeight();
+ } else {
+ throw new RuntimeException("Event source neither Window nor Component: "+source);
+ }
+ float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
+ float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
+
+ prevMouseX = x;
+ prevMouseY = y;
+
+ view_rotx += thetaX;
+ view_roty += thetaY;
+ }
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java
new file mode 100644
index 000000000..660218e6f
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java
@@ -0,0 +1,93 @@
+/**
+ * Copyright (C) 2011 JogAmp Community. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.jogamp.opengl.test.junit.jogl.demos.es2;
+
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLUniformData;
+
+
+import com.jogamp.opengl.test.junit.jogl.demos.GearsObject;
+import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+/**
+ * GearsObjectES2.java <BR>
+ * author: Brian Paul (converted to Java by Sven Gothel) <P>
+ */
+public class GearsObjectES2 extends GearsObject {
+ final ShaderState st;
+ final PMVMatrix pmvMatrix;
+ final GLUniformData pmvMatrixUniform;
+ final GLUniformData colorUniform;
+
+ public GearsObjectES2(float inner_radius, float outer_radius, float width,
+ int teeth, float tooth_depth,
+ PMVMatrix pmvMatrix,
+ GLUniformData pmvMatrixUniform,
+ GLUniformData colorUniform)
+ {
+ super(inner_radius, outer_radius, width, teeth, tooth_depth);
+ this.st = ShaderState.getCurrentShaderState();
+ this.pmvMatrix = pmvMatrix;
+ this.pmvMatrixUniform = pmvMatrixUniform;
+ this.colorUniform = colorUniform;
+ }
+
+ @Override
+ public void addInterleavedVertexAndNormalArrays(GLArrayDataServer array,
+ int components) {
+ final ShaderState st = ShaderState.getCurrentShaderState();
+ array.addGLSLSubArray(st, "vertices", 3);
+ array.addGLSLSubArray(st, "normals", 3);
+ }
+
+ private void draw(GL2ES2 gl, GLArrayDataServer array, int mode) {
+ array.enableBuffer(gl, true);
+ gl.glDrawArrays(mode, 0, array.getElementCount());
+ array.enableBuffer(gl, false);
+ }
+
+ @Override
+ public void draw(GL _gl, float x, float y, float angle, FloatBuffer color) {
+ GL2ES2 gl = _gl.getGL2ES2();
+ pmvMatrix.glPushMatrix();
+ pmvMatrix.glTranslatef(x, y, 0f);
+ pmvMatrix.glRotatef(angle, 0f, 0f, 1f);
+ pmvMatrix.update();
+ st.uniform(gl, pmvMatrixUniform);
+
+ colorUniform.setData(color);
+ st.uniform(gl, colorUniform);
+
+ draw(gl, frontFace, GL.GL_TRIANGLE_STRIP);
+ draw(gl, frontSide, GL.GL_TRIANGLES);
+ draw(gl, backFace, GL.GL_TRIANGLE_STRIP);
+ draw(gl, backSide, GL.GL_TRIANGLES);
+ draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP);
+ draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP);
+
+ pmvMatrix.glPopMatrix();
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquare0.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index d38a60ea6..544ec4af5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquare0.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -42,7 +42,7 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLUniformData;
import org.junit.Assert;
-public class RedSquare0 implements GLEventListener {
+public class RedSquareES2 implements GLEventListener {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream pbaos = new PrintStream(baos);
GLSLSimpleProgram myShader;
@@ -82,18 +82,10 @@ public class RedSquare0 implements GLEventListener {
{
// Fill them up
FloatBuffer verticeb = (FloatBuffer) vertices.getBuffer();
- verticeb.put(-2);
- verticeb.put(2);
- verticeb.put(0);
- verticeb.put(2);
- verticeb.put(2);
- verticeb.put(0);
- verticeb.put(-2);
- verticeb.put(-2);
- verticeb.put(0);
- verticeb.put(2);
- verticeb.put(-2);
- verticeb.put(0);
+ verticeb.put(-2); verticeb.put( 2); verticeb.put( 0);
+ verticeb.put( 2); verticeb.put( 2); verticeb.put( 0);
+ verticeb.put(-2); verticeb.put(-2); verticeb.put( 0);
+ verticeb.put( 2); verticeb.put(-2); verticeb.put( 0);
}
buffer.flip();
vertices.setLocation(mgl_Vertex);
@@ -111,22 +103,10 @@ public class RedSquare0 implements GLEventListener {
{
// Fill them up
FloatBuffer colorb = (FloatBuffer) colors.getBuffer();
- colorb.put(1);
- colorb.put(0);
- colorb.put(0);
- colorb.put(1);
- colorb.put(0);
- colorb.put(0);
- colorb.put(1);
- colorb.put(1);
- colorb.put(1);
- colorb.put(0);
- colorb.put(0);
- colorb.put(1);
- colorb.put(1);
- colorb.put(0);
- colorb.put(0);
- colorb.put(1);
+ colorb.put(1); colorb.put(0); colorb.put(0); colorb.put(1);
+ colorb.put(0); colorb.put(0); colorb.put(1); colorb.put(1);
+ colorb.put(1); colorb.put(0); colorb.put(0); colorb.put(1);
+ colorb.put(1); colorb.put(0); colorb.put(0); colorb.put(1);
}
buffer.flip();
colors.setLocation(mgl_Color);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp
new file mode 100644
index 000000000..be2ec6843
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp
@@ -0,0 +1,50 @@
+// Copyright (C) 2011 JogAmp Community. All rights reserved.
+// Details see GearsES2.java
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+uniform MEDIUMP vec4 color;
+
+varying MEDIUMP vec3 normal;
+varying MEDIUMP vec4 position;
+varying MEDIUMP vec3 lightDir;
+varying MEDIUMP float attenuation;
+varying MEDIUMP vec3 cameraDir;
+
+// Defining The Material Colors
+const MEDIUMP vec4 matAmbient = vec4(0.2, 0.2, 0.2, 1.0); // orig default
+const MEDIUMP vec4 matDiffuse = vec4(0.8, 0.8, 0.8, 1.0); // orig default
+// const MEDIUMP vec4 matSpecular = vec4(0.0, 0.0, 0.0, 1.0); // orig default
+const MEDIUMP vec4 matSpecular = vec4(0.8, 0.8, 0.8, 1.0);
+// const MEDIUMP float matShininess = 0.0; // orig default
+const MEDIUMP float matShininess = 0.5;
+
+void main()
+{
+ MEDIUMP float lambertTerm = dot(normal, lightDir);
+
+ MEDIUMP vec4 ambient = color * matAmbient;
+ MEDIUMP vec4 diffuse = color * lambertTerm * attenuation * matDiffuse;
+ MEDIUMP vec4 specular = vec4(0.0);
+ if (lambertTerm > 0.0) {
+ float NdotHV;
+ /*
+ MEDIUMP vec3 halfDir;
+ halfDir = normalize (lightDir + cameraDir);
+ NdotHV = max(0.0, dot(normal, halfDir));
+ */
+ vec3 E = normalize(-position.xyz);
+ vec3 R = reflect(-lightDir, normal);
+ NdotHV = max(0.0, dot(R, E));
+
+ specular += color * pow(NdotHV, matShininess) * attenuation * matSpecular;
+ }
+
+ gl_FragColor = ambient + diffuse + specular ;
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.vp
new file mode 100644
index 000000000..0e417290c
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.vp
@@ -0,0 +1,48 @@
+// Copyright (C) 2011 JogAmp Community. All rights reserved.
+// Details see GearsES2.java
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+uniform MEDIUMP mat4 pmvMatrix[4]; // P, Mv, Mvi and Mvit
+uniform MEDIUMP vec3 lightPos;
+
+attribute MEDIUMP vec4 vertices;
+attribute MEDIUMP vec4 normals;
+
+varying MEDIUMP vec3 normal;
+varying MEDIUMP vec4 position;
+varying MEDIUMP vec3 lightDir;
+varying MEDIUMP float attenuation;
+varying MEDIUMP vec3 cameraDir;
+
+const MEDIUMP float constantAttenuation = 0.5; // 1.0;
+const MEDIUMP float linearAttenuation = 0.001; // 0.0;
+const MEDIUMP float quadraticAttenuation= 0.0002; // 0.0;
+
+void main(void)
+{
+ // Transforming The Vertex Position To ModelView-Space
+ position = pmvMatrix[1] * vertices; // vertex eye position
+
+ // incl. projection
+ gl_Position = pmvMatrix[0] * position;
+
+ // Transforming The Normal To ModelView-Space
+ normal = normalize((pmvMatrix[3] * normals).xyz);
+
+ // Calculating The Vector From The Vertex Position To The Light Position
+ lightDir = lightPos - position.xyz;
+ MEDIUMP float d = length(lightDir);
+ attenuation = 1.0 / (
+ constantAttenuation +
+ linearAttenuation * d +
+ quadraticAttenuation * d * d );
+ lightDir = normalize(lightDir);
+ cameraDir = normalize((pmvMatrix[2] * vec4(0,0,0,1.0)).xyz - vertices.xyz);
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/GearsGL2ES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/GearsGL2ES1.java
deleted file mode 100644
index 0997ba4a8..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2es1/gears/GearsGL2ES1.java
+++ /dev/null
@@ -1,441 +0,0 @@
-
-package com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES1;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLProfile;
-import com.jogamp.opengl.util.ImmModeSink;
-import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil;
-
-import com.jogamp.newt.Window;
-import com.jogamp.newt.event.KeyAdapter;
-import com.jogamp.newt.event.KeyEvent;
-import com.jogamp.newt.event.KeyListener;
-import com.jogamp.newt.event.MouseAdapter;
-import com.jogamp.newt.event.MouseEvent;
-import com.jogamp.newt.event.MouseListener;
-import com.jogamp.newt.event.awt.AWTKeyAdapter;
-import com.jogamp.newt.event.awt.AWTMouseAdapter;
-
-/**
- * Gears.java <BR>
- * author: Brian Paul (converted to Java by Ron Cemer and Sven Gothel) <P>
- *
- * This version is equal to Brian Paul's version 1.2 1999/10/21
- */
-
-public class GearsGL2ES1 implements GLEventListener {
- private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
- private final float red[] = { 0.8f, 0.1f, 0.0f, 0.7f };
- private final float green[] = { 0.0f, 0.8f, 0.2f, 0.7f };
- private final float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f };
-
- private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
- private GearBuffers gear1=null, gear2=null, gear3=null;
- private float angle = 0.0f;
- private int swapInterval;
-
- private boolean mouseRButtonDown = false;
- private int prevMouseX, prevMouseY;
-
- public GearsGL2ES1(int swapInterval) {
- this.swapInterval = swapInterval;
- }
-
- public GearsGL2ES1() {
- this.swapInterval = 1;
- }
-
- public void init(GLAutoDrawable drawable) {
- System.err.println("Gears: Init: "+drawable);
- // Use debug pipeline
- // drawable.setGL(new DebugGL(drawable.getGL()));
-
- GL _gl = drawable.getGL();
- // GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/);
- GL2ES1 gl = _gl.getGL2ES1();
-
- System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
- System.err.println("INIT GL IS: " + gl.getClass().getName());
- System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
- System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
- System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
-
- gl.glLightfv(GL2ES1.GL_LIGHT0, GL2ES1.GL_POSITION, pos, 0);
- gl.glEnable(GL.GL_CULL_FACE);
- gl.glEnable(GL2ES1.GL_LIGHTING);
- gl.glEnable(GL2ES1.GL_LIGHT0);
- gl.glEnable(GL2ES1.GL_DEPTH_TEST);
-
- /* make the gears */
- if(null == gear1) {
- gear1 = gear(gl, 1.0f, 4.0f, 1.0f, 20, 0.7f);
- System.err.println("gear1 created: "+gear1);
- } else {
- System.err.println("gear1 reused: "+gear1);
- }
-
- if(null == gear2) {
- gear2 = gear(gl, 0.5f, 2.0f, 2.0f, 10, 0.7f);
- System.err.println("gear2 created: "+gear2);
- } else {
- System.err.println("gear2 reused: "+gear2);
- }
-
- if(null == gear3) {
- gear3 = gear(gl, 1.3f, 2.0f, 0.5f, 10, 0.7f);
- System.err.println("gear3 created: "+gear3);
- } else {
- System.err.println("gear3 reused: "+gear3);
- }
-
- gl.glEnable(GL2ES1.GL_NORMALIZE);
-
- // MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
- MouseListener gearsMouse = new GearsMouseAdapter();
- KeyListener gearsKeys = new GearsKeyAdapter();
-
- if (drawable instanceof Window) {
- Window window = (Window) drawable;
- window.addMouseListener(gearsMouse);
- window.addKeyListener(gearsKeys);
- } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) {
- java.awt.Component comp = (java.awt.Component) drawable;
- new AWTMouseAdapter(gearsMouse).addTo(comp);
- new AWTKeyAdapter(gearsKeys).addTo(comp);
- }
- }
-
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height);
- GL2ES1 gl = drawable.getGL().getGL2ES1();
-
- gl.setSwapInterval(swapInterval);
-
- float h = (float)height / (float)width;
-
- gl.glMatrixMode(GL2ES1.GL_PROJECTION);
-
- gl.glLoadIdentity();
- gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
- gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
- gl.glLoadIdentity();
- gl.glTranslatef(0.0f, 0.0f, -40.0f);
- }
-
- public void dispose(GLAutoDrawable drawable) {
- System.err.println("Gears: Dispose");
- }
-
- public void display(GLAutoDrawable drawable) {
- // Turn the gears' teeth
- angle += 2.0f;
-
- // Get the GL corresponding to the drawable we are animating
- GL2ES1 gl = drawable.getGL().getGL2ES1();
-
- gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
- // Special handling for the case where the GLJPanel is translucent
- // and wants to be composited with other Java 2D content
- if (GLProfile.isAWTAvailable() &&
- (drawable instanceof javax.media.opengl.awt.GLJPanel) &&
- !((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() &&
- ((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) {
- gl.glClear(GL2ES1.GL_DEPTH_BUFFER_BIT);
- } else {
- gl.glClear(GL2ES1.GL_COLOR_BUFFER_BIT | GL2ES1.GL_DEPTH_BUFFER_BIT);
- }
-
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
-
- // Rotate the entire assembly of gears based on how the user
- // dragged the mouse around
- gl.glPushMatrix();
- gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
- gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
- gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
-
- final boolean disableBufferAfterDraw = true;
-
- // Place the first gear and call its display list
- gl.glPushMatrix();
- gl.glTranslatef(-3.0f, -2.0f, 0.0f);
- gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
- gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, red, 0);
- gear1.draw(gl, disableBufferAfterDraw);
- gl.glPopMatrix();
-
- // Place the second gear and call its display list
- gl.glPushMatrix();
- gl.glTranslatef(3.1f, -2.0f, 0.0f);
- gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
- gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, green, 0);
- gear2.draw(gl, disableBufferAfterDraw);
- gl.glPopMatrix();
-
- // Place the third gear and call its display list
- gl.glPushMatrix();
- gl.glTranslatef(-3.1f, 4.2f, 0.0f);
- gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
- gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, blue, 0);
- gear3.draw(gl, disableBufferAfterDraw);
- gl.glPopMatrix();
-
- // Remember that every push needs a pop; this one is paired with
- // rotating the entire gear assembly
- gl.glPopMatrix();
- }
-
- static class GearBuffers {
- public final ImmModeSink frontFace;
- public final ImmModeSink frontSide;
- public final ImmModeSink backFace;
- public final ImmModeSink backSide;
- public final ImmModeSink outwardFace;
- public final ImmModeSink insideRadiusCyl;
-
- public GearBuffers(
- ImmModeSink frontFace,
- ImmModeSink frontSide,
- ImmModeSink backFace,
- ImmModeSink backSide,
- ImmModeSink outwardFace,
- ImmModeSink insideRadiusCyl) {
- this.frontFace = frontFace;
- this.frontSide = frontSide;
- this.backFace = backFace;
- this.backSide = backSide;
- this.outwardFace = outwardFace;
- this.insideRadiusCyl = insideRadiusCyl;
- }
-
- public void draw(GL2ES1 gl, boolean disableBufferAfterDraw) {
- gl.glShadeModel(GL2ES1.GL_FLAT);
- frontFace.draw(gl, disableBufferAfterDraw);
- frontSide.draw(gl, disableBufferAfterDraw);
- backFace.draw(gl, disableBufferAfterDraw);
- backSide.draw(gl, disableBufferAfterDraw);
- outwardFace.draw(gl, disableBufferAfterDraw);
- gl.glShadeModel(GL2ES1.GL_SMOOTH);
- insideRadiusCyl.draw(gl, disableBufferAfterDraw);
- }
- }
-
- public static GearBuffers gear(GL2ES1 gl,
- float inner_radius,
- float outer_radius,
- float width,
- int teeth,
- float tooth_depth)
- {
- final float dz = width * 0.5f;
- int i;
- float r0, r1, r2;
- float angle, da;
- float u, v, len;
-
- r0 = inner_radius;
- r1 = outer_radius - tooth_depth / 2.0f;
- r2 = outer_radius + tooth_depth / 2.0f;
-
- da = 2.0f * (float) Math.PI / teeth / 4.0f;
-
- /* draw front face */
- ImmModeSink vboFrontFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*teeth+2,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 0, GL.GL_BYTE, /* texture */ 0, GL.GL_FLOAT);
- vboFrontFace.glBegin(GL.GL_TRIANGLE_STRIP);
- for (i = 0; i < teeth; i++) {
- angle = i * 2.0f * (float) Math.PI / teeth;
- vboFrontFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz);
- vboFrontFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- vboFrontFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz);
- vboFrontFace.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), dz);
- }
- vboFrontFace.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), dz);
- vboFrontFace.glVertex3f(r1 * (float)Math.cos(0f), r1 * (float)Math.sin(0f), dz);
- vboFrontFace.glEnd(gl, false /* immediate */);
-
- /* draw front sides of teeth */
- ImmModeSink vboFrontSide = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 6*teeth,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboFrontSide.glBegin(GL.GL_TRIANGLES);
- for (i = 0; i < teeth; i++) {
- // QUAD [s0..s3] -> 2x TRIs
- angle = i * 2.0f * (float) Math.PI / teeth;
- // s0
- vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- // s1
- vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), dz);
- // s2
- vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), dz);
-
- // s0
- vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- // s2
- vboFrontSide.glVertex3f(r2 * (float)Math.cos(angle + 2.0f * da), r2 * (float)Math.sin(angle + 2.0f * da), dz);
- // s3
- vboFrontSide.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), dz);
- }
- vboFrontSide.glEnd(gl, false /* immediate */);
-
- /* draw back face */
- ImmModeSink vboBackFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*teeth+2,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboBackFace.glBegin(GL.GL_TRIANGLE_STRIP);
- for (i = 0; i < teeth; i++) {
- angle = i * 2.0f * (float) Math.PI / teeth;
- vboBackFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
- vboBackFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz);
- vboBackFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
- vboBackFace.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz);
- }
- vboBackFace.glVertex3f(r1 * (float)Math.cos(0f), r1 * (float)Math.sin(0f), -dz);
- vboBackFace.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), -dz);
- vboBackFace.glEnd(gl, false /* immediate */);
-
- /* draw back sides of teeth */
- ImmModeSink vboBackSide = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 6*teeth,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 0, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboBackSide.glBegin(GL.GL_TRIANGLES);
- for (i = 0; i < teeth; i++) {
- // QUAD [s0..s3] -> 2x TRIs
- angle = i * 2.0f * (float) Math.PI / teeth;
- // s0
- vboBackSide.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
- // s1
- vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz);
- // s2
- vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -dz);
-
- // s0
- vboBackSide.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
- // s2
- vboBackSide.glVertex3f(r2 * (float)Math.cos(angle + da), r2 * (float)Math.sin(angle + da), -dz);
- // s3
- vboBackSide.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
- }
- vboBackSide.glEnd(gl, false /* immediate */);
-
- /* draw outward faces of teeth */
- ImmModeSink vboOutwardFace = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 4*4*teeth,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 3, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboOutwardFace.glBegin(GL.GL_TRIANGLE_STRIP);
- for (i = 0; i < teeth; i++) {
- angle = i * 2.0f * (float) Math.PI / teeth;
- u = r2 * (float)Math.cos(angle + da) - r1 * (float)Math.cos(angle);
- v = r2 * (float)Math.sin(angle + da) - r1 * (float)Math.sin(angle);
- len = (float)Math.sqrt(u * u + v * v);
- u /= len;
- v /= len;
-
- vboOutwardFace.glNormal3f(v, -u, 0.0f);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), -dz);
-
- vboOutwardFace.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 1 * da), r2 * (float)Math.sin(angle + 1 * da), -dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz);
-
- u = r1 * (float)Math.cos(angle + 3 * da) - r2 * (float)Math.cos(angle + 2 * da);
- v = r1 * (float)Math.sin(angle + 3 * da) - r2 * (float)Math.sin(angle + 2 * da);
- vboOutwardFace.glNormal3f(v, -u, 0.0f);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), dz);
- vboOutwardFace.glVertex3f(r2 * (float)Math.cos(angle + 2 * da), r2 * (float)Math.sin(angle + 2 * da), -dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
-
- vboOutwardFace.glNormal3f((float)Math.cos(angle), (float)Math.sin(angle), 0.0f);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle + 3 * da), r1 * (float)Math.sin(angle + 3 * da), -dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), dz);
- vboOutwardFace.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -dz);
- }
- vboOutwardFace.glEnd(gl, false /* immediate */);
-
- /* draw inside radius cylinder */
- ImmModeSink vboInsideRadiusCyl = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 2*teeth+2,
- /* vertex */ 3, GL.GL_FLOAT, /* color */ 0, GL.GL_FLOAT,
- /* normal */ 3, GL.GL_FLOAT, /* texture */ 0, GL.GL_FLOAT);
- vboInsideRadiusCyl.glBegin(GL.GL_TRIANGLE_STRIP);
- for (i = 0; i < teeth; i++) {
- angle = i * 2.0f * (float) Math.PI / teeth;
- vboInsideRadiusCyl.glNormal3f(-(float)Math.cos(angle), -(float)Math.sin(angle), 0.0f);
- vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -dz);
- vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), dz);
- }
- vboInsideRadiusCyl.glNormal3f(-(float)Math.cos(0f), -(float)Math.sin(0f), 0.0f);
- vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), -dz);
- vboInsideRadiusCyl.glVertex3f(r0 * (float)Math.cos(0f), r0 * (float)Math.sin(0f), dz);
- vboInsideRadiusCyl.glEnd(gl, false /* immediate */);
- return new GearBuffers(vboFrontFace, vboFrontSide, vboBackFace, vboBackSide, vboOutwardFace, vboInsideRadiusCyl);
- }
-
- class GearsKeyAdapter extends KeyAdapter {
- public void keyPressed(KeyEvent e) {
- int kc = e.getKeyCode();
- if(KeyEvent.VK_LEFT == kc) {
- view_roty -= 1;
- } else if(KeyEvent.VK_RIGHT == kc) {
- view_roty += 1;
- } else if(KeyEvent.VK_UP == kc) {
- view_rotx -= 1;
- } else if(KeyEvent.VK_DOWN == kc) {
- view_rotx += 1;
- }
- }
- }
-
- class GearsMouseAdapter extends MouseAdapter {
- public void mousePressed(MouseEvent e) {
- prevMouseX = e.getX();
- prevMouseY = e.getY();
- if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
- mouseRButtonDown = true;
- }
- }
-
- public void mouseReleased(MouseEvent e) {
- if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
- mouseRButtonDown = false;
- }
- }
-
- public void mouseDragged(MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
- int width=0, height=0;
- Object source = e.getSource();
- if(source instanceof Window) {
- Window window = (Window) source;
- width=window.getWidth();
- height=window.getHeight();
- } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
- java.awt.Component comp = (java.awt.Component) source;
- width=comp.getWidth();
- height=comp.getHeight();
- } else {
- throw new RuntimeException("Event source neither Window nor Component: "+source);
- }
- float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
- float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
-
- prevMouseX = x;
- prevMouseY = y;
-
- view_rotx += thetaX;
- view_roty += thetaY;
- }
- }
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
index e75f4ebe3..504691fbe 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/GLSLMiscHelper.java
@@ -55,7 +55,7 @@ public class GLSLMiscHelper {
Assert.assertEquals(data.enabled()?GL.GL_TRUE:GL.GL_FALSE, qi[0]);
gl.glGetVertexAttribiv(data.getLocation(), GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, qi, 0);
Assert.assertEquals(data.getVBOName(), qi[0]);
- Assert.assertEquals(data.getByteSize(), gl.glGetBufferSize(data.getVBOName()));
+ Assert.assertEquals(data.getSizeInBytes(), gl.glGetBufferSize(data.getVBOName()));
}
public static void pause(long ms) throws InterruptedException {
@@ -127,7 +127,7 @@ public class GLSLMiscHelper {
vertices0.seal(gl, true);
Assert.assertTrue(vertices0.isVBOWritten());
Assert.assertTrue(vertices0.sealed());
- Assert.assertEquals(4, vertices0.getElementNumber());
+ Assert.assertEquals(4, vertices0.getElementCount());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
Assert.assertEquals(vertices0.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER));
validateGLArrayDataServerState(gl, st, vertices0);
@@ -147,7 +147,7 @@ public class GLSLMiscHelper {
vertices1.seal(gl, true);
Assert.assertTrue(vertices1.isVBOWritten());
Assert.assertTrue(vertices1.sealed());
- Assert.assertEquals(4, vertices1.getElementNumber());
+ Assert.assertEquals(4, vertices1.getElementCount());
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
Assert.assertEquals(vertices1.getVBOName(), gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER));
validateGLArrayDataServerState(gl, st, vertices1);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
index f3af56fb3..2785a2701 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
@@ -33,7 +33,7 @@ import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.glsl.ShaderState;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.NEWTGLContext;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -68,9 +68,9 @@ public class TestFBOMRTNEWT01 extends UITestCase {
final ShaderState st = new ShaderState();
// st.setVerbose(true);
- final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class,
+ final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "fbo-mrt-1");
- final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "fbo-mrt-1");
final ShaderProgram sp0 = new ShaderProgram();
sp0.add(gl, vp0, System.err);
@@ -81,9 +81,9 @@ public class TestFBOMRTNEWT01 extends UITestCase {
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
st.attachShaderProgram(gl, sp0);
- final ShaderCode vp1 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class,
+ final ShaderCode vp1 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "fbo-mrt-2");
- final ShaderCode fp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode fp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "fbo-mrt-2");
final ShaderProgram sp1 = new ShaderProgram();
sp1.add(gl, vp1, System.err);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
index 484734b28..b8551527e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
@@ -32,7 +32,7 @@ import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.glsl.ShaderState;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.NEWTGLContext;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -70,9 +70,9 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
// test code ..
final ShaderState st = new ShaderState();
- final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
- final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
final ShaderProgram sp = new ShaderProgram();
@@ -195,9 +195,9 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
// test code ..
final ShaderState st = new ShaderState();
- final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
- final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
final ShaderProgram sp = new ShaderProgram();
@@ -284,9 +284,9 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
// test code ..
final ShaderState st = new ShaderState();
- final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
- final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
final ShaderProgram sp = new ShaderProgram();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
index 2ecc3b30d..f71b7bea7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
@@ -32,7 +32,7 @@ import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.glsl.ShaderState;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.NEWTGLContext;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -78,11 +78,11 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
// test code ..
final ShaderState st = new ShaderState();
- final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
- final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
- final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader2");
final ShaderProgram sp1 = new ShaderProgram();
@@ -243,11 +243,11 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
// test code ..
final ShaderState st = new ShaderState();
- final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
- final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader");
- final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "RedSquareShader2");
final ShaderProgram sp1 = new ShaderProgram();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java
index ed9fbd455..b683cb2e7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java
@@ -28,7 +28,7 @@
package com.jogamp.opengl.test.junit.jogl.glsl;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import com.jogamp.opengl.test.junit.util.GLSLSimpleProgram;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -115,7 +115,7 @@ public class TestGLSLSimple01NEWT extends UITestCase {
window.setSize(800, 600);
window.setVisible(true);
Assert.assertTrue(window.isNativeValid());
- window.addGLEventListener(new RedSquare0());
+ window.addGLEventListener(new RedSquareES2());
Animator animator = new Animator(window);
animator.setUpdateFPSFrames(1, null);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
index cc0ec4601..1ea9c731a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
@@ -34,7 +34,7 @@ import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.glsl.ShaderState;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquare0;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.NEWTGLContext;
import com.jogamp.opengl.test.junit.util.UITestCase;
@@ -42,7 +42,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import java.io.IOException;
import java.nio.FloatBuffer;
-import javax.media.nativewindow.util.DimensionReadOnly;
+import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLDrawable;
@@ -67,9 +67,9 @@ public class TestRulerNEWT01 extends UITestCase {
// test code ..
final ShaderState st = new ShaderState();
- final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare0.class,
+ final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "default");
- final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare0.class,
+ final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquareES2.class,
"shader", "shader/bin", "ruler");
final ShaderProgram sp0 = new ShaderProgram();
@@ -100,8 +100,8 @@ public class TestRulerNEWT01 extends UITestCase {
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
final MonitorMode mmode = winctx.window.getScreen().getCurrentScreenMode().getMonitorMode();
- final DimensionReadOnly sdim = mmode.getScreenSizeMM();
- final DimensionReadOnly spix = mmode.getSurfaceSize().getResolution();
+ final DimensionImmutable sdim = mmode.getScreenSizeMM();
+ final DimensionImmutable spix = mmode.getSurfaceSize().getResolution();
final GLUniformData rulerPixFreq = new GLUniformData("gcu_RulerPixFreq", 2, Buffers.newDirectFloatBuffer(2));
final FloatBuffer rulerPixFreqV = (FloatBuffer) rulerPixFreq.getBuffer();
rulerPixFreqV.put(0, (float)spix.getWidth() / (float)sdim.getWidth() * 10.0f);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java
index 8c315e97f..5bdef2869 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java
@@ -62,7 +62,7 @@ public class ReadBuffer2Screen extends ReadBufferBase {
if(null==readTextureVertices) {
//readTextureVertices = GLArrayDataClient.createFixed(gl, GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex",
// 2, GL.GL_FLOAT, true, 4);
- readTextureVertices = GLArrayDataServer.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex", 2,
+ readTextureVertices = GLArrayDataServer.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, 2,
GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW);
readTextureVertices.setEnableAlways(enableBufferAlways);
readTextureVertices.setVBOEnabled(enableBufferVBO);
@@ -142,7 +142,7 @@ public class ReadBuffer2Screen extends ReadBufferBase {
if(null!=readTextureCoords) {
readTextureCoords.enableBuffer(gl, true);
}
- gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, readTextureVertices.getElementNumber());
+ gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, readTextureVertices.getElementCount());
/**
if(null!=readTextureCoords) {
readTextureCoords.enableBuffer(gl, false);
@@ -154,7 +154,7 @@ public class ReadBuffer2Screen extends ReadBufferBase {
void updateTextureCoords(GL gl, boolean force) {
if(force || null==readTextureCoords) {
- readTextureCoords = GLArrayDataServer.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, "mgl_MultiTexCoord0", 2,
+ readTextureCoords = GLArrayDataServer.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, 2,
GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW);
readTextureCoords.setEnableAlways(enableBufferAlways);
readTextureCoords.setVBOEnabled(enableBufferVBO);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
index 40ea6848a..8b4d199e8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java
@@ -46,7 +46,7 @@ import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import java.io.IOException;
public class TestOffscreen01GLPBufferNEWT extends UITestCase {
@@ -88,7 +88,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase {
Assert.assertNotNull(glWindow);
glWindow.setVisible(true);
- GLEventListener demo = new RedSquare();
+ GLEventListener demo = new RedSquareES1();
WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
glWindow.addGLEventListener(demo);
@@ -182,7 +182,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase {
Assert.assertNotNull(glWindows[i]);
glWindows[i].setVisible(true);
- demos[i] = new RedSquare();
+ demos[i] = new RedSquareES1();
WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false);
glWindows[i].addGLEventListener(demos[i]);
}
@@ -235,7 +235,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase {
glWindows[i] = GLWindow.create(windows[i]);
Assert.assertNotNull(glWindows[i]);
glWindows[i].setVisible(true);
- demos[i] = new RedSquare();
+ demos[i] = new RedSquareES1();
WindowUtilNEWT.setDemoFields(demos[i], windows[i], glWindows[i], false);
glWindows[i].addGLEventListener(demos[i]);
}
@@ -287,7 +287,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase {
MouseListener ml=null;
SurfaceUpdatedListener ul=null;
- GLEventListener demo = new RedSquare();
+ GLEventListener demo = new RedSquareES1();
Assert.assertNotNull(demo);
WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
index cc6e9b26d..766f64d70 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java
@@ -46,7 +46,7 @@ import javax.media.opengl.*;
import javax.media.nativewindow.*;
import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import java.io.IOException;
public class TestOffscreen02BitmapNEWT extends UITestCase {
@@ -97,7 +97,7 @@ public class TestOffscreen02BitmapNEWT extends UITestCase {
Assert.assertNotNull(glWindow);
glWindow.setVisible(true);
- GLEventListener demo = new RedSquare();
+ GLEventListener demo = new RedSquareES1();
WindowUtilNEWT.setDemoFields(demo, window, glWindow, false);
glWindow.addGLEventListener(demo);
@@ -145,7 +145,7 @@ public class TestOffscreen02BitmapNEWT extends UITestCase {
MouseListener ml=null;
SurfaceUpdatedListener ul=null;
- GLEventListener demo = new RedSquare();
+ GLEventListener demo = new RedSquareES1();
Assert.assertNotNull(demo);
WindowUtilNEWT.run(glWindow, demo, windowOnScreen, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
index 79196bd4c..e23510e25 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java
@@ -51,7 +51,7 @@ import org.junit.Test;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import com.jogamp.opengl.test.junit.util.*;
@@ -93,7 +93,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase {
// Create a window.
GLWindow glWindow1 = GLWindow.create(glCaps);
glWindow1.setTitle("testNewtChildFocus");
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
TestListenerCom01AWT.setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1");
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
index 1b65c8910..1947930c0 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestListenerCom01AWT.java
@@ -57,7 +57,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT;
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.*;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears;
public class TestListenerCom01AWT extends UITestCase {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
index 810539c90..9ad487bdf 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java
@@ -46,7 +46,7 @@ import java.util.Iterator;
import java.util.List;
import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.util.Dimension;
-import javax.media.nativewindow.util.DimensionReadOnly;
+import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.SurfaceSize;
public class TestScreenMode00NEWT extends UITestCase {
@@ -66,9 +66,9 @@ public class TestScreenMode00NEWT extends UITestCase {
@Test
public void testScreenModeInfo00() throws InterruptedException {
- DimensionReadOnly res = new Dimension(640, 480);
+ DimensionImmutable res = new Dimension(640, 480);
SurfaceSize surfsz = new SurfaceSize(res, 32);
- DimensionReadOnly mm = new Dimension(500, 400);
+ DimensionImmutable mm = new Dimension(500, 400);
MonitorMode mon = new MonitorMode(surfsz, mm, 60);
ScreenMode sm_out = new ScreenMode(mon, 90);
System.err.println("00 out: "+sm_out);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
index f4aa44354..560d1ec7c 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
@@ -43,7 +43,7 @@ import com.jogamp.newt.opengl.*;
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.*;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears;
public class TestParenting01NEWT extends UITestCase {
@@ -83,7 +83,7 @@ public class TestParenting01NEWT extends UITestCase {
glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
glWindow1.setSize(640, 480);
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
@@ -305,7 +305,7 @@ public class TestParenting01NEWT extends UITestCase {
GLWindow glWindow1 = GLWindow.create(glCaps);
glWindow1.setTitle("testWindowParenting02ReparentTop2Win");
glWindow1.setSize(640, 480);
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
screen1 = glWindow1.getScreen();
@@ -502,7 +502,7 @@ public class TestParenting01NEWT extends UITestCase {
display1 = screen1.getDisplay();
glWindow1.setTitle("testWindowParenting03ReparentWin2Top");
glWindow1.setSize(640, 480);
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java
index 50461bba0..7e0f18f00 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java
@@ -59,7 +59,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT;
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.*;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears;
public class TestParenting01aAWT extends UITestCase {
@@ -90,7 +90,7 @@ public class TestParenting01aAWT extends UITestCase {
Assert.assertEquals(false, glWindow1.isNativeValid());
Assert.assertNull(glWindow1.getParent());
glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
@@ -160,7 +160,7 @@ public class TestParenting01aAWT extends UITestCase {
Assert.assertEquals(false, glWindow1.isVisible());
Assert.assertEquals(false, glWindow1.isNativeValid());
Assert.assertNull(glWindow1.getParent());
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
@@ -201,7 +201,7 @@ public class TestParenting01aAWT extends UITestCase {
NEWTEventFiFo eventFifo = new NEWTEventFiFo();
GLWindow glWindow1 = GLWindow.create(glCaps);
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
@@ -239,7 +239,7 @@ public class TestParenting01aAWT extends UITestCase {
NEWTEventFiFo eventFifo = new NEWTEventFiFo();
GLWindow glWindow1 = GLWindow.create(glCaps);
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
@@ -290,7 +290,7 @@ public class TestParenting01aAWT extends UITestCase {
NEWTEventFiFo eventFifo = new NEWTEventFiFo();
GLWindow glWindow1 = GLWindow.create(glCaps);
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
@@ -347,7 +347,7 @@ public class TestParenting01aAWT extends UITestCase {
GLWindow glWindow1 = GLWindow.create(glCaps);
glWindow1.setUndecorated(true);
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java
index 84edfc8ba..f929b6fbc 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java
@@ -59,7 +59,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT;
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.*;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears;
public class TestParenting01bAWT extends UITestCase {
@@ -94,7 +94,7 @@ public class TestParenting01bAWT extends UITestCase {
GLWindow glWindow1 = GLWindow.create(glCaps);
glWindow1.setUndecorated(true);
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java
index 905d80925..c84655e23 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java
@@ -58,7 +58,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT;
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.*;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears;
public class TestParenting01cAWT extends UITestCase {
@@ -88,7 +88,7 @@ public class TestParenting01cAWT extends UITestCase {
Assert.assertEquals(false, glWindow1.isNativeValid());
Assert.assertNull(glWindow1.getParent());
glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
@@ -150,7 +150,7 @@ public class TestParenting01cAWT extends UITestCase {
GLWindow glWindow1 = GLWindow.create(glCaps);
glWindow1.setUndecorated(true);
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java
index 949fb29df..ed6f9ea75 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java
@@ -52,7 +52,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT;
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.*;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
public class TestParenting01cSwingAWT extends UITestCase {
static int width, height;
@@ -79,7 +79,7 @@ public class TestParenting01cSwingAWT extends UITestCase {
Assert.assertEquals(false, glWindow1.isNativeValid());
Assert.assertNull(glWindow1.getParent());
glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
Animator animator1 = new Animator(glWindow1);
@@ -190,7 +190,7 @@ public class TestParenting01cSwingAWT extends UITestCase {
Assert.assertEquals(false, glWindow1.isNativeValid());
Assert.assertNull(glWindow1.getParent());
glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, glWindow1, false);
glWindow1.addGLEventListener(demo1);
Animator animator1 = new Animator(glWindow1);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
index b6e02d810..ba73ae6d9 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java
@@ -57,7 +57,7 @@ import com.jogamp.newt.awt.NewtCanvasAWT;
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.*;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears;
public class TestParenting02AWT extends UITestCase {
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java
index b9bd2d93d..89f70421f 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java
@@ -52,7 +52,7 @@ import com.jogamp.newt.opengl.*;
import java.io.IOException;
import com.jogamp.opengl.test.junit.util.*;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquare;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1;
import com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.Gears;
public class TestParenting02NEWT extends UITestCase {
@@ -122,7 +122,7 @@ public class TestParenting02NEWT extends UITestCase {
glWindow1.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo)));
glWindow1.addWindowListener(new TraceWindowAdapter());
- GLEventListener demo1 = new RedSquare();
+ GLEventListener demo1 = new RedSquareES1();
setDemoFields(demo1, window1, glWindow1, false);
// glWindow1.addGLEventListener(demo1);