aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Jordan <[email protected]>2020-07-05 23:55:46 +1200
committerPhilip Jordan <[email protected]>2020-07-05 23:55:46 +1200
commit7656400fa263d5a9f63511a4fc10bf26a9a7de71 (patch)
treebe172310afe923f3d58ff05d9abb898d4cdc7b0c
parenta1d13f51eb0f5b9d5331aa862483aacf5e72b331 (diff)
first cut of shadow maps, working with a very basic case
-rw-r--r--src/main/java/org/jogamp/java3d/DirectionalLight.java5
-rw-r--r--src/main/java/org/jogamp/java3d/DirectionalLightRetained.java2
-rw-r--r--src/main/java/org/jogamp/java3d/Jogl2es2Context.java54
-rw-r--r--src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java1
-rw-r--r--src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java6632
-rw-r--r--src/main/java/org/jogamp/java3d/JoglPipeline.java8
-rw-r--r--src/main/java/org/jogamp/java3d/Light.java24
-rw-r--r--src/main/java/org/jogamp/java3d/LightBin.java81
-rw-r--r--src/main/java/org/jogamp/java3d/LightRetained.java51
-rw-r--r--src/main/java/org/jogamp/java3d/NoopPipeline.java8
-rw-r--r--src/main/java/org/jogamp/java3d/Pipeline.java8
-rw-r--r--src/main/java/org/jogamp/java3d/PointLightRetained.java2
-rw-r--r--src/main/java/org/jogamp/java3d/Renderer.java425
-rw-r--r--src/main/java/org/jogamp/java3d/SpotLightRetained.java3
14 files changed, 3338 insertions, 3966 deletions
diff --git a/src/main/java/org/jogamp/java3d/DirectionalLight.java b/src/main/java/org/jogamp/java3d/DirectionalLight.java
index 2bd1b97..2a255ec 100644
--- a/src/main/java/org/jogamp/java3d/DirectionalLight.java
+++ b/src/main/java/org/jogamp/java3d/DirectionalLight.java
@@ -163,9 +163,10 @@ public class DirectionalLight extends Light {
throw new CapabilityNotSetException(
J3dI18N.getString("DirectionalLight2"));
- ((DirectionalLightRetained)this.retained).getDirection(direction);
+ ((DirectionalLightRetained)this.retained).getDirection(direction);
}
-
+
+
/**
* Used to create a new instance of the node. This routine is called
* by <code>cloneTree</code> to duplicate the current node.
diff --git a/src/main/java/org/jogamp/java3d/DirectionalLightRetained.java b/src/main/java/org/jogamp/java3d/DirectionalLightRetained.java
index e75a663..fd5cb55 100644
--- a/src/main/java/org/jogamp/java3d/DirectionalLightRetained.java
+++ b/src/main/java/org/jogamp/java3d/DirectionalLightRetained.java
@@ -186,7 +186,7 @@ class DirectionalLightRetained extends LightRetained
Pipeline.getPipeline().updateDirectionalLight(ctx,
lightSlot, color.x, color.y, color.z,
xformDirection.x, xformDirection.y,
- xformDirection.z);
+ xformDirection.z, shadowMapSamplerId, projMatrix);
}
// Clones only the retained side, internal use only
diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2Context.java b/src/main/java/org/jogamp/java3d/Jogl2es2Context.java
index c6a0c48..d2211af 100644
--- a/src/main/java/org/jogamp/java3d/Jogl2es2Context.java
+++ b/src/main/java/org/jogamp/java3d/Jogl2es2Context.java
@@ -35,35 +35,34 @@ import com.jogamp.opengl.GL2ES3;
import com.jogamp.opengl.GLContext;
-public class Jogl2es2Context extends JoglContext
-{
+public class Jogl2es2Context extends JoglContext {
- public Jogl2es2Context(GLContext context)
- {
+ public Jogl2es2Context(GLContext context) {
super(context);
}
- public GL2ES2 gl2es2()
- {
+ public GL2ES2 gl2es2() {
return context.getGL().getGL2ES2();
}
- public GL2ES3 gl2es3()
- {
+ public GL2ES3 gl2es3() {
if(context.getGL().isGL2ES3())
return context.getGL().getGL2ES3();
else
return null;
}
- public JoglShaderObject shaderProgram;
+ private JoglShaderObject shaderProgram;
+ @Override
+ public JoglShaderObject getShaderProgram() {
+ return shaderProgram;
+ }
public int shaderProgramId = -1;
- public ProgramData programData;
+ public ProgramData programData;
@Override
void setShaderProgram(JoglShaderObject object)
- {
- super.setShaderProgram(object);
+ {
shaderProgram = object;
shaderProgramId = object == null ? -1 : object.getValue();
programData = allProgramData.get(shaderProgramId);
@@ -109,7 +108,9 @@ public class Jogl2es2Context extends JoglContext
public int[] geoToTexCoordOffset = new int[10];
// vertex array object id for this geom
- public int vaoId = -1;
+ // a vao is only loaded for the corresponding shader
+ public SparseArray<Integer> geoToVaoId = new SparseArray<Integer>();
+ public int currentVaoId = -1;
//used to identify each geometry as we see it
private static int nextNativeId = 0;
@@ -219,7 +220,7 @@ public class Jogl2es2Context extends JoglContext
/**
* below here are openGL state tracking to reduce unnecessary native calls
- * Note this is NOT like the "new" or so called current staet above taht needs to be st in the FFP
+ * Note this is NOT like the "new" or so called current state above that needs to be set in the FFP
* call, this is the old or previously set data, that might not need to be updated
* @author phil
*
@@ -262,7 +263,7 @@ public class Jogl2es2Context extends JoglContext
public Vector4f objectColor = new Vector4f();
public float transparencyAlpha;
public Matrix4d textureTransform = new Matrix4d();
- public Matrix4d modelMatrix = new Matrix4d();
+ public Matrix4d glModelMatrix = new Matrix4d();
public Matrix4d glModelViewMatrix = new Matrix4d();
public Matrix4d glModelViewMatrixInverse = new Matrix4d();
public Matrix4d glModelViewProjectionMatrix = new Matrix4d();
@@ -310,7 +311,7 @@ public class Jogl2es2Context extends JoglContext
objectColor.set(Float.NEGATIVE_INFINITY, -999f, -999f, -999f);
transparencyAlpha = -1;
textureTransform.m00 = Double.NEGATIVE_INFINITY;
- modelMatrix.m00 = Double.NEGATIVE_INFINITY;
+ glModelMatrix.m00 = Double.NEGATIVE_INFINITY;
glModelViewMatrix.m00 = Double.NEGATIVE_INFINITY;
glModelViewMatrixInverse.m00 = Double.NEGATIVE_INFINITY;
glModelViewProjectionMatrix.m00 = Double.NEGATIVE_INFINITY;
@@ -460,7 +461,10 @@ public class Jogl2es2Context extends JoglContext
public float quadraticAttenuation;
public float spotCutoff;
public float spotExponent;
- public Vector3f spotDirection = new Vector3f();
+ public Vector3f spotDirection = new Vector3f();
+ public int shadowMapSamplerId = -1;
+ public Matrix4d projMatrix = new Matrix4d();
+
public void clear()
{
@@ -469,12 +473,15 @@ public class Jogl2es2Context extends JoglContext
position.set(-999f, -999f, -999f, -999f);
diffuse.set(-999f, -999f, -999f, -999f);
specular.set(-999f, -999f, -999f, -999f);
- constantAttenuation = -99;
- linearAttenuation = -99;
- quadraticAttenuation = -99;
- spotCutoff = -99;
- spotExponent = -99;
+ constantAttenuation = -99f;
+ linearAttenuation = -99f;
+ quadraticAttenuation = -99f;
+ spotCutoff = -99f;
+ spotExponent = -99f;
spotDirection.set(-999f, -999f, -999f);
+ shadowMapSamplerId = -1;
+ projMatrix.set(new double[] {-999f,-999f,-999f,-999f,-999f,-999f,-999f,-999f,-999f,-999f,-999f,-999f,-999f,-999f,-999f,-999});
+
}
public void set(glLightSource ogfm)
@@ -490,6 +497,7 @@ public class Jogl2es2Context extends JoglContext
spotCutoff = ogfm.spotCutoff;
spotExponent = ogfm.spotExponent;
spotDirection.set(ogfm.spotDirection);
+ // don't copy opengl ids shadowMapSamplerId or projMatrix
}
@Override
@@ -521,6 +529,8 @@ public class Jogl2es2Context extends JoglContext
public int spotCutoff = -1;
public int spotExponent = -1;
public int spotDirection = -1;
+ public int shadowMapSamplerId = -1;
+ public int projMatrix = -1;
}
// in the shader as follows
diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java b/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java
index 210b7a3..f2beac7 100644
--- a/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java
+++ b/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java
@@ -96,6 +96,7 @@ public class Jogl2es2PerFrameStats
public int setViewport;
public int freeTexture;
public int generateTexID;
+ public int generateFrameBufferID;
public int setDepthBufferWriteEnable;
public int redundantUseProgram;
diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java
index 68b1e87..df97513 100644
--- a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java
+++ b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java
@@ -1,22 +1,17 @@
/*
- * Copyright (c) 2016 JogAmp Community. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * Copyright (c) 2016 JogAmp Community. All rights reserved. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE
+ * HEADER.
*
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
+ * This code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation. Sun designates this particular file as subject
+ * to the "Classpath" exception as provided by Sun in the LICENSE file that accompanied this code.
*
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
+ * This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for
+ * more details (a copy is included in the LICENSE file that accompanied this code).
*
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License version 2 along with this work; if not, write to
+ * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
@@ -96,40 +91,37 @@ import com.jogamp.opengl.Threading;
/**
* Concrete implementation of Pipeline class for the GL2ES2 rendering pipeline.
*/
-class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
-{
+class Jogl2es2Pipeline extends Jogl2es2DEPPipeline {
//Note this is VERY expensive and should be false unless debugging
- private static final boolean DO_OUTPUT_ERRORS = false;
+ private static final boolean DO_OUTPUT_ERRORS = false;
// Currently prints for entry points already implemented
- static final boolean VERBOSE = true;
+ static final boolean VERBOSE = false;
// Debugging output for graphics configuration selection
- private static final boolean DEBUG_CONFIG = false;
+ private static final boolean DEBUG_CONFIG = false;
// Prints extra debugging information
- private static final boolean EXTRA_DEBUGGING = false;
+ private static final boolean EXTRA_DEBUGGING = false;
- private static final boolean OUTPUT_PER_FRAME_STATS = false;
+ private static final boolean OUTPUT_PER_FRAME_STATS = false;
- private static final boolean MINIMISE_NATIVE_CALLS_FFP = true;
+ private static final boolean MINIMISE_NATIVE_CALLS_FFP = true;
- private static final boolean MINIMISE_NATIVE_CALLS_TRANSPARENCY = true;
- private static final boolean MINIMISE_NATIVE_CALLS_TEXTURE = true;
+ private static final boolean MINIMISE_NATIVE_CALLS_TRANSPARENCY = true;
+ private static final boolean MINIMISE_NATIVE_CALLS_TEXTURE = true;
- private static final boolean MINIMISE_NATIVE_SHADER = true;
- private static final boolean MINIMISE_NATIVE_CALLS_OTHER = true;
+ private static final boolean MINIMISE_NATIVE_SHADER = true;
+ private static final boolean MINIMISE_NATIVE_CALLS_OTHER = true;
// This MUST be true on android fullscreen
// setPosition on a GLWindow can lock-up if true
// also with on and offscreen must be false too
- private static final boolean NEVER_RELEASE_CONTEXT = false;
-
-
- private static boolean quadArrayCautionPrinted = false;
+ private static final boolean NEVER_RELEASE_CONTEXT = false;
+
+ private static boolean quadArrayCautionPrinted = false;
/**
* Constructor for singleton JoglPipeline instance
*/
- protected Jogl2es2Pipeline()
- {
+ protected Jogl2es2Pipeline() {
}
@@ -137,8 +129,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
* Initialize the pipeline
*/
@Override
- void initialize(Pipeline.Type pipelineType)
- {
+ void initialize(Pipeline.Type pipelineType) {
super.initialize(pipelineType);
// Java3D maintains strict control over which threads perform OpenGL work
@@ -150,80 +141,73 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// FIXME: ugly hack for buffer clearing on removal of a geometry
- public void registerClearBuffers(Context ctx, GeometryArrayRetained geo)
- {
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
- synchronized (joglesctx.geoToClearBuffers)
- {
+ public void registerClearBuffers(Context ctx, GeometryArrayRetained geo) {
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
+ synchronized (joglesctx.geoToClearBuffers) {
joglesctx.geoToClearBuffers.add(geo);
}
}
- private static void doClearBuffers(Context ctx)
- {
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
-
- if (joglesctx.geoToClearBuffers.size() > 0)
- {
- synchronized (joglesctx.geoToClearBuffers)
- {
+ private static void doClearBuffers(Context ctx) {
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
+
+ if (joglesctx.geoToClearBuffers.size() > 0) {
+ synchronized (joglesctx.geoToClearBuffers) {
GL2ES2 gl = joglesctx.gl2es2();
- for (GeometryArrayRetained geo : joglesctx.geoToClearBuffers)
- {
+ for (GeometryArrayRetained geo : joglesctx.geoToClearBuffers) {
GeometryData gd = joglesctx.allGeometryData.get(geo.nativeId);
joglesctx.allGeometryData.remove(geo.nativeId);
geo.nativeId = -1;
// TODO: why exactly is the same geo being removed twice?
- if (gd != null)
- {
+ if (gd != null) {
if (gd.geoToIndBuf != -1)
- gl.glDeleteBuffers(1, new int[] { gd.geoToIndBuf }, 0);
+ gl.glDeleteBuffers(1, new int[] {gd.geoToIndBuf}, 0);
if (gd.geoToCoordBuf != -1)
- gl.glDeleteBuffers(1, new int[] { gd.geoToCoordBuf }, 0);
+ gl.glDeleteBuffers(1, new int[] {gd.geoToCoordBuf}, 0);
if (gd.geoToColorBuf != -1)
- gl.glDeleteBuffers(1, new int[] { gd.geoToColorBuf }, 0);
+ gl.glDeleteBuffers(1, new int[] {gd.geoToColorBuf}, 0);
if (gd.geoToNormalBuf != -1)
- gl.glDeleteBuffers(1, new int[] { gd.geoToNormalBuf }, 0);
+ gl.glDeleteBuffers(1, new int[] {gd.geoToNormalBuf}, 0);
int[] bufIds = gd.geoToIndStripBuf;
- if (bufIds != null && bufIds.length > 0)
- {
+ if (bufIds != null && bufIds.length > 0) {
gl.glDeleteBuffers(bufIds.length, bufIds, 0);
}
SparseArray<Integer> tcBufIds = gd.geoToTexCoordsBuf;
- if (tcBufIds != null)
- {
- for (int i = 0; i < tcBufIds.size(); i++)
- {
+ if (tcBufIds != null) {
+ for (int i = 0; i < tcBufIds.size(); i++) {
Integer tcBufId = tcBufIds.get(tcBufIds.keyAt(i));
if (tcBufId != null)
- gl.glDeleteBuffers(1, new int[] { tcBufId.intValue() }, 0);
+ gl.glDeleteBuffers(1, new int[] {tcBufId.intValue()}, 0);
}
tcBufIds.clear();
}
SparseArray<Integer> vaBufIds = gd.geoToVertAttribBuf;
- if (vaBufIds != null)
- {
- for (int i = 0; i < vaBufIds.size(); i++)
- {
+ if (vaBufIds != null) {
+ for (int i = 0; i < vaBufIds.size(); i++) {
Integer vaBufId = vaBufIds.get(vaBufIds.keyAt(i));
if (vaBufId != null)
- gl.glDeleteBuffers(1, new int[] { vaBufId.intValue() }, 0);
+ gl.glDeleteBuffers(1, new int[] {vaBufId.intValue()}, 0);
}
vaBufIds.clear();
}
if (gd.interleavedBufId != -1)
- gl.glDeleteBuffers(1, new int[] { gd.interleavedBufId }, 0);
-
- if (gd.vaoId != -1)
- ((GL2ES3) gl).glDeleteVertexArrays(1, new int[] { gd.vaoId }, 0);
+ gl.glDeleteBuffers(1, new int[] {gd.interleavedBufId}, 0);
+ if (gd.geoToVaoId != null) {
+ for (int i = 0; i < gd.geoToVaoId.size(); i++) {
+ Integer vaoId = gd.geoToVaoId.get(gd.geoToVaoId.keyAt(i));
+ if (vaoId != null)
+ ((GL2ES3)gl).glDeleteVertexArrays(1, new int[] {vaoId.intValue()}, 0);
+ }
+ gd.geoToVaoId.clear();
+ }
}
}
@@ -247,45 +231,46 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// used for GeometryArrays by Copy or interleaved
@Override
- void execute(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha,
- boolean ignoreVertexColors, int startVIndex, int vcount, int vformat, int texCoordSetCount, int[] texCoordSetMap,
- int texCoordSetMapLen, int[] texUnitOffset, int numActiveTexUnitState, int vertexAttrCount, int[] vertexAttrSizes,
- float[] varray, float[] carray, int cDirty)
- {
+ void execute( Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha,
+ boolean ignoreVertexColors, int startVIndex, int vcount, int vformat, int texCoordSetCount,
+ int[] texCoordSetMap, int texCoordSetMapLen, int[] texUnitOffset, int numActiveTexUnitState,
+ int vertexAttrCount, int[] vertexAttrSizes, float[] varray, float[] carray, int cDirty) {
if (VERBOSE)
System.err.println("JoglPipeline.execute()");
- executeGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, startVIndex, vcount, vformat,
- texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnitState, vertexAttrCount, vertexAttrSizes,
- varray, null, carray, cDirty);
+ executeGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, startVIndex, vcount,
+ vformat, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnitState,
+ vertexAttrCount, vertexAttrSizes, varray, null, carray, cDirty);
}
// used by GeometryArray by Reference in interleaved format with NIO buffer
@Override
- void executeInterleavedBuffer(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha,
- boolean ignoreVertexColors, int startVIndex, int vcount, int vformat, int texCoordSetCount, int[] texCoordSetMap,
- int texCoordSetMapLen, int[] texUnitOffset, int numActiveTexUnit, FloatBuffer varray, float[] cdata, int cdirty)
- {
+ void executeInterleavedBuffer( Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
+ boolean useAlpha, boolean ignoreVertexColors, int startVIndex, int vcount,
+ int vformat, int texCoordSetCount, int[] texCoordSetMap, int texCoordSetMapLen,
+ int[] texUnitOffset, int numActiveTexUnit, FloatBuffer varray, float[] cdata,
+ int cdirty) {
if (VERBOSE)
System.err.println("JoglPipeline.executeInterleavedBuffer()");
- executeGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, startVIndex, vcount, vformat,
- texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnit, 0, null, null, varray, cdata, cdirty);
+ executeGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, startVIndex, vcount,
+ vformat, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnit, 0, null,
+ null, varray, cdata, cdirty);
}
- private void executeGeometryArray(Context absCtx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha,
- boolean ignoreVertexColors, int startVIndex, int vcount, int vformat, int texCoordSetCount, int[] texCoordSetMap,
- int texCoordSetMapLen, int[] texCoordSetMapOffset, int numActiveTexUnitState, int vertexAttrCount, int[] vertexAttrSizes,
- float[] varray, FloatBuffer varrayBuffer, float[] carray, int cDirty)
- {
+ private void executeGeometryArray( Context absCtx, GeometryArrayRetained geo, int geo_type,
+ boolean isNonUniformScale, boolean useAlpha, boolean ignoreVertexColors,
+ int startVIndex, int vcount, int vformat, int texCoordSetCount,
+ int[] texCoordSetMap, int texCoordSetMapLen, int[] texCoordSetMapOffset,
+ int numActiveTexUnitState, int vertexAttrCount, int[] vertexAttrSizes,
+ float[] varray, FloatBuffer varrayBuffer, float[] carray, int cDirty) {
if (VERBOSE)
System.err.println("JoglPipeline.executeGeometryArray()");
- Jogl2es2Context ctx = (Jogl2es2Context) absCtx;
+ Jogl2es2Context ctx = (Jogl2es2Context)absCtx;
int shaderProgramId = ctx.shaderProgramId;
- if (shaderProgramId != -1)
- {
+ if (shaderProgramId != -1) {
GL2ES2 gl = ctx.gl2es2();
ProgramData pd = ctx.programData;
LocationData locs = pd.programToLocationData;
@@ -301,63 +286,46 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] sarray = null;
int[] start_array = null;
- if (EXTRA_DEBUGGING)
- {
+ if (EXTRA_DEBUGGING) {
System.err.println("Vertex format: " + getVertexDescription(vformat));
System.err.println("Geometry type: " + getGeometryDescription(geo_type));
- if (carray != null)
- {
+ if (carray != null) {
System.err.println(" Separate color array");
- }
- else
- {
+ } else {
System.err.println(" Colors (if any) interleaved");
}
}
- if ((vformat & GeometryArray.COORDINATES) != 0)
- {
+ if ((vformat & GeometryArray.COORDINATES) != 0) {
stride += 3;
}
- if ((vformat & GeometryArray.NORMALS) != 0)
- {
+ if ((vformat & GeometryArray.NORMALS) != 0) {
stride += 3;
coordoff += 3;
}
- if ((vformat & GeometryArray.COLOR) != 0)
- {
- if ((vformat & GeometryArray.WITH_ALPHA) != 0)
- {
+ if ((vformat & GeometryArray.COLOR) != 0) {
+ if ((vformat & GeometryArray.WITH_ALPHA) != 0) {
stride += 4;
normoff += 4;
coordoff += 4;
- }
- else
- {
+ } else {
// Handle the case of executeInterleaved 3f
stride += 3;
normoff += 3;
coordoff += 3;
}
}
- if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0)
- {
- if (EXTRA_DEBUGGING)
- {
+ if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
+ if (EXTRA_DEBUGGING) {
System.err.println("Number of tex coord sets: " + texCoordSetCount);
}
- if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0)
- {
+ if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) {
texSize = 2;
texStride = 2 * texCoordSetCount;
- }
- else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0)
- {
+ } else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0) {
texSize = 3;
texStride = 3 * texCoordSetCount;
- }
- else if ((vformat & GeometryArray.TEXTURE_COORDINATE_4) != 0)
- {
+ } else if ((vformat & GeometryArray.TEXTURE_COORDINATE_4) != 0) {
texSize = 4;
texStride = 4 * texCoordSetCount;
}
@@ -366,11 +334,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
coloroff += texStride;
coordoff += texStride;
}
- if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0)
- {
- for (int i = 0; i < vertexAttrCount; i++)
- {
- vAttrStride += vertexAttrSizes[i];
+ if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
+ for (int i = 0; i < vertexAttrCount; i++) {
+ vAttrStride += vertexAttrSizes [i];
}
stride += vAttrStride;
normoff += vAttrStride;
@@ -382,16 +348,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
bstride = stride * Buffers.SIZEOF_FLOAT;
if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET)
- {
- sarray = ((GeometryStripArrayRetained) geo).stripVertexCounts;
- start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices;
+ || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) {
+ sarray = ((GeometryStripArrayRetained)geo).stripVertexCounts;
+ start_array = ((GeometryStripArrayRetained)geo).stripStartOffsetIndices;
}
// using byRef interleaved array and has a separate pointer, then ..
int cstride = stride;
- if (carray != null)
- {
+ if (carray != null) {
cstride = 4;
}
@@ -399,13 +363,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int startVertex = stride * startVIndex;
int startClrs = cstride * startVIndex;
- if (carray == null)
- {
+ if (carray == null) {
startClrs += coloroff;
}
- if (EXTRA_DEBUGGING)
- {
+ if (EXTRA_DEBUGGING) {
System.err.println(" startVertex: " + startVertex);
System.err.println(" stride: " + stride);
System.err.println(" bstride: " + bstride);
@@ -415,81 +377,77 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
System.err.println(" texCoordoff: " + texCoordoff);
}
- GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vcount, vformat, vformat, varrayBuffer, varray, startVertex,
- varrayBuffer, carray, startClrs);
+ GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vcount, vformat, vformat, varrayBuffer,
+ varray, startVertex, varrayBuffer, carray, startClrs);
// GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of changeability
boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE)
- || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
+ || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
- // not required second time around for VAO (except morphable coords)
+ // not required second time around for VAO (except morphable coords, and for a change of shader)
boolean bindingRequired = true;
// Note although we ask for ES2 we can get ES3, which demands a VAO or nothing renders
- if (gl.isGL2ES3())
- {
+ if (gl.isGL2ES3()) {
GL2ES3 gl2es3 = (GL2ES3)gl;
- if (gd.vaoId == -1)
- {
+ Integer vaoIdI = gd.geoToVaoId.get(shaderProgramId);
+ int vaoId = vaoIdI == null ? -1 : vaoIdI.intValue();
+ if (vaoId == -1) {
int[] tmp = new int[1];
- gl2es3.glGenVertexArrays(1, tmp, 0);
- gd.vaoId = tmp[0];
+ gl2es3.glGenVertexArrays(1, tmp, 0);
+ vaoId = tmp [0];
+ gd.geoToVaoId.put(shaderProgramId, new Integer(vaoId));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
+ } else {
+ // don't rebind if this vao was used last time for this geometry
+ if(gd.currentVaoId == vaoId)
+ bindingRequired = false;
}
- else
- {
- bindingRequired = false;
- }
- gl2es3.glBindVertexArray(gd.vaoId);
+ gl2es3.glBindVertexArray(vaoId);
+ gd.currentVaoId = vaoId;
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
}
// refill the buffers in case of writeable data (morphable)
- if (locs.glVertex != -1)
- {
- if (gd.geoToCoordBuf == -1)
- {
+ if (locs.glVertex != -1) {
+ if (gd.geoToCoordBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
// rather than the morphable system above we should be able to use cDirty, but it appears to be wrong
// if ((cDirty & GeometryArrayRetained.COORDINATE_CHANGED) != 0)
- if (morphable)
- {
+ if (morphable) {
FloatBuffer verts = null;
// do we need to covert a float[]
- if (varray != null)
- {
+ if (varray != null) {
verts = getVertexArrayBuffer(varray);
- }
- else
- {
+ } else {
verts = varrayBuffer;
}
verts.position(startVertex);
// Sometime the FloatBuffer is swapped out for bigger or smaller
- if (gd.geoToCoordBufSize != verts.remaining())
- {
- System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != " + verts.remaining()
- + " un indexed ((GeometryArray) geo.source) " + ((GeometryArray) geo.source).getName() + " "
- + geo.source + ", this is not nessasarily a problem");
+ if (gd.geoToCoordBufSize != verts.remaining()) {
+ System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != "
+ + verts.remaining() + " un indexed ((GeometryArray) geo.source) "
+ + ((GeometryArray)geo.source).getName() + " " + geo.source
+ + ", this is not nessasarily a problem");
int prevBufId1 = gd.geoToCoordBuf1;// record these in order to delete after re-bind
int prevBufId2 = gd.geoToCoordBuf2;
int[] tmp = new int[2];
gl.glGenBuffers(2, tmp, 0);
- gd.geoToCoordBuf = tmp[0];
- gd.geoToCoordBuf1 = tmp[0];
- gd.geoToCoordBuf2 = tmp[1];
+ gd.geoToCoordBuf = tmp [0];
+ gd.geoToCoordBuf1 = tmp [0];
+ gd.geoToCoordBuf2 = tmp [1];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
- gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts, GL2ES2.GL_DYNAMIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts,
+ GL2ES2.GL_DYNAMIC_DRAW);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2);
- gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts, GL2ES2.GL_DYNAMIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts,
+ GL2ES2.GL_DYNAMIC_DRAW);
gd.geoToCoordBufSize = verts.remaining();
@@ -514,25 +472,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.coordCount += gd.geoToCoordBufSize;
- gl.glDeleteBuffers(1, new int[] { prevBufId1, prevBufId2 }, 0);
+ gl.glDeleteBuffers(1, new int[] {prevBufId1, prevBufId2}, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
+ } else {
// work out the buffer to update and buffer to swap to
- if (gd.geoToCoordBuf == gd.geoToCoordBuf1)
- {
+ if (gd.geoToCoordBuf == gd.geoToCoordBuf1) {
// update 1 but set to draw 2
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8), verts);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8),
+ verts);
gd.geoToCoordBuf = gd.geoToCoordBuf2;
- }
- else
- {
+ } else {
// update 2 but set to draw 1
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2);
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8), verts);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8),
+ verts);
gd.geoToCoordBuf = gd.geoToCoordBuf1;
}
@@ -544,36 +499,26 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
}
- }
- else
- {
- throw new UnsupportedOperationException("Shader has no glVertex.\n" + VALID_FORMAT_MESSAGE);
+ } else {
+ throw new UnsupportedOperationException("Shader has no glVertex.\n");
}
// update other attributes if required
- if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors)
- {
+ if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors) {
// if ((cDirty & GeometryArrayRetained.COLOR_CHANGED) != 0)
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_COLOR_WRITE);
- if (changable)
- {
+ if (changable) {
FloatBuffer verts = null;
FloatBuffer clrs = null;
// do we need to covert a float[]
- if (varray != null)
- {
+ if (varray != null) {
verts = getVertexArrayBuffer(varray);
- }
- else
- {
+ } else {
verts = varrayBuffer;
}
- if (carray != null)
- {
+ if (carray != null) {
verts = getColorArrayBuffer(carray);
- }
- else
- {
+ } else {
clrs = verts;
}
@@ -585,8 +530,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// notice morphables must always rebind each frame as coord buffers are swapped, so the vao
// (if it is bound points to the previous buffer)
- if (bindingRequired || morphable)
- {
+ if (bindingRequired || morphable) {
// always do coords
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, bstride,
@@ -602,16 +546,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
ctx.perFrameStats.coordCount += gd.geoToCoordBufSize;
}
- if (bindingRequired)
- {
- if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors)
- {
- if (gd.geoToColorBuf == -1)
- {
+ if (bindingRequired) {
+ if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors) {
+ if (gd.geoToColorBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
int sz = ((vformat & GeometryArray.WITH_ALPHA) != 0) ? 4 : 3;
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf);
@@ -624,23 +563,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glVertexAttribPointerColor++;
}
- }
- else if (locs.glColor != -1)
- {
+ } else if (locs.glColor != -1) {
// ignoreVertexcolors will have been set in FFP, now as the glColors is unbound
gl.glDisableVertexAttribArray(locs.glColor);
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDisableVertexAttribArray++;
}
- if (((vformat & GeometryArray.NORMALS) != 0) && locs.glNormal != -1)
- {
- if (gd.geoToCoordBuf == -1)
- {
+ if (((vformat & GeometryArray.NORMALS) != 0) && locs.glNormal != -1) {
+ if (gd.geoToCoordBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
gl.glVertexAttribPointer(locs.glNormal, 3, GL2ES2.GL_FLOAT, false, bstride,
(startVertex + normoff) * Buffers.SIZEOF_FLOAT);
@@ -651,32 +584,26 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glVertexAttribPointerNormals++;
}
- }
- else
- {
- if (locs.glNormal != -1)
- {
+ } else {
+ if (locs.glNormal != -1) {
gl.glDisableVertexAttribArray(locs.glNormal);
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDisableVertexAttribArray++;
}
}
- if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0)
- {
+ if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
int vAttrOffset = startVertex + vAttrOff;
- for (int index = 0; index < vertexAttrCount; index++)
- {
+ for (int index = 0; index < vertexAttrCount; index++) {
Integer attribLoc = locs.genAttIndexToLoc.get(index);
- if (attribLoc != null && attribLoc.intValue() != -1)
- {
- int sz = vertexAttrSizes[index];
+ if (attribLoc != null && attribLoc.intValue() != -1) {
+ int sz = vertexAttrSizes [index];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
gl.glVertexAttribPointer(attribLoc.intValue(), sz, GL2ES2.GL_FLOAT, false, bstride,
vAttrOffset * Buffers.SIZEOF_FLOAT);
gl.glEnableVertexAttribArray(attribLoc.intValue());
- vAttrOffset += vertexAttrSizes[index];
+ vAttrOffset += vertexAttrSizes [index];
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -687,19 +614,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0)
- {
+ if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
boolean[] texSetsBound = new boolean[texCoordSetMapLen];
- for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordSetMapLen; texUnit++)
- {
- int texSet = texCoordSetMap[texUnit];
- if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet])
- {
- texSetsBound[texSet] = true;
+ for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordSetMapLen; texUnit++) {
+ int texSet = texCoordSetMap [texUnit];
+ if (texSet != -1 && locs.glMultiTexCoord [texSet] != -1 && !texSetsBound [texSet]) {
+ texSetsBound [texSet] = true;
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
- gl.glVertexAttribPointer(locs.glMultiTexCoord[texUnit], texSize, GL2ES2.GL_FLOAT, true, bstride,
- (startVertex + texCoordoff + texCoordSetMapOffset[texUnit]) * Buffers.SIZEOF_FLOAT);
- gl.glEnableVertexAttribArray(locs.glMultiTexCoord[texUnit]);
+ gl.glVertexAttribPointer(locs.glMultiTexCoord [texUnit], texSize, GL2ES2.GL_FLOAT, true,
+ bstride, (startVertex + texCoordoff + texCoordSetMapOffset [texUnit])
+ * Buffers.SIZEOF_FLOAT);
+ gl.glEnableVertexAttribArray(locs.glMultiTexCoord [texUnit]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -717,8 +642,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
//////////////////////////////////////////////
if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET)
- {
+ || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) {
int primType = 0;
// FIXME: GL_LINE and GL_LINE_STRIP simply go from one vertex to the next drawing a line between
@@ -726,24 +650,21 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE)
geo_type = GeometryRetained.GEO_TYPE_LINE_STRIP_SET;
- switch (geo_type)
- {
- case GeometryRetained.GEO_TYPE_TRI_STRIP_SET:
- primType = GL2ES2.GL_TRIANGLE_STRIP;
- break;
- case GeometryRetained.GEO_TYPE_TRI_FAN_SET:
- primType = GL2ES2.GL_TRIANGLE_FAN;
- break;
- case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
- primType = GL2ES2.GL_LINE_LOOP;
- break;
+ switch (geo_type) {
+ case GeometryRetained.GEO_TYPE_TRI_STRIP_SET:
+ primType = GL2ES2.GL_TRIANGLE_STRIP;
+ break;
+ case GeometryRetained.GEO_TYPE_TRI_FAN_SET:
+ primType = GL2ES2.GL_TRIANGLE_FAN;
+ break;
+ case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
+ primType = GL2ES2.GL_LINE_LOOP;
+ break;
}
- for (int i = 0; i < sarray.length; i++)
- {
- if (sarray[i] > 0)
- {
- gl.glDrawArrays(primType, start_array[i], sarray[i]);
+ for (int i = 0; i < sarray.length; i++) {
+ if (sarray [i] > 0) {
+ gl.glDrawArrays(primType, start_array [i], sarray [i]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (OUTPUT_PER_FRAME_STATS)
@@ -752,35 +673,34 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDrawStripArrays++;
- }
- else
- {
+ } else {
//need to override if polygonAttributes says so
if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE)
geo_type = GeometryRetained.GEO_TYPE_LINE_SET;
else if (ctx.polygonMode == PolygonAttributes.POLYGON_POINT)
geo_type = GeometryRetained.GEO_TYPE_POINT_SET;
- switch (geo_type)
- {
- case GeometryRetained.GEO_TYPE_QUAD_SET:
- if(!quadArrayCautionPrinted) {
- System.err.println("QuadArray will render incorrectly, consider using TriangleArray. If you have the java3d-utils in the buildpath you can convert like this:");
- System.err.println("GeometryInfo gi = new GeometryInfo(quadArray);");
- System.err.println("gi.convertToIndexedTriangles(); ");
- System.err.println("GeometryArray ga = gi.getIndexedGeometryArray(true, true, true, true, true);");
- quadArrayCautionPrinted = true;
- }
- //fallthrough
- case GeometryRetained.GEO_TYPE_TRI_SET:
- gl.glDrawArrays(GL2ES2.GL_TRIANGLES, 0, vcount);
- break;
- case GeometryRetained.GEO_TYPE_POINT_SET:
- gl.glDrawArrays(GL2ES2.GL_POINTS, 0, vcount);
- break;
- case GeometryRetained.GEO_TYPE_LINE_SET:
- gl.glDrawArrays(GL2ES2.GL_LINES, 0, vcount);
- break;
+ switch (geo_type) {
+ case GeometryRetained.GEO_TYPE_QUAD_SET:
+ if (!quadArrayCautionPrinted) {
+ System.err.println(
+ "QuadArray will render incorrectly, consider using TriangleArray. If you have the java3d-utils in the buildpath you can convert like this:");
+ System.err.println("GeometryInfo gi = new GeometryInfo(quadArray);");
+ System.err.println("gi.convertToIndexedTriangles(); ");
+ System.err.println(
+ "GeometryArray ga = gi.getIndexedGeometryArray(true, true, true, true, true);");
+ quadArrayCautionPrinted = true;
+ }
+ //fallthrough
+ case GeometryRetained.GEO_TYPE_TRI_SET:
+ gl.glDrawArrays(GL2ES2.GL_TRIANGLES, 0, vcount);
+ break;
+ case GeometryRetained.GEO_TYPE_POINT_SET:
+ gl.glDrawArrays(GL2ES2.GL_POINTS, 0, vcount);
+ break;
+ case GeometryRetained.GEO_TYPE_LINE_SET:
+ gl.glDrawArrays(GL2ES2.GL_LINES, 0, vcount);
+ break;
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -788,13 +708,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDrawArrays++;
}
- }
- else
- {
+ } else {
if (!NO_PROGRAM_WARNING_GIVEN)
System.err.println("Execute called with no shader Program in use!");
NO_PROGRAM_WARNING_GIVEN = true;
-
+
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.executeSkippedNoShaderProgram++;
}
@@ -808,8 +726,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Private helper methods for GeometryArrayRetained
//
- private static String getVertexDescription(int vformat)
- {
+ private static String getVertexDescription(int vformat) {
String res = "";
if ((vformat & GeometryArray.COORDINATES) != 0)
res += "COORDINATES ";
@@ -832,38 +749,37 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
return res;
}
- private static String getGeometryDescription(int geo_type)
- {
- switch (geo_type)
- {
- case GeometryRetained.GEO_TYPE_TRI_STRIP_SET:
- return "GEO_TYPE_TRI_STRIP_SET";
- case GeometryRetained.GEO_TYPE_TRI_FAN_SET:
- return "GEO_TYPE_TRI_FAN_SET";
- case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
- return "GEO_TYPE_LINE_STRIP_SET";
- case GeometryRetained.GEO_TYPE_QUAD_SET:
- return "GEO_TYPE_QUAD_SET";
- case GeometryRetained.GEO_TYPE_TRI_SET:
- return "GEO_TYPE_TRI_SET";
- case GeometryRetained.GEO_TYPE_POINT_SET:
- return "GEO_TYPE_POINT_SET";
- case GeometryRetained.GEO_TYPE_LINE_SET:
- return "GEO_TYPE_LINE_SET";
- default:
- return "(unknown " + geo_type + ")";
+ private static String getGeometryDescription(int geo_type) {
+ switch (geo_type) {
+ case GeometryRetained.GEO_TYPE_TRI_STRIP_SET:
+ return "GEO_TYPE_TRI_STRIP_SET";
+ case GeometryRetained.GEO_TYPE_TRI_FAN_SET:
+ return "GEO_TYPE_TRI_FAN_SET";
+ case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
+ return "GEO_TYPE_LINE_STRIP_SET";
+ case GeometryRetained.GEO_TYPE_QUAD_SET:
+ return "GEO_TYPE_QUAD_SET";
+ case GeometryRetained.GEO_TYPE_TRI_SET:
+ return "GEO_TYPE_TRI_SET";
+ case GeometryRetained.GEO_TYPE_POINT_SET:
+ return "GEO_TYPE_POINT_SET";
+ case GeometryRetained.GEO_TYPE_LINE_SET:
+ return "GEO_TYPE_LINE_SET";
+ default:
+ return "(unknown " + geo_type + ")";
}
}
// used by GeometryArray by Reference with NIO buffer non indexed
//texCoords will be an array of FloatBuffer
@Override
- void executeVABuffer(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean ignoreVertexColors,
- int vcount, int vformat, int vdefined, int initialCoordIndex, Buffer vcoords, int initialColorIndex, Buffer cdataBuffer,
- float[] cfdata, byte[] cbdata, int initialNormalIndex, FloatBuffer ndata, int vertexAttrCount, int[] vertexAttrSizes,
- int[] vertexAttrIndices, FloatBuffer[] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState,
- int[] texIndex, int texstride, Object[] texCoords, int cdirty)
- {
+ void executeVABuffer( Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
+ boolean ignoreVertexColors, int vcount, int vformat, int vdefined, int initialCoordIndex,
+ Buffer vcoords, int initialColorIndex, Buffer cdataBuffer, float[] cfdata, byte[] cbdata,
+ int initialNormalIndex, FloatBuffer ndata, int vertexAttrCount, int[] vertexAttrSizes,
+ int[] vertexAttrIndices, FloatBuffer[] vertexAttrData, int texCoordMapLength,
+ int[] texcoordoffset, int numActiveTexUnitState, int[] texIndex, int texstride,
+ Object[] texCoords, int cdirty) {
if (VERBOSE)
System.err.println("JoglPipeline.executeVABuffer() ");
@@ -889,30 +805,23 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
vertexAttrBufs = vertexAttrData;
// get coordinate array
- if (floatCoordDefined)
- {
- fverts = (FloatBuffer) vcoords;
- }
- else if (doubleCoordDefined)
- {
+ if (floatCoordDefined) {
+ fverts = (FloatBuffer)vcoords;
+ } else if (doubleCoordDefined) {
// FIXME: doubles not supported for now
throw new UnsupportedOperationException("Double coordinates in use.\n" + VALID_FORMAT_MESSAGE);
// dverts = (DoubleBuffer) vcoords;
}
- if (fverts == null && dverts == null)
- {
+ if (fverts == null && dverts == null) {
return;
}
-
- if (floatColorsDefined)
- {
- fclrs = (FloatBuffer) cdataBuffer;
+ if (floatColorsDefined) {
+ fclrs = (FloatBuffer)cdataBuffer;
}
- if (byteColorsDefined)
- {
+ if (byteColorsDefined) {
// FIXME: bytes not supported for now
throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE);
// if (cbdata != null)
@@ -922,8 +831,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// get normal array
- if (normalsDefined)
- {
+ if (normalsDefined) {
norms = ndata;
}
@@ -931,28 +839,28 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] start_array = null;
int strip_len = 0;
if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET)
- {
- sarray = ((GeometryStripArrayRetained) geo).stripVertexCounts;
+ || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) {
+ sarray = ((GeometryStripArrayRetained)geo).stripVertexCounts;
strip_len = sarray.length;
- start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices;
+ start_array = ((GeometryStripArrayRetained)geo).stripStartOffsetIndices;
}
- executeGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex,
- fverts, null, dverts, null, initialColorIndex, fclrs, cfdata, bclrs, null, initialNormalIndex, norms, null, vertexAttrCount,
- vertexAttrSizes, vertexAttrIndices, vertexAttrBufs, null, texCoordMapLength, texcoordoffset, numActiveTexUnitState,
- texIndex, texstride, texCoords, cdirty, sarray, strip_len, start_array);
+ executeGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, vcount, vformat, vdefined,
+ initialCoordIndex, fverts, null, dverts, null, initialColorIndex, fclrs, cfdata, bclrs, null,
+ initialNormalIndex, norms, null, vertexAttrCount, vertexAttrSizes, vertexAttrIndices, vertexAttrBufs,
+ null, texCoordMapLength, texcoordoffset, numActiveTexUnitState, texIndex, texstride, texCoords, cdirty,
+ sarray, strip_len, start_array);
}
// used by GeometryArray by Reference with java arrays non indexed
//Object[] texCoords is an array of float arrays
@Override
- void executeVA(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean ignoreVertexColors, int vcount,
- int vformat, int vdefined, int initialCoordIndex, float[] vfcoords, double[] vdcoords, int initialColorIndex, float[] cfdata,
- byte[] cbdata, int initialNormalIndex, float[] ndata, int vertexAttrCount, int[] vertexAttrSizes, int[] vertexAttrIndices,
- float[][] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState, int[] texIndex, int texstride,
- Object[] texCoords, int cdirty)
- {
+ void executeVA( Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
+ boolean ignoreVertexColors, int vcount, int vformat, int vdefined, int initialCoordIndex,
+ float[] vfcoords, double[] vdcoords, int initialColorIndex, float[] cfdata, byte[] cbdata,
+ int initialNormalIndex, float[] ndata, int vertexAttrCount, int[] vertexAttrSizes,
+ int[] vertexAttrIndices, float[][] vertexAttrData, int texCoordMapLength, int[] texcoordoffset,
+ int numActiveTexUnitState, int[] texIndex, int texstride, Object[] texCoords, int cdirty) {
if (VERBOSE)
System.err.println("JoglPipeline.executeVA()");
@@ -968,46 +876,45 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] start_array = null;
int strip_len = 0;
if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET)
- {
- sarray = ((GeometryStripArrayRetained) geo).stripVertexCounts;
+ || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) {
+ sarray = ((GeometryStripArrayRetained)geo).stripVertexCounts;
strip_len = sarray.length;
- start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices;
+ start_array = ((GeometryStripArrayRetained)geo).stripStartOffsetIndices;
}
- if (doubleCoordDefined)
- {
+ if (doubleCoordDefined) {
// FIXME: doubles not supported for now
throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE);
// dverts = getVertexArrayBuffer(vdcoords);
}
- if (byteColorsDefined)
- {
+ if (byteColorsDefined) {
// FIXME: byte colors not supported for now
throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE);
// bclrs = getColorArrayBuffer(cbdata);
}
- executeGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex,
- null, vfcoords, null, vdcoords, initialColorIndex, null, cfdata, null, cbdata, initialNormalIndex, null, ndata,
- vertexAttrCount, vertexAttrSizes, vertexAttrIndices, null, vertexAttrData, texCoordMapLength, texcoordoffset,
- numActiveTexUnitState, texIndex, texstride, texCoords, cdirty, sarray, strip_len, start_array);
- }
-
- private void executeGeometryArrayVA(Context absCtx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
- boolean ignoreVertexColors, int vertexCount, int vformat, int vdefined, int initialCoordIndex, FloatBuffer fverts,
- float[] vfcoords, DoubleBuffer dverts, double[] vdcoords, int initialColorIndex, FloatBuffer fclrs, float[] cfdata,
- ByteBuffer bclrs, byte[] cbdata, int initialNormalIndex, FloatBuffer norms, float[] ndata, int vertexAttrCount,
- int[] vertexAttrSizes, int[] vertexAttrIndices, FloatBuffer[] vertexAttrBufs, float[][] vertexAttrData, int texCoordMapLength,
- int[] texCoordSetMap, int numActiveTexUnitState, int[] texindices, int texStride, Object[] texCoords, int cDirty, int[] sarray,
- int strip_len, int[] start_array)
- {
- Jogl2es2Context ctx = (Jogl2es2Context) absCtx;
+ executeGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, vcount, vformat, vdefined,
+ initialCoordIndex, null, vfcoords, null, vdcoords, initialColorIndex, null, cfdata, null, cbdata,
+ initialNormalIndex, null, ndata, vertexAttrCount, vertexAttrSizes, vertexAttrIndices, null,
+ vertexAttrData, texCoordMapLength, texcoordoffset, numActiveTexUnitState, texIndex, texstride,
+ texCoords, cdirty, sarray, strip_len, start_array);
+ }
+
+ private void executeGeometryArrayVA(Context absCtx, GeometryArrayRetained geo, int geo_type,
+ boolean isNonUniformScale, boolean ignoreVertexColors, int vertexCount,
+ int vformat, int vdefined, int initialCoordIndex, FloatBuffer fverts,
+ float[] vfcoords, DoubleBuffer dverts, double[] vdcoords, int initialColorIndex,
+ FloatBuffer fclrs, float[] cfdata, ByteBuffer bclrs, byte[] cbdata,
+ int initialNormalIndex, FloatBuffer norms, float[] ndata, int vertexAttrCount,
+ int[] vertexAttrSizes, int[] vertexAttrIndices, FloatBuffer[] vertexAttrBufs,
+ float[][] vertexAttrData, int texCoordMapLength, int[] texCoordSetMap,
+ int numActiveTexUnitState, int[] texindices, int texStride, Object[] texCoords,
+ int cDirty, int[] sarray, int strip_len, int[] start_array) {
+ Jogl2es2Context ctx = (Jogl2es2Context)absCtx;
int shaderProgramId = ctx.shaderProgramId;
- if (shaderProgramId != -1)
- {
+ if (shaderProgramId != -1) {
GL2ES2 gl = ctx.gl2es2();
ProgramData pd = ctx.programData;
LocationData locs = pd.programToLocationData;
@@ -1015,9 +922,10 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
setFFPAttributes(ctx, gl, shaderProgramId, pd, vdefined, ignoreVertexColors);
// If any buffers need loading do that now
- GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vertexCount, vformat, vdefined, fverts, vfcoords, dverts,
- vdcoords, fclrs, cfdata, bclrs, cbdata, norms, ndata, vertexAttrCount, vertexAttrSizes, vertexAttrBufs, vertexAttrData,
- texCoordMapLength, texCoordSetMap, texStride, texCoords);
+ GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vertexCount, vformat, vdefined, fverts,
+ vfcoords, dverts, vdcoords, fclrs, cfdata, bclrs, cbdata, norms, ndata, vertexAttrCount,
+ vertexAttrSizes, vertexAttrBufs, vertexAttrData, texCoordMapLength, texCoordSetMap, texStride,
+ texCoords);
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
@@ -1029,69 +937,64 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of changeability
boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE)
- || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
+ || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
- // not required second time around for VAO (except morphable coords)
+ // not required second time around for VAO (except morphable coords, and for a change of shader)
boolean bindingRequired = true;
// Note although we ask for ES2 we can get ES3, which demands a VAO or nothing renders
- if (gl.isGL2ES3())
- {
+ if (gl.isGL2ES3()) {
GL2ES3 gl2es3 = (GL2ES3)gl;
- if (gd.vaoId == -1)
- {
+ Integer vaoIdI = gd.geoToVaoId.get(shaderProgramId);
+ int vaoId = vaoIdI == null ? -1 : vaoIdI.intValue();
+ if (vaoId == -1) {
int[] tmp = new int[1];
- gl2es3.glGenVertexArrays(1, tmp, 0);
- gd.vaoId = tmp[0];
+ gl2es3.glGenVertexArrays(1, tmp, 0);
+ vaoId = tmp [0];
+ gd.geoToVaoId.put(shaderProgramId, new Integer(vaoId));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
+ } else {
+ // don't rebind if this vao was used last time for this geometry
+ if(gd.currentVaoId == vaoId)
+ bindingRequired = false;
}
- else
- {
- bindingRequired = false;
- }
- gl2es3.glBindVertexArray(gd.vaoId);
+ gl2es3.glBindVertexArray(vaoId);
+ gd.currentVaoId = vaoId;
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
}
// Define the data pointers
- if (locs.glVertex != -1)
- {
- if (floatCoordDefined)
- {
- if (gd.geoToCoordBuf == -1)
- {
+ if (locs.glVertex != -1) {
+ if (floatCoordDefined) {
+ if (gd.geoToCoordBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
// rather than the morphable system above we should be able to use cDirty, but it appears to be wrong
// if ((cDirty & GeometryArrayRetained.COORDINATE_CHANGED) != 0)
- if (morphable)
- {
+ if (morphable) {
//if I have vfcoords instead of fverts need to get a fverts buff now
- if (vfcoords != null)
- {
+ if (vfcoords != null) {
fverts = getVertexArrayBuffer(vfcoords);
}
int coordoff = 3 * initialCoordIndex;
fverts.position(coordoff);
// Sometime the FloatBuffer is swapped out for bigger or smaller
- if (gd.geoToCoordBufSize != fverts.remaining())
- {
- System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != " + fverts.remaining()
- + " un indexed ((GeometryArray) geo.source) " + ((GeometryArray) geo.source).getName() + " "
- + geo.source + ", this is not nessasarily a problem");
+ if (gd.geoToCoordBufSize != fverts.remaining()) {
+ System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != "
+ + fverts.remaining() + " un indexed ((GeometryArray) geo.source) "
+ + ((GeometryArray)geo.source).getName() + " " + geo.source
+ + ", this is not nessasarily a problem");
int prevBufId1 = gd.geoToCoordBuf1;// record these in order to delete after re-bind
int prevBufId2 = gd.geoToCoordBuf2;
int[] tmp = new int[2];
gl.glGenBuffers(2, tmp, 0);
- gd.geoToCoordBuf = tmp[0];
- gd.geoToCoordBuf1 = tmp[0];
- gd.geoToCoordBuf2 = tmp[1];
+ gd.geoToCoordBuf = tmp [0];
+ gd.geoToCoordBuf1 = tmp [0];
+ gd.geoToCoordBuf2 = tmp [1];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts,
@@ -1123,25 +1026,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.coordCount += gd.geoToCoordBufSize;
- gl.glDeleteBuffers(1, new int[] { prevBufId1, prevBufId2 }, 0);
+ gl.glDeleteBuffers(1, new int[] {prevBufId1, prevBufId2}, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
+ } else {
// work out the buffer to update and buffer to swap to
- if (gd.geoToCoordBuf == gd.geoToCoordBuf1)
- {
+ if (gd.geoToCoordBuf == gd.geoToCoordBuf1) {
// update 1 but set to draw 2
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8), fverts);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8),
+ fverts);
gd.geoToCoordBuf = gd.geoToCoordBuf2;
- }
- else
- {
+ } else {
// update 2 but set to draw 1
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2);
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8), fverts);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8),
+ fverts);
gd.geoToCoordBuf = gd.geoToCoordBuf1;
}
@@ -1155,31 +1055,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
- }
- else if (doubleCoordDefined)
- {
+ } else if (doubleCoordDefined) {
throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE);
- }
- else
- {
+ } else {
throw new UnsupportedOperationException("No coords defined.\n" + VALID_FORMAT_MESSAGE);
}
- }
- else
- {
- throw new UnsupportedOperationException("Shader has no glVertex.\n" + VALID_FORMAT_MESSAGE);
+ } else {
+ throw new UnsupportedOperationException("Shader has no glVertex.\n");
}
// update other attributes if required
- if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors)
- {
+ if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors) {
// if ((cDirty & GeometryArrayRetained.COLOR_CHANGED) != 0)
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_COLOR_WRITE);
- if (changable)
- {
+ if (changable) {
//if I have cfdata instead of fclrs need to get a fclrs buff now
- if (cfdata != null)
- {
+ if (cfdata != null) {
fclrs = getColorArrayBuffer(cfdata);
}
@@ -1188,15 +1079,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, fclrs.remaining() * Float.SIZE / 8, fclrs);
}
}
- if (normalsDefined && locs.glNormal != -1)
- {
+ if (normalsDefined && locs.glNormal != -1) {
// if ((cDirty & GeometryArrayRetained.NORMAL_CHANGED) != 0)
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_NORMAL_WRITE);
- if (changable)
- {
+ if (changable) {
//if I have ndata instead of norms need to get a norms buff now
- if (ndata != null)
- {
+ if (ndata != null) {
norms = getNormalArrayBuffer(ndata);
}
norms.position(0);
@@ -1205,49 +1093,40 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (vattrDefined)
- {
- if (vertexAttrData != null)
- {
+ if (vattrDefined) {
+ if (vertexAttrData != null) {
vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);
}
- for (int index = 0; index < vertexAttrCount; index++)
- {
+ for (int index = 0; index < vertexAttrCount; index++) {
Integer attribLoc = locs.genAttIndexToLoc.get(index);
- if (attribLoc != null && attribLoc.intValue() != -1)
- {
+ if (attribLoc != null && attribLoc.intValue() != -1) {
// if ((cDirty & GeometryArrayRetained.VATTR_CHANGED) != 0)
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_VERTEX_ATTR_WRITE);
- if (changable)
- {
- FloatBuffer vertexAttrs = vertexAttrBufs[index];
+ if (changable) {
+ FloatBuffer vertexAttrs = vertexAttrBufs [index];
vertexAttrs.position(0);
SparseArray<Integer> bufIds = gd.geoToVertAttribBuf;
Integer bufId = bufIds.get(index);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue());
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, vertexAttrs.remaining() * Float.SIZE / 8, vertexAttrs);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, vertexAttrs.remaining() * Float.SIZE / 8,
+ vertexAttrs);
}
}
}
}
- if (textureDefined)
- {
+ if (textureDefined) {
// convert from float[][] to FloatBuffer[]
- if (!(texCoords[0] instanceof FloatBuffer))
- {
+ if (!(texCoords [0] instanceof FloatBuffer)) {
texCoords = getTexCoordSetBuffer(texCoords);
}
boolean[] texSetsBound = new boolean[texCoords.length];
- for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++)
- {
- int texSet = texCoordSetMap[texUnit];
- if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet])
- {
+ for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++) {
+ int texSet = texCoordSetMap [texUnit];
+ if (texSet != -1 && locs.glMultiTexCoord [texSet] != -1 && !texSetsBound [texSet]) {
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_TEXCOORD_WRITE);
- if (changable)
- {
- FloatBuffer buf = (FloatBuffer) texCoords[texSet];
+ if (changable) {
+ FloatBuffer buf = (FloatBuffer)texCoords [texSet];
buf.position(0);
SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf;
Integer bufId = bufIds.get(texUnit);
@@ -1259,8 +1138,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// notice morphables must always rebind each frame as coord buffers are swapped
- if (bindingRequired || morphable)
- {
+ if (bindingRequired || morphable) {
// always do coords
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, 0, 0);
@@ -1274,16 +1152,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
ctx.perFrameStats.coordCount += gd.geoToCoordBufSize;
}
- if (bindingRequired)
- {
- if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors)
- {
- if (gd.geoToColorBuf == -1)
- {
+ if (bindingRequired) {
+ if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors) {
+ if (gd.geoToColorBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
int coloroff;
int sz = ((vformat & GeometryArray.WITH_ALPHA) != 0) ? 4 : 3;
@@ -1300,9 +1173,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glVertexAttribPointerColor++;
}
- }
- else if (byteColorsDefined && locs.glColor != -1 && !ignoreVertexColors)
- {
+ } else if (byteColorsDefined && locs.glColor != -1 && !ignoreVertexColors) {
//FIXME: byteColors not supported for now, but I want them a lot
throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE);
/*int coloroff;
@@ -1319,23 +1190,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
bclrs.position(coloroff);
gl.glColorPointer(sz, GL2ES2.GL_UNSIGNED_BYTE, 0, bclrs);*/
- }
- else if (locs.glColor != -1)
- {
+ } else if (locs.glColor != -1) {
// ignoreVertexcolors will have been set in FFP now as the glColors is unbound
gl.glDisableVertexAttribArray(locs.glColor);
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDisableVertexAttribArray++;
}
- if (normalsDefined && locs.glNormal != -1)
- {
- if (gd.geoToNormalBuf == -1)
- {
+ if (normalsDefined && locs.glNormal != -1) {
+ if (gd.geoToNormalBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToNormalBuf);
gl.glVertexAttribPointer(locs.glNormal, 3, GL2ES2.GL_FLOAT, false, 0, 0);
gl.glEnableVertexAttribArray(locs.glNormal);//must be called after Pointer above
@@ -1345,38 +1210,28 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glVertexAttribPointerNormals++;
}
- }
- else
- {
- if (locs.glNormal != -1)
- {
+ } else {
+ if (locs.glNormal != -1) {
gl.glDisableVertexAttribArray(locs.glNormal);
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDisableVertexAttribArray++;
}
}
- if (vattrDefined)
- {
- for (int index = 0; index < vertexAttrCount; index++)
- {
+ if (vattrDefined) {
+ for (int index = 0; index < vertexAttrCount; index++) {
Integer attribLoc = locs.genAttIndexToLoc.get(index);
- if (attribLoc != null && attribLoc.intValue() != -1)
- {
+ if (attribLoc != null && attribLoc.intValue() != -1) {
SparseArray<Integer> bufIds = gd.geoToVertAttribBuf;
- if (bufIds == null)
- {
+ if (bufIds == null) {
new Throwable("Buffer load issue!").printStackTrace();
}
Integer bufId = bufIds.get(index);
- if (bufId == null)
- {
+ if (bufId == null) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
- int sz = vertexAttrSizes[index];
+ } else {
+ int sz = vertexAttrSizes [index];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue());
gl.glVertexAttribPointer(attribLoc.intValue(), sz, GL2ES2.GL_FLOAT, false, 0, 0);
@@ -1391,31 +1246,25 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (textureDefined)
- {
+ if (textureDefined) {
boolean[] texSetsBound = new boolean[texCoords.length];
- for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++)
- {
- int texSet = texCoordSetMap[texUnit];
- if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet])
- {
- texSetsBound[texSet] = true;
+ for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++) {
+ int texSet = texCoordSetMap [texUnit];
+ if (texSet != -1 && locs.glMultiTexCoord [texSet] != -1 && !texSetsBound [texSet]) {
+ texSetsBound [texSet] = true;
SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf;
- if (bufIds == null)
- {
+ if (bufIds == null) {
new Throwable("Buffer load issue!").printStackTrace();
}
Integer bufId = bufIds.get(texUnit);
- if (bufId == null)
- {
+ if (bufId == null) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue());
- gl.glVertexAttribPointer(locs.glMultiTexCoord[texUnit], texStride, GL2ES2.GL_FLOAT, true, 0, 0);
- gl.glEnableVertexAttribArray(locs.glMultiTexCoord[texUnit]);
+ gl.glVertexAttribPointer(locs.glMultiTexCoord [texUnit], texStride, GL2ES2.GL_FLOAT,
+ true, 0, 0);
+ gl.glEnableVertexAttribArray(locs.glMultiTexCoord [texUnit]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -1431,8 +1280,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET)
- {
+ || geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) {
int primType = 0;
// FIXME: GL_LINE and GL_LINE_STRIP simply go from one vertex to the next drawing a line between
@@ -1440,24 +1288,21 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE)
geo_type = GeometryRetained.GEO_TYPE_LINE_STRIP_SET;
- switch (geo_type)
- {
- case GeometryRetained.GEO_TYPE_TRI_STRIP_SET:
- primType = GL2ES2.GL_TRIANGLE_STRIP;
- break;
- case GeometryRetained.GEO_TYPE_TRI_FAN_SET:
- primType = GL2ES2.GL_TRIANGLE_FAN;
- break;
- case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
- primType = GL2ES2.GL_LINE_LOOP;
- break;
+ switch (geo_type) {
+ case GeometryRetained.GEO_TYPE_TRI_STRIP_SET:
+ primType = GL2ES2.GL_TRIANGLE_STRIP;
+ break;
+ case GeometryRetained.GEO_TYPE_TRI_FAN_SET:
+ primType = GL2ES2.GL_TRIANGLE_FAN;
+ break;
+ case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
+ primType = GL2ES2.GL_LINE_LOOP;
+ break;
}
- for (int i = 0; i < strip_len; i++)
- {
- if (sarray[i] > 0)
- {
- gl.glDrawArrays(primType, start_array[i], sarray[i]);
+ for (int i = 0; i < strip_len; i++) {
+ if (sarray [i] > 0) {
+ gl.glDrawArrays(primType, start_array [i], sarray [i]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (OUTPUT_PER_FRAME_STATS)
@@ -1466,35 +1311,34 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDrawStripArrays++;
- }
- else
- {
+ } else {
// need to override if polygonAttributes says so
if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE)
geo_type = GeometryRetained.GEO_TYPE_LINE_SET;
else if (ctx.polygonMode == PolygonAttributes.POLYGON_POINT)
geo_type = GeometryRetained.GEO_TYPE_POINT_SET;
- switch (geo_type)
- {
- case GeometryRetained.GEO_TYPE_QUAD_SET:
- if(!quadArrayCautionPrinted) {
- System.err.println("QuadArray will render incorrectly, consider using TriangleArray. If you have the java3d-utils in the buildpath you can convert like this:");
- System.err.println("GeometryInfo gi = new GeometryInfo(quadArray);");
- System.err.println("gi.convertToIndexedTriangles(); ");
- System.err.println("GeometryArray ga = gi.getIndexedGeometryArray(true, true, true, true, true);");
- quadArrayCautionPrinted = true;
- }
- //fallthrough
- case GeometryRetained.GEO_TYPE_TRI_SET:
- gl.glDrawArrays(GL2ES2.GL_TRIANGLES, 0, vertexCount);
- break;
- case GeometryRetained.GEO_TYPE_POINT_SET:
- gl.glDrawArrays(GL2ES2.GL_POINTS, 0, vertexCount);
- break;
- case GeometryRetained.GEO_TYPE_LINE_SET:
- gl.glDrawArrays(GL2ES2.GL_LINES, 0, vertexCount);
- break;
+ switch (geo_type) {
+ case GeometryRetained.GEO_TYPE_QUAD_SET:
+ if (!quadArrayCautionPrinted) {
+ System.err.println(
+ "QuadArray will render incorrectly, consider using TriangleArray. If you have the java3d-utils in the buildpath you can convert like this:");
+ System.err.println("GeometryInfo gi = new GeometryInfo(quadArray);");
+ System.err.println("gi.convertToIndexedTriangles(); ");
+ System.err.println(
+ "GeometryArray ga = gi.getIndexedGeometryArray(true, true, true, true, true);");
+ quadArrayCautionPrinted = true;
+ }
+ //fallthrough
+ case GeometryRetained.GEO_TYPE_TRI_SET:
+ gl.glDrawArrays(GL2ES2.GL_TRIANGLES, 0, vertexCount);
+ break;
+ case GeometryRetained.GEO_TYPE_POINT_SET:
+ gl.glDrawArrays(GL2ES2.GL_POINTS, 0, vertexCount);
+ break;
+ case GeometryRetained.GEO_TYPE_LINE_SET:
+ gl.glDrawArrays(GL2ES2.GL_LINES, 0, vertexCount);
+ break;
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -1502,13 +1346,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDrawArrays++;
}
- }
- else
- {
+ } else {
if (!NO_PROGRAM_WARNING_GIVEN)
System.err.println("Execute called with no shader Program in use!");
NO_PROGRAM_WARNING_GIVEN = true;
-
+
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.executeSkippedNoShaderProgram++;
}
@@ -1526,32 +1368,35 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// by-copy or interleaved, by reference, Java arrays
@Override
- void executeIndexedGeometry(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha,
- boolean ignoreVertexColors, int initialIndexIndex, int indexCount, int vertexCount, int vformat, int vertexAttrCount,
- int[] vertexAttrSizes, int texCoordSetCount, int[] texCoordSetMap, int texCoordSetMapLen, int[] texCoordSetOffset,
- int numActiveTexUnitState, float[] varray, float[] carray, int cdirty, int[] indexCoord)
- {
+ void executeIndexedGeometry(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
+ boolean useAlpha, boolean ignoreVertexColors, int initialIndexIndex, int indexCount,
+ int vertexCount, int vformat, int vertexAttrCount, int[] vertexAttrSizes,
+ int texCoordSetCount, int[] texCoordSetMap, int texCoordSetMapLen,
+ int[] texCoordSetOffset, int numActiveTexUnitState, float[] varray, float[] carray,
+ int cdirty, int[] indexCoord) {
if (VERBOSE)
System.err.println("JoglPipeline.executeIndexedGeometry()");
- executeIndexedGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, initialIndexIndex, indexCount,
- vertexCount, vformat, vertexAttrCount, vertexAttrSizes, texCoordSetCount, texCoordSetMap, texCoordSetMapLen,
- texCoordSetOffset, numActiveTexUnitState, varray, null, carray, cdirty, indexCoord);
+ executeIndexedGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors,
+ initialIndexIndex, indexCount, vertexCount, vformat, vertexAttrCount, vertexAttrSizes, texCoordSetCount,
+ texCoordSetMap, texCoordSetMapLen, texCoordSetOffset, numActiveTexUnitState, varray, null, carray,
+ cdirty, indexCoord);
}
// interleaved, by reference, nio buffer
@Override
- void executeIndexedGeometryBuffer(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale, boolean useAlpha,
- boolean ignoreVertexColors, int initialIndexIndex, int indexCount, int vertexCount, int vformat, int texCoordSetCount,
- int[] texCoordSetMap, int texCoordSetMapLen, int[] texCoordSetOffset, int numActiveTexUnitState, FloatBuffer vdata,
- float[] carray, int cDirty, int[] indexCoord)
- {
+ void executeIndexedGeometryBuffer( Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
+ boolean useAlpha, boolean ignoreVertexColors, int initialIndexIndex,
+ int indexCount, int vertexCount, int vformat, int texCoordSetCount,
+ int[] texCoordSetMap, int texCoordSetMapLen, int[] texCoordSetOffset,
+ int numActiveTexUnitState, FloatBuffer vdata, float[] carray, int cDirty,
+ int[] indexCoord) {
if (VERBOSE)
System.err.println("JoglPipeline.executeIndexedGeometryBuffer()");
- executeIndexedGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors, initialIndexIndex, indexCount,
- vertexCount, vformat, 0, null, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, texCoordSetOffset,
- numActiveTexUnitState, null, vdata, carray, cDirty, indexCoord);
+ executeIndexedGeometryArray(ctx, geo, geo_type, isNonUniformScale, useAlpha, ignoreVertexColors,
+ initialIndexIndex, indexCount, vertexCount, vformat, 0, null, texCoordSetCount, texCoordSetMap,
+ texCoordSetMapLen, texCoordSetOffset, numActiveTexUnitState, null, vdata, carray, cDirty, indexCoord);
}
//----------------------------------------------------------------------
@@ -1559,21 +1404,21 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Helper routines for IndexedGeometryArrayRetained
//
- private void executeIndexedGeometryArray(Context absCtx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
- boolean useAlpha, boolean ignoreVertexColors, int initialIndexIndex, int indexCount, int vcount, int vformat,
- int vertexAttrCount, int[] vertexAttrSizes, int texCoordSetCount, int[] texCoordSetMap, int texCoordSetMapLen,
- int[] texCoordSetOffset, int numActiveTexUnitState, float[] varray, FloatBuffer vdata, float[] carray, int cDirty,
- int[] indexCoord)
- {
+ private void executeIndexedGeometryArray( Context absCtx, GeometryArrayRetained geo, int geo_type,
+ boolean isNonUniformScale, boolean useAlpha, boolean ignoreVertexColors,
+ int initialIndexIndex, int indexCount, int vcount, int vformat,
+ int vertexAttrCount, int[] vertexAttrSizes, int texCoordSetCount,
+ int[] texCoordSetMap, int texCoordSetMapLen, int[] texCoordSetOffset,
+ int numActiveTexUnitState, float[] varray, FloatBuffer vdata,
+ float[] carray, int cDirty, int[] indexCoord) {
if (VERBOSE)
System.err.println("JoglPipeline.executeIndexedGeometryArray()");
- Jogl2es2Context ctx = (Jogl2es2Context) absCtx;
+ Jogl2es2Context ctx = (Jogl2es2Context)absCtx;
int shaderProgramId = ctx.shaderProgramId;
- if (shaderProgramId != -1)
- {
+ if (shaderProgramId != -1) {
GL2ES2 gl = ctx.gl2es2();
ProgramData pd = ctx.programData;
LocationData locs = pd.programToLocationData;
@@ -1589,40 +1434,30 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] sarray = null;
int strip_len = 0;
- if (EXTRA_DEBUGGING)
- {
+ if (EXTRA_DEBUGGING) {
System.err.println("Vertex format: " + getVertexDescription(vformat));
System.err.println("Geometry type: " + getGeometryDescription(geo_type));
- if (carray != null)
- {
+ if (carray != null) {
System.err.println(" Separate color array");
- }
- else
- {
+ } else {
System.err.println(" Colors (if any) interleaved");
}
}
- if ((vformat & GeometryArray.COORDINATES) != 0)
- {
+ if ((vformat & GeometryArray.COORDINATES) != 0) {
stride += 3;
}
- if ((vformat & GeometryArray.NORMALS) != 0)
- {
+ if ((vformat & GeometryArray.NORMALS) != 0) {
stride += 3;
coordoff += 3;
}
- if ((vformat & GeometryArray.COLOR) != 0)
- {
- if ((vformat & GeometryArray.WITH_ALPHA) != 0)
- {
+ if ((vformat & GeometryArray.COLOR) != 0) {
+ if ((vformat & GeometryArray.WITH_ALPHA) != 0) {
stride += 4;
normoff += 4;
coordoff += 4;
- }
- else
- {
+ } else {
// Handle the case of executeInterleaved 3f
stride += 3;
normoff += 3;
@@ -1630,20 +1465,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0)
- {
- if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0)
- {
+ if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
+ if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) {
texSize = 2;
texStride = 2 * texCoordSetCount;
- }
- else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0)
- {
+ } else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0) {
texSize = 3;
texStride = 3 * texCoordSetCount;
- }
- else if ((vformat & GeometryArray.TEXTURE_COORDINATE_4) != 0)
- {
+ } else if ((vformat & GeometryArray.TEXTURE_COORDINATE_4) != 0) {
texSize = 4;
texStride = 4 * texCoordSetCount;
}
@@ -1653,11 +1482,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
coordoff += texStride;
}
- if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0)
- {
- for (int i = 0; i < vertexAttrCount; i++)
- {
- vAttrStride += vertexAttrSizes[i];
+ if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
+ for (int i = 0; i < vertexAttrCount; i++) {
+ vAttrStride += vertexAttrSizes [i];
}
stride += vAttrStride;
normoff += vAttrStride;
@@ -1668,24 +1495,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
bstride = stride * Buffers.SIZEOF_FLOAT;
- if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET)
- {
- sarray = ((IndexedGeometryStripArrayRetained) geo).stripIndexCounts;
+ if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) {
+ sarray = ((IndexedGeometryStripArrayRetained)geo).stripIndexCounts;
strip_len = sarray.length;
}
// using byRef interleaved array and has a separate pointer, then ..
int cstride = stride;
- if (carray != null)
- {
+ if (carray != null) {
cstride = 4;
}
cbstride = cstride * Buffers.SIZEOF_FLOAT;
- if (EXTRA_DEBUGGING)
- {
+ if (EXTRA_DEBUGGING) {
System.err.println(" initialIndexIndex: " + initialIndexIndex);
System.err.println(" stride: " + stride);
System.err.println(" bstride: " + bstride);
@@ -1695,81 +1520,78 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
System.err.println(" texCoordoff: " + texCoordoff);
}
- GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vcount, vformat, vformat, vdata, varray, 0, vdata, carray,
- 0);
+ GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vcount, vformat, vformat, vdata, varray,
+ 0, vdata, carray, 0);
// GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of changeability
boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE)
- || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
+ || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
- // not required second time around for VAO (except morphable coords)
+ // not required second time around for VAO (except morphable coords, and for a change of shader)
boolean bindingRequired = true;
// Note although we ask for ES2 we can get ES3, which demands a VAO or nothing renders
- if (gl.isGL2ES3())
- {
+ if (gl.isGL2ES3()) {
GL2ES3 gl2es3 = (GL2ES3)gl;
- if (gd.vaoId == -1)
- {
+ Integer vaoIdI = gd.geoToVaoId.get(shaderProgramId);
+ int vaoId = vaoIdI == null ? -1 : vaoIdI.intValue();
+ if (vaoId == -1) {
int[] tmp = new int[1];
- gl2es3.glGenVertexArrays(1, tmp, 0);
- gd.vaoId = tmp[0];
+ gl2es3.glGenVertexArrays(1, tmp, 0);
+ vaoId = tmp [0];
+ gd.geoToVaoId.put(shaderProgramId, new Integer(vaoId));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
+ } else {
+ // don't rebind if this vao was used last time for this geometry
+ if(gd.currentVaoId == vaoId)
+ bindingRequired = false;
}
- else
- {
- bindingRequired = false;
- }
- gl2es3.glBindVertexArray(gd.vaoId);
+ gl2es3.glBindVertexArray(vaoId);
+ gd.currentVaoId = vaoId;
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
}
+
// refill the buffers in case of writeable data
- if (locs.glVertex != -1)
- {
+ if (locs.glVertex != -1) {
- if (gd.geoToCoordBuf == -1)
- {
+ if (gd.geoToCoordBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
// if ((cDirty & GeometryArrayRetained.COORDINATE_CHANGED) != 0)
- if (morphable)
- {
+ if (morphable) {
FloatBuffer verts = null;
// do we need to covert a float[]
- if (varray != null)
- {
+ if (varray != null) {
verts = getVertexArrayBuffer(varray);
- }
- else
- {
+ } else {
verts = vdata;
}
verts.position(0);
// Sometime the FloatBuffer is swapped out for bigger or smaller
- if (gd.geoToCoordBufSize != verts.remaining())
- {
- System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != " + verts.remaining()
- + " un indexed ((GeometryArray) geo.source) " + ((GeometryArray) geo.source).getName() + " "
- + geo.source + ", this is not nessasarily a problem");
+ if (gd.geoToCoordBufSize != verts.remaining()) {
+ System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != "
+ + verts.remaining() + " un indexed ((GeometryArray) geo.source) "
+ + ((GeometryArray)geo.source).getName() + " " + geo.source
+ + ", this is not nessasarily a problem");
int prevBufId1 = gd.geoToCoordBuf1;// record these in order to delete after re-bind
int prevBufId2 = gd.geoToCoordBuf2;
int[] tmp = new int[2];
gl.glGenBuffers(2, tmp, 0);
- gd.geoToCoordBuf = tmp[0];
- gd.geoToCoordBuf1 = tmp[0];
- gd.geoToCoordBuf2 = tmp[1];
+ gd.geoToCoordBuf = tmp [0];
+ gd.geoToCoordBuf1 = tmp [0];
+ gd.geoToCoordBuf2 = tmp [1];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
- gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts, GL2ES2.GL_DYNAMIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts,
+ GL2ES2.GL_DYNAMIC_DRAW);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2);
- gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts, GL2ES2.GL_DYNAMIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (verts.remaining() * Float.SIZE / 8), verts,
+ GL2ES2.GL_DYNAMIC_DRAW);
gd.geoToCoordBufSize = verts.remaining();
@@ -1794,25 +1616,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.coordCount += gd.geoToCoordBufSize;
- gl.glDeleteBuffers(1, new int[] { prevBufId1, prevBufId2 }, 0);
+ gl.glDeleteBuffers(1, new int[] {prevBufId1, prevBufId2}, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
+ } else {
// work out the buffer to update and buffer to swap to
- if (gd.geoToCoordBuf == gd.geoToCoordBuf1)
- {
+ if (gd.geoToCoordBuf == gd.geoToCoordBuf1) {
// update 1 but set to draw 2
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8), verts);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8),
+ verts);
gd.geoToCoordBuf = gd.geoToCoordBuf2;
- }
- else
- {
+ } else {
// update 2 but set to draw 1
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2);
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8), verts);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (verts.remaining() * Float.SIZE / 8),
+ verts);
gd.geoToCoordBuf = gd.geoToCoordBuf1;
}
@@ -1826,38 +1645,28 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
- }
- else
- {
- throw new UnsupportedOperationException("Shader has no glVertex.\n" + VALID_FORMAT_MESSAGE);
+ } else {
+ throw new UnsupportedOperationException("Shader has no glVertex.\n");
}
// update other attributes if required
- if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors)
- {
+ if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors) {
// if ((cDirty & GeometryArrayRetained.COLOR_CHANGED) != 0)
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_COLOR_WRITE);
- if (changable)
- {
+ if (changable) {
// clrs in the vdata, unless seperate
FloatBuffer clrs = null;
FloatBuffer verts = null;
// do we need to covert a float[]
- if (varray != null)
- {
+ if (varray != null) {
verts = getVertexArrayBuffer(varray);
- }
- else
- {
+ } else {
verts = vdata;
}
- if (carray != null)
- {
+ if (carray != null) {
clrs = getColorArrayBuffer(carray);
- }
- else
- {
+ } else {
clrs = verts;
}
clrs.position(0);
@@ -1867,11 +1676,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// notice morphables must always rebind each frame as coord buffers are swapped
- if (bindingRequired || morphable)
- {
+ if (bindingRequired || morphable) {
// always do coords
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
- gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, bstride, coordoff * Buffers.SIZEOF_FLOAT);
+ gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, bstride,
+ coordoff * Buffers.SIZEOF_FLOAT);
gl.glEnableVertexAttribArray(locs.glVertex);
if (DO_OUTPUT_ERRORS)
@@ -1883,20 +1692,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
ctx.perFrameStats.coordCount += gd.geoToCoordBufSize;
}
- if (bindingRequired)
- {
- if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors)
- {
- if (gd.geoToColorBuf == -1)
- {
+ if (bindingRequired) {
+ if (((vformat & GeometryArray.COLOR) != 0) && locs.glColor != -1 && !ignoreVertexColors) {
+ if (gd.geoToColorBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
int sz = ((vformat & GeometryArray.WITH_ALPHA) != 0) ? 4 : 3;
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf);
- gl.glVertexAttribPointer(locs.glColor, sz, GL2ES2.GL_FLOAT, false, cbstride, coloroff * Buffers.SIZEOF_FLOAT);
+ gl.glVertexAttribPointer(locs.glColor, sz, GL2ES2.GL_FLOAT, false, cbstride,
+ coloroff * Buffers.SIZEOF_FLOAT);
gl.glEnableVertexAttribArray(locs.glColor);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -1904,25 +1709,20 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glVertexAttribPointerColor++;
}
- }
- else if (locs.glColor != -1)
- {
+ } else if (locs.glColor != -1) {
// ignoreVertexcolors will have been set in FFP now as the glColors is unbound
gl.glDisableVertexAttribArray(locs.glColor);
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDisableVertexAttribArray++;
}
- if (((vformat & GeometryArray.NORMALS) != 0) && locs.glNormal != -1)
- {
- if (gd.geoToCoordBuf == -1)
- {
+ if (((vformat & GeometryArray.NORMALS) != 0) && locs.glNormal != -1) {
+ if (gd.geoToCoordBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
- gl.glVertexAttribPointer(locs.glNormal, 3, GL2ES2.GL_FLOAT, false, bstride, normoff * Buffers.SIZEOF_FLOAT);
+ gl.glVertexAttribPointer(locs.glNormal, 3, GL2ES2.GL_FLOAT, false, bstride,
+ normoff * Buffers.SIZEOF_FLOAT);
gl.glEnableVertexAttribArray(locs.glNormal);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -1930,33 +1730,27 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glVertexAttribPointerNormals++;
}
- }
- else
- {
- if (locs.glNormal != -1)
- {
+ } else {
+ if (locs.glNormal != -1) {
gl.glDisableVertexAttribArray(locs.glNormal);
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDisableVertexAttribArray++;
}
}
- if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0)
- {
+ if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
int vAttrOffset = vAttrOff;
- for (int index = 0; index < vertexAttrCount; index++)
- {
+ for (int index = 0; index < vertexAttrCount; index++) {
Integer attribLoc = locs.genAttIndexToLoc.get(index);
- if (attribLoc != null && attribLoc.intValue() != -1)
- {
- int sz = vertexAttrSizes[index];
+ if (attribLoc != null && attribLoc.intValue() != -1) {
+ int sz = vertexAttrSizes [index];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
gl.glVertexAttribPointer(attribLoc.intValue(), sz, GL2ES2.GL_FLOAT, false, bstride,
vAttrOffset * Buffers.SIZEOF_FLOAT);
gl.glEnableVertexAttribArray(attribLoc.intValue());
- vAttrOffset += vertexAttrSizes[index];
+ vAttrOffset += vertexAttrSizes [index];
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -1967,19 +1761,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0)
- {
+ if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
boolean[] texSetsBound = new boolean[texCoordSetMapLen];
- for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordSetMapLen; texUnit++)
- {
- int texSet = texCoordSetMap[texUnit];
- if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet])
- {
- texSetsBound[texSet] = true;
+ for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordSetMapLen; texUnit++) {
+ int texSet = texCoordSetMap [texUnit];
+ if (texSet != -1 && locs.glMultiTexCoord [texSet] != -1 && !texSetsBound [texSet]) {
+ texSetsBound [texSet] = true;
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
- gl.glVertexAttribPointer(locs.glMultiTexCoord[texUnit], texSize, GL2ES2.GL_FLOAT, true, bstride,
- texCoordoff * Buffers.SIZEOF_FLOAT);
- gl.glEnableVertexAttribArray(locs.glMultiTexCoord[texUnit]);
+ gl.glVertexAttribPointer(locs.glMultiTexCoord [texUnit], texSize, GL2ES2.GL_FLOAT, true,
+ bstride, texCoordoff * Buffers.SIZEOF_FLOAT);
+ gl.glEnableVertexAttribArray(locs.glMultiTexCoord [texUnit]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -1995,9 +1786,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
//////////////////////////////////////////////
- if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET)
- {
+ if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) {
int primType = 0;
//FIXME: GL_LINE and GL_LINE_STRIP simply go from one vertex to the next drawing a line between
@@ -2006,23 +1797,21 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE)
geo_type = GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET;
- switch (geo_type)
- {
- case GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET:
- primType = GL2ES2.GL_TRIANGLE_STRIP;
- break;
- case GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET:
- primType = GL2ES2.GL_TRIANGLE_FAN;
- break;
- case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET:
- primType = GL2ES2.GL_LINE_LOOP;
- break;
+ switch (geo_type) {
+ case GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET:
+ primType = GL2ES2.GL_TRIANGLE_STRIP;
+ break;
+ case GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET:
+ primType = GL2ES2.GL_TRIANGLE_FAN;
+ break;
+ case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET:
+ primType = GL2ES2.GL_LINE_LOOP;
+ break;
}
int[] stripInd = gd.geoToIndStripBuf;
// if no index buffers build build them now
- if (stripInd == null)
- {
+ if (stripInd == null) {
stripInd = new int[strip_len];
gl.glGenBuffers(strip_len, stripInd, 0);
@@ -2031,16 +1820,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
.asShortBuffer();
for (int s = 0; s < indexCoord.length; s++)
indicesBuffer.put(s, (short) indexCoord[s]);*/
-
+
ShortBuffer indicesBuffer = getIndexArrayBuffer(indexCoord);
- for (int i = 0; i < strip_len; i++)
- {
+ for (int i = 0; i < strip_len; i++) {
indicesBuffer.position(offset);
- int count = sarray[i];
- int indBufId = stripInd[i];
+ int count = sarray [i];
+ int indBufId = stripInd [i];
gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBufId);
- gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, count * Short.SIZE / 8, indicesBuffer, GL2ES2.GL_STATIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, count * Short.SIZE / 8, indicesBuffer,
+ GL2ES2.GL_STATIC_DRAW);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
offset += count;
@@ -2052,10 +1841,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gd.geoToIndStripBuf = stripInd;
}
- for (int i = 0; i < strip_len; i++)
- {
- int count = sarray[i];
- int indBufId = stripInd[i];
+ for (int i = 0; i < strip_len; i++) {
+ int count = sarray [i];
+ int indBufId = stripInd [i];
//type Specifies the type of the values in indices. Must be
// GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT.
@@ -2083,13 +1871,10 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.indexCount += gd.geoToIndBufSize;
- }
- else
- {
+ } else {
// bind my indexes ready for the draw call
- if (gd.geoToIndBuf == -1)
- {
+ if (gd.geoToIndBuf == -1) {
// create and fill index buffer
//ShortBuffer indBuf = ByteBuffer.allocateDirect(indexCoord.length * 2).order(ByteOrder.nativeOrder()).asShortBuffer();
//for (int s = 0; s < indexCoord.length; s++)
@@ -2099,9 +1884,10 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] tmp = new int[1];
gl.glGenBuffers(1, tmp, 0);
- gd.geoToIndBuf = tmp[0];// about to add to map below
+ gd.geoToIndBuf = tmp [0];// about to add to map below
gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, gd.geoToIndBuf);
- gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBuf.remaining() * Short.SIZE / 8, indBuf, GL2ES2.GL_STATIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBuf.remaining() * Short.SIZE / 8, indBuf,
+ GL2ES2.GL_STATIC_DRAW);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -2124,39 +1910,38 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
else if (ctx.polygonMode == PolygonAttributes.POLYGON_POINT)
geo_type = GeometryRetained.GEO_TYPE_INDEXED_POINT_SET;
- switch (geo_type)
- {
- case GeometryRetained.GEO_TYPE_INDEXED_QUAD_SET:
- if(!quadArrayCautionPrinted) {
- System.err.println("QuadArray will render incorrectly, consider using TriangleArray. If you have the java3d-utils in the buildpath you can convert like this:");
- System.err.println("GeometryInfo gi = new GeometryInfo(quadArray);");
- System.err.println("gi.convertToIndexedTriangles(); ");
- System.err.println("GeometryArray ga = gi.getIndexedGeometryArray(true, true, true, true, true);");
- quadArrayCautionPrinted = true;
- }
- //fallthrough
- case GeometryRetained.GEO_TYPE_INDEXED_TRI_SET:
- gl.glDrawElements(GL2ES2.GL_TRIANGLES, indexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
- break;
- case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET:
- gl.glDrawElements(GL2ES2.GL_POINTS, indexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
- break;
- case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET:
- gl.glDrawElements(GL2ES2.GL_LINES, indexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
- break;
+ switch (geo_type) {
+ case GeometryRetained.GEO_TYPE_INDEXED_QUAD_SET:
+ if (!quadArrayCautionPrinted) {
+ System.err.println(
+ "QuadArray will render incorrectly, consider using TriangleArray. If you have the java3d-utils in the buildpath you can convert like this:");
+ System.err.println("GeometryInfo gi = new GeometryInfo(quadArray);");
+ System.err.println("gi.convertToIndexedTriangles(); ");
+ System.err.println(
+ "GeometryArray ga = gi.getIndexedGeometryArray(true, true, true, true, true);");
+ quadArrayCautionPrinted = true;
+ }
+ //fallthrough
+ case GeometryRetained.GEO_TYPE_INDEXED_TRI_SET:
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, indexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
+ break;
+ case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET:
+ gl.glDrawElements(GL2ES2.GL_POINTS, indexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
+ break;
+ case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET:
+ gl.glDrawElements(GL2ES2.GL_LINES, indexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
+ break;
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDrawElements++;
}
- }
- else
- {
+ } else {
if (!NO_PROGRAM_WARNING_GIVEN)
System.err.println("Execute called with no shader Program in use!");
NO_PROGRAM_WARNING_GIVEN = true;
-
+
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.executeSkippedNoShaderProgram++;
}
@@ -2169,12 +1954,13 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// non interleaved, by reference, Java arrays
@Override
- void executeIndexedGeometryVA(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
- boolean ignoreVertexColors, int initialIndexIndex, int validIndexCount, int vertexCount, int vformat, int vdefined,
- float[] vfcoords, double[] vdcoords, float[] cfdata, byte[] cbdata, float[] ndata, int vertexAttrCount, int[] vertexAttrSizes,
- float[][] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState, int texStride,
- Object[] texCoords, int cdirty, int[] indexCoord)
- {
+ void executeIndexedGeometryVA( Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
+ boolean ignoreVertexColors, int initialIndexIndex, int validIndexCount,
+ int vertexCount, int vformat, int vdefined, float[] vfcoords, double[] vdcoords,
+ float[] cfdata, byte[] cbdata, float[] ndata, int vertexAttrCount,
+ int[] vertexAttrSizes, float[][] vertexAttrData, int texCoordMapLength,
+ int[] texcoordoffset, int numActiveTexUnitState, int texStride, Object[] texCoords,
+ int cdirty, int[] indexCoord) {
if (VERBOSE)
System.err.println("JoglPipeline.executeIndexedGeometryVA()");
@@ -2188,42 +1974,41 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] sarray = null;
int strip_len = 0;
- if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET)
- {
- sarray = ((IndexedGeometryStripArrayRetained) geo).stripIndexCounts;
+ if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) {
+ sarray = ((IndexedGeometryStripArrayRetained)geo).stripIndexCounts;
strip_len = sarray.length;
}
- if (doubleCoordDefined)
- {
+ if (doubleCoordDefined) {
// FIXME: doubles not supported for now
throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE);
// dverts = getVertexArrayBuffer(vdcoords);
}
- if (byteColorsDefined)
- {
+ if (byteColorsDefined) {
// FIXME: byte colors not supported for now
throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE);
// bclrs = getColorArrayBuffer(cbdata);
}
- executeIndexedGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, initialIndexIndex, validIndexCount,
- vertexCount, vformat, vdefined, null, vfcoords, null, vdcoords, null, cfdata, null, cbdata, null, ndata, vertexAttrCount,
- vertexAttrSizes, null, vertexAttrData, texCoordMapLength, texcoordoffset, numActiveTexUnitState, texStride, texCoords,
- cdirty, indexCoord, sarray, strip_len);
+ executeIndexedGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, initialIndexIndex,
+ validIndexCount, vertexCount, vformat, vdefined, null, vfcoords, null, vdcoords, null, cfdata, null,
+ cbdata, null, ndata, vertexAttrCount, vertexAttrSizes, null, vertexAttrData, texCoordMapLength,
+ texcoordoffset, numActiveTexUnitState, texStride, texCoords, cdirty, indexCoord, sarray, strip_len);
}
// non interleaved, by reference, nio buffer
@Override
void executeIndexedGeometryVABuffer(Context ctx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
- boolean ignoreVertexColors, int initialIndexIndex, int validIndexCount, int vertexCount, int vformat, int vdefined,
- Buffer vcoords, Buffer cdataBuffer, float[] cfdata, byte[] cbdata, FloatBuffer ndata, int vertexAttrCount,
- int[] vertexAttrSizes, FloatBuffer[] vertexAttrData, int texCoordMapLength, int[] texcoordoffset, int numActiveTexUnitState,
- int texStride, Object[] texCoords, int cdirty, int[] indexCoord)
- {
+ boolean ignoreVertexColors, int initialIndexIndex, int validIndexCount,
+ int vertexCount, int vformat, int vdefined, Buffer vcoords, Buffer cdataBuffer,
+ float[] cfdata, byte[] cbdata, FloatBuffer ndata, int vertexAttrCount,
+ int[] vertexAttrSizes, FloatBuffer[] vertexAttrData, int texCoordMapLength,
+ int[] texcoordoffset, int numActiveTexUnitState, int texStride,
+ Object[] texCoords, int cdirty, int[] indexCoord) {
if (VERBOSE)
System.err.println("JoglPipeline.executeIndexedGeometryVABuffer() ");
@@ -2244,44 +2029,36 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
FloatBuffer[] vertexAttrBufs = null;
// Get vertex attribute arrays
- if (vattrDefined)
- {
+ if (vattrDefined) {
vertexAttrBufs = vertexAttrData;
}
// get coordinate array
- if (floatCoordDefined)
- {
- fverts = (FloatBuffer) vcoords;
- }
- else if (doubleCoordDefined)
- {
+ if (floatCoordDefined) {
+ fverts = (FloatBuffer)vcoords;
+ } else if (doubleCoordDefined) {
// FIXME: doubles not supported for now
throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE);
// dverts = (DoubleBuffer) vcoords;
}
- if (fverts == null && dverts == null)
- {
+ if (fverts == null && dverts == null) {
return;
}
int[] sarray = null;
int strip_len = 0;
- if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET)
- {
- sarray = ((IndexedGeometryStripArrayRetained) geo).stripIndexCounts;
+ if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) {
+ sarray = ((IndexedGeometryStripArrayRetained)geo).stripIndexCounts;
strip_len = sarray.length;
}
// get color array
- if (floatColorsDefined)
- {
- fclrs = (FloatBuffer) cdataBuffer;
- }
- else if (byteColorsDefined)
- {
+ if (floatColorsDefined) {
+ fclrs = (FloatBuffer)cdataBuffer;
+ } else if (byteColorsDefined) {
// FIXME: not supported for now
throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE);
@@ -2292,15 +2069,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// get normal array
- if (normalsDefined)
- {
+ if (normalsDefined) {
norms = ndata;
}
- executeIndexedGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, initialIndexIndex, validIndexCount,
- vertexCount, vformat, vdefined, fverts, null, dverts, null, fclrs, cfdata, bclrs, null, norms, null, vertexAttrCount,
- vertexAttrSizes, vertexAttrBufs, null, texCoordMapLength, texcoordoffset, numActiveTexUnitState, texStride, texCoords,
- cdirty, indexCoord, sarray, strip_len);
+ executeIndexedGeometryArrayVA(ctx, geo, geo_type, isNonUniformScale, ignoreVertexColors, initialIndexIndex,
+ validIndexCount, vertexCount, vformat, vdefined, fverts, null, dverts, null, fclrs, cfdata, bclrs, null,
+ norms, null, vertexAttrCount, vertexAttrSizes, vertexAttrBufs, null, texCoordMapLength, texcoordoffset,
+ numActiveTexUnitState, texStride, texCoords, cdirty, indexCoord, sarray, strip_len);
}
// ----------------------------------------------------------------------
@@ -2308,22 +2084,25 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Helper routines for IndexedGeometryArrayRetained
//
// careful - isNonUniformScale is always false regardless
- private void executeIndexedGeometryArrayVA(Context absCtx, GeometryArrayRetained geo, int geo_type, boolean isNonUniformScale,
- boolean ignoreVertexColors, int initialIndexIndex, int validIndexCount, int vertexCount, int vformat, int vdefined,
- FloatBuffer fverts, float[] vfarray, DoubleBuffer dverts, double[] vdarray, FloatBuffer fclrs, float[] cfarray,
- ByteBuffer bclrs, byte[] cbarray, FloatBuffer norms, float[] fnorms, int vertexAttrCount, int[] vertexAttrSizes,
- FloatBuffer[] vertexAttrBufs, float[][] vertexAttrArrays, int texCoordMapLength, int[] texCoordSetMap,
- int numActiveTexUnitState, int texStride, Object[] texCoords, int cDirty, int[] indexCoord, int[] sarray, int strip_len)
- {
+ private void executeIndexedGeometryArrayVA( Context absCtx, GeometryArrayRetained geo, int geo_type,
+ boolean isNonUniformScale, boolean ignoreVertexColors,
+ int initialIndexIndex, int validIndexCount, int vertexCount,
+ int vformat, int vdefined, FloatBuffer fverts, float[] vfarray,
+ DoubleBuffer dverts, double[] vdarray, FloatBuffer fclrs,
+ float[] cfarray, ByteBuffer bclrs, byte[] cbarray, FloatBuffer norms,
+ float[] fnorms, int vertexAttrCount, int[] vertexAttrSizes,
+ FloatBuffer[] vertexAttrBufs, float[][] vertexAttrArrays,
+ int texCoordMapLength, int[] texCoordSetMap, int numActiveTexUnitState,
+ int texStride, Object[] texCoords, int cDirty, int[] indexCoord,
+ int[] sarray, int strip_len) {
// removed if (ATTEMPT_OPTIMIZED_VERTICES &&
// executeIndexedGeometryOptimized(...
- Jogl2es2Context ctx = (Jogl2es2Context) absCtx;
+ Jogl2es2Context ctx = (Jogl2es2Context)absCtx;
int shaderProgramId = ctx.shaderProgramId;
- if (shaderProgramId != -1)
- {
+ if (shaderProgramId != -1) {
GL2ES2 gl = ctx.gl2es2();
ProgramData pd = ctx.programData;
LocationData locs = pd.programToLocationData;
@@ -2331,9 +2110,10 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
setFFPAttributes(ctx, gl, shaderProgramId, pd, vdefined, ignoreVertexColors);
// If any buffers need loading do that now
- GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vertexCount, vformat, vdefined, fverts, vfarray, dverts,
- vdarray, fclrs, cfarray, bclrs, cbarray, norms, fnorms, vertexAttrCount, vertexAttrSizes, vertexAttrBufs,
- vertexAttrArrays, texCoordMapLength, texCoordSetMap, texStride, texCoords);
+ GeometryData gd = loadAllBuffers(ctx, gl, geo, ignoreVertexColors, vertexCount, vformat, vdefined, fverts,
+ vfarray, dverts, vdarray, fclrs, cfarray, bclrs, cbarray, norms, fnorms, vertexAttrCount,
+ vertexAttrSizes, vertexAttrBufs, vertexAttrArrays, texCoordMapLength, texCoordSetMap, texStride,
+ texCoords);
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
@@ -2345,68 +2125,63 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of changeability
boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE)
- || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
+ || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
- // not required second time around for VAO (except morphable coords)
+ // not required second time around for VAO (except morphable coords, and for a change of shader)
boolean bindingRequired = true;
// Note although we ask for ES2 we can get ES3, which demands a VAO or nothing renders
- if (gl.isGL2ES3())
- {
+ if (gl.isGL2ES3()) {
GL2ES3 gl2es3 = (GL2ES3)gl;
- if (gd.vaoId == -1)
- {
+ Integer vaoIdI = gd.geoToVaoId.get(shaderProgramId);
+ int vaoId = vaoIdI == null ? -1 : vaoIdI.intValue();
+ if (vaoId == -1) {
int[] tmp = new int[1];
- gl2es3.glGenVertexArrays(1, tmp, 0);
- gd.vaoId = tmp[0];
+ gl2es3.glGenVertexArrays(1, tmp, 0);
+ vaoId = tmp [0];
+ gd.geoToVaoId.put(shaderProgramId, new Integer(vaoId));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
+ } else {
+ // don't rebind if this vao was used last time for this geometry
+ if(gd.currentVaoId == vaoId)
+ bindingRequired = false;
}
- else
- {
- bindingRequired = false;
- }
- gl2es3.glBindVertexArray(gd.vaoId);
+ gl2es3.glBindVertexArray(vaoId);
+ gd.currentVaoId = vaoId;
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
}
// Define the data pointers
- if (locs.glVertex != -1)
- {
- if (floatCoordDefined)
- {
+ if (locs.glVertex != -1) {
+ if (floatCoordDefined) {
// TODO: Building of buffers etc and index buffers should really take place not on the j3d thread if possible
- if (gd.geoToCoordBuf == -1)
- {
+ if (gd.geoToCoordBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
- if (morphable)
- {
+ } else {
+ if (morphable) {
//if I have vfcoords instead of fverts need to get a fverts buff now
- if (vfarray != null)
- {
+ if (vfarray != null) {
fverts = getVertexArrayBuffer(vfarray);
}
fverts.position(0);
// Sometime the FloatBuffer is swapped out for bigger or smaller
- if (gd.geoToCoordBufSize != fverts.remaining())
- {
- System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != " + fverts.remaining()
- + " ((GeometryArray) geo.source) " + ((GeometryArray) geo.source).getName() + " " + geo.source);
+ if (gd.geoToCoordBufSize != fverts.remaining()) {
+ System.err.println("Morphable buffer changed " + gd.geoToCoordBufSize + " != "
+ + fverts.remaining() + " ((GeometryArray) geo.source) "
+ + ((GeometryArray)geo.source).getName() + " " + geo.source);
int prevBufId1 = gd.geoToCoordBuf1;// record these in order to delete below
int prevBufId2 = gd.geoToCoordBuf2;
int[] tmp = new int[2];
gl.glGenBuffers(2, tmp, 0);
- gd.geoToCoordBuf = tmp[0];
- gd.geoToCoordBuf1 = tmp[0];
- gd.geoToCoordBuf2 = tmp[1];
+ gd.geoToCoordBuf = tmp [0];
+ gd.geoToCoordBuf1 = tmp [0];
+ gd.geoToCoordBuf2 = tmp [1];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts,
@@ -2439,26 +2214,23 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.coordCount += gd.geoToCoordBufSize;
- gl.glDeleteBuffers(1, new int[] { prevBufId1, prevBufId2 }, 0);
+ gl.glDeleteBuffers(1, new int[] {prevBufId1, prevBufId2}, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
+ } else {
// work out the buffer to update and buffer to swap to
- if (gd.geoToCoordBuf == gd.geoToCoordBuf1)
- {
+ if (gd.geoToCoordBuf == gd.geoToCoordBuf1) {
// update 1 but set to draw 2
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8), fverts);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8),
+ fverts);
gd.geoToCoordBuf = gd.geoToCoordBuf2;
- }
- else
- {
+ } else {
// update 2 but set to draw 1
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2);
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8), fverts);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, (fverts.remaining() * Float.SIZE / 8),
+ fverts);
gd.geoToCoordBuf = gd.geoToCoordBuf1;
}
@@ -2471,31 +2243,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- }
- else if (doubleCoordDefined)
- {
+ } else if (doubleCoordDefined) {
throw new UnsupportedOperationException("doubleCoordDefined.\n" + VALID_FORMAT_MESSAGE);
- }
- else
- {
+ } else {
throw new UnsupportedOperationException("No coords defined.\n" + VALID_FORMAT_MESSAGE);
}
- }
- else
- {
- throw new UnsupportedOperationException("Shader has no glVertex.\n" + VALID_FORMAT_MESSAGE);
+ } else {
+ throw new UnsupportedOperationException("Shader has no glVertex.\n");
}
// update other attributes if required
- if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors)
- {
+ if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors) {
// if ((cDirty & GeometryArrayRetained.COLOR_CHANGED) != 0)
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_COLOR_WRITE);
- if (changable)
- {
+ if (changable) {
//if I have cfdata instead of fclrs need to get a fclrs buff now
- if (cfarray != null)
- {
+ if (cfarray != null) {
fclrs = getColorArrayBuffer(cfarray);
}
@@ -2504,15 +2267,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, fclrs.remaining() * Float.SIZE / 8, fclrs);
}
}
- if (normalsDefined && locs.glNormal != -1)
- {
+ if (normalsDefined && locs.glNormal != -1) {
// if ((cDirty & GeometryArrayRetained.NORMAL_CHANGED) != 0)
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_NORMAL_WRITE);
- if (changable)
- {
+ if (changable) {
//if I have ndata instead of norms need to get a norms buff now
- if (fnorms != null)
- {
+ if (fnorms != null) {
norms = getNormalArrayBuffer(fnorms);
}
@@ -2522,50 +2282,41 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (vattrDefined)
- {
- if (vertexAttrArrays != null)
- {
+ if (vattrDefined) {
+ if (vertexAttrArrays != null) {
vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrArrays);
}
- for (int index = 0; index < vertexAttrCount; index++)
- {
+ for (int index = 0; index < vertexAttrCount; index++) {
Integer attribLoc = locs.genAttIndexToLoc.get(index);
- if (attribLoc != null && attribLoc.intValue() != -1)
- {
+ if (attribLoc != null && attribLoc.intValue() != -1) {
// if ((cDirty & GeometryArrayRetained.VATTR_CHANGED) != 0)
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_VERTEX_ATTR_WRITE);
- if (changable)
- {
- FloatBuffer vertexAttrs = vertexAttrBufs[index];
+ if (changable) {
+ FloatBuffer vertexAttrs = vertexAttrBufs [index];
vertexAttrs.position(0);
SparseArray<Integer> bufIds = gd.geoToVertAttribBuf;
Integer bufId = bufIds.get(index);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue());
- gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, vertexAttrs.remaining() * Float.SIZE / 8, vertexAttrs);
+ gl.glBufferSubData(GL2ES2.GL_ARRAY_BUFFER, 0, vertexAttrs.remaining() * Float.SIZE / 8,
+ vertexAttrs);
}
}
}
}
- if (textureDefined)
- {
+ if (textureDefined) {
// convert from float[][] to FloatBuffer[]
- if (texCoords instanceof float[][])
- {
+ if (texCoords instanceof float[][]) {
texCoords = getTexCoordSetBuffer(texCoords);
}
boolean[] texSetsBound = new boolean[texCoords.length];
- for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++)
- {
- int texSet = texCoordSetMap[texUnit];
- if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet])
- {
+ for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++) {
+ int texSet = texCoordSetMap [texUnit];
+ if (texSet != -1 && locs.glMultiTexCoord [texSet] != -1 && !texSetsBound [texSet]) {
boolean changable = geo.source.getCapability(GeometryArray.ALLOW_TEXCOORD_WRITE);
- if (changable)
- {
- FloatBuffer buf = (FloatBuffer) texCoords[texSet];
+ if (changable) {
+ FloatBuffer buf = (FloatBuffer)texCoords [texSet];
buf.position(0);
SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf;
Integer bufId = bufIds.get(texUnit);
@@ -2577,8 +2328,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// binding is required for morphables coords as always swappping buffers each second frame
- if (bindingRequired || morphable)
- {
+ if (bindingRequired || morphable) {
// always coords
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
gl.glVertexAttribPointer(locs.glVertex, 3, GL2ES2.GL_FLOAT, false, 0, 0);
@@ -2594,16 +2344,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
- if (bindingRequired)
- {
- if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors)
- {
- if (gd.geoToColorBuf == -1)
- {
+ if (bindingRequired) {
+ if (floatColorsDefined && locs.glColor != -1 && !ignoreVertexColors) {
+ if (gd.geoToColorBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
int sz = ((vformat & GeometryArray.WITH_ALPHA) != 0) ? 4 : 3;
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf);
@@ -2616,9 +2361,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
ctx.perFrameStats.glVertexAttribPointerColor++;
}
- }
- else if (byteColorsDefined && locs.glColor != -1 && !ignoreVertexColors)
- {
+ } else if (byteColorsDefined && locs.glColor != -1 && !ignoreVertexColors) {
//FIXME: byteColors not supported for now
throw new UnsupportedOperationException("byteColorsDefined.\n" + VALID_FORMAT_MESSAGE);
@@ -2631,25 +2374,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
{
gl.glColorPointer(3, GL2ES2.GL_UNSIGNED_BYTE, 0, bclrs);
}*/
- }
- else if (locs.glColor != -1)
- {
+ } else if (locs.glColor != -1) {
// ignoreVertexcolors will be set in FFP now as the glColors is unbound
gl.glDisableVertexAttribArray(locs.glColor);
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDisableVertexAttribArray++;
}
- if (normalsDefined)
- {
- if (locs.glNormal != -1)
- {
- if (gd.geoToNormalBuf == -1)
- {
+ if (normalsDefined) {
+ if (locs.glNormal != -1) {
+ if (gd.geoToNormalBuf == -1) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToNormalBuf);
gl.glVertexAttribPointer(locs.glNormal, 3, GL2ES2.GL_FLOAT, true, 0, 0);
@@ -2661,40 +2397,30 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
ctx.perFrameStats.glVertexAttribPointerNormals++;
}
}
- }
- else
- {
- if (locs.glNormal != -1)
- {
+ } else {
+ if (locs.glNormal != -1) {
gl.glDisableVertexAttribArray(locs.glNormal);
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glDisableVertexAttribArray++;
}
}
- if (vattrDefined)
- {
- for (int index = 0; index < vertexAttrCount; index++)
- {
+ if (vattrDefined) {
+ for (int index = 0; index < vertexAttrCount; index++) {
Integer attribLoc = locs.genAttIndexToLoc.get(index);
- if (attribLoc != null && attribLoc.intValue() != -1)
- {
+ if (attribLoc != null && attribLoc.intValue() != -1) {
SparseArray<Integer> bufIds = gd.geoToVertAttribBuf;
- if (bufIds == null)
- {
+ if (bufIds == null) {
new Throwable("Buffer load issue!").printStackTrace();
}
Integer bufId = bufIds.get(index);
- if (bufId == null)
- {
+ if (bufId == null) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue());
- int sz = vertexAttrSizes[index];
+ int sz = vertexAttrSizes [index];
gl.glVertexAttribPointer(attribLoc.intValue(), sz, GL2ES2.GL_FLOAT, false, 0, 0);
gl.glEnableVertexAttribArray(attribLoc.intValue());//must be called after Pointer above
@@ -2708,34 +2434,28 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (textureDefined)
- {
+ if (textureDefined) {
boolean[] texSetsBound = new boolean[texCoords.length];
- for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++)
- {
- int texSet = texCoordSetMap[texUnit];
- if (texSet != -1 && locs.glMultiTexCoord[texSet] != -1 && !texSetsBound[texSet])
- {
- texSetsBound[texSet] = true;
+ for (int texUnit = 0; texUnit < numActiveTexUnitState && texUnit < texCoordMapLength; texUnit++) {
+ int texSet = texCoordSetMap [texUnit];
+ if (texSet != -1 && locs.glMultiTexCoord [texSet] != -1 && !texSetsBound [texSet]) {
+ texSetsBound [texSet] = true;
// stupid interface...
- FloatBuffer buf = (FloatBuffer) texCoords[texSet];
+ FloatBuffer buf = (FloatBuffer)texCoords [texSet];
buf.position(0);
SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf;
- if (bufIds == null)
- {
+ if (bufIds == null) {
new Throwable("Buffer load issue!").printStackTrace();
}
Integer bufId = bufIds.get(texUnit);
- if (bufId == null)
- {
+ if (bufId == null) {
new Throwable("Buffer load issue!").printStackTrace();
- }
- else
- {
+ } else {
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue());
- gl.glVertexAttribPointer(locs.glMultiTexCoord[texUnit], texStride, GL2ES2.GL_FLOAT, true, 0, 0);
- gl.glEnableVertexAttribArray(locs.glMultiTexCoord[texUnit]);// must be called after Pointer above
+ gl.glVertexAttribPointer(locs.glMultiTexCoord [texUnit], texStride, GL2ES2.GL_FLOAT,
+ true, 0, 0);
+ gl.glEnableVertexAttribArray(locs.glMultiTexCoord [texUnit]);// must be called after Pointer above
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -2751,32 +2471,30 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
- if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
- || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET)
- {
+ if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET
+ || geo_type == GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET) {
int primType = 0;
// need to override if polygonAttributes says so
if (ctx.polygonMode == PolygonAttributes.POLYGON_LINE)
geo_type = GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET;
- switch (geo_type)
- {
- case GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET:
- primType = GL2ES2.GL_TRIANGLE_STRIP;
- break;
- case GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET:
- primType = GL2ES2.GL_TRIANGLE_FAN;
- break;
- case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET:
- primType = GL2ES2.GL_LINES;
- break;
+ switch (geo_type) {
+ case GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET:
+ primType = GL2ES2.GL_TRIANGLE_STRIP;
+ break;
+ case GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET:
+ primType = GL2ES2.GL_TRIANGLE_FAN;
+ break;
+ case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET:
+ primType = GL2ES2.GL_LINES;
+ break;
}
int[] stripInd = gd.geoToIndStripBuf;
// if no index buffers build build them now
- if (stripInd == null)
- {
+ if (stripInd == null) {
stripInd = new int[strip_len];
gl.glGenBuffers(strip_len, stripInd, 0);
@@ -2785,17 +2503,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
.asShortBuffer();
for (int s = 0; s < indexCoord.length; s++)
indicesBuffer.put(s, (short) indexCoord[s]);*/
-
+
ShortBuffer indicesBuffer = getIndexArrayBuffer(indexCoord);
-
- for (int i = 0; i < strip_len; i++)
- {
+
+ for (int i = 0; i < strip_len; i++) {
indicesBuffer.position(offset);
- int count = sarray[i];
- int indBufId = stripInd[i];
+ int count = sarray [i];
+ int indBufId = stripInd [i];
gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBufId);
- gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, count * Short.SIZE / 8, indicesBuffer, GL2ES2.GL_STATIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, count * Short.SIZE / 8, indicesBuffer,
+ GL2ES2.GL_STATIC_DRAW);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
offset += count;
@@ -2805,9 +2523,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
gd.geoToIndStripBuf = stripInd;
- }
- else
- {
+ } else {
//a good cDirty and a DYNAMIC_DRAW call needed
/*if ((cDirty & GeometryArrayRetained.INDEX_CHANGED) != 0)
{
@@ -2826,10 +2542,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}*/
}
- for (int i = 0; i < strip_len; i++)
- {
- int count = sarray[i];
- int indBufId = stripInd[i];
+ for (int i = 0; i < strip_len; i++) {
+ int count = sarray [i];
+ int indBufId = stripInd [i];
// type Specifies the type of the values in indices. Must be
// GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT.
@@ -2855,33 +2570,29 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.indexCount += gd.geoToIndBufSize;
- }
- else
- {
+ } else {
// bind my indexes ready for the draw call
- if (gd.geoToIndBuf == -1)
- {
+ if (gd.geoToIndBuf == -1) {
// create and fill index buffer
/*ShortBuffer indBuf = ByteBuffer.allocateDirect(indexCoord.length * 2).order(ByteOrder.nativeOrder()).asShortBuffer();
for (int s = 0; s < indexCoord.length; s++)
indBuf.put(s, (short) indexCoord[s]);
indBuf.position(initialIndexIndex);*/
-
+
ShortBuffer indBuf = getIndexArrayBuffer(indexCoord);
int[] tmp = new int[1];
gl.glGenBuffers(1, tmp, 0);
- gd.geoToIndBuf = tmp[0];// about to add to map below
+ gd.geoToIndBuf = tmp [0];// about to add to map below
gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, gd.geoToIndBuf);
- gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBuf.remaining() * Short.SIZE / 8, indBuf, GL2ES2.GL_STATIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, indBuf.remaining() * Short.SIZE / 8, indBuf,
+ GL2ES2.GL_STATIC_DRAW);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
gd.geoToIndBufSize = indBuf.remaining();
- }
- else
- {
+ } else {
//a good cDirty and a DYNAMIC_DRAW call needed
/*if ((cDirty & GeometryArrayRetained.INDEX_CHANGED) != 0)
{
@@ -2907,26 +2618,27 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
else if (ctx.polygonMode == PolygonAttributes.POLYGON_POINT)
geo_type = GeometryRetained.GEO_TYPE_INDEXED_POINT_SET;
- switch (geo_type)
- {
- case GeometryRetained.GEO_TYPE_INDEXED_QUAD_SET:
- if(!quadArrayCautionPrinted) {
- System.err.println("QuadArray will render incorrectly, consider using TriangleArray. If you have the java3d-utils in the buildpath you can convert like this:");
- System.err.println("GeometryInfo gi = new GeometryInfo(quadArray);");
- System.err.println("gi.convertToIndexedTriangles(); ");
- System.err.println("GeometryArray ga = gi.getIndexedGeometryArray(true, true, true, true, true);");
- quadArrayCautionPrinted = true;
- }
- //fallthrough
- case GeometryRetained.GEO_TYPE_INDEXED_TRI_SET:
- gl.glDrawElements(GL2ES2.GL_TRIANGLES, validIndexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
- break;
- case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET:
- gl.glDrawElements(GL2ES2.GL_POINTS, validIndexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
- break;
- case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET:
- gl.glDrawElements(GL2ES2.GL_LINES, validIndexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
- break;
+ switch (geo_type) {
+ case GeometryRetained.GEO_TYPE_INDEXED_QUAD_SET:
+ if (!quadArrayCautionPrinted) {
+ System.err.println(
+ "QuadArray will render incorrectly, consider using TriangleArray. If you have the java3d-utils in the buildpath you can convert like this:");
+ System.err.println("GeometryInfo gi = new GeometryInfo(quadArray);");
+ System.err.println("gi.convertToIndexedTriangles(); ");
+ System.err.println(
+ "GeometryArray ga = gi.getIndexedGeometryArray(true, true, true, true, true);");
+ quadArrayCautionPrinted = true;
+ }
+ //fallthrough
+ case GeometryRetained.GEO_TYPE_INDEXED_TRI_SET:
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, validIndexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
+ break;
+ case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET:
+ gl.glDrawElements(GL2ES2.GL_POINTS, validIndexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
+ break;
+ case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET:
+ gl.glDrawElements(GL2ES2.GL_LINES, validIndexCount, GL2ES2.GL_UNSIGNED_SHORT, 0);
+ break;
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -2934,13 +2646,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
ctx.perFrameStats.glDrawElements++;
}
- }
- else
- {
+ } else {
if (!NO_PROGRAM_WARNING_GIVEN)
System.err.println("Execute called with no shader Program in use!");
NO_PROGRAM_WARNING_GIVEN = true;
-
+
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.executeSkippedNoShaderProgram++;
}
@@ -2949,14 +2659,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
/**
- * Over time we have had things recorded and in FFP they are considered current state
- * in programmable we have to push them across manually each time recorded in JoglesContext
+ * Over time we have had things recorded and in FFP they are considered current state in programmable we have to
+ * push them across manually each time recorded in JoglesContext
* @param gl
* @param vdefined
*/
- private static void setFFPAttributes(Jogl2es2Context ctx, GL2ES2 gl, int shaderProgramId, ProgramData pd, int vdefined, boolean ignoreVertexColors)
- {
+ private static void setFFPAttributes( Jogl2es2Context ctx, GL2ES2 gl, int shaderProgramId, ProgramData pd,
+ int vdefined, boolean ignoreVertexColors) {
LocationData locs = pd.programToLocationData;
@@ -2973,12 +2683,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
boolean isGL2ES3 = gl.isGL2ES3();
// if shader hasn't changed location of uniform I don't need to reset these (they are cleared to -1 at the start of each swap)
- if (locs.glProjectionMatrix != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram))
- {
+ if (locs.glProjectionMatrix != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram)) {
if (isGL2ES3)
- gl.glUniformMatrix4fv(locs.glProjectionMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentProjMat), 0);
+ gl.glUniformMatrix4fv(locs.glProjectionMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentProjMat),
+ 0);
else
gl.glUniformMatrix4fv(locs.glProjectionMatrix, 1, false,
Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentProjMat)), 0);
@@ -2987,23 +2696,19 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
}
- if (locs.glProjectionMatrixInverse != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram))
- {
+ if (locs.glProjectionMatrixInverse != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram)) {
// EXPENSIVE!!!!! only calc if asked for, and even then...
- try
- {
+ try {
ctx.currentProjMatInverse.set(ctx.currentProjMat);
ctx.matrixUtil.invert(ctx.currentProjMatInverse);
- }
- catch (SingularMatrixException e)
- {
+ } catch (SingularMatrixException e) {
System.err.println("" + e);
}
if (isGL2ES3)
- gl.glUniformMatrix4fv(locs.glProjectionMatrixInverse, 1, true, ctx.matrixUtil.toArray(ctx.currentProjMatInverse), 0);
+ gl.glUniformMatrix4fv(locs.glProjectionMatrixInverse, 1, true,
+ ctx.matrixUtil.toArray(ctx.currentProjMatInverse), 0);
else
gl.glUniformMatrix4fv(locs.glProjectionMatrixInverse, 1, false,
Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentProjMatInverse)), 0);
@@ -3012,21 +2717,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
}
- if (locs.glViewMatrix != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram))
- {
+ if (locs.glViewMatrix != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram)) {
gl.glUniformMatrix4fv(locs.glViewMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentViewMat), 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
}
}
- if (locs.glModelMatrix != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.modelMatrix.m00 == Double.NEGATIVE_INFINITY))
- {
+ if (locs.glModelMatrix != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glModelMatrix.m00 == Double.NEGATIVE_INFINITY)) {
if (isGL2ES3)
gl.glUniformMatrix4fv(locs.glModelMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelMat), 0);
@@ -3037,127 +2738,117 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (MINIMISE_NATIVE_CALLS_FFP)
- ctx.gl_state.modelMatrix.m00 = 0;
+ ctx.gl_state.glModelMatrix.m00 = 0;
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.modelMatrixUpdated++;
- }
- else if (OUTPUT_PER_FRAME_STATS)
- {
+ } else if (OUTPUT_PER_FRAME_STATS) {
ctx.perFrameStats.modelMatrixSkipped++;
}
}
- if (locs.glModelViewMatrix != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glModelViewMatrix.m00 == Double.NEGATIVE_INFINITY))
- {
+ if (locs.glModelViewMatrix != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glModelViewMatrix.m00 == Double.NEGATIVE_INFINITY)) {
// Expensive, only calc if required, not in the setmodelview call, in case unneeded
if (ctx.currentModelViewMat.m00 == Double.NEGATIVE_INFINITY)
- ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat);
-
+ ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat);
+
if (isGL2ES3)
- gl.glUniformMatrix4fv(locs.glModelViewMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewMat), 0);
+ gl.glUniformMatrix4fv(locs.glModelViewMatrix, 1, true,
+ ctx.matrixUtil.toArray(ctx.currentModelViewMat), 0);
else
gl.glUniformMatrix4fv(locs.glModelViewMatrix, 1, false,
Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentModelViewMat)), 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
-
+
if (MINIMISE_NATIVE_CALLS_FFP)
ctx.gl_state.glModelViewMatrix.m00 = 0;
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glModelViewMatrixUpdated++;
- }
- else if (OUTPUT_PER_FRAME_STATS)
- {
+ } else if (OUTPUT_PER_FRAME_STATS) {
ctx.perFrameStats.glModelViewMatrixSkipped++;
}
}
- if (locs.glModelViewMatrixInverse != -1)
- {
+ if (locs.glModelViewMatrixInverse != -1) {
if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glModelViewMatrixInverse.m00 == Double.NEGATIVE_INFINITY))
- {
+ || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glModelViewMatrixInverse.m00 == Double.NEGATIVE_INFINITY)) {
// Expensive, only calc if required, not in the setmodelview call, in case unneeded
- if (ctx.currentModelViewMatInverse.m00 == Double.NEGATIVE_INFINITY)
- {
- ctx.currentModelViewMatInverse.mul(ctx.currentViewMat, ctx.currentModelMat);
- ctx.matrixUtil.invert(ctx.currentModelViewMatInverse);
+ if (ctx.currentModelViewMatInverse.m00 == Double.NEGATIVE_INFINITY) {
+ ctx.currentModelViewMatInverse.mul(ctx.currentViewMat, ctx.currentModelMat);
+ ctx.matrixUtil.invert(ctx.currentModelViewMatInverse);
}
-
-
+
if (isGL2ES3)
- gl.glUniformMatrix4fv(locs.glModelViewMatrixInverse, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewMatInverse), 0);
+ gl.glUniformMatrix4fv(locs.glModelViewMatrixInverse, 1, true,
+ ctx.matrixUtil.toArray(ctx.currentModelViewMatInverse), 0);
else
gl.glUniformMatrix4fv(locs.glModelViewMatrixInverse, 1, false,
- Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentModelViewMatInverse)), 0);
+ Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentModelViewMatInverse)),
+ 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
-
+
if (MINIMISE_NATIVE_CALLS_FFP)
ctx.gl_state.glModelViewMatrixInverse.m00 = 0;
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glModelViewMatrixInverseUpdated++;
- }
- else if (OUTPUT_PER_FRAME_STATS)
- {
+ } else if (OUTPUT_PER_FRAME_STATS) {
ctx.perFrameStats.glModelViewMatrixInverseSkipped++;
}
}
- if (locs.glModelViewProjectionMatrix != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
- || ctx.gl_state.glModelViewProjectionMatrix.m00 == Double.NEGATIVE_INFINITY))
- {
+ if (locs.glModelViewProjectionMatrix != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP
+ || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glModelViewProjectionMatrix.m00 == Double.NEGATIVE_INFINITY)) {
// Expensive, only calc if required, not in the setmodelview call, in case unneeded
if (ctx.currentModelViewMat.m00 == Double.NEGATIVE_INFINITY)
- ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat);
+ ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat);
if (ctx.currentModelViewProjMat.m00 == Double.NEGATIVE_INFINITY)
- ctx.currentModelViewProjMat.mul(ctx.currentProjMat, ctx.currentModelViewMat);
-
+ ctx.currentModelViewProjMat.mul(ctx.currentProjMat, ctx.currentModelViewMat);
+
if (isGL2ES3)
- gl.glUniformMatrix4fv(locs.glModelViewProjectionMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewProjMat), 0);
+ gl.glUniformMatrix4fv(locs.glModelViewProjectionMatrix, 1, true,
+ ctx.matrixUtil.toArray(ctx.currentModelViewProjMat), 0);
else
gl.glUniformMatrix4fv(locs.glModelViewProjectionMatrix, 1, false,
- Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentModelViewProjMat)), 0);
-
+ Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentModelViewProjMat)),
+ 0);
+
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
-
+
if (MINIMISE_NATIVE_CALLS_FFP)
ctx.gl_state.glModelViewProjectionMatrix.m00 = 0;
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glModelViewProjectionMatrixUpdated++;
- }
- else if (OUTPUT_PER_FRAME_STATS)
- {
+ } else if (OUTPUT_PER_FRAME_STATS) {
ctx.perFrameStats.glModelViewProjectionMatrixSkipped++;
}
}
- if (locs.glNormalMatrix != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glNormalMatrix.m00 == Double.NEGATIVE_INFINITY))
- {
+ if (locs.glNormalMatrix != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glNormalMatrix.m00 == Double.NEGATIVE_INFINITY)) {
// Expensive, only calc if required, not in the setmodelview call, in case unneeded
if (ctx.currentModelViewMat.m00 == Double.NEGATIVE_INFINITY)
- ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat);
+ ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat);
if (ctx.currentNormalMat.m00 == Double.NEGATIVE_INFINITY)
- Jogl2es2MatrixUtil.transposeInvert(ctx.currentModelViewMat, ctx.currentNormalMat);
-
+ Jogl2es2MatrixUtil.transposeInvert(ctx.currentModelViewMat, ctx.currentNormalMat);
+
if (isGL2ES3)
- gl.glUniformMatrix3fv(locs.glNormalMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentNormalMat), 0);
+ gl.glUniformMatrix3fv(locs.glNormalMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentNormalMat),
+ 0);
else
gl.glUniformMatrix3fv(locs.glNormalMatrix, 1, false,
Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentNormalMat)), 0);
-
+
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (MINIMISE_NATIVE_CALLS_FFP)
@@ -3165,20 +2856,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (OUTPUT_PER_FRAME_STATS)
ctx.perFrameStats.glNormalMatrixUpdated++;
- }
- else if (OUTPUT_PER_FRAME_STATS)
- {
+ } else if (OUTPUT_PER_FRAME_STATS) {
ctx.perFrameStats.glNormalMatrixSkipped++;
}
}
// if set one of the 2 colors below should be used by the shader (material for lighting)
- if (locs.ignoreVertexColors != -1)
- {
+ if (locs.ignoreVertexColors != -1) {
// vertex colors MUST be ignored if no glColors set
- boolean finalIgnoreVertexColors = (!floatColorsDefined && !byteColorsDefined) || ctx.renderingData.ignoreVertexColors == 1;
-
+ boolean finalIgnoreVertexColors = (!floatColorsDefined && !byteColorsDefined)
+ || ctx.renderingData.ignoreVertexColors == 1;
+
//TODO: the execute calls all have a separate ignore vertex colors bool, but it appears to add no value?
// is it just a legacy artifact of some sort?
/*if(finalIgnoreVertexColors != ignoreVertexColors )
@@ -3188,13 +2877,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
System.out.println("ctx.renderingData.ignoreVertexColors " +ctx.renderingData.ignoreVertexColors);
System.out.println("floatColorsDefined " +floatColorsDefined);
}*/
-
+
int finalIgnoreVertexColorsInt = finalIgnoreVertexColors ? 1 : 0;
//note ctx.gl_state.ignoreVertexColors can be -1 for not set
if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
- || ctx.gl_state.ignoreVertexColors != finalIgnoreVertexColorsInt))
- {
+ || ctx.gl_state.ignoreVertexColors != finalIgnoreVertexColorsInt)) {
gl.glUniform1i(locs.ignoreVertexColors, finalIgnoreVertexColorsInt);// note local variable used
if (DO_OUTPUT_ERRORS)
@@ -3205,63 +2893,60 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// the front material structure
- if (locs.glFrontMaterial.present)
- {
+ if (locs.glFrontMaterial.present) {
//note != not equals
- if (locs.glFrontMaterial.lightEnabled != -1 && (shaderProgramId != ctx.prevShaderProgram
- || ctx.gl_state.glFrontMaterial.lightEnabled != ctx.materialData.lightEnabled))
- {
- gl.glUniform1i(locs.glFrontMaterial.lightEnabled, ctx.materialData.lightEnabled);
+ if (locs.glFrontMaterial.lightEnabled != -1
+ && (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glFrontMaterial.lightEnabled != ctx.materialData.lightEnabled)) {
+ gl.glUniform1i(locs.glFrontMaterial.lightEnabled, ctx.materialData.lightEnabled);
ctx.gl_state.glFrontMaterial.lightEnabled = ctx.materialData.lightEnabled;
}
if (locs.glFrontMaterial.ambient != -1
- && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.ambient.x == Float.NEGATIVE_INFINITY))
- {
- gl.glUniform4f(locs.glFrontMaterial.ambient, ctx.materialData.ambient.x, ctx.materialData.ambient.y,
- ctx.materialData.ambient.z, 1f);
+ && (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glFrontMaterial.ambient.x == Float.NEGATIVE_INFINITY)) {
+ gl.glUniform4f(locs.glFrontMaterial.ambient, ctx.materialData.ambient.x, ctx.materialData.ambient.y,
+ ctx.materialData.ambient.z, 1f);
ctx.gl_state.glFrontMaterial.ambient.x = 0;
}
if (locs.glFrontMaterial.diffuse != -1
- && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.diffuse.x == Float.NEGATIVE_INFINITY))
- {
- gl.glUniform4f(locs.glFrontMaterial.diffuse, ctx.materialData.diffuse.x, ctx.materialData.diffuse.y,
- ctx.materialData.diffuse.z, ctx.materialData.diffuse.w);
+ && (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glFrontMaterial.diffuse.x == Float.NEGATIVE_INFINITY)) {
+ gl.glUniform4f(locs.glFrontMaterial.diffuse, ctx.materialData.diffuse.x, ctx.materialData.diffuse.y,
+ ctx.materialData.diffuse.z, ctx.materialData.diffuse.w);
ctx.gl_state.glFrontMaterial.diffuse.x = 0;
}
if (locs.glFrontMaterial.emission != -1
- && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.emission.x == Float.NEGATIVE_INFINITY))
- {
- gl.glUniform4f(locs.glFrontMaterial.emission, ctx.materialData.emission.x, ctx.materialData.emission.y,
- ctx.materialData.emission.z, 1f); // note extra alpha value for ease
+ && (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glFrontMaterial.emission.x == Float.NEGATIVE_INFINITY)) {
+ gl.glUniform4f(locs.glFrontMaterial.emission, ctx.materialData.emission.x, ctx.materialData.emission.y,
+ ctx.materialData.emission.z, 1f); // note extra alpha value for ease
ctx.gl_state.glFrontMaterial.emission.x = 0;
}
if (locs.glFrontMaterial.specular != -1
- && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.specular.x == Float.NEGATIVE_INFINITY))
- {
- gl.glUniform3f(locs.glFrontMaterial.specular, ctx.materialData.specular.x, ctx.materialData.specular.y,
- ctx.materialData.specular.z);
+ && (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glFrontMaterial.specular.x == Float.NEGATIVE_INFINITY)) {
+ gl.glUniform3f(locs.glFrontMaterial.specular, ctx.materialData.specular.x, ctx.materialData.specular.y,
+ ctx.materialData.specular.z);
ctx.gl_state.glFrontMaterial.specular.x = 0;
}
if (locs.glFrontMaterial.shininess != -1
- && (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glFrontMaterial.shininess != ctx.materialData.shininess))
- {
- gl.glUniform1f(locs.glFrontMaterial.shininess, ctx.materialData.shininess);
+ && (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glFrontMaterial.shininess != ctx.materialData.shininess)) {
+ gl.glUniform1f(locs.glFrontMaterial.shininess, ctx.materialData.shininess);
ctx.gl_state.glFrontMaterial.shininess = ctx.materialData.shininess;
}
- if (DO_OUTPUT_ERRORS)
- outputErrors(ctx);
+ if (DO_OUTPUT_ERRORS)
+ outputErrors(ctx);
- }
+ }
// ambient does not come from material notice
- if (locs.glLightModelambient != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glLightModelambient.x == Float.NEGATIVE_INFINITY))
- {
- gl.glUniform4f(locs.glLightModelambient, ctx.currentAmbientColor.x, ctx.currentAmbientColor.y, ctx.currentAmbientColor.z,
- ctx.currentAmbientColor.w);
+ if (locs.glLightModelambient != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glLightModelambient.x == Float.NEGATIVE_INFINITY)) {
+ gl.glUniform4f(locs.glLightModelambient, ctx.currentAmbientColor.x, ctx.currentAmbientColor.y,
+ ctx.currentAmbientColor.z, ctx.currentAmbientColor.w);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (MINIMISE_NATIVE_CALLS_FFP)
@@ -3270,12 +2955,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// always bind object color, the shader can decide to use it if it's no lighting and no vertex colors
- if (locs.objectColor != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.objectColor.x == Float.NEGATIVE_INFINITY))
- {
- gl.glUniform4f(locs.objectColor, ctx.objectColor.x, ctx.objectColor.y, ctx.objectColor.z, ctx.objectColor.w);
+ if (locs.objectColor != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.objectColor.x == Float.NEGATIVE_INFINITY)) {
+ gl.glUniform4f(locs.objectColor, ctx.objectColor.x, ctx.objectColor.y, ctx.objectColor.z,
+ ctx.objectColor.w);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (MINIMISE_NATIVE_CALLS_FFP)
@@ -3283,11 +2967,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (locs.transparencyAlpha != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.transparencyAlpha != ctx.transparencyAlpha))
- {
+ if (locs.transparencyAlpha != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.transparencyAlpha != ctx.transparencyAlpha)) {
gl.glUniform1f(locs.transparencyAlpha, ctx.transparencyAlpha);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -3297,12 +2979,10 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// count of enabled lights currentEnabledLights
- if (locs.numberOfLights != -1)
- {
+ if (locs.numberOfLights != -1) {
//note ctx.gl_state.numberOfLights can be -1 for not set
if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.numberOfLights != ctx.numberOfLights))
- {
+ || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.numberOfLights != ctx.numberOfLights)) {
gl.glUniform1i(locs.numberOfLights, ctx.numberOfLights);
if (DO_OUTPUT_ERRORS)
@@ -3314,29 +2994,26 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// the lighting structures
int pipelineLightSlotToUse = 0;
- for (int shaderLightIndex = 0; shaderLightIndex < ctx.maxLights; shaderLightIndex++)
- {
- if (locs.glLightSource[pipelineLightSlotToUse] != null)
- {
- glLightSource glLightSource = ctx.glLightSource[shaderLightIndex];
- if (glLightSource.enabled == 1)
- {
+ for (int shaderLightIndex = 0; shaderLightIndex < ctx.maxLights; shaderLightIndex++) {
+ if (locs.glLightSource [pipelineLightSlotToUse] != null) {
+ glLightSource glLightSource = ctx.glLightSource [shaderLightIndex];
+ if (glLightSource.enabled == 1) {
//Notice use of == as we want to see it's simply the exact same light source or not
if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.glLightSource[shaderLightIndex] != glLightSource))
- {
+ || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.glLightSource [shaderLightIndex] != glLightSource)) {
glLightSource.prevLightSlot = pipelineLightSlotToUse;// record for the equals to check for moved
- glLightSourceLocs glLightSourceLocs = locs.glLightSource[pipelineLightSlotToUse];
+ glLightSourceLocs glLightSourceLocs = locs.glLightSource [pipelineLightSlotToUse];
if (glLightSourceLocs.position != -1)
- gl.glUniform4f(glLightSourceLocs.position, glLightSource.position.x, glLightSource.position.y,
- glLightSource.position.z, glLightSource.position.w);
+ gl.glUniform4f(glLightSourceLocs.position, glLightSource.position.x,
+ glLightSource.position.y, glLightSource.position.z, glLightSource.position.w);
if (glLightSourceLocs.diffuse != -1)
gl.glUniform4f(glLightSourceLocs.diffuse, glLightSource.diffuse.x, glLightSource.diffuse.y,
glLightSource.diffuse.z, glLightSource.diffuse.w);
if (glLightSourceLocs.specular != -1)
- gl.glUniform4f(glLightSourceLocs.specular, glLightSource.specular.x, glLightSource.specular.y,
- glLightSource.specular.z, glLightSource.specular.w);
+ gl.glUniform4f(glLightSourceLocs.specular, glLightSource.specular.x,
+ glLightSource.specular.y, glLightSource.specular.z, glLightSource.specular.w);
if (glLightSourceLocs.constantAttenuation != -1)
gl.glUniform1f(glLightSourceLocs.constantAttenuation, glLightSource.constantAttenuation);
if (glLightSourceLocs.linearAttenuation != -1)
@@ -3348,13 +3025,26 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (glLightSourceLocs.spotExponent != -1)
gl.glUniform1f(glLightSourceLocs.spotExponent, glLightSource.spotExponent);
if (glLightSourceLocs.spotDirection != -1)
- gl.glUniform3f(glLightSourceLocs.spotDirection, glLightSource.spotDirection.x, glLightSource.spotDirection.y,
- glLightSource.spotDirection.z);
+ gl.glUniform3f(glLightSourceLocs.spotDirection, glLightSource.spotDirection.x,
+ glLightSource.spotDirection.y, glLightSource.spotDirection.z);
+ if (glLightSourceLocs.shadowMapSamplerId != -1) {
+ //FIXME: this will not ply nice with other textures, I need to be well off into a unique texture unit
+ gl.glActiveTexture(GL2ES2.GL_TEXTURE0);
+ gl.glBindTexture(GL2ES2.GL_TEXTURE_2D, glLightSource.shadowMapSamplerId);
+ gl.glUniform1i(glLightSourceLocs.shadowMapSamplerId, 0);
+ }
+ if (glLightSourceLocs.projMatrix != -1) {
+ if (isGL2ES3)
+ gl.glUniformMatrix4fv(glLightSourceLocs.projMatrix, 1, true, ctx.matrixUtil.toArray(glLightSource.projMatrix), 0);
+ else
+ gl.glUniformMatrix4fv(glLightSourceLocs.projMatrix, 1, false,
+ Jogl2es2MatrixUtil.transposeInPlace(ctx.matrixUtil.toArray(ctx.currentProjMat)), 0);
+ }
- if (DO_OUTPUT_ERRORS)
- outputErrors(ctx);
- if (MINIMISE_NATIVE_CALLS_FFP)
- ctx.gl_state.glLightSource[shaderLightIndex] = glLightSource;
+ if (DO_OUTPUT_ERRORS)
+ outputErrors(ctx);
+ if (MINIMISE_NATIVE_CALLS_FFP)
+ ctx.gl_state.glLightSource [shaderLightIndex] = glLightSource;
}
pipelineLightSlotToUse++;
@@ -3362,28 +3052,26 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (locs.alphaTestEnabled != -1)
- {
+ if (locs.alphaTestEnabled != -1) {
if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.alphaTestEnabled != ctx.renderingData.alphaTestEnabled))
- {
+ || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.alphaTestEnabled != ctx.renderingData.alphaTestEnabled)) {
gl.glUniform1i(locs.alphaTestEnabled, ctx.renderingData.alphaTestEnabled ? 1 : 0);
if (MINIMISE_NATIVE_CALLS_FFP)
ctx.gl_state.alphaTestEnabled = ctx.renderingData.alphaTestEnabled;
- if (ctx.renderingData.alphaTestEnabled == true)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
- || ctx.gl_state.alphaTestFunction != ctx.renderingData.alphaTestFunction))
- {
+ if (ctx.renderingData.alphaTestEnabled == true) {
+ if (!MINIMISE_NATIVE_CALLS_FFP
+ || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.alphaTestFunction != ctx.renderingData.alphaTestFunction)) {
gl.glUniform1i(locs.alphaTestFunction, getFunctionValue(ctx.renderingData.alphaTestFunction));
if (MINIMISE_NATIVE_CALLS_FFP)
ctx.gl_state.alphaTestFunction = ctx.renderingData.alphaTestFunction;
}
- if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
- || ctx.gl_state.alphaTestValue != ctx.renderingData.alphaTestValue))
- {
+ if (!MINIMISE_NATIVE_CALLS_FFP
+ || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.alphaTestValue != ctx.renderingData.alphaTestValue)) {
gl.glUniform1f(locs.alphaTestValue, ctx.renderingData.alphaTestValue);
if (MINIMISE_NATIVE_CALLS_FFP)
ctx.gl_state.alphaTestValue = ctx.renderingData.alphaTestValue;
@@ -3394,11 +3082,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
- if (locs.textureTransform != -1)
- {
- if (!MINIMISE_NATIVE_CALLS_FFP
- || (shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.textureTransform.m00 == Double.NEGATIVE_INFINITY))
- {
+ if (locs.textureTransform != -1) {
+ if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.textureTransform.m00 == Double.NEGATIVE_INFINITY)) {
// gl.glUniformMatrix4fv(locs.textureTransform, 1, true, ctx.toFB(ctx.textureTransform));
gl.glUniformMatrix4fv(locs.textureTransform, 1, true, ctx.matrixUtil.toArray(ctx.textureTransform), 0);
if (DO_OUTPUT_ERRORS)
@@ -3409,35 +3095,32 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// Fog
- if (locs.fogData.present && locs.fogData.fogEnabled != -1)
- {
+ if (locs.fogData.present && locs.fogData.fogEnabled != -1) {
if (!MINIMISE_NATIVE_CALLS_FFP || shaderProgramId != ctx.prevShaderProgram
- || ctx.gl_state.fogData.fogEnabled != ctx.fogData.fogEnabled)
- {
- gl.glUniform1i(locs.fogData.fogEnabled, ctx.fogData.fogEnabled);
+ || ctx.gl_state.fogData.fogEnabled != ctx.fogData.fogEnabled) {
+ gl.glUniform1i(locs.fogData.fogEnabled, ctx.fogData.fogEnabled);
ctx.gl_state.fogData.fogEnabled = ctx.fogData.fogEnabled;
- if (ctx.fogData.fogEnabled == 1)
- {
- if ((shaderProgramId != ctx.prevShaderProgram || ctx.gl_state.fogData.expColor.x == Float.NEGATIVE_INFINITY))
- {
- if (locs.fogData.expColor != -1)
- gl.glUniform4f(locs.fogData.expColor, ctx.fogData.expColor.x, ctx.fogData.expColor.y, ctx.fogData.expColor.z,
- 1.0f);
- if (locs.fogData.expDensity != -1)
- gl.glUniform1f(locs.fogData.expDensity, ctx.fogData.expDensity);
- if (locs.fogData.linearColor != -1)
- gl.glUniform4f(locs.fogData.linearColor, ctx.fogData.linearColor.x, ctx.fogData.linearColor.y,
- ctx.fogData.linearColor.z, 1.0f);
- if (locs.fogData.linearStart != -1)
- gl.glUniform1f(locs.fogData.linearStart, ctx.fogData.linearStart);
- if (locs.fogData.linearEnd != -1)
- gl.glUniform1f(locs.fogData.linearEnd, ctx.fogData.linearEnd);
+ if (ctx.fogData.fogEnabled == 1) {
+ if ((shaderProgramId != ctx.prevShaderProgram
+ || ctx.gl_state.fogData.expColor.x == Float.NEGATIVE_INFINITY)) {
+ if (locs.fogData.expColor != -1)
+ gl.glUniform4f(locs.fogData.expColor, ctx.fogData.expColor.x, ctx.fogData.expColor.y,
+ ctx.fogData.expColor.z, 1.0f);
+ if (locs.fogData.expDensity != -1)
+ gl.glUniform1f(locs.fogData.expDensity, ctx.fogData.expDensity);
+ if (locs.fogData.linearColor != -1)
+ gl.glUniform4f(locs.fogData.linearColor, ctx.fogData.linearColor.x,
+ ctx.fogData.linearColor.y, ctx.fogData.linearColor.z, 1.0f);
+ if (locs.fogData.linearStart != -1)
+ gl.glUniform1f(locs.fogData.linearStart, ctx.fogData.linearStart);
+ if (locs.fogData.linearEnd != -1)
+ gl.glUniform1f(locs.fogData.linearEnd, ctx.fogData.linearEnd);
- if (DO_OUTPUT_ERRORS)
- outputErrors(ctx);
- if (MINIMISE_NATIVE_CALLS_FFP)
+ if (DO_OUTPUT_ERRORS)
+ outputErrors(ctx);
+ if (MINIMISE_NATIVE_CALLS_FFP)
ctx.gl_state.fogData.expColor.x = 0;
}
}
@@ -3457,11 +3140,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Private helper methods for GeometryArrayRetained and IndexedGeometryArrayRetained
//
- private static void loadLocs(Jogl2es2Context ctx, GL2ES2 gl)
- {
+ private static void loadLocs(Jogl2es2Context ctx, GL2ES2 gl) {
ProgramData pd = ctx.programData;
- if (pd.programToLocationData == null)
- {
+ if (pd.programToLocationData == null) {
LocationData locs = new LocationData();
if (OUTPUT_PER_FRAME_STATS)
@@ -3469,15 +3150,15 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int shaderProgramId = ctx.shaderProgramId;
// shader program can be disabled, but locs still called
- if (shaderProgramId != -1)
- {
+ if (shaderProgramId != -1) {
locs.glProjectionMatrix = gl.glGetUniformLocation(shaderProgramId, "glProjectionMatrix");
locs.glProjectionMatrixInverse = gl.glGetUniformLocation(shaderProgramId, "glProjectionMatrixInverse");
locs.glModelMatrix = gl.glGetUniformLocation(shaderProgramId, "glModelMatrix");
locs.glViewMatrix = gl.glGetUniformLocation(shaderProgramId, "glViewMatrix");
locs.glModelViewMatrix = gl.glGetUniformLocation(shaderProgramId, "glModelViewMatrix");
locs.glModelViewMatrixInverse = gl.glGetUniformLocation(shaderProgramId, "glModelViewMatrixInverse");
- locs.glModelViewProjectionMatrix = gl.glGetUniformLocation(shaderProgramId, "glModelViewProjectionMatrix");
+ locs.glModelViewProjectionMatrix = gl.glGetUniformLocation(shaderProgramId,
+ "glModelViewProjectionMatrix");
locs.glNormalMatrix = gl.glGetUniformLocation(shaderProgramId, "glNormalMatrix");
locs.ignoreVertexColors = gl.glGetUniformLocation(shaderProgramId, "ignoreVertexColors");
locs.glLightModelambient = gl.glGetUniformLocation(shaderProgramId, "glLightModelambient");
@@ -3496,7 +3177,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
locs.fogData.linearEnd = gl.glGetUniformLocation(shaderProgramId, "fogData.linearEnd");
locs.fogData.setPresent();
- locs.glFrontMaterial.lightEnabled = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.lightEnabled");
+ locs.glFrontMaterial.lightEnabled = gl.glGetUniformLocation(shaderProgramId,
+ "glFrontMaterial.lightEnabled");
locs.glFrontMaterial.ambient = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.ambient");
locs.glFrontMaterial.diffuse = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.diffuse");
locs.glFrontMaterial.emission = gl.glGetUniformLocation(shaderProgramId, "glFrontMaterial.emission");
@@ -3508,29 +3190,33 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// lights, notice the vertex attribute is made of a string concat
// notice we stop once the light loc is not found, as that is the max the shader will accept
- for (int i = 0; i < locs.glLightSource.length; i++)
- {
+ for (int i = 0; i < locs.glLightSource.length; i++) {
int position = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].position");
- if (position != -1)
- {
- locs.glLightSource[i] = new glLightSourceLocs();
- locs.glLightSource[i].position = position;
- locs.glLightSource[i].diffuse = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].diffuse");
- locs.glLightSource[i].specular = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].specular");
- locs.glLightSource[i].constantAttenuation = gl.glGetUniformLocation(shaderProgramId,
- "glLightSource[" + i + "].constantAttenuation");
- locs.glLightSource[i].linearAttenuation = gl.glGetUniformLocation(shaderProgramId,
- "glLightSource[" + i + "].linearAttenuation");
- locs.glLightSource[i].quadraticAttenuation = gl.glGetUniformLocation(shaderProgramId,
- "glLightSource[" + i + "].quadraticAttenuation");
- locs.glLightSource[i].spotCutoff = gl.glGetUniformLocation(shaderProgramId, "glLightSource[" + i + "].spotCutoff");
- locs.glLightSource[i].spotExponent = gl.glGetUniformLocation(shaderProgramId,
+ if (position != -1) {
+ locs.glLightSource [i] = new glLightSourceLocs();
+ locs.glLightSource [i].position = position;
+ locs.glLightSource [i].diffuse = gl.glGetUniformLocation(shaderProgramId,
+ "glLightSource[" + i + "].diffuse");
+ locs.glLightSource [i].specular = gl.glGetUniformLocation(shaderProgramId,
+ "glLightSource[" + i + "].specular");
+ locs.glLightSource [i].constantAttenuation = gl.glGetUniformLocation(shaderProgramId,
+ "glLightSource[" + i + "].constantAttenuation");
+ locs.glLightSource [i].linearAttenuation = gl.glGetUniformLocation(shaderProgramId,
+ "glLightSource[" + i + "].linearAttenuation");
+ locs.glLightSource [i].quadraticAttenuation = gl.glGetUniformLocation(shaderProgramId,
+ "glLightSource[" + i + "].quadraticAttenuation");
+ locs.glLightSource [i].spotCutoff = gl.glGetUniformLocation(shaderProgramId,
+ "glLightSource[" + i + "].spotCutoff");
+ locs.glLightSource [i].spotExponent = gl.glGetUniformLocation(shaderProgramId,
"glLightSource[" + i + "].spotExponent");
- locs.glLightSource[i].spotDirection = gl.glGetUniformLocation(shaderProgramId,
- "glLightSource[" + i + "].spotDirection");
- }
- else
- {
+ locs.glLightSource [i].spotDirection = gl.glGetUniformLocation(shaderProgramId,
+ "glLightSource[" + i + "].spotDirection");
+ locs.glLightSource [i].projMatrix = gl.glGetUniformLocation(shaderProgramId,
+ "glLightSource[" + i + "].projMatrix");
+
+ locs.glLightSource [i].shadowMapSamplerId = gl.glGetUniformLocation(shaderProgramId,
+ "shadowMapSampler[" + i + "]");
+ } else {
break;
}
}
@@ -3541,17 +3227,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
locs.glNormal = gl.glGetAttribLocation(shaderProgramId, "glNormal");
// tex coords, notice the vertex attribute is made of a string concat
- for (int i = 0; i < locs.glMultiTexCoord.length; i++)
- {
- locs.glMultiTexCoord[i] = gl.glGetAttribLocation(shaderProgramId, "glMultiTexCoord" + i);
+ for (int i = 0; i < locs.glMultiTexCoord.length; i++) {
+ locs.glMultiTexCoord [i] = gl.glGetAttribLocation(shaderProgramId, "glMultiTexCoord" + i);
}
// generic attributes, notice allocated on a program basis not per geom
HashMap<String, Integer> attToIndex = pd.progToGenVertAttNameToGenVertAttIndex;
- if (attToIndex != null)
- {
- for (String attrib : attToIndex.keySet())
- {
+ if (attToIndex != null) {
+ for (String attrib : attToIndex.keySet()) {
int index = attToIndex.get(attrib);
int attribLoc = gl.glGetAttribLocation(shaderProgramId, attrib);
locs.genAttIndexToLoc.put(index, new Integer(attribLoc));
@@ -3567,8 +3250,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
/**
- * The buffers will be loaded and pointers set in GeometryData for this geometry native id
- * Note however morphable data will also be reloaded (only coords for now)
+ * The buffers will be loaded and pointers set in GeometryData for this geometry native id Note however morphable
+ * data will also be reloaded (only coords for now)
* @param ctx
* @param gl
* @param geo
@@ -3582,54 +3265,48 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
* @param startClrs
* @return
*/
- private static GeometryData loadAllBuffers(Jogl2es2Context ctx, GL2ES2 gl, GeometryArrayRetained geo, boolean ignoreVertexColors,
- int vertexCount, int vformat, int vdefined, FloatBuffer fverts, float[] vfarray, int startVertex, FloatBuffer fclrs,
- float[] cfarray, int startClrs)
- {
+ private static GeometryData loadAllBuffers( Jogl2es2Context ctx, GL2ES2 gl, GeometryArrayRetained geo,
+ boolean ignoreVertexColors, int vertexCount, int vformat, int vdefined,
+ FloatBuffer fverts, float[] vfarray, int startVertex, FloatBuffer fclrs,
+ float[] cfarray, int startClrs) {
if (VERBOSE)
System.err.println("private static GeometryData loadAllBuffers");
GeometryData gd = ctx.allGeometryData.get(geo.nativeId);
- if (gd == null)
- {
+ if (gd == null) {
gd = new GeometryData();
geo.nativeId = gd.nativeId;
ctx.allGeometryData.put(geo.nativeId, gd);
}
- if (gd.geoToCoordBuf == -1)
- {
+ if (gd.geoToCoordBuf == -1) {
// do we need to covert a float[]
- if (vfarray != null)
- {
+ if (vfarray != null) {
fverts = getVertexArrayBuffer(vfarray);
}
// can it change ever? (GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of this feature)
boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE)
- || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
+ || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
fverts.position(startVertex);
- if (morphable)
- {
+ if (morphable) {
int[] tmp = new int[2];
gl.glGenBuffers(2, tmp, 0);
- gd.geoToCoordBuf = tmp[0];
- gd.geoToCoordBuf1 = tmp[0];
- gd.geoToCoordBuf2 = tmp[1];
+ gd.geoToCoordBuf = tmp [0];
+ gd.geoToCoordBuf1 = tmp [0];
+ gd.geoToCoordBuf2 = tmp [1];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
int usage = morphable ? GL2ES2.GL_DYNAMIC_DRAW : GL2ES2.GL_STATIC_DRAW;
gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2);
gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage);
- }
- else
- {
+ } else {
int[] tmp = new int[1];
gl.glGenBuffers(1, tmp, 0);
- gd.geoToCoordBuf = tmp[0];
+ gd.geoToCoordBuf = tmp [0];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
int usage = morphable ? GL2ES2.GL_DYNAMIC_DRAW : GL2ES2.GL_STATIC_DRAW;
@@ -3640,8 +3317,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gd.geoToCoordBufSize = fverts.remaining();
- if (ctx.allGeometryData.size() % 500 == 0)
- {
+ if (ctx.allGeometryData.size() % 500 == 0) {
System.out.println("Coord buffer count " + ctx.allGeometryData.size());
}
@@ -3649,28 +3325,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
ctx.perFrameStats.glBufferData++;
}
- if (!ignoreVertexColors)
- {
- if (gd.geoToColorBuf == -1)
- {
- if (cfarray != null)
- {
+ if (!ignoreVertexColors) {
+ if (gd.geoToColorBuf == -1) {
+ if (cfarray != null) {
fclrs = getColorArrayBuffer(cfarray);
}
- if (fclrs != null)
- {
- if (fclrs != fverts)
- {
+ if (fclrs != null) {
+ if (fclrs != fverts) {
fclrs.position(startClrs);
int[] tmp = new int[1];
gl.glGenBuffers(1, tmp, 0);
- gd.geoToColorBuf = tmp[0];
+ gd.geoToColorBuf = tmp [0];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf);
- gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, fclrs.remaining() * Float.SIZE / 8, fclrs, GL2ES2.GL_STATIC_DRAW);
- }
- else
- {
+ gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, fclrs.remaining() * Float.SIZE / 8, fclrs,
+ GL2ES2.GL_STATIC_DRAW);
+ } else {
gd.geoToColorBuf = gd.geoToCoordBuf;
}
if (DO_OUTPUT_ERRORS)
@@ -3688,18 +3358,19 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
return gd;
}
- private static GeometryData loadAllBuffers(Jogl2es2Context ctx, GL2ES2 gl, GeometryArrayRetained geo, boolean ignoreVertexColors,
- int vertexCount, int vformat, int vdefined, FloatBuffer fverts, float[] vfcoords, DoubleBuffer dverts, double[] vdcoords,
- FloatBuffer fclrs, float[] cfarray, ByteBuffer bclrs, byte[] cbdata, FloatBuffer norms, float[] narray, int vertexAttrCount,
- int[] vertexAttrSizes, FloatBuffer[] vertexAttrBufs, float[][] vertexAttrData, int texCoordMapLength, int[] texCoordSetMap,
- int texStride, Object[] texCoords)
- {
+ private static GeometryData loadAllBuffers( Jogl2es2Context ctx, GL2ES2 gl, GeometryArrayRetained geo,
+ boolean ignoreVertexColors, int vertexCount, int vformat, int vdefined,
+ FloatBuffer fverts, float[] vfcoords, DoubleBuffer dverts,
+ double[] vdcoords, FloatBuffer fclrs, float[] cfarray, ByteBuffer bclrs,
+ byte[] cbdata, FloatBuffer norms, float[] narray, int vertexAttrCount,
+ int[] vertexAttrSizes, FloatBuffer[] vertexAttrBufs,
+ float[][] vertexAttrData, int texCoordMapLength, int[] texCoordSetMap,
+ int texStride, Object[] texCoords) {
if (VERBOSE)
System.err.println("private static GeometryData loadAllBuffers");
GeometryData gd = ctx.allGeometryData.get(geo.nativeId);
- if (gd == null)
- {
+ if (gd == null) {
gd = new GeometryData();
geo.nativeId = gd.nativeId;
ctx.allGeometryData.put(geo.nativeId, gd);
@@ -3713,41 +3384,35 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0);
boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);
- if (floatCoordDefined)
- {
- if (gd.geoToCoordBuf == -1)
- {
+ if (floatCoordDefined) {
+ if (gd.geoToCoordBuf == -1) {
// do we need to covert a float[]
- if (vfcoords != null)
- {
+ if (vfcoords != null) {
fverts = getVertexArrayBuffer(vfcoords);
}
// can it change ever? (GeometryArray.ALLOW_REF_DATA_WRITE is just my indicator of this feature)
boolean morphable = geo.source.getCapability(GeometryArray.ALLOW_REF_DATA_WRITE)
- || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
+ || geo.source.getCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
fverts.position(0);
- if (morphable)
- {
+ if (morphable) {
int[] tmp = new int[2];
gl.glGenBuffers(2, tmp, 0);
- gd.geoToCoordBuf = tmp[0];
- gd.geoToCoordBuf1 = tmp[0];
- gd.geoToCoordBuf2 = tmp[1];
+ gd.geoToCoordBuf = tmp [0];
+ gd.geoToCoordBuf1 = tmp [0];
+ gd.geoToCoordBuf2 = tmp [1];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf1);
int usage = morphable ? GL2ES2.GL_DYNAMIC_DRAW : GL2ES2.GL_STATIC_DRAW;
gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf2);
gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, (fverts.remaining() * Float.SIZE / 8), fverts, usage);
- }
- else
- {
+ } else {
int[] tmp = new int[1];
gl.glGenBuffers(1, tmp, 0);
- gd.geoToCoordBuf = tmp[0];
+ gd.geoToCoordBuf = tmp [0];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToCoordBuf);
int usage = morphable ? GL2ES2.GL_DYNAMIC_DRAW : GL2ES2.GL_STATIC_DRAW;
@@ -3758,8 +3423,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gd.geoToCoordBufSize = fverts.remaining();
- if (ctx.allGeometryData.size() % 500 == 0)
- {
+ if (ctx.allGeometryData.size() % 500 == 0) {
System.out.println("Coord buffer count " + ctx.allGeometryData.size());
}
@@ -3769,22 +3433,20 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (floatColorsDefined && !ignoreVertexColors)
- {
- if (gd.geoToColorBuf == -1)
- {
- if (cfarray != null)
- {
+ if (floatColorsDefined && !ignoreVertexColors) {
+ if (gd.geoToColorBuf == -1) {
+ if (cfarray != null) {
fclrs = getColorArrayBuffer(cfarray);
}
fclrs.position(0);
int[] tmp = new int[1];
gl.glGenBuffers(1, tmp, 0);
- gd.geoToColorBuf = tmp[0];
+ gd.geoToColorBuf = tmp [0];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToColorBuf);
- gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, fclrs.remaining() * Float.SIZE / 8, fclrs, GL2ES2.GL_STATIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, fclrs.remaining() * Float.SIZE / 8, fclrs,
+ GL2ES2.GL_STATIC_DRAW);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -3794,12 +3456,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (normalsDefined)
- {
- if (gd.geoToNormalBuf == -1)
- {
- if (narray != null)
- {
+ if (normalsDefined) {
+ if (gd.geoToNormalBuf == -1) {
+ if (narray != null) {
norms = getNormalArrayBuffer(narray);
}
@@ -3807,10 +3466,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] tmp = new int[1];
gl.glGenBuffers(1, tmp, 0);
- gd.geoToNormalBuf = tmp[0];
+ gd.geoToNormalBuf = tmp [0];
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, gd.geoToNormalBuf);
- gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, norms.remaining() * Float.SIZE / 8, norms, GL2ES2.GL_STATIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, norms.remaining() * Float.SIZE / 8, norms,
+ GL2ES2.GL_STATIC_DRAW);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -3820,35 +3480,31 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (vattrDefined)
- {
- if (vertexAttrData != null)
- {
+ if (vattrDefined) {
+ if (vertexAttrData != null) {
vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);
}
- for (int index = 0; index < vertexAttrCount; index++)
- {
- FloatBuffer vertexAttrs = vertexAttrBufs[index];
+ for (int index = 0; index < vertexAttrCount; index++) {
+ FloatBuffer vertexAttrs = vertexAttrBufs [index];
vertexAttrs.position(0);
SparseArray<Integer> bufIds = gd.geoToVertAttribBuf;
- if (bufIds == null)
- {
+ if (bufIds == null) {
bufIds = new SparseArray<Integer>();
gd.geoToVertAttribBuf = bufIds;
}
Integer bufId = bufIds.get(index);
- if (bufId == null)
- {
+ if (bufId == null) {
int[] tmp2 = new int[1];
gl.glGenBuffers(1, tmp2, 0);
- bufId = new Integer(tmp2[0]);
+ bufId = new Integer(tmp2 [0]);
bufIds.put(index, bufId);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue());
- gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, vertexAttrs.remaining() * Float.SIZE / 8, vertexAttrs, GL2ES2.GL_STATIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, vertexAttrs.remaining() * Float.SIZE / 8, vertexAttrs,
+ GL2ES2.GL_STATIC_DRAW);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -3859,42 +3515,37 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (textureDefined)
- {
+ if (textureDefined) {
// convert from float[][] to FloatBuffer[]
//WOW careful java has a hard time knowing what an Object[] contains can't check float[][]
- if (!(texCoords[0] instanceof FloatBuffer))
- {
+ if (!(texCoords [0] instanceof FloatBuffer)) {
texCoords = getTexCoordSetBuffer(texCoords);
}
boolean[] texSetsLoaded = new boolean[texCoords.length];
- for (int texUnit = 0; texUnit < texCoordMapLength; texUnit++)
- {
- int texSet = texCoordSetMap[texUnit];
- if (texSet != -1 && !texSetsLoaded[texSet])
- {
- texSetsLoaded[texSet] = true;
+ for (int texUnit = 0; texUnit < texCoordMapLength; texUnit++) {
+ int texSet = texCoordSetMap [texUnit];
+ if (texSet != -1 && !texSetsLoaded [texSet]) {
+ texSetsLoaded [texSet] = true;
// stupid interface...
- FloatBuffer buf = (FloatBuffer) texCoords[texSet];
+ FloatBuffer buf = (FloatBuffer)texCoords [texSet];
buf.position(0);
SparseArray<Integer> bufIds = gd.geoToTexCoordsBuf;
- if (bufIds == null)
- {
+ if (bufIds == null) {
bufIds = new SparseArray<Integer>();
gd.geoToTexCoordsBuf = bufIds;
}
Integer bufId = bufIds.get(texUnit);
- if (bufId == null)
- {
+ if (bufId == null) {
int[] tmp = new int[1];
gl.glGenBuffers(1, tmp, 0);
- bufId = new Integer(tmp[0]);
+ bufId = new Integer(tmp [0]);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, bufId.intValue());
- gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, buf.remaining() * Float.SIZE / 8, buf, GL2ES2.GL_STATIC_DRAW);
+ gl.glBufferData(GL2ES2.GL_ARRAY_BUFFER, buf.remaining() * Float.SIZE / 8, buf,
+ GL2ES2.GL_STATIC_DRAW);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
bufIds.put(texUnit, bufId);
@@ -3914,8 +3565,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// --Noop
@Override
- void setVertexFormat(Context ctx, GeometryArrayRetained geo, int vformat, boolean useAlpha, boolean ignoreVertexColors)
- {
+ void setVertexFormat( Context ctx, GeometryArrayRetained geo, int vformat, boolean useAlpha,
+ boolean ignoreVertexColors) {
// if (VERBOSE)
// System.err.println("JoglPipeline.setVertexFormat()");
}
@@ -3923,10 +3574,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// ---------------------------------------------------------------------
// Native method for readRaster
@Override
- void readRaster(Context ctx, int type, int xSrcOffset, int ySrcOffset, int width, int height, int hCanvas, int imageDataType,
- int imageFormat, Object imageBuffer, int depthFormat, Object depthBuffer)
- {
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
+ void readRaster(Context ctx, int type, int xSrcOffset, int ySrcOffset, int width, int height, int hCanvas,
+ int imageDataType, int imageFormat, Object imageBuffer, int depthFormat, Object depthBuffer) {
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
GL2ES2 gl = joglesctx.gl2es2();
//gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, width);
@@ -3935,86 +3585,78 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
int yAdjusted = hCanvas - height - ySrcOffset;
- if ((type & Raster.RASTER_COLOR) != 0)
- {
+ if ((type & Raster.RASTER_COLOR) != 0) {
int format = 0;
- if (imageDataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY)
- {
+ if (imageDataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
- switch (imageFormat)
- {
- case ImageComponentRetained.TYPE_BYTE_BGR:
- format = GL2ES2.GL_BGR;
- break;
- case ImageComponentRetained.TYPE_BYTE_RGB:
- format = GL2ES2.GL_RGB;
- break;
- case ImageComponentRetained.TYPE_BYTE_ABGR:
- format = GL2ES2.GL_RGBA;
- break;
- case ImageComponentRetained.TYPE_BYTE_RGBA:
- // all RGB types are stored as RGBA
- format = GL2ES2.GL_RGBA;
- break;
- case ImageComponentRetained.TYPE_BYTE_LA:
- // all LA types are stored as LA8
- format = GL2ES2.GL_LUMINANCE_ALPHA;
- break;
- case ImageComponentRetained.TYPE_BYTE_GRAY:
- case ImageComponentRetained.TYPE_USHORT_GRAY:
- case ImageComponentRetained.TYPE_INT_BGR:
- case ImageComponentRetained.TYPE_INT_RGB:
- case ImageComponentRetained.TYPE_INT_ARGB:
- default:
- assert false;
- return;
+ switch (imageFormat) {
+ case ImageComponentRetained.TYPE_BYTE_BGR:
+ format = GL2ES2.GL_BGR;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_RGB:
+ format = GL2ES2.GL_RGB;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_ABGR:
+ format = GL2ES2.GL_RGBA;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_RGBA:
+ // all RGB types are stored as RGBA
+ format = GL2ES2.GL_RGBA;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_LA:
+ // all LA types are stored as LA8
+ format = GL2ES2.GL_LUMINANCE_ALPHA;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_GRAY:
+ case ImageComponentRetained.TYPE_USHORT_GRAY:
+ case ImageComponentRetained.TYPE_INT_BGR:
+ case ImageComponentRetained.TYPE_INT_RGB:
+ case ImageComponentRetained.TYPE_INT_ARGB:
+ default:
+ assert false;
+ return;
}
gl.glReadPixels(xSrcOffset, yAdjusted, width, height, format, GL2ES2.GL_UNSIGNED_BYTE,
- ByteBuffer.wrap((byte[]) imageBuffer));
+ ByteBuffer.wrap((byte[])imageBuffer));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else if (imageDataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
- {
- switch (imageFormat)
- {
- case ImageComponentRetained.TYPE_INT_BGR:
- //PJ does this work correctly?
- format = GL2ES2.GL_RGB;
- break;
- case ImageComponentRetained.TYPE_INT_RGB:
- format = GL2ES2.GL_RGB;
- break;
- case ImageComponentRetained.TYPE_INT_ARGB:
- format = GL2ES2.GL_RGBA;
- break;
- // This method only supports 3 and 4 components formats and INT types.
- case ImageComponentRetained.TYPE_BYTE_LA:
- case ImageComponentRetained.TYPE_BYTE_GRAY:
- case ImageComponentRetained.TYPE_USHORT_GRAY:
- case ImageComponentRetained.TYPE_BYTE_BGR:
- case ImageComponentRetained.TYPE_BYTE_RGB:
- case ImageComponentRetained.TYPE_BYTE_RGBA:
- case ImageComponentRetained.TYPE_BYTE_ABGR:
- default:
- assert false;
- return;
+ } else if (imageDataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
+ switch (imageFormat) {
+ case ImageComponentRetained.TYPE_INT_BGR:
+ //PJ does this work correctly?
+ format = GL2ES2.GL_RGB;
+ break;
+ case ImageComponentRetained.TYPE_INT_RGB:
+ format = GL2ES2.GL_RGB;
+ break;
+ case ImageComponentRetained.TYPE_INT_ARGB:
+ format = GL2ES2.GL_RGBA;
+ break;
+ // This method only supports 3 and 4 components formats and INT types.
+ case ImageComponentRetained.TYPE_BYTE_LA:
+ case ImageComponentRetained.TYPE_BYTE_GRAY:
+ case ImageComponentRetained.TYPE_USHORT_GRAY:
+ case ImageComponentRetained.TYPE_BYTE_BGR:
+ case ImageComponentRetained.TYPE_BYTE_RGB:
+ case ImageComponentRetained.TYPE_BYTE_RGBA:
+ case ImageComponentRetained.TYPE_BYTE_ABGR:
+ default:
+ assert false;
+ return;
}
- gl.glReadPixels(xSrcOffset, yAdjusted, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, IntBuffer.wrap((int[]) imageBuffer));
+ gl.glReadPixels(xSrcOffset, yAdjusted, width, height, format, GL2ES2.GL_UNSIGNED_BYTE,
+ IntBuffer.wrap((int[])imageBuffer));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
+ } else {
assert false;
}
}
- if ((type & Raster.RASTER_DEPTH) != 0)
- {
+ if ((type & Raster.RASTER_DEPTH) != 0) {
throw new UnsupportedOperationException(
"To get depth you should use a shader that return depth info for gl2es2 then read from color");
/*if (depthFormat == DepthComponentRetained.DEPTH_COMPONENT_TYPE_INT)
@@ -4047,142 +3689,140 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// ShaderAttributeValue methods
@Override
- ShaderError setGLSLUniform1i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int value)
- {
+ ShaderError setGLSLUniform1i( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniform1i(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value=" + value + ")");
+ System.err.println("JoglPipeline.setGLSLUniform1i(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value=" + value + ")");
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
GL2ES2 gl = joglesctx.gl2es2();
int loc = unbox(uniformLocation);
- if (!MINIMISE_NATIVE_SHADER || joglesctx.gl_state.setGLSLUniform1i[loc] != value)
- {
+ if (!MINIMISE_NATIVE_SHADER || joglesctx.gl_state.setGLSLUniform1i [loc] != value) {
gl.glUniform1i(loc, value);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (MINIMISE_NATIVE_SHADER)
- joglesctx.gl_state.setGLSLUniform1i[loc] = value;
+ joglesctx.gl_state.setGLSLUniform1i [loc] = value;
}
return null;
}
@Override
- ShaderError setGLSLUniform1f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float value)
- {
+ ShaderError setGLSLUniform1f( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ float value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniform1f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value=" + value + ")");
+ System.err.println("JoglPipeline.setGLSLUniform1f(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value=" + value + ")");
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
GL2ES2 gl = joglesctx.gl2es2();
int loc = unbox(uniformLocation);
- if (!MINIMISE_NATIVE_SHADER || joglesctx.gl_state.setGLSLUniform1f[loc] != value)
- {
+ if (!MINIMISE_NATIVE_SHADER || joglesctx.gl_state.setGLSLUniform1f [loc] != value) {
gl.glUniform1f(loc, value);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (MINIMISE_NATIVE_SHADER)
- joglesctx.gl_state.setGLSLUniform1f[loc] = value;
+ joglesctx.gl_state.setGLSLUniform1f [loc] = value;
}
return null;
}
@Override
- ShaderError setGLSLUniform2i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int[] value)
- {
+ ShaderError setGLSLUniform2i( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int[] value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniform2i(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value[0]=" + value[0] + ")");
+ System.err.println("JoglPipeline.setGLSLUniform2i(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value[0]=" + value [0] + ")");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
- gl.glUniform2i(unbox(uniformLocation), value[0], value[1]);
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+ gl.glUniform2i(unbox(uniformLocation), value [0], value [1]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
return null;
}
@Override
- ShaderError setGLSLUniform2f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value)
- {
+ ShaderError setGLSLUniform2f( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ float[] value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniform2f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value[0]=" + value[0] + ")");
+ System.err.println("JoglPipeline.setGLSLUniform2f(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value[0]=" + value [0] + ")");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
- gl.glUniform2f(unbox(uniformLocation), value[0], value[1]);
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+ gl.glUniform2f(unbox(uniformLocation), value [0], value [1]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
return null;
}
@Override
- ShaderError setGLSLUniform3i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int[] value)
- {
+ ShaderError setGLSLUniform3i( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int[] value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniform3i(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value[0]=" + value[0] + ")");
+ System.err.println("JoglPipeline.setGLSLUniform3i(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value[0]=" + value [0] + ")");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
- gl.glUniform3i(unbox(uniformLocation), value[0], value[1], value[2]);
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+ gl.glUniform3i(unbox(uniformLocation), value [0], value [1], value [2]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
return null;
}
@Override
- ShaderError setGLSLUniform3f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value)
- {
+ ShaderError setGLSLUniform3f( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ float[] value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniform3f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value[0]=" + value[0] + ")");
+ System.err.println("JoglPipeline.setGLSLUniform3f(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value[0]=" + value [0] + ")");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
- gl.glUniform3f(unbox(uniformLocation), value[0], value[1], value[2]);
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+ gl.glUniform3f(unbox(uniformLocation), value [0], value [1], value [2]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
return null;
}
@Override
- ShaderError setGLSLUniform4i(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int[] value)
- {
+ ShaderError setGLSLUniform4i( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int[] value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniform4i(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value[0]=" + value[0] + ")");
+ System.err.println("JoglPipeline.setGLSLUniform4i(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value[0]=" + value [0] + ")");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
- gl.glUniform4i(unbox(uniformLocation), value[0], value[1], value[2], value[3]);
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+ gl.glUniform4i(unbox(uniformLocation), value [0], value [1], value [2], value [3]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
return null;
}
@Override
- ShaderError setGLSLUniform4f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value)
- {
+ ShaderError setGLSLUniform4f( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ float[] value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniform4f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value[0]=" + value[0] + ")");
+ System.err.println("JoglPipeline.setGLSLUniform4f(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value[0]=" + value [0] + ")");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
- gl.glUniform4f(unbox(uniformLocation), value[0], value[1], value[2], value[3]);
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+ gl.glUniform4f(unbox(uniformLocation), value [0], value [1], value [2], value [3]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
return null;
}
@Override
- ShaderError setGLSLUniformMatrix3f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value)
- {
+ ShaderError setGLSLUniformMatrix3f( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ float[] value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniformMatrix3f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value[0]=" + value[0] + ")");
+ System.err.println("JoglPipeline.setGLSLUniformMatrix3f(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value[0]=" + value [0] + ")");
// Load attribute
// transpose is true : each matrix is supplied in row major order
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
- gl.glUniformMatrix3fv(unbox(uniformLocation), 1, false, ((Jogl2es2Context) ctx).matrixUtil.toFB3(value));
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+ gl.glUniformMatrix3fv(unbox(uniformLocation), 1, false, ((Jogl2es2Context)ctx).matrixUtil.toFB3(value));
// gl.glUniformMatrix3fv(unbox(uniformLocation), 1, true, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4190,16 +3830,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniformMatrix4f(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, float[] value)
- {
+ ShaderError setGLSLUniformMatrix4f( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ float[] value) {
if (VERBOSE)
- System.err.println("JoglPipeline.setGLSLUniformMatrix4f(shaderProgramId = " + unbox(shaderProgramId) + ",uniformLocation="
- + unbox(uniformLocation) + ",value[0]=" + value[0] + ")");
+ System.err.println("JoglPipeline.setGLSLUniformMatrix4f(shaderProgramId = " + unbox(shaderProgramId)
+ + ",uniformLocation=" + unbox(uniformLocation) + ",value[0]=" + value [0] + ")");
// Load attribute
// transpose is true : each matrix is supplied in row major order
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
- gl.glUniformMatrix4fv(unbox(uniformLocation), 1, false, ((Jogl2es2Context) ctx).matrixUtil.toFB4(value));
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+ gl.glUniformMatrix4fv(unbox(uniformLocation), 1, false, ((Jogl2es2Context)ctx).matrixUtil.toFB4(value));
// gl.glUniformMatrix4fv(unbox(uniformLocation), 1, true, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4209,13 +3849,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// ShaderAttributeArray methods
@Override
- ShaderError setGLSLUniform1iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- int[] value)
- {
+ ShaderError setGLSLUniform1iArray( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, int[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniform1iArray()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniform1iv(unbox(uniformLocation), numElements, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4223,13 +3862,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniform1fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- float[] value)
- {
+ ShaderError setGLSLUniform1fArray( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, float[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniform1fArray()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniform1fv(unbox(uniformLocation), numElements, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4237,13 +3875,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniform2iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- int[] value)
- {
+ ShaderError setGLSLUniform2iArray( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, int[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniform2iArray()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniform2iv(unbox(uniformLocation), numElements, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4251,13 +3888,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniform2fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- float[] value)
- {
+ ShaderError setGLSLUniform2fArray( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, float[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniform2fArray()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniform2fv(unbox(uniformLocation), numElements, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4265,13 +3901,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniform3iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- int[] value)
- {
+ ShaderError setGLSLUniform3iArray( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, int[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniform3iArray()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniform3iv(unbox(uniformLocation), numElements, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4279,13 +3914,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniform3fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- float[] value)
- {
+ ShaderError setGLSLUniform3fArray( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, float[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniform3fArray()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniform3fv(unbox(uniformLocation), numElements, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4293,13 +3927,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniform4iArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- int[] value)
- {
+ ShaderError setGLSLUniform4iArray( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, int[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniform4iArray()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniform4iv(unbox(uniformLocation), numElements, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4307,13 +3940,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniform4fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- float[] value)
- {
+ ShaderError setGLSLUniform4fArray( Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, float[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniform4fArray()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniform4fv(unbox(uniformLocation), numElements, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4321,15 +3953,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniformMatrix3fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- float[] value)
- {
+ ShaderError setGLSLUniformMatrix3fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, float[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniformMatrix3fArray()");
// Load attribute
// transpose is true : each matrix is supplied in row major order
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniformMatrix3fv(unbox(uniformLocation), numElements, true, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4337,15 +3968,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError setGLSLUniformMatrix4fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation, int numElements,
- float[] value)
- {
+ ShaderError setGLSLUniformMatrix4fArray(Context ctx, ShaderProgramId shaderProgramId, ShaderAttrLoc uniformLocation,
+ int numElements, float[] value) {
if (VERBOSE)
System.err.println("JoglPipeline.setGLSLUniformMatrix4fArray()");
// Load attribute
// transpose is true : each matrix is supplied in row major order
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glUniformMatrix4fv(unbox(uniformLocation), numElements, true, value, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4354,46 +3984,40 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// interfaces for shader compilation, etc.
@Override
- ShaderError createGLSLShader(Context ctx, int shaderType, ShaderId[] shaderId)
- {
+ ShaderError createGLSLShader(Context ctx, int shaderType, ShaderId[] shaderId) {
if (VERBOSE)
System.err.println("JoglPipeline.createGLSLShader()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.createGLSLShader++;
+ ((Jogl2es2Context)ctx).perFrameStats.createGLSLShader++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
int shaderHandle = 0;
- if (shaderType == Shader.SHADER_TYPE_VERTEX)
- {
+ if (shaderType == Shader.SHADER_TYPE_VERTEX) {
shaderHandle = gl.glCreateShader(GL2ES2.GL_VERTEX_SHADER);
- }
- else if (shaderType == Shader.SHADER_TYPE_FRAGMENT)
- {
+ } else if (shaderType == Shader.SHADER_TYPE_FRAGMENT) {
shaderHandle = gl.glCreateShader(GL2ES2.GL_FRAGMENT_SHADER);
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- if (shaderHandle == 0)
- {
+ if (shaderHandle == 0) {
return new ShaderError(ShaderError.COMPILE_ERROR, "Unable to create native shader object");
}
- shaderId[0] = new JoglShaderObject(shaderHandle);
+ shaderId [0] = new JoglShaderObject(shaderHandle);
return null;
}
@Override
- ShaderError destroyGLSLShader(Context ctx, ShaderId shaderId)
- {
+ ShaderError destroyGLSLShader(Context ctx, ShaderId shaderId) {
if (VERBOSE)
System.err.println("JoglPipeline.destroyGLSLShader()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.destroyGLSLShader++;
+ ((Jogl2es2Context)ctx).perFrameStats.destroyGLSLShader++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glDeleteShader(unbox(shaderId));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -4401,28 +4025,25 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError compileGLSLShader(Context ctx, ShaderId shaderId, String program)
- {
+ ShaderError compileGLSLShader(Context ctx, ShaderId shaderId, String program) {
if (VERBOSE)
System.err.println("JoglPipeline.compileGLSLShader()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.compileGLSLShader++;
+ ((Jogl2es2Context)ctx).perFrameStats.compileGLSLShader++;
int id = unbox(shaderId);
- if (id == 0)
- {
+ if (id == 0) {
throw new AssertionError("shaderId == 0");
}
- if (program == null)
- {
+ if (program == null) {
throw new AssertionError("shader program string is null");
}
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
- gl.glShaderSource(id, 1, new String[] { program }, null, 0);
+ gl.glShaderSource(id, 1, new String[] {program}, null, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
gl.glCompileShader(id);
@@ -4430,8 +4051,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
int[] status = new int[1];
gl.glGetShaderiv(id, GL2ES2.GL_COMPILE_STATUS, status, 0);
- if (status[0] == 0)
- {
+ if (status [0] == 0) {
String detailMsg = getShaderInfoLog(gl, id);
ShaderError res = new ShaderError(ShaderError.COMPILE_ERROR, "GLSL shader compile error");
res.setDetailMessage(detailMsg);
@@ -4441,62 +4061,57 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError createGLSLShaderProgram(Context ctx, ShaderProgramId[] shaderProgramId)
- {
+ ShaderError createGLSLShaderProgram(Context ctx, ShaderProgramId[] shaderProgramId) {
if (VERBOSE)
System.err.println("JoglPipeline.createGLSLShaderProgram()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.createGLSLShaderProgram++;
+ ((Jogl2es2Context)ctx).perFrameStats.createGLSLShaderProgram++;
int shaderProgramHandle = gl.glCreateProgram();
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- if (shaderProgramHandle == 0)
- {
+ if (shaderProgramHandle == 0) {
return new ShaderError(ShaderError.LINK_ERROR, "Unable to create native shader program object");
}
- shaderProgramId[0] = new JoglShaderObject(shaderProgramHandle);
+ shaderProgramId [0] = new JoglShaderObject(shaderProgramHandle);
return null;
}
@Override
- ShaderError destroyGLSLShaderProgram(Context ctx, ShaderProgramId shaderProgramId)
- {
+ ShaderError destroyGLSLShaderProgram(Context ctx, ShaderProgramId shaderProgramId) {
if (VERBOSE)
System.err.println("JoglPipeline.destroyGLSLShaderProgram()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.destroyGLSLShaderProgram++;
+ ((Jogl2es2Context)ctx).perFrameStats.destroyGLSLShaderProgram++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glDeleteShader(unbox(shaderProgramId));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
// just dump data
- ((Jogl2es2Context) ctx).allProgramData.remove(unbox(shaderProgramId));
+ ((Jogl2es2Context)ctx).allProgramData.remove(unbox(shaderProgramId));
return null;
}
@Override
- ShaderError linkGLSLShaderProgram(Context ctx, ShaderProgramId shaderProgramId, ShaderId[] shaderIds)
- {
+ ShaderError linkGLSLShaderProgram(Context ctx, ShaderProgramId shaderProgramId, ShaderId[] shaderIds) {
if (VERBOSE)
System.err.println("JoglPipeline.linkGLSLShaderProgram()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.linkGLSLShaderProgram++;
+ ((Jogl2es2Context)ctx).perFrameStats.linkGLSLShaderProgram++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
int id = unbox(shaderProgramId);
- for (int i = 0; i < shaderIds.length; i++)
- {
- gl.glAttachShader(id, unbox(shaderIds[i]));
+ for (int i = 0; i < shaderIds.length; i++) {
+ gl.glAttachShader(id, unbox(shaderIds [i]));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
}
@@ -4505,8 +4120,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
int[] status = new int[1];
gl.glGetProgramiv(id, GL2ES2.GL_LINK_STATUS, status, 0);
- if (status[0] == 0)
- {
+ if (status [0] == 0) {
String detailMsg = getProgramInfoLog(gl, id);
ShaderError res = new ShaderError(ShaderError.LINK_ERROR, "GLSL shader program link error");
res.setDetailMessage(detailMsg);
@@ -4516,29 +4130,26 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- ShaderError bindGLSLVertexAttrName(Context ctx, ShaderProgramId shaderProgramId, String attrName, int attrIndex)
- {
+ ShaderError bindGLSLVertexAttrName(Context ctx, ShaderProgramId shaderProgramId, String attrName, int attrIndex) {
if (VERBOSE)
System.err.println("JoglPipeline.bindGLSLVertexAttrName()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.bindGLSLVertexAttrName++;
+ ((Jogl2es2Context)ctx).perFrameStats.bindGLSLVertexAttrName++;
// GL2ES2 gl = context(ctx).getGL().getGL2ES2();
// gl.glBindAttribLocation(unbox(shaderProgramId), attrIndex + VirtualUniverse.mc.glslVertexAttrOffset, attrName);
// record this for later, we'll get real locations in the locationData setup
int progId = unbox(shaderProgramId);
- Jogl2es2Context joglesContext = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesContext = (Jogl2es2Context)ctx;
ProgramData pd = joglesContext.allProgramData.get(progId);
- if (pd == null)
- {
+ if (pd == null) {
pd = new ProgramData();
joglesContext.allProgramData.put(progId, pd);
}
HashMap<String, Integer> attToIndex = pd.progToGenVertAttNameToGenVertAttIndex;
- if (attToIndex == null)
- {
+ if (attToIndex == null) {
attToIndex = new HashMap<String, Integer>();
pd.progToGenVertAttNameToGenVertAttIndex = attToIndex;
}
@@ -4549,22 +4160,20 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void lookupGLSLShaderAttrNames(Context ctx, ShaderProgramId shaderProgramId, int numAttrNames, String[] attrNames,
- ShaderAttrLoc[] locArr, int[] typeArr, int[] sizeArr, boolean[] isArrayArr)
- {
+ void lookupGLSLShaderAttrNames( Context ctx, ShaderProgramId shaderProgramId, int numAttrNames, String[] attrNames,
+ ShaderAttrLoc[] locArr, int[] typeArr, int[] sizeArr, boolean[] isArrayArr) {
if (VERBOSE)
System.err.println("JoglPipeline.lookupGLSLShaderAttrNames()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.lookupGLSLShaderAttrNames++;
+ ((Jogl2es2Context)ctx).perFrameStats.lookupGLSLShaderAttrNames++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
// set the loc, type, and size arrays to out-of-bound values
- for (int i = 0; i < attrNames.length; i++)
- {
- locArr[i] = null;
- typeArr[i] = -1;
- sizeArr[i] = -1;
+ for (int i = 0; i < attrNames.length; i++) {
+ locArr [i] = null;
+ typeArr [i] = -1;
+ sizeArr [i] = -1;
}
// Loop through the list of active uniform variables, one at a
@@ -4582,60 +4191,49 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] tmp3 = new int[1];
gl.glGetProgramiv(id, GL2ES2.GL_ACTIVE_UNIFORMS, tmp, 0);
- int numActiveUniforms = tmp[0];
+ int numActiveUniforms = tmp [0];
gl.glGetProgramiv(id, GL2ES2.GL_ACTIVE_UNIFORM_MAX_LENGTH, tmp, 0);
- int maxStrLen = tmp[0];
+ int maxStrLen = tmp [0];
byte[] nameBuf = new byte[maxStrLen];
- for (int i = 0; i < numActiveUniforms; i++)
- {
+ for (int i = 0; i < numActiveUniforms; i++) {
gl.glGetActiveUniform(id, i, maxStrLen, tmp3, 0, tmp, 0, tmp2, 0, nameBuf, 0);
- int size = tmp[0];
- int type = tmp2[0];
+ int size = tmp [0];
+ int type = tmp2 [0];
String name = null;
- try
- {
- name = new String(nameBuf, 0, tmp3[0], "US-ASCII");
- }
- catch (UnsupportedEncodingException e)
- {
+ try {
+ name = new String(nameBuf, 0, tmp3 [0], "US-ASCII");
+ } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
// Issue 247 - we need to workaround an ATI bug where they erroneously
// report individual elements of arrays rather than the array itself
- if (name.length() >= 3 && name.endsWith("]"))
- {
- if (name.endsWith("[0]"))
- {
+ if (name.length() >= 3 && name.endsWith("]")) {
+ if (name.endsWith("[0]")) {
name = name.substring(0, name.length() - 3);
- }
- else
- {
+ } else {
// Ignore this name
continue;
}
}
// Now try to find the name
- for (int j = 0; j < numAttrNames; j++)
- {
- if (name.equals(attrNames[j]))
- {
- sizeArr[j] = size;
- isArrayArr[j] = (size > 1);
- typeArr[j] = glslToJ3dType(type);
+ for (int j = 0; j < numAttrNames; j++) {
+ if (name.equals(attrNames [j])) {
+ sizeArr [j] = size;
+ isArrayArr [j] = (size > 1);
+ typeArr [j] = glslToJ3dType(type);
break;
}
}
}
// Now lookup the location of each name in the attrNames array
- for (int i = 0; i < numAttrNames; i++)
- {
+ for (int i = 0; i < numAttrNames; i++) {
// Get uniform attribute location
- int loc = gl.glGetUniformLocation(id, attrNames[i]);
- locArr[i] = new JoglShaderObject(loc);
+ int loc = gl.glGetUniformLocation(id, attrNames [i]);
+ locArr [i] = new JoglShaderObject(loc);
}
if (DO_OUTPUT_ERRORS)
@@ -4647,47 +4245,43 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
private boolean USE_NULL_SHADER_WARNING_GIVEN = false;
@Override
- ShaderError useGLSLShaderProgram(Context ctx, ShaderProgramId inShaderProgramId)
- {
+ ShaderError useGLSLShaderProgram(Context ctx, ShaderProgramId inShaderProgramId) {
int shaderProgramId = unbox(inShaderProgramId);
if (VERBOSE)
System.err.println("JoglPipeline.useGLSLShaderProgram(shaderProgramId=" + shaderProgramId + ")");
- Jogl2es2Context joglesContext = (Jogl2es2Context) ctx;
- if (OUTPUT_PER_FRAME_STATS)
- {
- if (joglesContext.gl_state.currentProgramId == shaderProgramId)
- {
- joglesContext.perFrameStats.redundantUseProgram++;
- }
- else
- {
- joglesContext.perFrameStats.useGLSLShaderProgram++;
- joglesContext.perFrameStats.usedPrograms.add(inShaderProgramId);
+ Jogl2es2Context joglesContext = (Jogl2es2Context)ctx;
+ //shadow passes uses depth only shader
+ if (!useShadowShaderOverride) {
+ if (OUTPUT_PER_FRAME_STATS) {
+ if (joglesContext.gl_state.currentProgramId == shaderProgramId) {
+ joglesContext.perFrameStats.redundantUseProgram++;
+ } else {
+ joglesContext.perFrameStats.useGLSLShaderProgram++;
+ joglesContext.perFrameStats.usedPrograms.add(inShaderProgramId);
+ }
}
- }
- if (!MINIMISE_NATIVE_SHADER || joglesContext.gl_state.currentProgramId != shaderProgramId)
- {
- if (shaderProgramId == -1)
- {
- if (!USE_NULL_SHADER_WARNING_GIVEN)
- System.err.println("Null shader passed for use");
- USE_NULL_SHADER_WARNING_GIVEN = true;
- }
+ if (!MINIMISE_NATIVE_SHADER || joglesContext.gl_state.currentProgramId != shaderProgramId) {
+ if (shaderProgramId == -1) {
+ if (!USE_NULL_SHADER_WARNING_GIVEN)
+ System.err.println("Null shader passed for use");
+ USE_NULL_SHADER_WARNING_GIVEN = true;
+ }
- GL2ES2 gl = joglesContext.gl2es2();
+ GL2ES2 gl = joglesContext.gl2es2();
- gl.glUseProgram(shaderProgramId);
- if (DO_OUTPUT_ERRORS)
- outputErrors(ctx);
+ gl.glUseProgram(shaderProgramId);
+ if (DO_OUTPUT_ERRORS)
+ outputErrors(ctx);
- joglesContext.setShaderProgram((JoglShaderObject) inShaderProgramId);
- loadLocs(joglesContext, gl);
+ joglesContext.setShaderProgram((JoglShaderObject)inShaderProgramId);
+ loadLocs(joglesContext, gl);
- if (MINIMISE_NATIVE_SHADER)
- joglesContext.gl_state.currentProgramId = shaderProgramId;
+ if (MINIMISE_NATIVE_SHADER)
+ joglesContext.gl_state.currentProgramId = shaderProgramId;
+ }
}
return null;
}
@@ -4695,119 +4289,104 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// ----------------------------------------------------------------------
// Helper methods for above shader routines
//
- private static int unbox(ShaderAttrLoc loc)
- {
+ private static int unbox(ShaderAttrLoc loc) {
if (loc == null)
return -1;//0 is a valid location
- return ((JoglShaderObject) loc).getValue();
+ return ((JoglShaderObject)loc).getValue();
}
- private static int unbox(ShaderProgramId id)
- {
+ private static int unbox(ShaderProgramId id) {
if (id == null)
return 0;
- return ((JoglShaderObject) id).getValue();
+ return ((JoglShaderObject)id).getValue();
}
- private static int unbox(ShaderId id)
- {
+ private static int unbox(ShaderId id) {
if (id == null)
return 0;
- return ((JoglShaderObject) id).getValue();
+ return ((JoglShaderObject)id).getValue();
}
- private static String getShaderInfoLog(GL2ES2 gl, int id)
- {
+ private static String getShaderInfoLog(GL2ES2 gl, int id) {
int[] infoLogLength = new int[1];
gl.glGetShaderiv(id, GL2ES2.GL_INFO_LOG_LENGTH, infoLogLength, 0);
- if (infoLogLength[0] > 0)
- {
- byte[] storage = new byte[infoLogLength[0]];
+ if (infoLogLength [0] > 0) {
+ byte[] storage = new byte[infoLogLength [0]];
int[] len = new int[1];
- gl.glGetShaderInfoLog(id, infoLogLength[0], len, 0, storage, 0);
- try
- {
- return new String(storage, 0, len[0], "US-ASCII");
- }
- catch (UnsupportedEncodingException e)
- {
+ gl.glGetShaderInfoLog(id, infoLogLength [0], len, 0, storage, 0);
+ try {
+ return new String(storage, 0, len [0], "US-ASCII");
+ } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
return null;
}
- private static String getProgramInfoLog(GL2ES2 gl, int id)
- {
+ private static String getProgramInfoLog(GL2ES2 gl, int id) {
int[] infoLogLength = new int[1];
gl.glGetProgramiv(id, GL2ES2.GL_INFO_LOG_LENGTH, infoLogLength, 0);
- if (infoLogLength[0] > 0)
- {
- byte[] storage = new byte[infoLogLength[0]];
+ if (infoLogLength [0] > 0) {
+ byte[] storage = new byte[infoLogLength [0]];
int[] len = new int[1];
- gl.glGetProgramInfoLog(id, infoLogLength[0], len, 0, storage, 0);
- try
- {
- return new String(storage, 0, len[0], "US-ASCII");
- }
- catch (UnsupportedEncodingException e)
- {
+ gl.glGetProgramInfoLog(id, infoLogLength [0], len, 0, storage, 0);
+ try {
+ return new String(storage, 0, len [0], "US-ASCII");
+ } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
return null;
}
- private static int glslToJ3dType(int type)
- {
- switch (type)
- {
- case GL2ES2.GL_BOOL:
- case GL2ES2.GL_INT:
- case GL2ES2.GL_SAMPLER_2D:
- case GL2ES2.GL_SAMPLER_3D:
- case GL2ES2.GL_SAMPLER_CUBE:
- return ShaderAttributeObjectRetained.TYPE_INTEGER;
+ private static int glslToJ3dType(int type) {
+ switch (type) {
+ case GL2ES2.GL_BOOL:
+ case GL2ES2.GL_INT:
+ case GL2ES2.GL_SAMPLER_2D:
+ case GL2ES2.GL_SAMPLER_3D:
+ case GL2ES2.GL_SAMPLER_CUBE:
+ return ShaderAttributeObjectRetained.TYPE_INTEGER;
- case GL2ES2.GL_FLOAT:
- return ShaderAttributeObjectRetained.TYPE_FLOAT;
+ case GL2ES2.GL_FLOAT:
+ return ShaderAttributeObjectRetained.TYPE_FLOAT;
- case GL2ES2.GL_INT_VEC2:
- case GL2ES2.GL_BOOL_VEC2:
- return ShaderAttributeObjectRetained.TYPE_TUPLE2I;
+ case GL2ES2.GL_INT_VEC2:
+ case GL2ES2.GL_BOOL_VEC2:
+ return ShaderAttributeObjectRetained.TYPE_TUPLE2I;
- case GL2ES2.GL_FLOAT_VEC2:
- return ShaderAttributeObjectRetained.TYPE_TUPLE2F;
+ case GL2ES2.GL_FLOAT_VEC2:
+ return ShaderAttributeObjectRetained.TYPE_TUPLE2F;
- case GL2ES2.GL_INT_VEC3:
- case GL2ES2.GL_BOOL_VEC3:
- return ShaderAttributeObjectRetained.TYPE_TUPLE3I;
+ case GL2ES2.GL_INT_VEC3:
+ case GL2ES2.GL_BOOL_VEC3:
+ return ShaderAttributeObjectRetained.TYPE_TUPLE3I;
- case GL2ES2.GL_FLOAT_VEC3:
- return ShaderAttributeObjectRetained.TYPE_TUPLE3F;
+ case GL2ES2.GL_FLOAT_VEC3:
+ return ShaderAttributeObjectRetained.TYPE_TUPLE3F;
- case GL2ES2.GL_INT_VEC4:
- case GL2ES2.GL_BOOL_VEC4:
- return ShaderAttributeObjectRetained.TYPE_TUPLE4I;
+ case GL2ES2.GL_INT_VEC4:
+ case GL2ES2.GL_BOOL_VEC4:
+ return ShaderAttributeObjectRetained.TYPE_TUPLE4I;
- case GL2ES2.GL_FLOAT_VEC4:
- return ShaderAttributeObjectRetained.TYPE_TUPLE4F;
+ case GL2ES2.GL_FLOAT_VEC4:
+ return ShaderAttributeObjectRetained.TYPE_TUPLE4F;
- // case GL2ES2.GL_FLOAT_MAT2:
+ // case GL2ES2.GL_FLOAT_MAT2:
- case GL2ES2.GL_FLOAT_MAT3:
- return ShaderAttributeObjectRetained.TYPE_MATRIX3F;
+ case GL2ES2.GL_FLOAT_MAT3:
+ return ShaderAttributeObjectRetained.TYPE_MATRIX3F;
- case GL2ES2.GL_FLOAT_MAT4:
- return ShaderAttributeObjectRetained.TYPE_MATRIX4F;
+ case GL2ES2.GL_FLOAT_MAT4:
+ return ShaderAttributeObjectRetained.TYPE_MATRIX4F;
- // Java 3D does not support the following sampler types:
- //
- // case GL2ES2.GL_SAMPLER_1D_ARB:
- // case GL2ES2.GL_SAMPLER_1D_SHADOW_ARB:
- // case GL2ES2.GL_SAMPLER_2D_SHADOW_ARB:
- // case GL2ES2.GL_SAMPLER_2D_RECT_ARB:
- // case GL2ES2.GL_SAMPLER_2D_RECT_SHADOW_ARB:
+ // Java 3D does not support the following sampler types:
+ //
+ // case GL2ES2.GL_SAMPLER_1D_ARB:
+ // case GL2ES2.GL_SAMPLER_1D_SHADOW_ARB:
+ // case GL2ES2.GL_SAMPLER_2D_SHADOW_ARB:
+ // case GL2ES2.GL_SAMPLER_2D_RECT_ARB:
+ // case GL2ES2.GL_SAMPLER_2D_RECT_SHADOW_ARB:
}
return -1;
@@ -4821,50 +4400,54 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// DirectionalLightRetained methods
//
@Override
- void updateDirectionalLight(Context ctx, int lightSlot, float red, float green, float blue, float dirx, float diry, float dirz)
- {
+ void updateDirectionalLight(Context ctx, int lightSlot, float red, float green, float blue, float dirx, float diry,
+ float dirz, int shadowMapSamplerId, double[] projMatrix) {
if (VERBOSE)
- System.err.println("JoglPipeline.updateDirectionalLight() " + lightSlot + " " + red + " " + green + " " + blue + " " + dirx
- + " " + diry + " " + dirz);
+ System.err.println("JoglPipeline.updateDirectionalLight() " + lightSlot + " " + red + " " + green + " "
+ + blue + " " + dirx + " " + diry + " " + dirz);
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateDirectionalLight++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateDirectionalLight++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
// note the current state of MV MUST be used by the lights when setting position!
// https://www.opengl.org/discussion_boards/showthread.php/168706-Light-Position-in-eye-s-cordinate
- // note can't use the modelview as it's calced late
+ // note can't use the modelview as it's calced late
//TODO:? possibly directional should only take the view mat, but surely I'd get a blank model??
- Vector4f lightPos = joglesctx.matrixUtil.transform(joglesctx.currentModelMat, joglesctx.currentViewMat, -dirx, -diry, -dirz, 0f);
-
- if (joglesctx.glLightSource[lightSlot] == null)
- {
- joglesctx.glLightSource[lightSlot] = new glLightSource();
- joglesctx.gl_state.glLightSource[lightSlot] = null;
- }
-
- joglesctx.glLightSource[lightSlot].diffuse.x = red;
- joglesctx.glLightSource[lightSlot].diffuse.y = green;
- joglesctx.glLightSource[lightSlot].diffuse.z = blue;
- joglesctx.glLightSource[lightSlot].diffuse.w = 1.0f;
- joglesctx.glLightSource[lightSlot].specular.x = red;
- joglesctx.glLightSource[lightSlot].specular.y = green;
- joglesctx.glLightSource[lightSlot].specular.z = blue;
- joglesctx.glLightSource[lightSlot].specular.w = 1.0f;
- joglesctx.glLightSource[lightSlot].position.x = lightPos.x;
- joglesctx.glLightSource[lightSlot].position.y = lightPos.y;
- joglesctx.glLightSource[lightSlot].position.z = lightPos.z;
- joglesctx.glLightSource[lightSlot].position.w = 0.0f;// 0 means directional light
+ Vector4f lightPos = joglesctx.matrixUtil.transform(joglesctx.currentModelMat, joglesctx.currentViewMat, -dirx,
+ -diry, -dirz, 0f);
+
+ if (joglesctx.glLightSource [lightSlot] == null) {
+ joglesctx.glLightSource [lightSlot] = new glLightSource();
+ joglesctx.gl_state.glLightSource [lightSlot] = null;
+ }
+
+ joglesctx.glLightSource [lightSlot].diffuse.x = red;
+ joglesctx.glLightSource [lightSlot].diffuse.y = green;
+ joglesctx.glLightSource [lightSlot].diffuse.z = blue;
+ joglesctx.glLightSource [lightSlot].diffuse.w = 1.0f;
+ joglesctx.glLightSource [lightSlot].specular.x = red;
+ joglesctx.glLightSource [lightSlot].specular.y = green;
+ joglesctx.glLightSource [lightSlot].specular.z = blue;
+ joglesctx.glLightSource [lightSlot].specular.w = 1.0f;
+ joglesctx.glLightSource [lightSlot].position.x = lightPos.x;
+ joglesctx.glLightSource [lightSlot].position.y = lightPos.y;
+ joglesctx.glLightSource [lightSlot].position.z = lightPos.z;
+ joglesctx.glLightSource [lightSlot].position.w = 0.0f;// 0 means directional light
//joglesctx.glLightSource[lightSlot].ambient = black;// odd
// joglesctx.glLightSource[lightSlot].GL_POSITION = 1.0f; // what is this?
- joglesctx.glLightSource[lightSlot].constantAttenuation = 1.0f;
- joglesctx.glLightSource[lightSlot].linearAttenuation = 0.0f;
- joglesctx.glLightSource[lightSlot].quadraticAttenuation = 0.0f;
- joglesctx.glLightSource[lightSlot].spotExponent = 0.0f;
- joglesctx.glLightSource[lightSlot].spotCutoff = 180.0f;
+ joglesctx.glLightSource [lightSlot].constantAttenuation = 1.0f;
+ joglesctx.glLightSource [lightSlot].linearAttenuation = 0.0f;
+ joglesctx.glLightSource [lightSlot].quadraticAttenuation = 0.0f;
+ joglesctx.glLightSource [lightSlot].spotExponent = 0.0f;
+ joglesctx.glLightSource [lightSlot].spotCutoff = 180.0f;
+ joglesctx.glLightSource [lightSlot].shadowMapSamplerId = shadowMapSamplerId;
+ if( shadowMapSamplerId != -1) {
+ joglesctx.glLightSource [lightSlot].projMatrix.set(projMatrix);
+ }
}
// ---------------------------------------------------------------------
@@ -4873,46 +4456,49 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// PointLightRetained methods
//
@Override
- void updatePointLight(Context ctx, int lightSlot, float red, float green, float blue, float attenx, float atteny, float attenz,
- float posx, float posy, float posz)
- {
+ void updatePointLight( Context ctx, int lightSlot, float red, float green, float blue, float attenx, float atteny,
+ float attenz, float posx, float posy, float posz, int shadowMapSamplerId, double[] projMatrix) {
if (VERBOSE)
System.err.println("JoglPipeline.updatePointLight()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updatePointLight++;
+ ((Jogl2es2Context)ctx).perFrameStats.updatePointLight++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
// note the current state of MV MUST be used by the lights when setting position!
// https://www.opengl.org/discussion_boards/showthread.php/168706-Light-Position-in-eye-s-cordinate
// note can't use the modelview as it's calced late
- Vector4f lightPos = joglesctx.matrixUtil.transform(joglesctx.currentModelMat, joglesctx.currentViewMat, posx, posy, posz, 1.0f);
-
- if (joglesctx.glLightSource[lightSlot] == null)
- {
- joglesctx.glLightSource[lightSlot] = new glLightSource();
- joglesctx.gl_state.glLightSource[lightSlot] = null;
- }
-
- joglesctx.glLightSource[lightSlot].diffuse.x = red;
- joglesctx.glLightSource[lightSlot].diffuse.y = green;
- joglesctx.glLightSource[lightSlot].diffuse.z = blue;
- joglesctx.glLightSource[lightSlot].diffuse.w = 1.0f;
- joglesctx.glLightSource[lightSlot].specular.x = red;
- joglesctx.glLightSource[lightSlot].specular.y = green;
- joglesctx.glLightSource[lightSlot].specular.z = blue;
- joglesctx.glLightSource[lightSlot].specular.w = 1.0f;
- joglesctx.glLightSource[lightSlot].position.x = lightPos.x;
- joglesctx.glLightSource[lightSlot].position.y = lightPos.y;
- joglesctx.glLightSource[lightSlot].position.z = lightPos.z;
- joglesctx.glLightSource[lightSlot].position.w = 1.0f;// 1 mean pos not dir
+ Vector4f lightPos = joglesctx.matrixUtil.transform(joglesctx.currentModelMat, joglesctx.currentViewMat, posx,
+ posy, posz, 1.0f);
+
+ if (joglesctx.glLightSource [lightSlot] == null) {
+ joglesctx.glLightSource [lightSlot] = new glLightSource();
+ joglesctx.gl_state.glLightSource [lightSlot] = null;
+ }
+
+ joglesctx.glLightSource [lightSlot].diffuse.x = red;
+ joglesctx.glLightSource [lightSlot].diffuse.y = green;
+ joglesctx.glLightSource [lightSlot].diffuse.z = blue;
+ joglesctx.glLightSource [lightSlot].diffuse.w = 1.0f;
+ joglesctx.glLightSource [lightSlot].specular.x = red;
+ joglesctx.glLightSource [lightSlot].specular.y = green;
+ joglesctx.glLightSource [lightSlot].specular.z = blue;
+ joglesctx.glLightSource [lightSlot].specular.w = 1.0f;
+ joglesctx.glLightSource [lightSlot].position.x = lightPos.x;
+ joglesctx.glLightSource [lightSlot].position.y = lightPos.y;
+ joglesctx.glLightSource [lightSlot].position.z = lightPos.z;
+ joglesctx.glLightSource [lightSlot].position.w = 1.0f;// 1 mean pos not dir
//joglesctx.pointLight[lightSlot].ambient = black;// odd
- joglesctx.glLightSource[lightSlot].constantAttenuation = attenx;
- joglesctx.glLightSource[lightSlot].linearAttenuation = atteny;
- joglesctx.glLightSource[lightSlot].quadraticAttenuation = attenz;
- joglesctx.glLightSource[lightSlot].spotExponent = 0.0f;
- joglesctx.glLightSource[lightSlot].spotCutoff = 180.0f;
+ joglesctx.glLightSource [lightSlot].constantAttenuation = attenx;
+ joglesctx.glLightSource [lightSlot].linearAttenuation = atteny;
+ joglesctx.glLightSource [lightSlot].quadraticAttenuation = attenz;
+ joglesctx.glLightSource [lightSlot].spotExponent = 0.0f;
+ joglesctx.glLightSource [lightSlot].spotCutoff = 180.0f;
+ joglesctx.glLightSource [lightSlot].shadowMapSamplerId = shadowMapSamplerId;
+ if( shadowMapSamplerId != -1) {
+ joglesctx.glLightSource [lightSlot].projMatrix.set(projMatrix);
+ }
}
// ---------------------------------------------------------------------
@@ -4921,49 +4507,53 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// SpotLightRetained methods
//
@Override
- void updateSpotLight(Context ctx, int lightSlot, float red, float green, float blue, float attenx, float atteny, float attenz,
- float posx, float posy, float posz, float spreadAngle, float concentration, float dirx, float diry, float dirz)
- {
+ void updateSpotLight( Context ctx, int lightSlot, float red, float green, float blue, float attenx, float atteny,
+ float attenz, float posx, float posy, float posz, float spreadAngle, float concentration,
+ float dirx, float diry, float dirz, int shadowMapSamplerId, double[] projMatrix) {
if (VERBOSE)
System.err.println("JoglPipeline.updateSpotLight()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateSpotLight++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateSpotLight++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
// note the current state of MV MUST be used by the lights when setting position!
//https://www.opengl.org/discussion_boards/showthread.php/168706-Light-Position-in-eye-s-cordinate
// note can't use the modelview as it's calced late
- Vector4f lightPos = joglesctx.matrixUtil.transform(joglesctx.currentModelMat, joglesctx.currentViewMat, posx, posy, posz, 1.0f);
-
- if (joglesctx.glLightSource[lightSlot] == null)
- {
- joglesctx.glLightSource[lightSlot] = new glLightSource();
- joglesctx.gl_state.glLightSource[lightSlot] = null;
- }
-
- joglesctx.glLightSource[lightSlot].diffuse.x = red;
- joglesctx.glLightSource[lightSlot].diffuse.y = green;
- joglesctx.glLightSource[lightSlot].diffuse.z = blue;
- joglesctx.glLightSource[lightSlot].diffuse.w = 1.0f;
- joglesctx.glLightSource[lightSlot].specular.x = red;
- joglesctx.glLightSource[lightSlot].specular.y = green;
- joglesctx.glLightSource[lightSlot].specular.z = blue;
- joglesctx.glLightSource[lightSlot].specular.w = 1.0f;
- joglesctx.glLightSource[lightSlot].position.x = lightPos.x;
- joglesctx.glLightSource[lightSlot].position.y = lightPos.y;
- joglesctx.glLightSource[lightSlot].position.z = lightPos.z;
- joglesctx.glLightSource[lightSlot].position.w = 1.0f;// 1 mean pos not dir
+ Vector4f lightPos = joglesctx.matrixUtil.transform(joglesctx.currentModelMat, joglesctx.currentViewMat, posx,
+ posy, posz, 1.0f);
+
+ if (joglesctx.glLightSource [lightSlot] == null) {
+ joglesctx.glLightSource [lightSlot] = new glLightSource();
+ joglesctx.gl_state.glLightSource [lightSlot] = null;
+ }
+
+ joglesctx.glLightSource [lightSlot].diffuse.x = red;
+ joglesctx.glLightSource [lightSlot].diffuse.y = green;
+ joglesctx.glLightSource [lightSlot].diffuse.z = blue;
+ joglesctx.glLightSource [lightSlot].diffuse.w = 1.0f;
+ joglesctx.glLightSource [lightSlot].specular.x = red;
+ joglesctx.glLightSource [lightSlot].specular.y = green;
+ joglesctx.glLightSource [lightSlot].specular.z = blue;
+ joglesctx.glLightSource [lightSlot].specular.w = 1.0f;
+ joglesctx.glLightSource [lightSlot].position.x = lightPos.x;
+ joglesctx.glLightSource [lightSlot].position.y = lightPos.y;
+ joglesctx.glLightSource [lightSlot].position.z = lightPos.z;
+ joglesctx.glLightSource [lightSlot].position.w = 1.0f;// 1 mean pos not dir
//joglesctx.glLightSource[lightSlot].ambient = black;// odd
- joglesctx.glLightSource[lightSlot].constantAttenuation = attenx;
- joglesctx.glLightSource[lightSlot].linearAttenuation = atteny;
- joglesctx.glLightSource[lightSlot].quadraticAttenuation = attenz;
- joglesctx.glLightSource[lightSlot].spotDirection.x = dirx;
- joglesctx.glLightSource[lightSlot].spotDirection.y = diry;
- joglesctx.glLightSource[lightSlot].spotDirection.z = dirz;
- joglesctx.glLightSource[lightSlot].spotExponent = concentration;
- joglesctx.glLightSource[lightSlot].spotCutoff = (float) (spreadAngle * 180.0f / Math.PI);
+ joglesctx.glLightSource [lightSlot].constantAttenuation = attenx;
+ joglesctx.glLightSource [lightSlot].linearAttenuation = atteny;
+ joglesctx.glLightSource [lightSlot].quadraticAttenuation = attenz;
+ joglesctx.glLightSource [lightSlot].spotDirection.x = dirx;
+ joglesctx.glLightSource [lightSlot].spotDirection.y = diry;
+ joglesctx.glLightSource [lightSlot].spotDirection.z = dirz;
+ joglesctx.glLightSource [lightSlot].spotExponent = concentration;
+ joglesctx.glLightSource [lightSlot].spotCutoff = (float)(spreadAngle * 180.0f / Math.PI);
+ joglesctx.glLightSource [lightSlot].shadowMapSamplerId = shadowMapSamplerId;
+ if( shadowMapSamplerId != -1) {
+ joglesctx.glLightSource [lightSlot].projMatrix.set(projMatrix);
+ }
}
@@ -4973,14 +4563,13 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// ExponentialFogRetained methods
//
@Override
- void updateExponentialFog(Context ctx, float red, float green, float blue, float density)
- {
+ void updateExponentialFog(Context ctx, float red, float green, float blue, float density) {
if (VERBOSE)
System.err.println("JoglPipeline.updateExponentialFog()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateExponentialFog++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateExponentialFog++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
joglesctx.gl_state.fogData.expColor.x = Float.NEGATIVE_INFINITY;
joglesctx.fogData.expColor.x = red;
joglesctx.fogData.expColor.y = green;
@@ -4995,50 +4584,47 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// LinearFogRetained methods
//
@Override
- void updateLinearFog(Context ctx, float red, float green, float blue, double fdist, double bdist)
- {
+ void updateLinearFog(Context ctx, float red, float green, float blue, double fdist, double bdist) {
if (VERBOSE)
System.err.println("JoglPipeline.updateLinearFog()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateLinearFog++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateLinearFog++;
// see
// https://www.opengl.org/discussion_boards/showthread.php/151415-Fog-with-pixel-shader-%28arb_fragment_program%29
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
joglesctx.gl_state.fogData.expColor.x = Float.NEGATIVE_INFINITY;
joglesctx.fogData.linearColor.x = red;
joglesctx.fogData.linearColor.y = green;
joglesctx.fogData.linearColor.z = blue;
- joglesctx.fogData.linearStart = (float) fdist;
- joglesctx.fogData.linearEnd = (float) bdist;
+ joglesctx.fogData.linearStart = (float)fdist;
+ joglesctx.fogData.linearEnd = (float)bdist;
joglesctx.fogData.fogEnabled = 1;
}
// native method for disabling fog
@Override
- void disableFog(Context ctx)
- {
+ void disableFog(Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.disableFog()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.disableFog++;
+ ((Jogl2es2Context)ctx).perFrameStats.disableFog++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
joglesctx.gl_state.fogData.expColor.x = Float.NEGATIVE_INFINITY;
joglesctx.fogData.fogEnabled = 0;
}
// native method for setting fog enable flag
@Override
- void setFogEnableFlag(Context ctx, boolean enable)
- {
+ void setFogEnableFlag(Context ctx, boolean enable) {
if (VERBOSE)
System.err.println("JoglPipeline.setFogEnableFlag()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setFogEnableFlag++;
+ ((Jogl2es2Context)ctx).perFrameStats.setFogEnableFlag++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
joglesctx.gl_state.fogData.expColor.x = Float.NEGATIVE_INFINITY;
joglesctx.fogData.fogEnabled = enable ? 1 : 0;
}
@@ -5049,15 +4635,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// LineAttributesRetained methods
//
@Override
- void updateLineAttributes(Context ctx, float lineWidth, int linePattern, int linePatternMask, int linePatternScaleFactor,
- boolean lineAntialiasing)
- {
+ void updateLineAttributes( Context ctx, float lineWidth, int linePattern, int linePatternMask,
+ int linePatternScaleFactor, boolean lineAntialiasing) {
if (VERBOSE)
System.err.println("JoglPipeline.updateLineAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateLineAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateLineAttributes++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glLineWidth(lineWidth);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5066,14 +4651,13 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting default LineAttributes
@Override
- void resetLineAttributes(Context ctx)
- {
+ void resetLineAttributes(Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.resetLineAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.resetLineAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.resetLineAttributes++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glLineWidth(1.0f);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5085,66 +4669,70 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// MaterialRetained methods
//
@Override
- void updateMaterial(Context ctx, float red, float green, float blue, float alpha, float aRed, float aGreen, float aBlue, float eRed,
- float eGreen, float eBlue, float dRed, float dGreen, float dBlue, float sRed, float sGreen, float sBlue, float shininess,
- int colorTarget, boolean lightEnable)
- {
+ void updateMaterial(Context ctx, float red, float green, float blue, float alpha, float aRed, float aGreen,
+ float aBlue, float eRed, float eGreen, float eBlue, float dRed, float dGreen, float dBlue,
+ float sRed, float sGreen, float sBlue, float shininess, int colorTarget, boolean lightEnable) {
if (VERBOSE)
System.err.println("JoglPipeline.updateMaterial()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateMaterial++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateMaterial++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
// will we need to repush to shaders?
if (joglesctx.objectColor.x != red || joglesctx.objectColor.y != green || joglesctx.objectColor.z != blue
- || joglesctx.objectColor.w != alpha){
+ || joglesctx.objectColor.w != alpha) {
joglesctx.gl_state.objectColor.x = Float.NEGATIVE_INFINITY;
- joglesctx.objectColor.x = red;
- joglesctx.objectColor.y = green;
- joglesctx.objectColor.z = blue;
- joglesctx.objectColor.w = alpha;}
+ joglesctx.objectColor.x = red;
+ joglesctx.objectColor.y = green;
+ joglesctx.objectColor.z = blue;
+ joglesctx.objectColor.w = alpha;
+ }
joglesctx.materialData.lightEnabled = lightEnable ? 1 : 0;
joglesctx.materialData.shininess = shininess;
if (joglesctx.materialData.emission.x != eRed || joglesctx.materialData.emission.y != eGreen
- || joglesctx.materialData.emission.z != eBlue){
+ || joglesctx.materialData.emission.z != eBlue) {
joglesctx.gl_state.glFrontMaterial.emission.x = Float.NEGATIVE_INFINITY;
- joglesctx.materialData.emission.x = eRed;
- joglesctx.materialData.emission.y = eGreen;
- joglesctx.materialData.emission.z = eBlue;}
+ joglesctx.materialData.emission.x = eRed;
+ joglesctx.materialData.emission.y = eGreen;
+ joglesctx.materialData.emission.z = eBlue;
+ }
if (joglesctx.materialData.ambient.x != aRed || joglesctx.materialData.ambient.y != aGreen
- || joglesctx.materialData.ambient.z != aBlue){
+ || joglesctx.materialData.ambient.z != aBlue) {
joglesctx.gl_state.glFrontMaterial.ambient.x = Float.NEGATIVE_INFINITY;
- joglesctx.materialData.ambient.x = aRed;
- joglesctx.materialData.ambient.y = aGreen;
- joglesctx.materialData.ambient.z = aBlue;}
+ joglesctx.materialData.ambient.x = aRed;
+ joglesctx.materialData.ambient.y = aGreen;
+ joglesctx.materialData.ambient.z = aBlue;
+ }
if (joglesctx.materialData.specular.x != sRed || joglesctx.materialData.specular.y != sGreen
- || joglesctx.materialData.specular.z != sBlue){
+ || joglesctx.materialData.specular.z != sBlue) {
joglesctx.gl_state.glFrontMaterial.specular.x = Float.NEGATIVE_INFINITY;
- joglesctx.materialData.specular.x = sRed;
- joglesctx.materialData.specular.y = sGreen;
- joglesctx.materialData.specular.z = sBlue;}
+ joglesctx.materialData.specular.x = sRed;
+ joglesctx.materialData.specular.y = sGreen;
+ joglesctx.materialData.specular.z = sBlue;
+ }
if (joglesctx.materialData.diffuse.x != dRed || joglesctx.materialData.diffuse.y != dGreen
- || joglesctx.materialData.diffuse.z != dBlue || joglesctx.materialData.diffuse.w != alpha){
+ || joglesctx.materialData.diffuse.z != dBlue || joglesctx.materialData.diffuse.w != alpha) {
joglesctx.gl_state.glFrontMaterial.diffuse.x = Float.NEGATIVE_INFINITY;
- joglesctx.materialData.diffuse.x = dRed;
- joglesctx.materialData.diffuse.y = dGreen;
- joglesctx.materialData.diffuse.z = dBlue;
- joglesctx.materialData.diffuse.w = alpha;}
+ joglesctx.materialData.diffuse.x = dRed;
+ joglesctx.materialData.diffuse.y = dGreen;
+ joglesctx.materialData.diffuse.z = dBlue;
+ joglesctx.materialData.diffuse.w = alpha;
+ }
}
// native method for setting Material when no material is present
@Override
- void updateMaterialColor(Context ctx, float r, float g, float b, float a)
- {
+ void updateMaterialColor(Context ctx, float r, float g, float b, float a) {
if (VERBOSE)
System.err.println("JoglPipeline.updateMaterialColor()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateMaterialColor++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateMaterialColor++;
// update single color in case where material has color and there are no coloring attributes
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
- if (joglesctx.objectColor.x != r || joglesctx.objectColor.y != g || joglesctx.objectColor.z != b || joglesctx.objectColor.w != a)
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
+ if (joglesctx.objectColor.x != r || joglesctx.objectColor.y != g || joglesctx.objectColor.z != b
+ || joglesctx.objectColor.w != a)
joglesctx.gl_state.objectColor.x = Float.NEGATIVE_INFINITY;
joglesctx.objectColor.x = r;
joglesctx.objectColor.y = g;
@@ -5157,18 +4745,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
//
// ColoringAttributesRetained methods
@Override
- void updateColoringAttributes(Context ctx, float dRed, float dGreen, float dBlue, float red, float green, float blue, float alpha,
- boolean lightEnable, int shadeModel)
- {
+ void updateColoringAttributes( Context ctx, float dRed, float dGreen, float dBlue, float red, float green,
+ float blue, float alpha, boolean lightEnable, int shadeModel) {
if (VERBOSE)
System.err.println("JoglPipeline.updateColoringAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateColoringAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateColoringAttributes++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
// note we ignore lightEnabled and always pass the object color to the shader if it wants it
if (joglesctx.objectColor.x != red || joglesctx.objectColor.y != green || joglesctx.objectColor.z != blue
- || joglesctx.objectColor.w != alpha)
+ || joglesctx.objectColor.w != alpha)
joglesctx.gl_state.objectColor.x = Float.NEGATIVE_INFINITY;
joglesctx.objectColor.x = red;
joglesctx.objectColor.y = green;
@@ -5181,15 +4768,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting default ColoringAttributes
@Override
- void resetColoringAttributes(Context ctx, float r, float g, float b, float a, boolean enableLight)
- {
+ void resetColoringAttributes(Context ctx, float r, float g, float b, float a, boolean enableLight) {
if (VERBOSE)
- System.err.println("JoglPipeline.resetColoringAttributes() " + r + " " + g + " " + b + " " + a + " " + enableLight);
+ System.err.println(
+ "JoglPipeline.resetColoringAttributes() " + r + " " + g + " " + b + " " + a + " " + enableLight);
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.resetColoringAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.resetColoringAttributes++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
- if (joglesctx.objectColor.x != r || joglesctx.objectColor.y != g || joglesctx.objectColor.z != b || joglesctx.objectColor.w != a)
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
+ if (joglesctx.objectColor.x != r || joglesctx.objectColor.y != g || joglesctx.objectColor.z != b
+ || joglesctx.objectColor.w != a)
joglesctx.gl_state.objectColor.x = Float.NEGATIVE_INFINITY;
joglesctx.objectColor.x = r;
joglesctx.objectColor.y = g;
@@ -5208,20 +4796,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// http://stackoverflow.com/questions/3497068/textured-points-in-opengl-es-2-0
// http://stackoverflow.com/questions/7237086/opengl-es-2-0-equivalent-for-es-1-0-circles-using-gl-point-smooth
@Override
- void updatePointAttributes(Context ctx, float pointSize, boolean pointAntialiasing)
- {
+ void updatePointAttributes(Context ctx, float pointSize, boolean pointAntialiasing) {
if (VERBOSE)
System.err.println("JoglPipeline.updatePointAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updatePointAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.updatePointAttributes++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
joglesctx.pointSize = pointSize;
// one time enable call
- if (!pointsEnabled)
- {
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ if (!pointsEnabled) {
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
// bug in desktop requiring this to be set still
gl.glEnable(0x8642);// GL_VERTEX_PROGRAM_POINT_SIZE
gl.glEnable(34913);// GL.GL_POINT_SPRITE);
@@ -5233,14 +4819,13 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting default PointAttributes
@Override
- void resetPointAttributes(Context ctx)
- {
+ void resetPointAttributes(Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.resetPointAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.resetPointAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.resetPointAttributes++;
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
joglesctx.pointSize = 1.0f;
}
@@ -5250,31 +4835,23 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// PolygonAttributesRetained methods
//
@Override
- void updatePolygonAttributes(Context ctx, int polygonMode, int cullFace, boolean backFaceNormalFlip, float polygonOffset,
- float polygonOffsetFactor)
- {
+ void updatePolygonAttributes( Context ctx, int polygonMode, int cullFace, boolean backFaceNormalFlip,
+ float polygonOffset, float polygonOffsetFactor) {
if (VERBOSE)
System.err.println("JoglPipeline.updatePolygonAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updatePolygonAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.updatePolygonAttributes++;
GL2ES2 gl = null;// get only if needed, expensive call
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
- if (joglesctx.gl_state.cullFace != cullFace)
- {
- gl = ((Jogl2es2Context) ctx).gl2es2();
- if (cullFace == PolygonAttributes.CULL_NONE)
- {
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
+ if (joglesctx.gl_state.cullFace != cullFace) {
+ gl = ((Jogl2es2Context)ctx).gl2es2();
+ if (cullFace == PolygonAttributes.CULL_NONE) {
gl.glDisable(GL2ES2.GL_CULL_FACE);
- }
- else
- {
- if (cullFace == PolygonAttributes.CULL_BACK)
- {
+ } else {
+ if (cullFace == PolygonAttributes.CULL_BACK) {
gl.glCullFace(GL2ES2.GL_BACK);
- }
- else
- {
+ } else {
gl.glCullFace(GL2ES2.GL_FRONT);
}
gl.glEnable(GL2ES2.GL_CULL_FACE);
@@ -5286,23 +4863,19 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
joglesctx.gl_state.cullFace = cullFace;
}
- if (joglesctx.gl_state.polygonOffsetFactor != polygonOffsetFactor || joglesctx.gl_state.polygonOffset != polygonOffset)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (joglesctx.gl_state.polygonOffsetFactor != polygonOffsetFactor
+ || joglesctx.gl_state.polygonOffset != polygonOffset) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glPolygonOffset(polygonOffsetFactor, polygonOffset);
- if ((polygonOffsetFactor != 0.0f) || (polygonOffset != 0.0f))
- {
+ if ((polygonOffsetFactor != 0.0f) || (polygonOffset != 0.0f)) {
gl.glEnable(GL2ES2.GL_POLYGON_OFFSET_FILL);
- }
- else
- {
+ } else {
gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL);
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- if (MINIMISE_NATIVE_CALLS_OTHER)
- {
+ if (MINIMISE_NATIVE_CALLS_OTHER) {
joglesctx.gl_state.polygonOffsetFactor = polygonOffsetFactor;
joglesctx.gl_state.polygonOffset = polygonOffset;
}
@@ -5312,18 +4885,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting default PolygonAttributes
@Override
- void resetPolygonAttributes(Context ctx)
- {
+ void resetPolygonAttributes(Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.resetPolygonAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.resetPolygonAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.resetPolygonAttributes++;
GL2ES2 gl = null;// get only if needed, expensive call
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
- if (joglesctx.gl_state.cullFace != PolygonAttributes.CULL_BACK)
- {
- gl = ((Jogl2es2Context) ctx).gl2es2();
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
+ if (joglesctx.gl_state.cullFace != PolygonAttributes.CULL_BACK) {
+ gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glCullFace(GL2ES2.GL_BACK);
gl.glEnable(GL2ES2.GL_CULL_FACE);
if (DO_OUTPUT_ERRORS)
@@ -5332,15 +4903,13 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
joglesctx.gl_state.cullFace = PolygonAttributes.CULL_BACK;
}
- if (joglesctx.gl_state.polygonOffsetFactor != 0.0f || joglesctx.gl_state.polygonOffset != 0.0f)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (joglesctx.gl_state.polygonOffsetFactor != 0.0f || joglesctx.gl_state.polygonOffset != 0.0f) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glPolygonOffset(0.0f, 0.0f);
gl.glDisable(GL2ES2.GL_POLYGON_OFFSET_FILL);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- if (MINIMISE_NATIVE_CALLS_OTHER)
- {
+ if (MINIMISE_NATIVE_CALLS_OTHER) {
joglesctx.gl_state.polygonOffsetFactor = 0.0f;
joglesctx.gl_state.polygonOffset = 0.0f;
}
@@ -5355,35 +4924,32 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// RenderingAttributesRetained methods
//
@Override
- void updateRenderingAttributes(Context ctx, boolean depthBufferWriteEnableOverride, boolean depthBufferEnableOverride,
- boolean depthBufferEnable, boolean depthBufferWriteEnable, int depthTestFunction, float alphaTestValue, int alphaTestFunction,
- boolean ignoreVertexColors, boolean rasterOpEnable, int rasterOp, boolean userStencilAvailable, boolean stencilEnable,
- int stencilFailOp, int stencilZFailOp, int stencilZPassOp, int stencilFunction, int stencilReferenceValue,
- int stencilCompareMask, int stencilWriteMask)
- {
+ void updateRenderingAttributes( Context ctx, boolean depthBufferWriteEnableOverride,
+ boolean depthBufferEnableOverride, boolean depthBufferEnable,
+ boolean depthBufferWriteEnable, int depthTestFunction, float alphaTestValue,
+ int alphaTestFunction, boolean ignoreVertexColors, boolean rasterOpEnable,
+ int rasterOp, boolean userStencilAvailable, boolean stencilEnable,
+ int stencilFailOp, int stencilZFailOp, int stencilZPassOp, int stencilFunction,
+ int stencilReferenceValue, int stencilCompareMask, int stencilWriteMask) {
if (VERBOSE)
System.err.println("JoglPipeline.updateRenderingAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateRenderingAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateRenderingAttributes++;
GL2ES2 gl = null;// get late expensive
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
- if (joglesctx.gl_state.depthBufferEnableOverride != depthBufferEnable || joglesctx.gl_state.depthBufferEnable != depthBufferEnable
- || joglesctx.gl_state.depthTestFunction != depthTestFunction)
- {
- if (!depthBufferEnableOverride)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
- if (depthBufferEnable)
- {
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
+ if (joglesctx.gl_state.depthBufferEnableOverride != depthBufferEnable
+ || joglesctx.gl_state.depthBufferEnable != depthBufferEnable
+ || joglesctx.gl_state.depthTestFunction != depthTestFunction) {
+ if (!depthBufferEnableOverride) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
+ if (depthBufferEnable) {
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
gl.glDepthFunc(getFunctionValue(depthTestFunction));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
+ } else {
gl.glDisable(GL2ES2.GL_DEPTH_TEST);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5398,25 +4964,19 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
joglesctx.gl_state.depthTestFunction = depthTestFunction;
}
- if (!depthBufferWriteEnableOverride)
- {
- if (depthBufferWriteEnable)
- {
- if (joglesctx.gl_state.glDepthMask != true)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (!depthBufferWriteEnableOverride) {
+ if (depthBufferWriteEnable) {
+ if (joglesctx.gl_state.glDepthMask != true) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glDepthMask(true);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (MINIMISE_NATIVE_CALLS_OTHER)
joglesctx.gl_state.glDepthMask = true;
}
- }
- else
- {
- if (joglesctx.gl_state.glDepthMask != false)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ } else {
+ if (joglesctx.gl_state.glDepthMask != false) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glDepthMask(false);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5426,12 +4986,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
- if (alphaTestFunction == RenderingAttributes.ALWAYS)
- {
+ if (alphaTestFunction == RenderingAttributes.ALWAYS) {
joglesctx.renderingData.alphaTestEnabled = false;
- }
- else
- {
+ } else {
joglesctx.renderingData.alphaTestEnabled = true;
joglesctx.renderingData.alphaTestFunction = getFunctionValue(alphaTestFunction);
joglesctx.renderingData.alphaTestValue = alphaTestValue;
@@ -5439,25 +4996,24 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
joglesctx.renderingData.ignoreVertexColors = ignoreVertexColors ? 1 : 0;
- if (rasterOpEnable)
- {
+ if (rasterOpEnable) {
System.err.println("rasterOpEnable!!!! no no no!");
}
- if (userStencilAvailable)
- {
- if (stencilEnable)
- {
- if (joglesctx.gl_state.glEnableGL_STENCIL_TEST == false || joglesctx.gl_state.stencilFailOp != stencilFailOp
- || joglesctx.gl_state.stencilZFailOp != stencilZFailOp || joglesctx.gl_state.stencilZPassOp != stencilZPassOp
- || joglesctx.gl_state.stencilFunction != stencilFunction
- || joglesctx.gl_state.stencilReferenceValue != stencilReferenceValue
- || joglesctx.gl_state.stencilCompareMask != stencilCompareMask
- || joglesctx.gl_state.stencilWriteMask != stencilWriteMask)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (userStencilAvailable) {
+ if (stencilEnable) {
+ if (joglesctx.gl_state.glEnableGL_STENCIL_TEST == false
+ || joglesctx.gl_state.stencilFailOp != stencilFailOp
+ || joglesctx.gl_state.stencilZFailOp != stencilZFailOp
+ || joglesctx.gl_state.stencilZPassOp != stencilZPassOp
+ || joglesctx.gl_state.stencilFunction != stencilFunction
+ || joglesctx.gl_state.stencilReferenceValue != stencilReferenceValue
+ || joglesctx.gl_state.stencilCompareMask != stencilCompareMask
+ || joglesctx.gl_state.stencilWriteMask != stencilWriteMask) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glEnable(GL2ES2.GL_STENCIL_TEST);
- gl.glStencilOp(getStencilOpValue(stencilFailOp), getStencilOpValue(stencilZFailOp), getStencilOpValue(stencilZPassOp));
+ gl.glStencilOp(getStencilOpValue(stencilFailOp), getStencilOpValue(stencilZFailOp),
+ getStencilOpValue(stencilZPassOp));
gl.glStencilFunc(getFunctionValue(stencilFunction), stencilReferenceValue, stencilCompareMask);
gl.glStencilMask(stencilWriteMask);
if (DO_OUTPUT_ERRORS)
@@ -5465,12 +5021,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (MINIMISE_NATIVE_CALLS_OTHER)
joglesctx.gl_state.glEnableGL_STENCIL_TEST = true;
}
- }
- else
- {
- if (joglesctx.gl_state.glEnableGL_STENCIL_TEST == true)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ } else {
+ if (joglesctx.gl_state.glEnableGL_STENCIL_TEST == true) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glDisable(GL2ES2.GL_STENCIL_TEST);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5484,20 +5037,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting default RenderingAttributes
@Override
- void resetRenderingAttributes(Context ctx, boolean depthBufferWriteEnableOverride, boolean depthBufferEnableOverride)
- {
+ void resetRenderingAttributes( Context ctx, boolean depthBufferWriteEnableOverride,
+ boolean depthBufferEnableOverride) {
if (VERBOSE)
System.err.println("JoglPipeline.resetRenderingAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.resetRenderingAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.resetRenderingAttributes++;
GL2ES2 gl = null; // get late expensive
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
- if (!depthBufferWriteEnableOverride)
- {
- if (joglesctx.gl_state.glDepthMask != true)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
+ if (!depthBufferWriteEnableOverride) {
+ if (joglesctx.gl_state.glDepthMask != true) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glDepthMask(true);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5505,11 +5056,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
joglesctx.gl_state.glDepthMask = true;
}
}
- if (!depthBufferEnableOverride)
- {
- if (joglesctx.gl_state.depthBufferEnable != true)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (!depthBufferEnableOverride) {
+ if (joglesctx.gl_state.depthBufferEnable != true) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5517,9 +5066,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
joglesctx.gl_state.depthBufferEnable = true;
}
}
- if (joglesctx.gl_state.depthTestFunction != RenderingAttributes.LESS_OR_EQUAL)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (joglesctx.gl_state.depthTestFunction != RenderingAttributes.LESS_OR_EQUAL) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glDepthFunc(GL2ES2.GL_LEQUAL);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5532,9 +5080,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
joglesctx.renderingData.alphaTestValue = 0;
joglesctx.renderingData.ignoreVertexColors = 0;
- if (joglesctx.gl_state.glEnableGL_STENCIL_TEST == true)
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (joglesctx.gl_state.glEnableGL_STENCIL_TEST == true) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glDisable(GL2ES2.GL_STENCIL_TEST);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5545,48 +5092,46 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void updateTransparencyAttributes(Context ctx, float alpha, int geometryType, int polygonMode, boolean lineAA, boolean pointAA,
- int transparencyMode, int srcBlendFunction, int dstBlendFunction)
- {
+ void updateTransparencyAttributes( Context ctx, float alpha, int geometryType, int polygonMode, boolean lineAA,
+ boolean pointAA, int transparencyMode, int srcBlendFunction,
+ int dstBlendFunction) {
if (VERBOSE)
- System.err.println("JoglPipeline.updateTransparencyAttributes() " + alpha + " " + geometryType + " " + polygonMode + " "
- + lineAA + " " + pointAA + " " + transparencyMode + " " + srcBlendFunction + " " + dstBlendFunction);
+ System.err.println("JoglPipeline.updateTransparencyAttributes() " + alpha + " " + geometryType + " "
+ + polygonMode + " " + lineAA + " " + pointAA + " " + transparencyMode + " "
+ + srcBlendFunction + " " + dstBlendFunction);
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateTransparencyAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateTransparencyAttributes++;
GL2ES2 gl = null;//get late expensive
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
joglesctx.transparencyAlpha = alpha;
if ((transparencyMode < TransparencyAttributes.SCREEN_DOOR)
- || ((((geometryType & RenderMolecule.LINE) != 0) || (polygonMode == PolygonAttributes.POLYGON_LINE)) && lineAA)
- || ((((geometryType & RenderMolecule.POINT) != 0) || (polygonMode == PolygonAttributes.POLYGON_POINT)) && pointAA))
- {
+ || ((((geometryType & RenderMolecule.LINE) != 0) || (polygonMode == PolygonAttributes.POLYGON_LINE))
+ && lineAA)
+ || ((((geometryType & RenderMolecule.POINT) != 0) || (polygonMode == PolygonAttributes.POLYGON_POINT))
+ && pointAA)) {
if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != true
- || joglesctx.gl_state.srcBlendFunction != srcBlendFunction || joglesctx.gl_state.dstBlendFunction != dstBlendFunction))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ || joglesctx.gl_state.srcBlendFunction != srcBlendFunction
+ || joglesctx.gl_state.dstBlendFunction != dstBlendFunction)) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glEnable(GL2ES2.GL_BLEND);
// valid range of blendFunction 0..3 is already verified in shared code.
- gl.glBlendFunc(blendFunctionTable[srcBlendFunction], blendFunctionTable[dstBlendFunction]);
+ gl.glBlendFunc(blendFunctionTable [srcBlendFunction], blendFunctionTable [dstBlendFunction]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- if (MINIMISE_NATIVE_CALLS_TRANSPARENCY)
- {
+ if (MINIMISE_NATIVE_CALLS_TRANSPARENCY) {
joglesctx.gl_state.glEnableGL_BLEND = true;
joglesctx.gl_state.srcBlendFunction = srcBlendFunction;
joglesctx.gl_state.dstBlendFunction = dstBlendFunction;
}
}
- }
- else
- {
- if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != false))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ } else {
+ if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != false)) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glDisable(GL2ES2.GL_BLEND);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5599,43 +5144,38 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting default TransparencyAttributes
@Override
- void resetTransparency(Context ctx, int geometryType, int polygonMode, boolean lineAA, boolean pointAA)
- {
+ void resetTransparency(Context ctx, int geometryType, int polygonMode, boolean lineAA, boolean pointAA) {
if (VERBOSE)
System.err.println("JoglPipeline.resetTransparency()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.resetTransparency++;
+ ((Jogl2es2Context)ctx).perFrameStats.resetTransparency++;
GL2ES2 gl = null; //get late expensive
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
-
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
+
joglesctx.transparencyAlpha = 1.0f;
-
+
if (((((geometryType & RenderMolecule.LINE) != 0) || (polygonMode == PolygonAttributes.POLYGON_LINE)) && lineAA)
- || ((((geometryType & RenderMolecule.POINT) != 0) || (polygonMode == PolygonAttributes.POLYGON_POINT)) && pointAA))
- {
- if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != true
+ || ((((geometryType & RenderMolecule.POINT) != 0) || (polygonMode == PolygonAttributes.POLYGON_POINT))
+ && pointAA)) {
+ if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY
+ || (joglesctx.gl_state.glEnableGL_BLEND != true
|| joglesctx.gl_state.srcBlendFunction != TransparencyAttributes.BLEND_SRC_ALPHA
- || joglesctx.gl_state.dstBlendFunction != TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ || joglesctx.gl_state.dstBlendFunction != TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA)) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glEnable(GL2ES2.GL_BLEND);
gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- if (MINIMISE_NATIVE_CALLS_TRANSPARENCY)
- {
+ if (MINIMISE_NATIVE_CALLS_TRANSPARENCY) {
joglesctx.gl_state.glEnableGL_BLEND = true;
joglesctx.gl_state.srcBlendFunction = TransparencyAttributes.BLEND_SRC_ALPHA;
joglesctx.gl_state.dstBlendFunction = TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA;
}
}
- }
- else
- {
- if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != false))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ } else {
+ if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != false)) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glDisable(GL2ES2.GL_BLEND);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5649,31 +5189,29 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// TextureAttributesRetained methods
//
@Override
- void updateTextureAttributes(Context ctx, double[] transform, boolean isIdentity, int textureMode, int perspCorrectionMode,
- float textureBlendColorRed, float textureBlendColorGreen, float textureBlendColorBlue, float textureBlendColorAlpha,
- int textureFormat)
- {
+ void updateTextureAttributes( Context ctx, double[] transform, boolean isIdentity, int textureMode,
+ int perspCorrectionMode, float textureBlendColorRed, float textureBlendColorGreen,
+ float textureBlendColorBlue, float textureBlendColorAlpha, int textureFormat) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTextureAttributes() " + lineString(transform));
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateTextureAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateTextureAttributes++;
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
joglesctx.gl_state.textureTransform.m00 = Double.NEGATIVE_INFINITY;
joglesctx.textureTransform.set(transform);
}
// native method for setting default TextureAttributes
@Override
- void resetTextureAttributes(Context ctx)
- {
+ void resetTextureAttributes(Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.resetTextureAttributes()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.resetTextureAttributes++;
+ ((Jogl2es2Context)ctx).perFrameStats.resetTextureAttributes++;
// set Identity
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
joglesctx.gl_state.textureTransform.m00 = Double.NEGATIVE_INFINITY;
joglesctx.textureTransform.setIdentity();
@@ -5683,8 +5221,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting default TexCoordGeneration -Noop
@Override
- void resetTexCoordGeneration(Context ctx)
- {
+ void resetTexCoordGeneration(Context ctx) {
// TexCoordGeneration must be done in shaders
// if (VERBOSE)
// System.err.println("JoglPipeline.resetTexCoordGeneration()");
@@ -5698,21 +5235,19 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// TextureUnitStateRetained methods
//
@Override
- void updateTextureUnitState(Context ctx, int index, boolean enable)
- {
+ void updateTextureUnitState(Context ctx, int index, boolean enable) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTextureUnitState(index=" + index + ",enable=" + enable + ")");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.updateTextureUnitState++;
+ ((Jogl2es2Context)ctx).perFrameStats.updateTextureUnitState++;
- Jogl2es2Context joglesContext = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesContext = (Jogl2es2Context)ctx;
GL2ES2 gl = null;//get late expensive
- if (index >= 0)
- {
- if (!MINIMISE_NATIVE_CALLS_TEXTURE || (joglesContext.gl_state.glActiveTexture != (index + GL2ES2.GL_TEXTURE0)))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (index >= 0) {
+ if (!MINIMISE_NATIVE_CALLS_TEXTURE
+ || (joglesContext.gl_state.glActiveTexture != (index + GL2ES2.GL_TEXTURE0))) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glActiveTexture(index + GL2ES2.GL_TEXTURE0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -5729,61 +5264,57 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Texture2DRetained methods
//
@Override
- void bindTexture2D(Context ctx, int objectId, boolean enable)
- {
+ void bindTexture2D(Context ctx, int objectId, boolean enable) {
if (VERBOSE)
System.err.println("JoglPipeline.bindTexture2D(objectId=" + objectId + ",enable=" + enable + ")");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.bindTexture2D++;
+ ((Jogl2es2Context)ctx).perFrameStats.bindTexture2D++;
- Jogl2es2Context joglesContext = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesContext = (Jogl2es2Context)ctx;
GL2ES2 gl = null;// get late expensive
- if (enable)
- {
+ if (enable) {
if (!MINIMISE_NATIVE_CALLS_TEXTURE
- || (joglesContext.gl_state.glBindTextureGL_TEXTURE_2D[joglesContext.gl_state.glActiveTexture] != objectId))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ || (joglesContext.gl_state.glBindTextureGL_TEXTURE_2D [joglesContext.gl_state.glActiveTexture] != objectId)) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glBindTexture(GL2ES2.GL_TEXTURE_2D, objectId);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
if (MINIMISE_NATIVE_CALLS_TEXTURE)
- joglesContext.gl_state.glBindTextureGL_TEXTURE_2D[joglesContext.gl_state.glActiveTexture] = objectId;
+ joglesContext.gl_state.glBindTextureGL_TEXTURE_2D [joglesContext.gl_state.glActiveTexture] = objectId;
}
}
}
@Override
- void updateTexture2DImage(Context ctx, int numLevels, int level, int textureFormat, int imageFormat, int width, int height,
- int boundaryWidth, int dataType, Object data, boolean useAutoMipMap)
- {
+ void updateTexture2DImage( Context ctx, int numLevels, int level, int textureFormat, int imageFormat, int width,
+ int height, int boundaryWidth, int dataType, Object data, boolean useAutoMipMap) {
if (VERBOSE)
- System.err.println("JoglPipeline.updateTexture2DImage(width=" + width + ",height=" + height + ",level=" + level + ")");
+ System.err.println(
+ "JoglPipeline.updateTexture2DImage(width=" + width + ",height=" + height + ",level=" + level + ")");
- updateTexture2DImage(ctx, GL2ES2.GL_TEXTURE_2D, numLevels, level, textureFormat, imageFormat, width, height, boundaryWidth,
- dataType, data, useAutoMipMap);
+ updateTexture2DImage(ctx, GL2ES2.GL_TEXTURE_2D, numLevels, level, textureFormat, imageFormat, width, height,
+ boundaryWidth, dataType, data, useAutoMipMap);
}
// oddly in use when I press escape twice???
@Override
- void updateTexture2DSubImage(Context ctx, int level, int xoffset, int yoffset, int textureFormat, int imageFormat, int imgXOffset,
- int imgYOffset, int tilew, int width, int height, int dataType, Object data, boolean useAutoMipMap)
- {
+ void updateTexture2DSubImage( Context ctx, int level, int xoffset, int yoffset, int textureFormat, int imageFormat,
+ int imgXOffset, int imgYOffset, int tilew, int width, int height, int dataType,
+ Object data, boolean useAutoMipMap) {
// Note: useAutoMipMap is not use for SubImage in the jogl pipe
if (VERBOSE)
System.err.println("JoglPipeline.updateTexture2DSubImage()");
- updateTexture2DSubImage(ctx, GL2ES2.GL_TEXTURE_2D, level, xoffset, yoffset, textureFormat, imageFormat, imgXOffset, imgYOffset,
- tilew, width, height, dataType, data);
+ updateTexture2DSubImage(ctx, GL2ES2.GL_TEXTURE_2D, level, xoffset, yoffset, textureFormat, imageFormat,
+ imgXOffset, imgYOffset, tilew, width, height, dataType, data);
}
@Override
- void updateTexture2DLodRange(Context ctx, int baseLevel, int maximumLevel, float minimumLOD, float maximumLOD)
- {
+ void updateTexture2DLodRange(Context ctx, int baseLevel, int maximumLevel, float minimumLOD, float maximumLOD) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTexture2DLodRange()");
@@ -5791,19 +5322,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void updateTexture2DBoundary(Context ctx, int boundaryModeS, int boundaryModeT, float boundaryRed, float boundaryGreen,
- float boundaryBlue, float boundaryAlpha)
- {
+ void updateTexture2DBoundary( Context ctx, int boundaryModeS, int boundaryModeT, float boundaryRed,
+ float boundaryGreen, float boundaryBlue, float boundaryAlpha) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTexture2DBoundary()");
- updateTextureBoundary(ctx, GL2ES2.GL_TEXTURE_2D, boundaryModeS, boundaryModeT, -1, boundaryRed, boundaryGreen, boundaryBlue,
- boundaryAlpha);
+ updateTextureBoundary(ctx, GL2ES2.GL_TEXTURE_2D, boundaryModeS, boundaryModeT, -1, boundaryRed, boundaryGreen,
+ boundaryBlue, boundaryAlpha);
}
@Override
- void updateTexture2DFilterModes(Context ctx, int minFilter, int magFilter)
- {
+ void updateTexture2DFilterModes(Context ctx, int minFilter, int magFilter) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTexture2DFilterModes()");
@@ -5811,16 +5340,15 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void updateTexture2DAnisotropicFilter(Context ctx, float degree)
- {
+ void updateTexture2DAnisotropicFilter(Context ctx, float degree) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTexture2DAnisotropicFilter()");
updateTextureAnisotropicFilter(ctx, GL2ES2.GL_TEXTURE_2D, degree);
}
- private static void updateTextureLodRange(Context ctx, int target, int baseLevel, int maximumLevel, float minimumLOD, float maximumLOD)
- {
+ private static void updateTextureLodRange( Context ctx, int target, int baseLevel, int maximumLevel,
+ float minimumLOD, float maximumLOD) {
//GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
// I notice these 4 parameters don't appear under GL2ES2
@@ -5852,10 +5380,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
- private static void updateTextureAnisotropicFilter(Context ctx, int target, float degree)
- {
+ private static void updateTextureAnisotropicFilter(Context ctx, int target, float degree) {
// FIXME: is this a true thing to send in?
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
// it appears GL_TEXTURE_MAX_ANISOTROPY_EXT is still part of ES2
// but not allowed for glTexParameterf
@@ -5876,24 +5403,20 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// TextureCubeMapRetained methods
//
@Override
- void bindTextureCubeMap(Context ctx, int objectId, boolean enable)
- {
+ void bindTextureCubeMap(Context ctx, int objectId, boolean enable) {
if (VERBOSE)
System.err.println("JoglPipeline.bindTextureCubeMap()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.bindTextureCubeMap++;
+ ((Jogl2es2Context)ctx).perFrameStats.bindTextureCubeMap++;
GL2ES2 gl = null;// get late expensive
// TextureCubeMap will take precedents over 3D Texture so
// there is no need to disable 3D Texture here.
- if (!enable)
- {
+ if (!enable) {
// gl.glDisable(GL2ES2.GL_TEXTURE_CUBE_MAP);
- }
- else
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ } else {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glBindTexture(GL2ES2.GL_TEXTURE_CUBE_MAP, objectId);
// gl.glEnable(GL2ES2.GL_TEXTURE_CUBE_MAP);
if (DO_OUTPUT_ERRORS)
@@ -5902,27 +5425,27 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void updateTextureCubeMapImage(Context ctx, int face, int numLevels, int level, int textureFormat, int imageFormat, int width,
- int height, int boundaryWidth, int dataType, Object data, boolean useAutoMipMap)
- {
+ void updateTextureCubeMapImage( Context ctx, int face, int numLevels, int level, int textureFormat, int imageFormat,
+ int width, int height, int boundaryWidth, int dataType, Object data,
+ boolean useAutoMipMap) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTextureCubeMapImage()");
- updateTexture2DImage(ctx, _gl_textureCubeMapFace[face], numLevels, level, textureFormat, imageFormat, width, height, boundaryWidth,
- dataType, data, useAutoMipMap);
+ updateTexture2DImage(ctx, _gl_textureCubeMapFace [face], numLevels, level, textureFormat, imageFormat, width,
+ height, boundaryWidth, dataType, data, useAutoMipMap);
}
@Override
- void updateTextureCubeMapSubImage(Context ctx, int face, int level, int xoffset, int yoffset, int textureFormat, int imageFormat,
- int imgXOffset, int imgYOffset, int tilew, int width, int height, int dataType, Object data, boolean useAutoMipMap)
- {
+ void updateTextureCubeMapSubImage( Context ctx, int face, int level, int xoffset, int yoffset, int textureFormat,
+ int imageFormat, int imgXOffset, int imgYOffset, int tilew, int width,
+ int height, int dataType, Object data, boolean useAutoMipMap) {
// PJ why is this the case?
throw new UnsupportedOperationException();
}
@Override
- void updateTextureCubeMapLodRange(Context ctx, int baseLevel, int maximumLevel, float minimumLod, float maximumLod)
- {
+ void updateTextureCubeMapLodRange( Context ctx, int baseLevel, int maximumLevel, float minimumLod,
+ float maximumLod) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTextureCubeMapLodRange()");
@@ -5930,19 +5453,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void updateTextureCubeMapBoundary(Context ctx, int boundaryModeS, int boundaryModeT, float boundaryRed, float boundaryGreen,
- float boundaryBlue, float boundaryAlpha)
- {
+ void updateTextureCubeMapBoundary( Context ctx, int boundaryModeS, int boundaryModeT, float boundaryRed,
+ float boundaryGreen, float boundaryBlue, float boundaryAlpha) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTextureCubeMapBoundary()");
- updateTextureBoundary(ctx, GL2ES2.GL_TEXTURE_CUBE_MAP, boundaryModeS, boundaryModeT, -1, boundaryRed, boundaryGreen, boundaryBlue,
- boundaryAlpha);
+ updateTextureBoundary(ctx, GL2ES2.GL_TEXTURE_CUBE_MAP, boundaryModeS, boundaryModeT, -1, boundaryRed,
+ boundaryGreen, boundaryBlue, boundaryAlpha);
}
@Override
- void updateTextureCubeMapFilterModes(Context ctx, int minFilter, int magFilter)
- {
+ void updateTextureCubeMapFilterModes(Context ctx, int minFilter, int magFilter) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTextureCubeMapFilterModes()");
@@ -5950,8 +5471,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void updateTextureCubeMapAnisotropicFilter(Context ctx, float degree)
- {
+ void updateTextureCubeMapAnisotropicFilter(Context ctx, float degree) {
if (VERBOSE)
System.err.println("JoglPipeline.updateTextureCubeMapAnisotropicFilter()");
@@ -5963,10 +5483,10 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Helper routines for above texture methods
//
- private void updateTexture2DImage(Context ctx, int target, int numLevels, int level, int textureFormat, int imageFormat, int width,
- int height, int boundaryWidth, int dataType, Object data, boolean useAutoMipMap)
- {
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ private void updateTexture2DImage( Context ctx, int target, int numLevels, int level, int textureFormat,
+ int imageFormat, int width, int height, int boundaryWidth, int dataType,
+ Object data, boolean useAutoMipMap) {
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
// FIXME: there is a new call glGenerateMipmap() which is only in ES2 not GL2 so on pure ES2
// add back in checking for mipmap support under properties, then add that call after bind texture
@@ -5994,29 +5514,28 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int internalFormat = 0;
- switch (textureFormat)
- {
- case Texture.INTENSITY:
- new Throwable("Texture.INTENSITY not supported").printStackTrace();
- // internalFormat = GL2.GL_INTENSITY;
- break;
- case Texture.LUMINANCE:
- internalFormat = GL2ES2.GL_LUMINANCE;
- break;
- case Texture.ALPHA:
- internalFormat = GL2ES2.GL_ALPHA;
- break;
- case Texture.LUMINANCE_ALPHA:
- internalFormat = GL2ES2.GL_LUMINANCE_ALPHA;
- break;
- case Texture.RGB:
- internalFormat = GL2ES2.GL_RGB;
- break;
- case Texture.RGBA:
- internalFormat = GL2ES2.GL_RGBA;
- break;
- default:
- assert false;
+ switch (textureFormat) {
+ case Texture.INTENSITY:
+ new Throwable("Texture.INTENSITY not supported").printStackTrace();
+ // internalFormat = GL2.GL_INTENSITY;
+ break;
+ case Texture.LUMINANCE:
+ internalFormat = GL2ES2.GL_LUMINANCE;
+ break;
+ case Texture.ALPHA:
+ internalFormat = GL2ES2.GL_ALPHA;
+ break;
+ case Texture.LUMINANCE_ALPHA:
+ internalFormat = GL2ES2.GL_LUMINANCE_ALPHA;
+ break;
+ case Texture.RGB:
+ internalFormat = GL2ES2.GL_RGB;
+ break;
+ case Texture.RGBA:
+ internalFormat = GL2ES2.GL_RGBA;
+ break;
+ default:
+ assert false;
}
boolean createMipMaps = useAutoMipMap;
@@ -6024,192 +5543,167 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int format = 0;
if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY)
- || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER))
- {
+ || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
- switch (imageFormat)
- {
- case ImageComponentRetained.TYPE_BYTE_BGR:
- format = GL2ES2.GL_BGR;
- break;
- case ImageComponentRetained.TYPE_BYTE_RGB:
- format = GL2ES2.GL_RGB;
- break;
- case ImageComponentRetained.TYPE_BYTE_ABGR:
- if (isExtensionAvailable.GL_EXT_abgr(gl))
- {
- // If its zero, should never come here!
- format = GL2.GL_ABGR_EXT;
- }
- else
- {
+ switch (imageFormat) {
+ case ImageComponentRetained.TYPE_BYTE_BGR:
+ format = GL2ES2.GL_BGR;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_RGB:
+ format = GL2ES2.GL_RGB;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_ABGR:
+ if (isExtensionAvailable.GL_EXT_abgr(gl)) {
+ // If its zero, should never come here!
+ format = GL2.GL_ABGR_EXT;
+ } else {
+ assert false;
+ return;
+ }
+ break;
+ case ImageComponentRetained.TYPE_BYTE_RGBA:
+ // all RGB types are stored as RGBA
+ format = GL2ES2.GL_RGBA;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_LA:
+ // all LA types are stored as LA8
+ format = GL2ES2.GL_LUMINANCE_ALPHA;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_GRAY:
+ if (internalFormat == GL2ES2.GL_ALPHA) {
+ format = GL2ES2.GL_ALPHA;
+ } else {
+ format = GL2ES2.GL_LUMINANCE;
+ }
+ break;
+ /////////////////////////////////////////////////// PJPJPJ////////////////////
+ // DXT uncompressed D3DFMT_A8R8G8B8 indicator
+ case GL2.GL_RGBA_S3TC:
+ internalFormat = GL2ES2.GL_RGBA;
+ format = GL2ES2.GL_RGBA;
+ break;
+ // notice fall through
+ // DXT
+ case GL2ES2.GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL2ES2.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL2ES2.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL2.GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ // ETC2
+ // https://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexImage2D.xhtml
+ case GL3.GL_COMPRESSED_RGBA8_ETC2_EAC:
+ case GL3.GL_COMPRESSED_RGB8_ETC2:
+ case GL3.GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ case GL3.GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ case GL3.GL_COMPRESSED_SRGB8_ETC2:
+ case GL3.GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ // ASTC
+ case GL3.GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_6x5_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_6x6_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_8x6_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_10x5_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_10x6_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_10x8_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_10x10_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_12x10_KHR:
+ case GL3.GL_COMPRESSED_RGBA_ASTC_12x12_KHR:
+ internalFormat = imageFormat;
+ format = -1;// indicate compressed
+ break;
+ case ImageComponentRetained.TYPE_USHORT_GRAY:
+ case ImageComponentRetained.TYPE_INT_BGR:
+ case ImageComponentRetained.TYPE_INT_RGB:
+ case ImageComponentRetained.TYPE_INT_ARGB:
+ default:
assert false;
return;
- }
- break;
- case ImageComponentRetained.TYPE_BYTE_RGBA:
- // all RGB types are stored as RGBA
- format = GL2ES2.GL_RGBA;
- break;
- case ImageComponentRetained.TYPE_BYTE_LA:
- // all LA types are stored as LA8
- format = GL2ES2.GL_LUMINANCE_ALPHA;
- break;
- case ImageComponentRetained.TYPE_BYTE_GRAY:
- if (internalFormat == GL2ES2.GL_ALPHA)
- {
- format = GL2ES2.GL_ALPHA;
- }
- else
- {
- format = GL2ES2.GL_LUMINANCE;
- }
- break;
- /////////////////////////////////////////////////// PJPJPJ////////////////////
- // DXT uncompressed D3DFMT_A8R8G8B8 indicator
- case GL2.GL_RGBA_S3TC:
- internalFormat = GL2ES2.GL_RGBA;
- format = GL2ES2.GL_RGBA;
- break;
- // notice fall through
- // DXT
- case GL2ES2.GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL2ES2.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL2ES2.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- case GL2.GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
- // ETC2
- // https://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexImage2D.xhtml
- case GL3.GL_COMPRESSED_RGBA8_ETC2_EAC:
- case GL3.GL_COMPRESSED_RGB8_ETC2:
- case GL3.GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
- case GL3.GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
- case GL3.GL_COMPRESSED_SRGB8_ETC2:
- case GL3.GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
- // ASTC
- case GL3.GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_6x5_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_6x6_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_8x6_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_10x5_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_10x6_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_10x8_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_10x10_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_12x10_KHR:
- case GL3.GL_COMPRESSED_RGBA_ASTC_12x12_KHR:
- internalFormat = imageFormat;
- format = -1;// indicate compressed
- break;
- case ImageComponentRetained.TYPE_USHORT_GRAY:
- case ImageComponentRetained.TYPE_INT_BGR:
- case ImageComponentRetained.TYPE_INT_RGB:
- case ImageComponentRetained.TYPE_INT_ARGB:
- default:
- assert false;
- return;
}
- if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY)
- {
- gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE,
- ByteBuffer.wrap((byte[]) data));
+ if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
+ gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format,
+ GL2ES2.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[])data));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
- if (format == -1)
- {
-
- ByteBuffer bb = (ByteBuffer) data;
+ } else {
+ if (format == -1) {
- gl.glCompressedTexImage2D(target, level, internalFormat, width, height, boundaryWidth, bb.limit(), bb);
+ ByteBuffer bb = (ByteBuffer)data;
- if (DO_OUTPUT_ERRORS)
- {
+ gl.glCompressedTexImage2D(target, level, internalFormat, width, height, boundaryWidth, bb.limit(),
+ bb);
+
+ if (DO_OUTPUT_ERRORS) {
int err = gl.glGetError();
- if (err != GL2ES2.GL_NO_ERROR)
- {
- System.out.println("glCompressedTexImage2D Error " + err + " target " + target + " level " + level
- + " internalFormat " + internalFormat);
- System.out.println("width " + width + " height " + height + " boundaryWidth " + boundaryWidth + " bb.limit() "
- + bb.limit());
+ if (err != GL2ES2.GL_NO_ERROR) {
+ System.out.println("glCompressedTexImage2D Error " + err + " target " + target + " level "
+ + level + " internalFormat " + internalFormat);
+ System.out.println("width " + width + " height " + height + " boundaryWidth "
+ + boundaryWidth + " bb.limit() " + bb.limit());
// https://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexImage2D.xhtml
}
}
- }
- else
- {
- gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE,
- (Buffer) data);
- if (DO_OUTPUT_ERRORS)
- {
+ } else {
+ gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format,
+ GL2ES2.GL_UNSIGNED_BYTE, (Buffer)data);
+ if (DO_OUTPUT_ERRORS) {
int err = gl.glGetError();
- if (err != GL2ES2.GL_NO_ERROR)
- {
- System.out.println("glTexImage2D Error " + err + " target " + target + " level " + level + " internalFormat "
- + internalFormat);
- System.out.println("width " + width + " height " + height + " boundaryWidth " + boundaryWidth + " format "
- + format + " bb.limit() " + ((Buffer) data).limit());
+ if (err != GL2ES2.GL_NO_ERROR) {
+ System.out.println("glTexImage2D Error " + err + " target " + target + " level " + level
+ + " internalFormat " + internalFormat);
+ System.out
+ .println("width " + width + " height " + height + " boundaryWidth " + boundaryWidth
+ + " format " + format + " bb.limit() " + ((Buffer)data).limit());
// https://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexImage2D.xhtml
}
}
}
}
- }
- else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
- || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER))
- {
- switch (imageFormat)
- {
- case ImageComponentRetained.TYPE_INT_BGR:
- //PJ does this work correctly?
- format = GL2ES2.GL_RGB;
- break;
- case ImageComponentRetained.TYPE_INT_RGB:
- format = GL2ES2.GL_RGB;
- break;
- case ImageComponentRetained.TYPE_INT_ARGB:
- format = GL2ES2.GL_RGBA;
- break;
- // This method only supports 3 and 4 components formats and INT types.
- case ImageComponentRetained.TYPE_BYTE_LA:
- case ImageComponentRetained.TYPE_BYTE_GRAY:
- case ImageComponentRetained.TYPE_USHORT_GRAY:
- case ImageComponentRetained.TYPE_BYTE_BGR:
- case ImageComponentRetained.TYPE_BYTE_RGB:
- case ImageComponentRetained.TYPE_BYTE_RGBA:
- case ImageComponentRetained.TYPE_BYTE_ABGR:
- default:
- assert false;
- return;
+ } else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
+ || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) {
+ switch (imageFormat) {
+ case ImageComponentRetained.TYPE_INT_BGR:
+ //PJ does this work correctly?
+ format = GL2ES2.GL_RGB;
+ break;
+ case ImageComponentRetained.TYPE_INT_RGB:
+ format = GL2ES2.GL_RGB;
+ break;
+ case ImageComponentRetained.TYPE_INT_ARGB:
+ format = GL2ES2.GL_RGBA;
+ break;
+ // This method only supports 3 and 4 components formats and INT types.
+ case ImageComponentRetained.TYPE_BYTE_LA:
+ case ImageComponentRetained.TYPE_BYTE_GRAY:
+ case ImageComponentRetained.TYPE_USHORT_GRAY:
+ case ImageComponentRetained.TYPE_BYTE_BGR:
+ case ImageComponentRetained.TYPE_BYTE_RGB:
+ case ImageComponentRetained.TYPE_BYTE_RGBA:
+ case ImageComponentRetained.TYPE_BYTE_ABGR:
+ default:
+ assert false;
+ return;
}
- if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
- {
- gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE,
- IntBuffer.wrap((int[]) data));
+ if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
+ gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format,
+ GL2ES2.GL_UNSIGNED_BYTE, IntBuffer.wrap((int[])data));
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
- gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format, GL2ES2.GL_UNSIGNED_BYTE,
- (Buffer) data);
+ } else {
+ gl.glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, format,
+ GL2ES2.GL_UNSIGNED_BYTE, (Buffer)data);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
}
- }
- else
- {
+ } else {
assert false;
}
- if(createMipMaps && level == 0)
- {
+ if (createMipMaps && level == 0) {
gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_LINEAR_MIPMAP_LINEAR);
gl.glHint(GL.GL_GENERATE_MIPMAP_HINT, GL.GL_NICEST);
gl.glGenerateMipmap(target);
@@ -6221,112 +5715,99 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
- private void updateTexture2DSubImage(Context ctx, int target, int level, int xoffset, int yoffset, int textureFormat, int imageFormat,
- int imgXOffset, int imgYOffset, int tilew, int width, int height, int dataType, Object data)
- {
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ private void updateTexture2DSubImage( Context ctx, int target, int level, int xoffset, int yoffset,
+ int textureFormat, int imageFormat, int imgXOffset, int imgYOffset,
+ int tilew, int width, int height, int dataType, Object data) {
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
- if (imgXOffset > 0 || (width < tilew))
- {
+ if (imgXOffset > 0 || (width < tilew)) {
// PJ not sure what should be happening here
// new Throwable("(imgXOffset > 0 || (width < tilew))").printStackTrace();
}
int internalFormat = 0;
- switch (textureFormat)
- {
- case Texture.INTENSITY:
- // internalFormat = GL2.GL_INTENSITY;
- new Throwable("Texture.INTENSITY not supported").printStackTrace();
- break;
- case Texture.LUMINANCE:
- internalFormat = GL2ES2.GL_LUMINANCE;
- break;
- case Texture.ALPHA:
- internalFormat = GL2ES2.GL_ALPHA;
- break;
- case Texture.LUMINANCE_ALPHA:
- internalFormat = GL2ES2.GL_LUMINANCE_ALPHA;
- break;
- case Texture.RGB:
- internalFormat = GL2ES2.GL_RGB;
- break;
- case Texture.RGBA:
- internalFormat = GL2ES2.GL_RGBA;
- break;
- default:
- assert false;
+ switch (textureFormat) {
+ case Texture.INTENSITY:
+ // internalFormat = GL2.GL_INTENSITY;
+ new Throwable("Texture.INTENSITY not supported").printStackTrace();
+ break;
+ case Texture.LUMINANCE:
+ internalFormat = GL2ES2.GL_LUMINANCE;
+ break;
+ case Texture.ALPHA:
+ internalFormat = GL2ES2.GL_ALPHA;
+ break;
+ case Texture.LUMINANCE_ALPHA:
+ internalFormat = GL2ES2.GL_LUMINANCE_ALPHA;
+ break;
+ case Texture.RGB:
+ internalFormat = GL2ES2.GL_RGB;
+ break;
+ case Texture.RGBA:
+ internalFormat = GL2ES2.GL_RGBA;
+ break;
+ default:
+ assert false;
}
if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY)
- || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER))
- {
+ || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
int format = 0;
int numBytes = 0;
- switch (imageFormat)
- {
- case ImageComponentRetained.TYPE_BYTE_BGR:
- format = GL2ES2.GL_BGR;
- numBytes = 3;
- break;
- case ImageComponentRetained.TYPE_BYTE_RGB:
- format = GL2ES2.GL_RGB;
- numBytes = 3;
- break;
- case ImageComponentRetained.TYPE_BYTE_ABGR:
- if (isExtensionAvailable.GL_EXT_abgr(gl))
- {
- // If its zero, should never come here!
- format = GL2.GL_ABGR_EXT;
+ switch (imageFormat) {
+ case ImageComponentRetained.TYPE_BYTE_BGR:
+ format = GL2ES2.GL_BGR;
+ numBytes = 3;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_RGB:
+ format = GL2ES2.GL_RGB;
+ numBytes = 3;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_ABGR:
+ if (isExtensionAvailable.GL_EXT_abgr(gl)) {
+ // If its zero, should never come here!
+ format = GL2.GL_ABGR_EXT;
+ numBytes = 4;
+ } else {
+ assert false;
+ return;
+ }
+ break;
+ case ImageComponentRetained.TYPE_BYTE_RGBA:
+ // all RGB types are stored as RGBA
+ format = GL2ES2.GL_RGBA;
numBytes = 4;
- }
- else
- {
+ break;
+ case ImageComponentRetained.TYPE_BYTE_LA:
+ // all LA types are stored as LA8
+ format = GL2ES2.GL_LUMINANCE_ALPHA;
+ numBytes = 2;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_GRAY:
+ if (internalFormat == GL2ES2.GL_ALPHA) {
+ format = GL2ES2.GL_ALPHA;
+ numBytes = 1;
+ } else {
+ format = GL2ES2.GL_LUMINANCE;
+ numBytes = 1;
+ }
+ break;
+ case ImageComponentRetained.TYPE_USHORT_GRAY:
+ case ImageComponentRetained.TYPE_INT_BGR:
+ case ImageComponentRetained.TYPE_INT_RGB:
+ case ImageComponentRetained.TYPE_INT_ARGB:
+ default:
assert false;
return;
- }
- break;
- case ImageComponentRetained.TYPE_BYTE_RGBA:
- // all RGB types are stored as RGBA
- format = GL2ES2.GL_RGBA;
- numBytes = 4;
- break;
- case ImageComponentRetained.TYPE_BYTE_LA:
- // all LA types are stored as LA8
- format = GL2ES2.GL_LUMINANCE_ALPHA;
- numBytes = 2;
- break;
- case ImageComponentRetained.TYPE_BYTE_GRAY:
- if (internalFormat == GL2ES2.GL_ALPHA)
- {
- format = GL2ES2.GL_ALPHA;
- numBytes = 1;
- }
- else
- {
- format = GL2ES2.GL_LUMINANCE;
- numBytes = 1;
- }
- break;
- case ImageComponentRetained.TYPE_USHORT_GRAY:
- case ImageComponentRetained.TYPE_INT_BGR:
- case ImageComponentRetained.TYPE_INT_RGB:
- case ImageComponentRetained.TYPE_INT_ARGB:
- default:
- assert false;
- return;
}
ByteBuffer buf = null;
- if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY)
- {
- buf = ByteBuffer.wrap((byte[]) data);
- }
- else
- {
- buf = (ByteBuffer) data;
+ if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
+ buf = ByteBuffer.wrap((byte[])data);
+ } else {
+ buf = (ByteBuffer)data;
}
// offset by the imageOffset
@@ -6334,44 +5815,38 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gl.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, buf);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
- || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER))
- {
+ } else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
+ || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) {
int format = 0;
- switch (imageFormat)
- {
- case ImageComponentRetained.TYPE_INT_BGR:
- //PJ does this work correctly?
- format = GL2ES2.GL_RGB;
- break;
- case ImageComponentRetained.TYPE_INT_RGB:
- format = GL2ES2.GL_RGB;
- break;
- case ImageComponentRetained.TYPE_INT_ARGB:
- format = GL2ES2.GL_RGBA;
- break;
- // This method only supports 3 and 4 components formats and INT types.
- case ImageComponentRetained.TYPE_BYTE_LA:
- case ImageComponentRetained.TYPE_BYTE_GRAY:
- case ImageComponentRetained.TYPE_USHORT_GRAY:
- case ImageComponentRetained.TYPE_BYTE_BGR:
- case ImageComponentRetained.TYPE_BYTE_RGB:
- case ImageComponentRetained.TYPE_BYTE_RGBA:
- case ImageComponentRetained.TYPE_BYTE_ABGR:
- default:
- assert false;
- return;
+ switch (imageFormat) {
+ case ImageComponentRetained.TYPE_INT_BGR:
+ //PJ does this work correctly?
+ format = GL2ES2.GL_RGB;
+ break;
+ case ImageComponentRetained.TYPE_INT_RGB:
+ format = GL2ES2.GL_RGB;
+ break;
+ case ImageComponentRetained.TYPE_INT_ARGB:
+ format = GL2ES2.GL_RGBA;
+ break;
+ // This method only supports 3 and 4 components formats and INT types.
+ case ImageComponentRetained.TYPE_BYTE_LA:
+ case ImageComponentRetained.TYPE_BYTE_GRAY:
+ case ImageComponentRetained.TYPE_USHORT_GRAY:
+ case ImageComponentRetained.TYPE_BYTE_BGR:
+ case ImageComponentRetained.TYPE_BYTE_RGB:
+ case ImageComponentRetained.TYPE_BYTE_RGBA:
+ case ImageComponentRetained.TYPE_BYTE_ABGR:
+ default:
+ assert false;
+ return;
}
IntBuffer buf = null;
- if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
- {
- buf = IntBuffer.wrap((int[]) data);
- }
- else
- {
- buf = (IntBuffer) data;
+ if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
+ buf = IntBuffer.wrap((int[])data);
+ } else {
+ buf = (IntBuffer)data;
}
// offset by the imageOffset
@@ -6379,9 +5854,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gl.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, GL2ES2.GL_UNSIGNED_BYTE, buf);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
+ } else {
assert false;
return;
}
@@ -6391,9 +5864,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
- private static void updateTextureFilterModes(Context ctx, int target, int minFilter, int magFilter)
- {
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ private static void updateTextureFilterModes(Context ctx, int target, int minFilter, int magFilter) {
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
// FIXME: unclear whether we really need to set up the enum values
// in the JoglContext as is done in the native code depending on
@@ -6401,61 +5873,58 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// behavior of the various Java3D modes
// set texture min filter
- switch (minFilter)
- {
- case Texture.FASTEST:
- case Texture.BASE_LEVEL_POINT:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_NEAREST);
- break;
- case Texture.BASE_LEVEL_LINEAR:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_LINEAR);
- break;
- case Texture.MULTI_LEVEL_POINT:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_NEAREST_MIPMAP_NEAREST);
- break;
- case Texture.NICEST:
- case Texture.MULTI_LEVEL_LINEAR:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_LINEAR_MIPMAP_LINEAR);
- break;
- case Texture.FILTER4:
- // We should never get here as we've disabled the FILTER4 feature
- // gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER,
- // GL2ES2.GL_FILTER4_SGIS);
- break;
+ switch (minFilter) {
+ case Texture.FASTEST:
+ case Texture.BASE_LEVEL_POINT:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_NEAREST);
+ break;
+ case Texture.BASE_LEVEL_LINEAR:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_LINEAR);
+ break;
+ case Texture.MULTI_LEVEL_POINT:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_NEAREST_MIPMAP_NEAREST);
+ break;
+ case Texture.NICEST:
+ case Texture.MULTI_LEVEL_LINEAR:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER, GL2ES2.GL_LINEAR_MIPMAP_LINEAR);
+ break;
+ case Texture.FILTER4:
+ // We should never get here as we've disabled the FILTER4 feature
+ // gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MIN_FILTER,
+ // GL2ES2.GL_FILTER4_SGIS);
+ break;
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
// set texture mag filter
- switch (magFilter)
- {
- case Texture.FASTEST:
- case Texture.BASE_LEVEL_POINT:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MAG_FILTER, GL2ES2.GL_NEAREST);
- break;
- case Texture.NICEST:
- case Texture.BASE_LEVEL_LINEAR:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MAG_FILTER, GL2ES2.GL_LINEAR);
- break;
- case Texture.LINEAR_SHARPEN:
- case Texture.LINEAR_SHARPEN_RGB:
- case Texture.LINEAR_SHARPEN_ALPHA:
- case Texture2D.LINEAR_DETAIL:
- case Texture2D.LINEAR_DETAIL_RGB:
- case Texture2D.LINEAR_DETAIL_ALPHA:
- case Texture.FILTER4:
- default:
- assert false;
- return;
+ switch (magFilter) {
+ case Texture.FASTEST:
+ case Texture.BASE_LEVEL_POINT:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MAG_FILTER, GL2ES2.GL_NEAREST);
+ break;
+ case Texture.NICEST:
+ case Texture.BASE_LEVEL_LINEAR:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_MAG_FILTER, GL2ES2.GL_LINEAR);
+ break;
+ case Texture.LINEAR_SHARPEN:
+ case Texture.LINEAR_SHARPEN_RGB:
+ case Texture.LINEAR_SHARPEN_ALPHA:
+ case Texture2D.LINEAR_DETAIL:
+ case Texture2D.LINEAR_DETAIL_RGB:
+ case Texture2D.LINEAR_DETAIL_ALPHA:
+ case Texture.FILTER4:
+ default:
+ assert false;
+ return;
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
}
- void updateTextureBoundary(Context ctx, int target, int boundaryModeS, int boundaryModeT, int boundaryModeR, float boundaryRed,
- float boundaryGreen, float boundaryBlue, float boundaryAlpha)
- {
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ void updateTextureBoundary( Context ctx, int target, int boundaryModeS, int boundaryModeT, int boundaryModeR,
+ float boundaryRed, float boundaryGreen, float boundaryBlue, float boundaryAlpha) {
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
// except the R gear at bottom and boundary color
// but I'm dropping 3dtexture support so no probs and who cares about boundary color
@@ -6463,37 +5932,35 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// FIXME: GL_MIRRORED_REPEAT needs to be added
// set texture wrap parameter
- switch (boundaryModeS)
- {
- case Texture.WRAP:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_REPEAT);
- break;
- case Texture.CLAMP:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_EDGE);
- break;
- case Texture.CLAMP_TO_EDGE:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_EDGE);
- break;
- case Texture.CLAMP_TO_BOUNDARY:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_EDGE);
- break;
+ switch (boundaryModeS) {
+ case Texture.WRAP:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_REPEAT);
+ break;
+ case Texture.CLAMP:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_EDGE);
+ break;
+ case Texture.CLAMP_TO_EDGE:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_EDGE);
+ break;
+ case Texture.CLAMP_TO_BOUNDARY:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_EDGE);
+ break;
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- switch (boundaryModeT)
- {
- case Texture.WRAP:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_REPEAT);
- break;
- case Texture.CLAMP:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_EDGE);
- break;
- case Texture.CLAMP_TO_EDGE:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_EDGE);
- break;
- case Texture.CLAMP_TO_BOUNDARY:
- gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_EDGE);
- break;
+ switch (boundaryModeT) {
+ case Texture.WRAP:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_REPEAT);
+ break;
+ case Texture.CLAMP:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_EDGE);
+ break;
+ case Texture.CLAMP_TO_EDGE:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_EDGE);
+ break;
+ case Texture.CLAMP_TO_BOUNDARY:
+ gl.glTexParameteri(target, GL2ES2.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_EDGE);
+ break;
}
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -6535,26 +6002,25 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// mapping from java enum to gl enum
- private static final int[] _gl_textureCubeMapFace = { GL2ES2.GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL2ES2.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
- GL2ES2.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL2ES2.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL2ES2.GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
- GL2ES2.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, };
+ private static final int[] _gl_textureCubeMapFace = {GL2ES2.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
+ GL2ES2.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL2ES2.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
+ GL2ES2.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL2ES2.GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
+ GL2ES2.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,};
// The following three methods are used in multi-pass case
// native method for setting blend color
@Override
- void setBlendColor(Context ctx, float red, float green, float blue, float alpha)
- {
+ void setBlendColor(Context ctx, float red, float green, float blue, float alpha) {
if (VERBOSE)
System.err.println("JoglPipeline.setBlendColor()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setBlendColor++;
+ ((Jogl2es2Context)ctx).perFrameStats.setBlendColor++;
GL2ES2 gl = null;// get late expensive
- if (isExtensionAvailable.GL_ARB_imaging(gl))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (isExtensionAvailable.GL_ARB_imaging(gl)) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glBlendColor(red, green, blue, alpha);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -6564,26 +6030,24 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting blend func
@Override
- void setBlendFunc(Context ctx, int srcBlendFunction, int dstBlendFunction)
- {
+ void setBlendFunc(Context ctx, int srcBlendFunction, int dstBlendFunction) {
if (VERBOSE)
System.err.println("JoglPipeline.setBlendFunc()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setBlendFunc++;
+ ((Jogl2es2Context)ctx).perFrameStats.setBlendFunc++;
GL2ES2 gl = null;// get late expensive
- Jogl2es2Context joglesctx = ((Jogl2es2Context) ctx);
+ Jogl2es2Context joglesctx = ((Jogl2es2Context)ctx);
- if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY || (joglesctx.gl_state.glEnableGL_BLEND != true
- || joglesctx.gl_state.srcBlendFunction != srcBlendFunction || joglesctx.gl_state.dstBlendFunction != dstBlendFunction))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (!MINIMISE_NATIVE_CALLS_TRANSPARENCY
+ || (joglesctx.gl_state.glEnableGL_BLEND != true || joglesctx.gl_state.srcBlendFunction != srcBlendFunction
+ || joglesctx.gl_state.dstBlendFunction != dstBlendFunction)) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glEnable(GL2ES2.GL_BLEND);
- gl.glBlendFunc(blendFunctionTable[srcBlendFunction], blendFunctionTable[dstBlendFunction]);
+ gl.glBlendFunc(blendFunctionTable [srcBlendFunction], blendFunctionTable [dstBlendFunction]);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- if (MINIMISE_NATIVE_CALLS_TRANSPARENCY)
- {
+ if (MINIMISE_NATIVE_CALLS_TRANSPARENCY) {
joglesctx.gl_state.glEnableGL_BLEND = true;
joglesctx.gl_state.srcBlendFunction = srcBlendFunction;
joglesctx.gl_state.dstBlendFunction = dstBlendFunction;
@@ -6593,79 +6057,74 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting light enables
@Override
- void setLightEnables(Context ctx, long enableMask, int maxLights)
- {
+ void setLightEnables(Context ctx, long enableMask, int maxLights) {
if (VERBOSE)
System.err.println("JoglPipeline.setLightEnables()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setLightEnables++;
+ ((Jogl2es2Context)ctx).perFrameStats.setLightEnables++;
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
joglesctx.maxLights = maxLights;
joglesctx.numberOfLights = 0;
- for (int i = 0; i < maxLights; i++)
- {
+ for (int i = 0; i < maxLights; i++) {
boolean enable = (enableMask & (1 << i)) >> i != 0;
- if (joglesctx.glLightSource[i] == null)
- {
- joglesctx.glLightSource[i] = new glLightSource();
+ if (joglesctx.glLightSource [i] == null) {
+ joglesctx.glLightSource [i] = new glLightSource();
}
- joglesctx.glLightSource[i].enabled = enable ? 1 : 0;
+ joglesctx.glLightSource [i].enabled = enable ? 1 : 0;
joglesctx.numberOfLights += enable ? 1 : 0;
// clear gl_state
- joglesctx.gl_state.glLightSource[i] = null; // this is a pointer not a container
+ joglesctx.gl_state.glLightSource [i] = null; // this is a pointer not a container
}
}
// native method for setting scene ambient
@Override
- void setSceneAmbient(Context ctx, float red, float green, float blue)
- {
+ void setSceneAmbient(Context ctx, float red, float green, float blue) {
if (VERBOSE)
System.err.println("JoglPipeline.setSceneAmbient()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setSceneAmbient++;
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
+ ((Jogl2es2Context)ctx).perFrameStats.setSceneAmbient++;
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
// do we need to push onto the shader now?
- if (joglesctx.currentAmbientColor.x != red || joglesctx.currentAmbientColor.y != green || joglesctx.currentAmbientColor.z != blue)
- { joglesctx.gl_state.glLightModelambient.x = Float.NEGATIVE_INFINITY;
+ if (joglesctx.currentAmbientColor.x != red || joglesctx.currentAmbientColor.y != green
+ || joglesctx.currentAmbientColor.z != blue) {
+ joglesctx.gl_state.glLightModelambient.x = Float.NEGATIVE_INFINITY;
- joglesctx.currentAmbientColor.x = red;
- joglesctx.currentAmbientColor.y = green;
- joglesctx.currentAmbientColor.z = blue;
- joglesctx.currentAmbientColor.w = 1.0f;}
+ joglesctx.currentAmbientColor.x = red;
+ joglesctx.currentAmbientColor.y = green;
+ joglesctx.currentAmbientColor.z = blue;
+ joglesctx.currentAmbientColor.w = 1.0f;
+ }
}
// native method for disabling modelClip
// this is called as a reset
@Override
- void disableModelClip(Context ctx)
- {
+ void disableModelClip(Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.disableModelClip()");
}
// native method for activating a particular texture unit
@Override
- void activeTextureUnit(Context ctx, int texUnitIndex)
- {
+ void activeTextureUnit(Context ctx, int texUnitIndex) {
if (VERBOSE)
System.err.println("JoglPipeline.activeTextureUnit(texUnitIndex= " + texUnitIndex + ")");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.activeTextureUnit++;
+ ((Jogl2es2Context)ctx).perFrameStats.activeTextureUnit++;
- Jogl2es2Context joglesContext = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesContext = (Jogl2es2Context)ctx;
GL2ES2 gl = null;// get late expensive
- if (texUnitIndex >= 0)
- {
- if (!MINIMISE_NATIVE_CALLS_TEXTURE || (joglesContext.gl_state.glActiveTexture != (texUnitIndex + GL2ES2.GL_TEXTURE0)))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (texUnitIndex >= 0) {
+ if (!MINIMISE_NATIVE_CALLS_TEXTURE
+ || (joglesContext.gl_state.glActiveTexture != (texUnitIndex + GL2ES2.GL_TEXTURE0))) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glActiveTexture(texUnitIndex + GL2ES2.GL_TEXTURE0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -6677,21 +6136,19 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// native method for setting default texture
@Override
- void resetTextureNative(Context ctx, int texUnitIndex)
- {
+ void resetTextureNative(Context ctx, int texUnitIndex) {
if (VERBOSE)
System.err.println("JoglPipeline.resetTextureNative(texUnitIndex=" + texUnitIndex + ")");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.resetTextureNative++;
+ ((Jogl2es2Context)ctx).perFrameStats.resetTextureNative++;
- Jogl2es2Context joglesContext = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesContext = (Jogl2es2Context)ctx;
GL2ES2 gl = null;// get late expensive
- if (texUnitIndex >= 0)
- {
- if (!MINIMISE_NATIVE_CALLS_TEXTURE || (joglesContext.gl_state.glActiveTexture != (texUnitIndex + GL2ES2.GL_TEXTURE0)))
- {
- gl = gl == null ? ((Jogl2es2Context) ctx).gl2es2() : gl;
+ if (texUnitIndex >= 0) {
+ if (!MINIMISE_NATIVE_CALLS_TEXTURE
+ || (joglesContext.gl_state.glActiveTexture != (texUnitIndex + GL2ES2.GL_TEXTURE0))) {
+ gl = gl == null ? ((Jogl2es2Context)ctx).gl2es2() : gl;
gl.glActiveTexture(texUnitIndex + GL2ES2.GL_TEXTURE0);
// TODO: should I bind these to 0?
// gl.glBindTexture(GL2ES2.GL_TEXTURE_2D, 0);//-1 is no texture , 0 is default
@@ -6706,15 +6163,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// The native method for setting the ModelView matrix.
@Override
- void setModelViewMatrix(Context ctx, double[] viewMatrix, double[] modelMatrix)
- {
+ void setModelViewMatrix(Context ctx, double[] viewMatrix, double[] modelMatrix) {
if (VERBOSE)
- System.err.println("JoglPipeline.setModelViewMatrix(viewMatrix= " + lineString(viewMatrix) + " modelMatrix= "
- + lineString(modelMatrix) + ")");
+ System.err.println("JoglPipeline.setModelViewMatrix(viewMatrix= " + lineString(viewMatrix)
+ + " modelMatrix= " + lineString(modelMatrix) + ")");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setModelViewMatrix++;
+ ((Jogl2es2Context)ctx).perFrameStats.setModelViewMatrix++;
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
//joglesctx.matrixUtil.deburnV.set(viewMatrix);
//joglesctx.matrixUtil.deburnV.transpose();// now done in ffp by call to native
@@ -6724,7 +6180,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
//joglesctx.matrixUtil.deburnM.transpose();// now done in ffp by call to native
joglesctx.currentModelMat.set(modelMatrix);
- joglesctx.gl_state.modelMatrix.m00 = Double.NEGATIVE_INFINITY;// indicate needs pushing onto shader
+ joglesctx.gl_state.glModelMatrix.m00 = Double.NEGATIVE_INFINITY;// indicate needs pushing onto shader
joglesctx.gl_state.glModelViewMatrix.m00 = Double.NEGATIVE_INFINITY;
joglesctx.gl_state.glModelViewMatrixInverse.m00 = Double.NEGATIVE_INFINITY;
joglesctx.gl_state.glModelViewProjectionMatrix.m00 = Double.NEGATIVE_INFINITY;
@@ -6753,62 +6209,58 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// The native method for setting the Projection matrix.
@Override
- void setProjectionMatrix(Context ctx, double[] projMatrix)
- {
+ void setProjectionMatrix(Context ctx, double[] projMatrix) {
if (VERBOSE)
System.err.println("JoglPipeline.setProjectionMatrix()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setProjectionMatrix++;
+ ((Jogl2es2Context)ctx).perFrameStats.setProjectionMatrix++;
- Jogl2es2Context joglesctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context joglesctx = (Jogl2es2Context)ctx;
// Invert the Z value in clipping coordinates because OpenGL uses
// left-handed clipping coordinates, while Java3D defines right-handed
// coordinates everywhere.
- projMatrix[8] *= -1.0;
- projMatrix[9] *= -1.0;
- projMatrix[10] *= -1.0;
- projMatrix[11] *= -1.0;
+ projMatrix [8] *= -1.0;
+ projMatrix [9] *= -1.0;
+ projMatrix [10] *= -1.0;
+ projMatrix [11] *= -1.0;
joglesctx.currentProjMat.set(projMatrix);
// joglesctx.currentProjMat.transpose(); // done in set ffp now
// reverse it back in case others use it
- projMatrix[8] *= -1.0;
- projMatrix[9] *= -1.0;
- projMatrix[10] *= -1.0;
- projMatrix[11] *= -1.0;
+ projMatrix [8] *= -1.0;
+ projMatrix [9] *= -1.0;
+ projMatrix [10] *= -1.0;
+ projMatrix [11] *= -1.0;
}
// The native method for setting the Viewport.
@Override
- void setViewport(Context ctx, int x, int y, int width, int height)
- {
+ void setViewport(Context ctx, int x, int y, int width, int height) {
if (VERBOSE)
System.err.println("JoglPipeline.setViewport()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setViewport++;
+ ((Jogl2es2Context)ctx).perFrameStats.setViewport++;
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setViewportTime = System.nanoTime();
+ ((Jogl2es2Context)ctx).perFrameStats.setViewportTime = System.nanoTime();
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glViewport(x, y, width, height);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
}
- private static String lineString(double[] da)
- {
+ private static String lineString(double[] da) {
String ret = "double[";
for (double d : da)
ret += " " + d;
return ret + "]";
}
- private static String lineString(float[] fa)
- {
+ private static String lineString(float[] fa) {
String ret = "float[";
for (float f : fa)
ret += " " + f;
@@ -6816,56 +6268,51 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void freeTexture(Context ctx, int id)
- {
+ void freeTexture(Context ctx, int id) {
if (VERBOSE)
System.err.println("JoglPipeline.freeTexture()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.freeTexture++;
+ ((Jogl2es2Context)ctx).perFrameStats.freeTexture++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
- if (id > 0)
- {
+ if (id > 0) {
int[] tmp = new int[1];
- tmp[0] = id;
+ tmp [0] = id;
gl.glDeleteTextures(1, tmp, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
+ } else {
System.err.println("tried to delete tex with texid <= 0");
}
}
@Override
- int generateTexID(Context ctx)
- {
+ int generateTexID(Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.generateTexID()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.generateTexID++;
+ ((Jogl2es2Context)ctx).perFrameStats.generateTexID++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
- int[] tmp = new int[] { -1 };
+ int[] tmp = new int[] {-1};
gl.glGenTextures(1, tmp, 0);
- if (tmp[0] < 1)
+ if (tmp [0] < 1)
return -1;
- return tmp[0];
+ return tmp [0];
}
@Override
- void texturemapping(Context ctx, int px, int py, int minX, int minY, int maxX, int maxY, int texWidth, int texHeight, int rasWidth,
- int format, int objectId, byte[] imageYdown, int winWidth, int winHeight)
- {
+ void texturemapping(Context ctx, int px, int py, int minX, int minY, int maxX, int maxY, int texWidth,
+ int texHeight, int rasWidth, int format, int objectId, byte[] imageYdown, int winWidth,
+ int winHeight) {
if (VERBOSE)
System.err.println("JoglPipeline.texturemapping()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
int glType = GL.GL_RGBA;
@@ -6882,31 +6329,27 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
-
- if (isExtensionAvailable.GL_EXT_abgr(gl))
- {
+
+ if (isExtensionAvailable.GL_EXT_abgr(gl)) {
glType = GL2.GL_ABGR_EXT;
- }
- else
- {
- switch (format)
- {
- case ImageComponentRetained.TYPE_BYTE_RGBA:
- glType = GL.GL_RGBA;
- break;
- case ImageComponentRetained.TYPE_BYTE_RGB:
- glType = GL.GL_RGB;
- break;
+ } else {
+ switch (format) {
+ case ImageComponentRetained.TYPE_BYTE_RGBA:
+ glType = GL.GL_RGBA;
+ break;
+ case ImageComponentRetained.TYPE_BYTE_RGB:
+ glType = GL.GL_RGB;
+ break;
}
}
gl.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, minX, minY, maxX - minX, maxY - minY, glType, GL.GL_UNSIGNED_BYTE,
ByteBuffer.wrap(imageYdown));
- float texMinU = (float) minX / (float) texWidth;
- float texMinV = (float) minY / (float) texHeight;
- float texMaxU = (float) maxX / (float) texWidth;
- float texMaxV = (float) maxY / (float) texHeight;
+ float texMinU = (float)minX / (float)texWidth;
+ float texMinV = (float)minY / (float)texHeight;
+ float texMaxU = (float)maxX / (float)texWidth;
+ float texMaxV = (float)maxY / (float)texHeight;
float halfWidth = winWidth / 2.0f;
float halfHeight = winHeight / 2.0f;
@@ -6926,22 +6369,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- boolean initTexturemapping(Context ctx, int texWidth, int texHeight, int objectId)
- {
+ boolean initTexturemapping(Context ctx, int texWidth, int texHeight, int objectId) {
if (VERBOSE)
System.err.println("JoglPipeline.initTexturemapping()");
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
gl.glBindTexture(GL.GL_TEXTURE_2D, objectId);
int glType = GL.GL_RGBA;
- if (isExtensionAvailable.GL_EXT_abgr(gl))
- {
+ if (isExtensionAvailable.GL_EXT_abgr(gl)) {
glType = GL2.GL_ABGR_EXT;
- }
- else
- {
+ } else {
glType = GL.GL_RGBA;
}
//some sort of memory space check below?
@@ -6963,21 +6402,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Set glDepthMask.
@Override
- void setDepthBufferWriteEnable(Context ctx, boolean mode)
- {
+ void setDepthBufferWriteEnable(Context ctx, boolean mode) {
if (VERBOSE)
System.err.println("JoglPipeline.setDepthBufferWriteEnable()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setDepthBufferWriteEnable++;
+ ((Jogl2es2Context)ctx).perFrameStats.setDepthBufferWriteEnable++;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
- if (mode)
- {
+ if (mode) {
gl.glDepthMask(true);
- }
- else
- {
+ } else {
gl.glDepthMask(false);
}
if (DO_OUTPUT_ERRORS)
@@ -6990,8 +6425,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// FIELD_RIGHT. The boolean doubleBuffer is TRUE for double buffered mode, FALSE
// for single buffering.
@Override
- void setRenderMode(Context ctx, int mode, boolean doubleBuffer)
- {
+ void setRenderMode(Context ctx, int mode, boolean doubleBuffer) {
if (VERBOSE)
System.err.println("JoglPipeline.setRenderMode()");
@@ -7000,9 +6434,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// geoms are drawn
// so I take the opportunity to unbind the vertex array
- GL2ES3 gl2es3 = ((Jogl2es2Context) ctx).gl2es3();
- if (gl2es3 != null)
- {
+ GL2ES3 gl2es3 = ((Jogl2es2Context)ctx).gl2es3();
+ if (gl2es3 != null) {
gl2es3.glBindVertexArray(0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -7049,61 +6482,57 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gl.glDrawBuffer(drawBuf);*/
}
- private static int getFunctionValue(int func)
- {
- switch (func)
- {
- case RenderingAttributes.ALWAYS:
- func = GL2ES2.GL_ALWAYS;
- break;
- case RenderingAttributes.NEVER:
- func = GL2ES2.GL_NEVER;
- break;
- case RenderingAttributes.EQUAL:
- func = GL2ES2.GL_EQUAL;
- break;
- case RenderingAttributes.NOT_EQUAL:
- func = GL2ES2.GL_NOTEQUAL;
- break;
- case RenderingAttributes.LESS:
- func = GL2ES2.GL_LESS;
- break;
- case RenderingAttributes.LESS_OR_EQUAL:
- func = GL2ES2.GL_LEQUAL;
- break;
- case RenderingAttributes.GREATER:
- func = GL2ES2.GL_GREATER;
- break;
- case RenderingAttributes.GREATER_OR_EQUAL:
- func = GL2ES2.GL_GEQUAL;
- break;
+ private static int getFunctionValue(int func) {
+ switch (func) {
+ case RenderingAttributes.ALWAYS:
+ func = GL2ES2.GL_ALWAYS;
+ break;
+ case RenderingAttributes.NEVER:
+ func = GL2ES2.GL_NEVER;
+ break;
+ case RenderingAttributes.EQUAL:
+ func = GL2ES2.GL_EQUAL;
+ break;
+ case RenderingAttributes.NOT_EQUAL:
+ func = GL2ES2.GL_NOTEQUAL;
+ break;
+ case RenderingAttributes.LESS:
+ func = GL2ES2.GL_LESS;
+ break;
+ case RenderingAttributes.LESS_OR_EQUAL:
+ func = GL2ES2.GL_LEQUAL;
+ break;
+ case RenderingAttributes.GREATER:
+ func = GL2ES2.GL_GREATER;
+ break;
+ case RenderingAttributes.GREATER_OR_EQUAL:
+ func = GL2ES2.GL_GEQUAL;
+ break;
}
return func;
}
- private static int getStencilOpValue(int op)
- {
- switch (op)
- {
- case RenderingAttributes.STENCIL_KEEP:
- op = GL2ES2.GL_KEEP;
- break;
- case RenderingAttributes.STENCIL_ZERO:
- op = GL2ES2.GL_ZERO;
- break;
- case RenderingAttributes.STENCIL_REPLACE:
- op = GL2ES2.GL_REPLACE;
- break;
- case RenderingAttributes.STENCIL_INCR:
- op = GL2ES2.GL_INCR;
- break;
- case RenderingAttributes.STENCIL_DECR:
- op = GL2ES2.GL_DECR;
- break;
- case RenderingAttributes.STENCIL_INVERT:
- op = GL2ES2.GL_INVERT;
- break;
+ private static int getStencilOpValue(int op) {
+ switch (op) {
+ case RenderingAttributes.STENCIL_KEEP:
+ op = GL2ES2.GL_KEEP;
+ break;
+ case RenderingAttributes.STENCIL_ZERO:
+ op = GL2ES2.GL_ZERO;
+ break;
+ case RenderingAttributes.STENCIL_REPLACE:
+ op = GL2ES2.GL_REPLACE;
+ break;
+ case RenderingAttributes.STENCIL_INCR:
+ op = GL2ES2.GL_INCR;
+ break;
+ case RenderingAttributes.STENCIL_DECR:
+ op = GL2ES2.GL_DECR;
+ break;
+ case RenderingAttributes.STENCIL_INVERT:
+ op = GL2ES2.GL_INVERT;
+ break;
}
return op;
@@ -7117,44 +6546,38 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
private static final int[] blendFunctionTable = new int[TransparencyAttributes.MAX_BLEND_FUNC_TABLE_SIZE];
- static
- {
- blendFunctionTable[TransparencyAttributes.BLEND_ZERO] = GL2ES2.GL_ZERO;
- blendFunctionTable[TransparencyAttributes.BLEND_ONE] = GL2ES2.GL_ONE;
- blendFunctionTable[TransparencyAttributes.BLEND_SRC_ALPHA] = GL2ES2.GL_SRC_ALPHA;
- blendFunctionTable[TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA] = GL2ES2.GL_ONE_MINUS_SRC_ALPHA;
- blendFunctionTable[TransparencyAttributes.BLEND_DST_COLOR] = GL2ES2.GL_DST_COLOR;
- blendFunctionTable[TransparencyAttributes.BLEND_ONE_MINUS_DST_COLOR] = GL2ES2.GL_ONE_MINUS_DST_COLOR;
- blendFunctionTable[TransparencyAttributes.BLEND_SRC_COLOR] = GL2ES2.GL_SRC_COLOR;
- blendFunctionTable[TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR] = GL2ES2.GL_ONE_MINUS_SRC_COLOR;
- blendFunctionTable[TransparencyAttributes.BLEND_CONSTANT_COLOR] = GL2ES2.GL_CONSTANT_COLOR;
+ static {
+ blendFunctionTable [TransparencyAttributes.BLEND_ZERO] = GL2ES2.GL_ZERO;
+ blendFunctionTable [TransparencyAttributes.BLEND_ONE] = GL2ES2.GL_ONE;
+ blendFunctionTable [TransparencyAttributes.BLEND_SRC_ALPHA] = GL2ES2.GL_SRC_ALPHA;
+ blendFunctionTable [TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA] = GL2ES2.GL_ONE_MINUS_SRC_ALPHA;
+ blendFunctionTable [TransparencyAttributes.BLEND_DST_COLOR] = GL2ES2.GL_DST_COLOR;
+ blendFunctionTable [TransparencyAttributes.BLEND_ONE_MINUS_DST_COLOR] = GL2ES2.GL_ONE_MINUS_DST_COLOR;
+ blendFunctionTable [TransparencyAttributes.BLEND_SRC_COLOR] = GL2ES2.GL_SRC_COLOR;
+ blendFunctionTable [TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR] = GL2ES2.GL_ONE_MINUS_SRC_COLOR;
+ blendFunctionTable [TransparencyAttributes.BLEND_CONSTANT_COLOR] = GL2ES2.GL_CONSTANT_COLOR;
}
// ----------------------------------------------------------------------
// Helper private functions for Canvas3D
//
// USED BY CONTEXT QUERIER BELOW which is used for create new context
- private static boolean getPropertiesFromCurrentContext(JoglContext ctx, GL2ES2 gl)
- {
+ private static boolean getPropertiesFromCurrentContext(JoglContext ctx, GL2ES2 gl) {
// FIXME: this is a heavily abridged set of the stuff in Canvas3D.c;
// probably need to pull much more in
int[] tmp = new int[1];
gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, tmp, 0);
- ctx.setMaxTexCoordSets(tmp[0]);
- if (VirtualUniverse.mc.transparentOffScreen)
- {
+ ctx.setMaxTexCoordSets(tmp [0]);
+ if (VirtualUniverse.mc.transparentOffScreen) {
ctx.setAlphaClearValue(0.0f);
- }
- else
- {
+ } else {
ctx.setAlphaClearValue(1.0f);
}
return true;
}
// Used by createNewContext below
- private static int[] extractVersionInfo(String versionString)
- {
+ private static int[] extractVersionInfo(String versionString) {
// FIXME: use the second flash regex system to get the first number out
// examples
// OpenGL ES 3.0 [email protected] AU@ (GIT@I3fa967cfef)
@@ -7169,41 +6592,35 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// See if there's vendor-specific information which might
// imply a more recent OpenGL version
tok = new StringTokenizer(versionString, " ");
- if (tok.hasMoreTokens())
- {
+ if (tok.hasMoreTokens()) {
tok.nextToken();
- if (tok.hasMoreTokens())
- {
+ if (tok.hasMoreTokens()) {
Pattern p = Pattern.compile("\\D*(\\d+)\\.(\\d+)\\.?(\\d*).*");
Matcher m = p.matcher(tok.nextToken());
- if (m.matches())
- {
+ if (m.matches()) {
int altMajor = Integer.valueOf(m.group(1)).intValue();
int altMinor = Integer.valueOf(m.group(2)).intValue();
// Avoid possibly confusing situations by requiring
// major version to match
- if (altMajor == major && altMinor > minor)
- {
+ if (altMajor == major && altMinor > minor) {
minor = altMinor;
}
}
}
}
- return new int[] { major, minor };
+ return new int[] {major, minor};
}
// Used by createNewContext below
- private static void checkTextureExtensions(Canvas3D cv, JoglContext ctx, GL2ES2 gl, boolean gl13)
- {
- if (gl13)
- {
+ private static void checkTextureExtensions(Canvas3D cv, JoglContext ctx, GL2ES2 gl, boolean gl13) {
+ if (gl13) {
// FIXME: setting this to cv.maxTexCoordSets = 8; and cutting the rest out doesn't work!
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_MULTI_TEXTURE;
cv.multiTexAccelerated = true;
int[] tmp = new int[1];
gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, tmp, 0);
- cv.maxTextureUnits = tmp[0];
+ cv.maxTextureUnits = tmp [0];
cv.maxTexCoordSets = cv.maxTextureUnits;
}
@@ -7223,23 +6640,20 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COMBINE_DOT3;
}*/
- if (gl13)
- {
+ if (gl13) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_CUBE_MAP;
}
- if (gl.isExtensionAvailable("GL_EXT_texture_filter_anisotropic"))
- {
+ if (gl.isExtensionAvailable("GL_EXT_texture_filter_anisotropic")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_ANISOTROPIC_FILTER;
float[] tmp = new float[1];
gl.glGetFloatv(GL2ES2.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, tmp, 0);
- cv.anisotropicDegreeMax = tmp[0];
+ cv.anisotropicDegreeMax = tmp [0];
}
//Gles uses the GL_OES_texture_npot extension
- if (!VirtualUniverse.mc.enforcePowerOfTwo
- && (gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two") || gl.isExtensionAvailable("GL_OES_texture_npot")))
- {
+ if (!VirtualUniverse.mc.enforcePowerOfTwo && (gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two")
+ || gl.isExtensionAvailable("GL_OES_texture_npot"))) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO;
}
@@ -7252,17 +6666,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// Used by createNewContext above
- private static void checkGLSLShaderExtensions(Canvas3D cv, JoglContext ctx, GL2ES2 gl, boolean hasgl13)
- {
+ private static void checkGLSLShaderExtensions(Canvas3D cv, JoglContext ctx, GL2ES2 gl, boolean hasgl13) {
- //PJPJ Gl2ES2 MUST support shaders, and the support is NOT an extension
- // Force shaders to be disabled, since no multitexture support
- // if (!hasgl13)
- // return;
+ //PJPJ Gl2ES2 MUST support shaders, and the support is NOT an extension
+ // Force shaders to be disabled, since no multitexture support
+ // if (!hasgl13)
+ // return;
- // if ((gl.isExtensionAvailable("GL_ARB_shader_objects") //
- // && gl.isExtensionAvailable("GL_ARB_shading_language_100")) //
- // || gl.isExtensionAvailable("GL_AMD_program_binary_Z400"))
+ // if ((gl.isExtensionAvailable("GL_ARB_shader_objects") //
+ // && gl.isExtensionAvailable("GL_ARB_shading_language_100")) //
+ // || gl.isExtensionAvailable("GL_AMD_program_binary_Z400"))
{
// FIXME: this isn't complete and would need to set up the
@@ -7270,33 +6683,31 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// related to vertex attributes
int[] tmp = new int[1];
gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, tmp, 0);
- cv.maxTextureImageUnits = tmp[0];
+ cv.maxTextureImageUnits = tmp [0];
gl.glGetIntegerv(GL2ES2.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, tmp, 0);
- cv.maxVertexTextureImageUnits = tmp[0];
+ cv.maxVertexTextureImageUnits = tmp [0];
gl.glGetIntegerv(GL2ES2.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, tmp, 0);
- cv.maxCombinedTextureImageUnits = tmp[0];
+ cv.maxCombinedTextureImageUnits = tmp [0];
int vertexAttrOffset = VirtualUniverse.mc.glslVertexAttrOffset;
ctx.setGLSLVertexAttrOffset(vertexAttrOffset);
gl.glGetIntegerv(GL2ES2.GL_MAX_VERTEX_ATTRIBS, tmp, 0);
- cv.maxVertexAttrs = tmp[0];
+ cv.maxVertexAttrs = tmp [0];
// decr count to allow for reserved vertex attrs
cv.maxVertexAttrs -= vertexAttrOffset;
- if (cv.maxVertexAttrs < 0)
- {
+ if (cv.maxVertexAttrs < 0) {
cv.maxVertexAttrs = 0;
}
-
+
//http://stackoverflow.com/questions/26682631/webgl-shaders-maximum-number-of-varying-variables
gl.glGetIntegerv(GL2ES2.GL_MAX_VARYING_VECTORS, tmp, 0);
- cv.maxVaryingVectors = tmp[0];
-
+ cv.maxVaryingVectors = tmp [0];
+
cv.shadingLanguageGLSL = true;
}
}
// Used by createNewContext below
- private static void setupCanvasProperties(Canvas3D cv, JoglContext ctx, GL2ES2 gl)
- {
+ private static void setupCanvasProperties(Canvas3D cv, JoglContext ctx, GL2ES2 gl) {
// Note: this includes relevant portions from both the
// NativePipeline's getPropertiesFromCurrentContext and setupCanvasProperties
@@ -7337,8 +6748,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// find out the version, major and minor version number
int[] versionNumbers = extractVersionInfo(glVersion);
- int major = versionNumbers[0];
- int minor = versionNumbers[1];
+ int major = versionNumbers [0];
+ int minor = versionNumbers [1];
///////////////////////////////////////////
// setup the graphics context properties //
@@ -7351,8 +6762,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// are available in OpenGL 1.3, specifically multitexture, multisample,
// and cube map textures.
- if (major < 1 || (major == 1 && minor < 2))
- {
+ if (major < 1 || (major == 1 && minor < 2)) {
// In some double createNewContext uses or where getPreferredConfiguration is called before a Frame is constructed
// the disabling of D3D can cause this issue
// see Bug 1201 - Crash with option "sun.java2d.d3d=false"
@@ -7365,31 +6775,39 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// So we will detect Win10/Oracle Jre u > 51 and offer advice to down grade jre
if (glVendor.equalsIgnoreCase("Microsoft Corporation") && //
- glRenderer.equalsIgnoreCase("GDI Generic") && //
- glVersion.equalsIgnoreCase("1.1.0"))
- {
+ glRenderer.equalsIgnoreCase("GDI Generic") && //
+ glVersion.equalsIgnoreCase("1.1.0")) {
System.err.println("Java3D - GDI Generic Driver use detected.");
System.err.println("This may be caused by any of the following issues.");
if (System.getProperty("sun.java2d.noddraw", "false").equals("true")
- || System.getProperty("sun.java2d.d3d", "true").equals("false"))
- {
+ || System.getProperty("sun.java2d.d3d", "true").equals("false")) {
System.err.println("Issue: Use of System.setProperty(\"sun.java2d.noddraw\", \"true\");");
System.err.println("or System.setProperty(\"sun.java2d.d3d\", \"false\");");
- System.err.println("If either of these are being used please try either reversing or removing them,");
- System.err.println("or if they are required else where try adding System.setProperty(\"sun.awt.nopixfmt\", \"true\");");
+ System.err
+ .println("If either of these are being used please try either reversing or removing them,");
+ System.err.println(
+ "or if they are required else where try adding System.setProperty(\"sun.awt.nopixfmt\", \"true\");");
}
if (Platform.getOSName().equalsIgnoreCase("Windows 10") && //win10
- (Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version18) > 0) || // 1.9 or 1.8 > 51 //Version 19 was swapped to version 9 due to JEP 223 in jogl 2.4.0
- (Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version18) == 0 && Platform.JAVA_VERSION_UPDATE > 51) && //
- Platform.getJavaVMName().toLowerCase().startsWith("java hotspot(tm)"))// e.g. Java HotSpot(TM) 64-Bit Server VM ; OpenJDK would give OpenJDK 64-Bit Server VM
- {
- System.err.println("Issue: The use of an Intel HD2000/3000 driver in combination with Windows 10 and");
- System.err.println("a JRE greater than 1.8 update 51. Please downgrade the JRE in use to JRE 1.8u51 or lower.");
- System.err.println("For more information please see https://jogamp.org/bugzilla/show_bug.cgi?id=1278.");
- }
- System.err.println("If this software has been supplied to you and you are unable to modify it's configuration");
+ (Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version18) > 0) || // 1.9 or 1.8 > 51 //Version 19 was swapped to version 9 due to JEP 223 in jogl 2.4.0
+ (Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version18) == 0
+ && Platform.JAVA_VERSION_UPDATE > 51) && //
+ Platform.getJavaVMName()
+ .toLowerCase()
+ .startsWith(
+ "java hotspot(tm)"))// e.g. Java HotSpot(TM) 64-Bit Server VM ; OpenJDK would give OpenJDK 64-Bit Server VM
+ {
+ System.err.println(
+ "Issue: The use of an Intel HD2000/3000 driver in combination with Windows 10 and");
+ System.err.println(
+ "a JRE greater than 1.8 update 51. Please downgrade the JRE in use to JRE 1.8u51 or lower.");
+ System.err.println(
+ "For more information please see https://jogamp.org/bugzilla/show_bug.cgi?id=1278.");
+ }
+ System.err.println(
+ "If this software has been supplied to you and you are unable to modify it's configuration");
System.err.println("please contact the suppler of this software with this entire message.");
}
@@ -7401,22 +6819,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
boolean gl14 = false;
boolean gl13 = false;
- if (major == 1)
- {
- if (minor == 2)
- {
+ if (major == 1) {
+ if (minor == 2) {
System.err.println("JAVA 3D: OpenGL 1.2 detected; will run with reduced functionality");
}
- if (minor >= 3)
- {
+ if (minor >= 3) {
gl13 = true;
}
- if (minor >= 4)
- {
+ if (minor >= 4) {
gl14 = true;
}
- }
- else
+ } else
// major >= 2
{
gl13 = true;
@@ -7424,21 +6837,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gl20 = true;
}
- if (gl20)
- {
+ if (gl20) {
assert gl13;
assert gl14;
assert gl.isExtensionAvailable("GL_VERSION_2_0");
}
- if (gl14)
- {
+ if (gl14) {
assert gl13;
assert gl.isExtensionAvailable("GL_VERSION_1_4");
}
- if (gl13)
- {
+ if (gl13) {
assert gl.isExtensionAvailable("GL_VERSION_1_3");
}
@@ -7466,8 +6876,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// }
// Setup GL_EXT_abgr
- if (gl.isExtensionAvailable("GL_EXT_abgr"))
- {
+ if (gl.isExtensionAvailable("GL_EXT_abgr")) {
cv.extensionsSupported |= Canvas3D.EXT_ABGR;
}
@@ -7480,14 +6889,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// ES2 has new enable/disable on GL_SAMPLE_ALPHA_TO_COVERAGE and GL_SAMPLE_COVERAGE
// and GL2 and ES2 both have glSampleCoverage calls
// Renderer line 1158 is the guy that goes for accum if this is not set
- if (gl13)
- {
+ if (gl13) {
cv.extensionsSupported |= Canvas3D.MULTISAMPLE;
ctx.setHasMultisample(true);
}
- if ((cv.extensionsSupported & Canvas3D.MULTISAMPLE) != 0 && !VirtualUniverse.mc.implicitAntialiasing)
- {
+ if ((cv.extensionsSupported & Canvas3D.MULTISAMPLE) != 0 && !VirtualUniverse.mc.implicitAntialiasing) {
//with a bit of luck ES2 will ignore this call and leave sampling on
//gl.glDisable(GL2ES2.GL_MULTISAMPLE);
}
@@ -7500,12 +6907,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] tmp = new int[1];
gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_SIZE, tmp, 0);
- cv.textureWidthMax = tmp[0];
- cv.textureHeightMax = tmp[0];
+ cv.textureWidthMax = tmp [0];
+ cv.textureHeightMax = tmp [0];
}
- private static void disableAttribFor2D(GL2ES2 gl)
- {
+ private static void disableAttribFor2D(GL2ES2 gl) {
gl.glDisable(GL.GL_BLEND);
gl.glDisable(GL.GL_CULL_FACE);
gl.glDisable(GL.GL_DEPTH_TEST);
@@ -7513,42 +6919,39 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
gl.glDisable(GL.GL_STENCIL_TEST);
}
- private static void disableAttribForRaster(GL2ES2 gl)
- {
+ private static void disableAttribForRaster(GL2ES2 gl) {
gl.glDisable(GL.GL_CULL_FACE);
gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
}
// Not needed generally as transpose can be called on the interface with gl
- public static void copyTranspose(double[] src, double[] dst)
- {
- dst[0] = src[0];
- dst[1] = src[4];
- dst[2] = src[8];
- dst[3] = src[12];
- dst[4] = src[1];
- dst[5] = src[5];
- dst[6] = src[9];
- dst[7] = src[13];
- dst[8] = src[2];
- dst[9] = src[6];
- dst[10] = src[10];
- dst[11] = src[14];
- dst[12] = src[3];
- dst[13] = src[7];
- dst[14] = src[11];
- dst[15] = src[15];
- }
-
- @Override
- void clear(Context ctx, float r, float g, float b, boolean clearStencil)
- {
+ public static void copyTranspose(double[] src, double[] dst) {
+ dst [0] = src [0];
+ dst [1] = src [4];
+ dst [2] = src [8];
+ dst [3] = src [12];
+ dst [4] = src [1];
+ dst [5] = src [5];
+ dst [6] = src [9];
+ dst [7] = src [13];
+ dst [8] = src [2];
+ dst [9] = src [6];
+ dst [10] = src [10];
+ dst [11] = src [14];
+ dst [12] = src [3];
+ dst [13] = src [7];
+ dst [14] = src [11];
+ dst [15] = src [15];
+ }
+
+ @Override
+ void clear(Context ctx, float r, float g, float b, boolean clearStencil) {
if (VERBOSE)
System.err.println("JoglPipeline.clear()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.clear++;
+ ((Jogl2es2Context)ctx).perFrameStats.clear++;
- Jogl2es2Context jctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context jctx = (Jogl2es2Context)ctx;
GL2ES2 gl = jctx.gl2es2();
// Mask of which buffers to clear, this always includes color & depth
@@ -7563,8 +6966,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
- private static int createSimpleTextureShaderProgram(Context ctx)
- {
+ private static int createSimpleTextureShaderProgram(Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.createSimpleTextureShaderProgram()");
@@ -7591,7 +6993,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int programId = createShaderProgram(ctx, vertexProgram, fragmentProgram);
// now record the locations
- Jogl2es2Context jctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context jctx = (Jogl2es2Context)ctx;
GL2ES2 gl = jctx.gl2es2();
jctx.simpleTextureShaderProgramVertLoc = gl.glGetAttribLocation(programId, "glVertex");
jctx.simpleTextureShaderProgramTexCoordLoc = gl.glGetAttribLocation(programId, "glMultiTexCoord0");
@@ -7600,12 +7002,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
return programId;
}
- private static int createShaderProgram(Context ctx, String vertexProgram, String fragmentProgram)
- {
+ private static int createShaderProgram(Context ctx, String vertexProgram, String fragmentProgram) {
if (VERBOSE)
System.err.println("JoglPipeline.createShaderProgram()");
- Jogl2es2Context jctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context jctx = (Jogl2es2Context)ctx;
GL2ES2 gl = jctx.gl2es2();
int shaderHandleV = gl.glCreateShader(GL2ES2.GL_VERTEX_SHADER);
@@ -7618,7 +7019,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- gl.glShaderSource(shaderHandleV, 1, new String[] { vertexProgram }, null, 0);
+ gl.glShaderSource(shaderHandleV, 1, new String[] {vertexProgram}, null, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
gl.glCompileShader(shaderHandleV);
@@ -7626,20 +7027,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
int[] status = new int[1];
gl.glGetShaderiv(shaderHandleV, GL2ES2.GL_COMPILE_STATUS, status, 0);
- if (status[0] == 0)
- {
+ if (status [0] == 0) {
String detailMsg = getShaderInfoLog(gl, shaderHandleV);
System.err.println(detailMsg);
}
- gl.glShaderSource(shaderHandleF, 1, new String[] { fragmentProgram }, null, 0);
+ gl.glShaderSource(shaderHandleF, 1, new String[] {fragmentProgram}, null, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
gl.glCompileShader(shaderHandleF);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
gl.glGetShaderiv(shaderHandleF, GL2ES2.GL_COMPILE_STATUS, status, 0);
- if (status[0] == 0)
- {
+ if (status [0] == 0) {
String detailMsg = getShaderInfoLog(gl, shaderHandleF);
System.err.println(detailMsg);
}
@@ -7649,8 +7048,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
gl.glGetProgramiv(shaderProgramHandle, GL2ES2.GL_LINK_STATUS, status, 0);
- if (status[0] == 0)
- {
+ if (status [0] == 0) {
String detailMsg = getProgramInfoLog(gl, shaderProgramHandle);
System.err.println(detailMsg);
}
@@ -7660,21 +7058,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
/**
* Texture 0 must be bound by now
- * @param texMinU
+ * @param texMinU
*/
- private static void renderTexturedQuad(Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV, float mapMinX,
- float mapMaxX, float mapMinY, float mapMaxY, float mapZ)
- {
+ private static void renderTexturedQuad( Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV,
+ float mapMinX, float mapMaxX, float mapMinY, float mapMaxY, float mapZ) {
if (VERBOSE)
System.err.println("JoglPipeline.renderTexturedQuad()");
- Jogl2es2Context jctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context jctx = (Jogl2es2Context)ctx;
GL2ES2 gl = jctx.gl2es2();
//NOTE .order(ByteOrder.nativeOrder())!!!
int vcount = 6;
- FloatBuffer verts = ByteBuffer.allocateDirect(Float.SIZE / 8 * 3 * vcount).order(ByteOrder.nativeOrder()).asFloatBuffer();
- FloatBuffer tcs = ByteBuffer.allocateDirect(Float.SIZE / 8 * 2 * vcount).order(ByteOrder.nativeOrder()).asFloatBuffer();
+ FloatBuffer verts = ByteBuffer.allocateDirect(Float.SIZE / 8 * 3 * vcount).order(ByteOrder.nativeOrder())
+ .asFloatBuffer();
+ FloatBuffer tcs = ByteBuffer.allocateDirect(Float.SIZE / 8 * 2 * vcount).order(ByteOrder.nativeOrder())
+ .asFloatBuffer();
//CCW windings for fun (cull face should make unnecessary
tcs.put(texMinU).put(texMinV);
@@ -7696,8 +7095,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int[] tmp = new int[2];
gl.glGenBuffers(2, tmp, 0);
- int vertBufId = tmp[0];
- int tcBufId = tmp[1];
+ int vertBufId = tmp [0];
+ int tcBufId = tmp [1];
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, vertBufId);
@@ -7721,19 +7120,15 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// always create a new one
int vaoId = -1;
- if (gl.isGL2ES3())
- {
+ if (gl.isGL2ES3()) {
GL2ES3 gl2es3 = (GL2ES3)gl;
- if (vaoId == -1)
- {
+ if (vaoId == -1) {
int[] tmp2 = new int[1];
gl2es3.glGenVertexArrays(1, tmp2, 0);
- vaoId = tmp2[0];
+ vaoId = tmp2 [0];
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
+ } else {
bindingRequired = false;
}
gl2es3.glBindVertexArray(vaoId);
@@ -7741,10 +7136,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
- if (bindingRequired)
- {
- if (jctx.simpleTextureShaderProgramVertLoc != -1)
- {
+ if (bindingRequired) {
+ if (jctx.simpleTextureShaderProgramVertLoc != -1) {
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, vertBufId);
gl.glVertexAttribPointer(jctx.simpleTextureShaderProgramVertLoc, 3, GL2ES2.GL_FLOAT, false, 0, 0);
gl.glEnableVertexAttribArray(jctx.simpleTextureShaderProgramVertLoc);
@@ -7752,8 +7145,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
- if (jctx.simpleTextureShaderProgramTexCoordLoc != -1)
- {
+ if (jctx.simpleTextureShaderProgramTexCoordLoc != -1) {
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, tcBufId);
gl.glVertexAttribPointer(jctx.simpleTextureShaderProgramTexCoordLoc, 2, GL2ES2.GL_FLOAT, false, 0, 0);
gl.glEnableVertexAttribArray(jctx.simpleTextureShaderProgramTexCoordLoc);
@@ -7764,8 +7156,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
outputErrors(ctx);
}
- if (jctx.simpleTextureShaderProgramBaseMapLoc != -1)
- {
+ if (jctx.simpleTextureShaderProgramBaseMapLoc != -1) {
gl.glUniform1i(jctx.simpleTextureShaderProgramBaseMapLoc, 0);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
@@ -7777,30 +7168,28 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// clean u as we have to recreate each pass
if (vaoId != -1)
- ((GL2ES3)gl).glDeleteVertexArrays(1, new int[] { vaoId }, 0);
+ ((GL2ES3)gl).glDeleteVertexArrays(1, new int[] {vaoId}, 0);
if (vertBufId != -1)
- gl.glDeleteBuffers(1, new int[] { vertBufId }, 0);
+ gl.glDeleteBuffers(1, new int[] {vertBufId}, 0);
if (tcBufId != -1)
- gl.glDeleteBuffers(1, new int[] { tcBufId }, 0);
+ gl.glDeleteBuffers(1, new int[] {tcBufId}, 0);
}
@Override
- void textureFillBackground(Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV, float mapMinX, float mapMaxX,
- float mapMinY, float mapMaxY, boolean useBilinearFilter)
- {
+ void textureFillBackground( Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV, float mapMinX,
+ float mapMaxX, float mapMinY, float mapMaxY, boolean useBilinearFilter) {
if (VERBOSE)
System.err.println("JoglPipeline.textureFillBackground()");
- Jogl2es2Context jctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context jctx = (Jogl2es2Context)ctx;
GL2ES2 gl = jctx.gl2es2();
disableAttribFor2D(gl);
// Setup filter mode if needed
- if (useBilinearFilter)
- {
+ if (useBilinearFilter) {
// System.err.println("JoglPipeline - Raster : use bilinear filter\n");
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
@@ -7825,21 +7214,20 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void textureFillRaster(Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV, float mapMinX, float mapMaxX,
- float mapMinY, float mapMaxY, float mapZ, float alpha, boolean useBilinearFilter)
- {
+ void textureFillRaster( Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV, float mapMinX,
+ float mapMaxX, float mapMinY, float mapMaxY, float mapZ, float alpha,
+ boolean useBilinearFilter) {
if (VERBOSE)
System.err.println("JoglPipeline.textureFillRaster()");
- Jogl2es2Context jctx = (Jogl2es2Context) ctx;
+ Jogl2es2Context jctx = (Jogl2es2Context)ctx;
GL2ES2 gl = jctx.gl2es2();
disableAttribForRaster(gl);
// Setup filter mode if needed
- if (useBilinearFilter)
- {
+ if (useBilinearFilter) {
// System.err.println("JoglPipeline - Raster : use bilinear filter\n");
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
@@ -7862,15 +7250,15 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void executeRasterDepth(Context ctx, float posX, float posY, float posZ, int srcOffsetX, int srcOffsetY, int rasterWidth,
- int rasterHeight, int depthWidth, int depthHeight, int depthFormat, Object depthData)
- {
+ void executeRasterDepth(Context ctx, float posX, float posY, float posZ, int srcOffsetX, int srcOffsetY,
+ int rasterWidth, int rasterHeight, int depthWidth, int depthHeight, int depthFormat,
+ Object depthData) {
if (VERBOSE)
System.err.println("JoglPipeline.executeRasterDepth()");
-
+
//Jogl2es2Context jctx = (Jogl2es2Context) ctx;
//GL2ES2 gl = jctx.gl2es2();
-
+
throw new UnsupportedOperationException(
"To get depth you should use a shader that return depth info for gl2es2 then read from color");
/*
@@ -7939,29 +7327,26 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
/**
- * This native method makes sure that the rendering for this canvas gets
- * done now.
+ * This native method makes sure that the rendering for this canvas gets done now.
*/
@Override
// render is it's own thread so finish stops nothing
- void syncRender(Context ctx, boolean wait)
- {
+ void syncRender(Context ctx, boolean wait) {
if (VERBOSE)
System.err.println("JoglPipeline.syncRender() " + wait);
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.syncRenderTime = System.nanoTime();
+ ((Jogl2es2Context)ctx).perFrameStats.syncRenderTime = System.nanoTime();
// clean up any buffers that need freeing
doClearBuffers(ctx);
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).outputPerFrameData();
+ ((Jogl2es2Context)ctx).outputPerFrameData();
// also seems to be ok, just do it as well
- if (!NEVER_RELEASE_CONTEXT)
- {
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ if (!NEVER_RELEASE_CONTEXT) {
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
if (wait)
gl.glFinish();
else
@@ -7972,25 +7357,21 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// The native method for swapBuffers - onscreen only
@Override
- void swapBuffers(Canvas3D cv, Context ctx, Drawable drawable)
- {
+ void swapBuffers(Canvas3D cv, Context ctx, Drawable drawable) {
if (VERBOSE)
System.err.println("JoglPipeline.swapBuffers()");
GLDrawable draw = drawable(drawable);
draw.swapBuffers();
- ((Jogl2es2Context) ctx).gl_state.clear();
+ ((Jogl2es2Context)ctx).gl_state.clear();
}
- private static void outputErrors(Context ctx)
- {
- if (DO_OUTPUT_ERRORS)
- {
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ private static void outputErrors(Context ctx) {
+ if (DO_OUTPUT_ERRORS) {
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
int err = gl.glGetError();
- if (err != GL2ES2.GL_NO_ERROR)
- {
+ if (err != GL2ES2.GL_NO_ERROR) {
// GL_NO_ERROR = 0x0
// GL_INVALID_ENUM = 0x500; 1280
// GL_INVALID_VALUE = 0x501; 1281
@@ -8001,19 +7382,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// GL_STACK_OVERFLOW 504?
// check for no current shader program (likely a switch between scenes or something)
- if (err == GL2ES2.GL_INVALID_OPERATION)
- {
+ if (err == GL2ES2.GL_INVALID_OPERATION) {
int[] res = new int[1];
gl.glGetIntegerv(GL2ES2.GL_CURRENT_PROGRAM, res, 0);
// 0 is no current program
- if (res[0] == 0)
+ if (res [0] == 0)
return;
}
System.err.println("JoglesPipeline GL error reported " + err);
StackTraceElement[] st = new Throwable().getStackTrace();
if (st.length > 1)
- System.err.println("Occured in " + st[1]);
+ System.err.println("Occured in " + st [1]);
// seems to produce heaps?
/*err = gl.glGetError();
@@ -8032,14 +7412,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// The native method that sets this ctx to be the current one
@Override
- boolean useCtx(Context ctx, Drawable drawable)
- {
- if (!NEVER_RELEASE_CONTEXT || !currently_current)
- {
+ boolean useCtx(Context ctx, Drawable drawable) {
+ if (!NEVER_RELEASE_CONTEXT || !currently_current) {
if (VERBOSE)
System.err.println("JoglPipeline.useCtx()**********************************");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.useCtx++;
+ ((Jogl2es2Context)ctx).perFrameStats.useCtx++;
GLContext context = context(ctx);
@@ -8058,14 +7436,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Optionally release the context. Returns true if the context was released.
@Override
- boolean releaseCtx(Context ctx)
- {
- if (!NEVER_RELEASE_CONTEXT)
- {
+ boolean releaseCtx(Context ctx) {
+ if (!NEVER_RELEASE_CONTEXT) {
if (VERBOSE)
System.err.println("JoglPipeline.releaseCtx()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.releaseCtx++;
+ ((Jogl2es2Context)ctx).perFrameStats.releaseCtx++;
GLContext context = context(ctx);
if (context.isCurrent())
@@ -8082,8 +7458,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Maximum lights supported by the native API
@Override
- int getMaximumLights()
- {
+ int getMaximumLights() {
if (VERBOSE)
System.err.println("JoglPipeline.getMaximumLights()");
@@ -8091,28 +7466,25 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// is probably close enough
return 8;
}
-
+
// This is the native for reading the image from the offscreen buffer
@Override
- void readOffScreenBuffer(Canvas3D cv, Context ctx, int format, int dataType, Object data, int width, int height)
- {
+ void readOffScreenBuffer(Canvas3D cv, Context ctx, int format, int dataType, Object data, int width, int height) {
if (VERBOSE)
System.err.println("JoglPipeline.readOffScreenBuffer()");
- GLDrawable glDrawable = ((JoglDrawable) cv.drawable).getGLDrawable();
+ GLDrawable glDrawable = ((JoglDrawable)cv.drawable).getGLDrawable();
GLCapabilitiesImmutable chosenCaps = glDrawable.getChosenGLCapabilities();
GLFBODrawable fboDrawable = null;
GL2ES2 gl = context(ctx).getGL().getGL2ES2();
// If FBO
- if (chosenCaps.isFBO())
- {
+ if (chosenCaps.isFBO()) {
- fboDrawable = (GLFBODrawable) glDrawable;
+ fboDrawable = (GLFBODrawable)glDrawable;
- if (chosenCaps.getDoubleBuffered())
- {
+ if (chosenCaps.getDoubleBuffered()) {
// swap = resolve multisampling or flip back/front FBO
fboDrawable.swapBuffers();
// unbind texture render target, we read from FBO
@@ -8134,114 +7506,98 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
int type = 0;
if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY)
- || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER))
- {
+ || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
- switch (format)
- {
- // GL_BGR
- case ImageComponentRetained.TYPE_BYTE_BGR:
- type = GL2.GL_BGR;// not ok
- break;
- case ImageComponentRetained.TYPE_BYTE_RGB:
- type = GL.GL_RGB;//ok
- break;
- // GL_ABGR_EXT
- case ImageComponentRetained.TYPE_BYTE_ABGR:
- if (isExtensionAvailable.GL_EXT_abgr(gl))
- { // If false, should never come here!
- type = GL2.GL_ABGR_EXT; //ok
- }
- else
- {
- assert false;
- return;
- }
- break;
- case ImageComponentRetained.TYPE_BYTE_RGBA:
- type = GL.GL_RGBA;// this a valid case for GL2ES2
- break;
+ switch (format) {
+ // GL_BGR
+ case ImageComponentRetained.TYPE_BYTE_BGR:
+ type = GL2.GL_BGR;// not ok
+ break;
+ case ImageComponentRetained.TYPE_BYTE_RGB:
+ type = GL.GL_RGB;//ok
+ break;
+ // GL_ABGR_EXT
+ case ImageComponentRetained.TYPE_BYTE_ABGR:
+ if (isExtensionAvailable.GL_EXT_abgr(gl)) { // If false, should never come here!
+ type = GL2.GL_ABGR_EXT; //ok
+ } else {
+ assert false;
+ return;
+ }
+ break;
+ case ImageComponentRetained.TYPE_BYTE_RGBA:
+ type = GL.GL_RGBA;// this a valid case for GL2ES2
+ break;
- /*
- * This method only supports 3 and 4 components formats and BYTE
- * types.
- */
- case ImageComponentRetained.TYPE_BYTE_LA:
- case ImageComponentRetained.TYPE_BYTE_GRAY:
- case ImageComponentRetained.TYPE_USHORT_GRAY:
- case ImageComponentRetained.TYPE_INT_BGR:
- case ImageComponentRetained.TYPE_INT_RGB:
- case ImageComponentRetained.TYPE_INT_ARGB:
- default:
- throw new AssertionError("illegal format " + format);
+ /*
+ * This method only supports 3 and 4 components formats and BYTE
+ * types.
+ */
+ case ImageComponentRetained.TYPE_BYTE_LA:
+ case ImageComponentRetained.TYPE_BYTE_GRAY:
+ case ImageComponentRetained.TYPE_USHORT_GRAY:
+ case ImageComponentRetained.TYPE_INT_BGR:
+ case ImageComponentRetained.TYPE_INT_RGB:
+ case ImageComponentRetained.TYPE_INT_ARGB:
+ default:
+ throw new AssertionError("illegal format " + format);
}
ByteBuffer buf = null;
- if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY)
- {
- buf = ByteBuffer.wrap((byte[]) data);
+ if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
+ buf = ByteBuffer.wrap((byte[])data);
+ } else {
+ buf = (ByteBuffer)data;
}
- else
- {
- buf = (ByteBuffer) data;
- }
-
+
gl.glReadPixels(0, 0, width, height, type, GL.GL_UNSIGNED_BYTE, buf);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
- || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER))
- {
- switch (format)
- {
- // GL_BGR
- case ImageComponentRetained.TYPE_INT_BGR:
- type = GL2.GL_BGR;// not ok
- break;
- case ImageComponentRetained.TYPE_INT_RGB:
- type = GL.GL_RGB;//ok
- break;
- case ImageComponentRetained.TYPE_INT_ARGB:
- type = GL.GL_RGBA;// this a valid case for GL2ES2
- break;
+ } else if ((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
+ || (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) {
+ switch (format) {
+ // GL_BGR
+ case ImageComponentRetained.TYPE_INT_BGR:
+ type = GL2.GL_BGR;// not ok
+ break;
+ case ImageComponentRetained.TYPE_INT_RGB:
+ type = GL.GL_RGB;//ok
+ break;
+ case ImageComponentRetained.TYPE_INT_ARGB:
+ type = GL.GL_RGBA;// this a valid case for GL2ES2
+ break;
- /*
- * This method only supports 3 and 4 components formats and INT
- * types.
- */
- case ImageComponentRetained.TYPE_BYTE_LA:
- case ImageComponentRetained.TYPE_BYTE_GRAY:
- case ImageComponentRetained.TYPE_USHORT_GRAY:
- case ImageComponentRetained.TYPE_BYTE_BGR:
- case ImageComponentRetained.TYPE_BYTE_RGB:
- case ImageComponentRetained.TYPE_BYTE_RGBA:
- default:
- throw new AssertionError("illegal format " + format);
+ /*
+ * This method only supports 3 and 4 components formats and INT
+ * types.
+ */
+ case ImageComponentRetained.TYPE_BYTE_LA:
+ case ImageComponentRetained.TYPE_BYTE_GRAY:
+ case ImageComponentRetained.TYPE_USHORT_GRAY:
+ case ImageComponentRetained.TYPE_BYTE_BGR:
+ case ImageComponentRetained.TYPE_BYTE_RGB:
+ case ImageComponentRetained.TYPE_BYTE_RGBA:
+ default:
+ throw new AssertionError("illegal format " + format);
}
IntBuffer buf = null;
- if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY)
- {
- buf = IntBuffer.wrap((int[]) data);
- }
- else
- {
- buf = (IntBuffer) data;
+ if (dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
+ buf = IntBuffer.wrap((int[])data);
+ } else {
+ buf = (IntBuffer)data;
}
-
+
gl.glReadPixels(0, 0, width, height, type, GL.GL_UNSIGNED_BYTE, buf);
if (DO_OUTPUT_ERRORS)
outputErrors(ctx);
- }
- else
- {
- throw new AssertionError("illegal image data type " + dataType + " Try creating a BufferedImage of type TYPE_3BYTE_BGR");
+ } else {
+ throw new AssertionError(
+ "illegal image data type " + dataType + " Try creating a BufferedImage of type TYPE_3BYTE_BGR");
}
// If FBO
- if (chosenCaps.isFBO())
- {
+ if (chosenCaps.isFBO()) {
// bind FBO for drawing
fboDrawable.getFBObject(GL.GL_BACK).bind(gl);
}
@@ -8250,39 +7606,34 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// ----------------------- Below here are initialization methods
// Number of milliseconds to wait for windows to pop up on screen
- private static final int WAIT_TIME = 1000;
+ private static final int WAIT_TIME = 1000;
// Configurable constant just in case we want to change this later
- private static final int MIN_FRAME_SIZE = 1;
+ private static final int MIN_FRAME_SIZE = 1;
- private GLProfile profile;
+ private GLProfile profile;
- private Object mainThreadContext; // Fix for Bug 983
+ private Object mainThreadContext; // Fix for Bug 983
// Fix for Bug 983
- private void checkAppContext()
- {
+ private void checkAppContext() {
if (mainThreadContext == null)
return;
- try
- {
+ try {
// Check by reflection that sun.awt.AppContext.getAppContext()
// doesn't return null
// (required by ImageIO.write() and other JMF internal calls) to
// apply workaround proposed at
// http://stackoverflow.com/questions/17223304/appcontext-is-null-from-rmi-thread-with-java-7-update-25
final Class<?> appContextClass = Class.forName("sun.awt.AppContext");
- if (appContextClass.getMethod("getAppContext").invoke(null) == null)
- {
+ if (appContextClass.getMethod("getAppContext").invoke(null) == null) {
final Field field = appContextClass.getDeclaredField("threadGroup2appContext");
field.setAccessible(true);
- final Map threadGroup2appContext = (Map) field.get(null);
+ final Map threadGroup2appContext = (Map)field.get(null);
final ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup();
threadGroup2appContext.put(currentThreadGroup, mainThreadContext);
}
- }
- catch (Throwable ex)
- {
+ } catch (Throwable ex) {
// Let's consider app context is not necessary for the program
}
// Don't need mainThreadContext anymore
@@ -8291,8 +7642,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// This is the native method for creating the underlying graphics context.
@Override
- Context createNewContext(Canvas3D cv, Drawable drawable, Context shareCtx, boolean isSharedCtx, boolean offScreen)
- {
+ Context createNewContext(Canvas3D cv, Drawable drawable, Context shareCtx, boolean isSharedCtx, boolean offScreen) {
if (VERBOSE)
System.err.println("JoglPipeline.createNewContext()");
@@ -8300,28 +7650,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
GLDrawable glDrawable = null;
GLContext glContext = null;
- if (offScreen)
- {
+ if (offScreen) {
glDrawable = drawable(cv.drawable); // cv.drawable != null, set in
// 'createOffScreenBuffer'
glContext = glDrawable.createContext(context(shareCtx));
- }
- else
- {
+ } else {
// determined in 'getBestConfiguration'
GraphicsConfigInfo gcInf0 = Canvas3D.graphicsConfigTable.get(cv.graphicsConfiguration);
- AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) gcInf0.getPrivateData();
+ AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration)gcInf0.getPrivateData();
// JAWTWindow
- JAWTWindow nativeWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(cv, awtConfig);
+ JAWTWindow nativeWindow = (JAWTWindow)NativeWindowFactory.getNativeWindow(cv, awtConfig);
nativeWindow.lockSurface();
- try
- {
+ try {
glDrawable = GLDrawableFactory.getFactory(profile).createGLDrawable(nativeWindow);
glContext = glDrawable.createContext(context(shareCtx));
- }
- finally
- {
+ } finally {
nativeWindow.unlockSurface();
}
@@ -8342,28 +7686,21 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
boolean failed = false;
int failCount = 0;
int MAX_FAIL_COUNT = 5;
- do
- {
+ do {
failed = false;
int res = glContext.makeCurrent();
- if (res == GLContext.CONTEXT_NOT_CURRENT)
- {
+ if (res == GLContext.CONTEXT_NOT_CURRENT) {
// System.err.println("makeCurrent fail : " + failCount);
failed = true;
++failCount;
- try
- {
+ try {
Thread.sleep(100);
- }
- catch (InterruptedException e)
- {
+ } catch (InterruptedException e) {
}
}
- }
- while (failed && (failCount < MAX_FAIL_COUNT));
+ } while (failed && (failCount < MAX_FAIL_COUNT));
- if (failCount == MAX_FAIL_COUNT)
- {
+ if (failCount == MAX_FAIL_COUNT) {
throw new IllegalRenderingStateException("Unable to make new context current after " + failCount + "tries");
}
@@ -8371,15 +7708,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
Jogl2es2Context ctx = new Jogl2es2Context(glContext);
- try
- {
- if (!getPropertiesFromCurrentContext(ctx, gl))
- {
+ try {
+ if (!getPropertiesFromCurrentContext(ctx, gl)) {
throw new IllegalRenderingStateException("Unable to fetch properties from current OpenGL context");
}
- if (!isSharedCtx)
- {
+ if (!isSharedCtx) {
// Set up fields in Canvas3D
setupCanvasProperties(cv, ctx, gl);
}
@@ -8413,9 +7747,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Mac OS X / JRE 7 : onscreen rendering = offscreen rendering
// bind FBO
- if (!offScreen && glDrawable instanceof GLFBODrawable)
- {
- GLFBODrawable fboDrawable = (GLFBODrawable) glDrawable;
+ if (!offScreen && glDrawable instanceof GLFBODrawable) {
+ GLFBODrawable fboDrawable = (GLFBODrawable)glDrawable;
// bind GLFBODrawable's drawing FBObject
// GL_BACK returns the correct FBOObject for single/double
// buffering, incl. multisampling
@@ -8423,24 +7756,21 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// FBO or pbuffer
- if (offScreen)
- {
+ if (offScreen) {
// Final caps
GLCapabilitiesImmutable chosenCaps = glDrawable.getChosenGLCapabilities();
// FBO
- if (glDrawable instanceof GLFBODrawable)
- {
- GLFBODrawable fboDrawable = (GLFBODrawable) glDrawable;
+ if (glDrawable instanceof GLFBODrawable) {
+ GLFBODrawable fboDrawable = (GLFBODrawable)glDrawable;
// bind GLFBODrawable's drawing FBObject
// GL_BACK returns the correct FBOObject for single/double
// buffering, incl. multisampling
fboDrawable.getFBObject(GL.GL_BACK).bind(gl);
}
// pbuffer
- else
- {
+ else {
// Double buffering: read from back buffer, as we don't swap
// Even this setting is identical to the initially mode it
// is set explicitly
@@ -8451,9 +7781,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
*/
}
}
- }
- finally
- {
+ } finally {
glContext.release();
}
@@ -8461,15 +7789,13 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- void createQueryContext(Canvas3D cv, Drawable drawable, boolean offScreen, int width, int height)
- {
+ void createQueryContext(Canvas3D cv, Drawable drawable, boolean offScreen, int width, int height) {
if (VERBOSE)
System.err.println("JoglPipeline.createQueryContext()");
// Assumes createQueryContext is never called for a drawable != null
- if (offScreen)
- {
+ if (offScreen) {
Drawable offDrawable = createOffScreenBuffer(cv, null, width, height);
@@ -8494,9 +7820,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
glContext.release();
glContext.destroy();
glDrawable.setRealized(false);
- }
- else
- {
+ } else {
// TODO can't find an implementation which avoids the use of
// QueryCanvas
@@ -8508,8 +7832,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
ContextQuerier querier = new ContextQuerier(cv);
- AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) Canvas3D.graphicsConfigTable.get(cv.graphicsConfiguration)
- .getPrivateData();
+ AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration)Canvas3D.graphicsConfigTable
+ .get(cv.graphicsConfiguration).getPrivateData();
QueryCanvas canvas = new QueryCanvas(awtConfig, querier);
@@ -8519,18 +7843,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
canvas.doQuery();
// Attempt to wait for the frame to become visible, but don't block
// the EDT
- if (!EventQueue.isDispatchThread())
- {
- synchronized (querier)
- {
- if (!querier.done())
- {
- try
- {
+ if (!EventQueue.isDispatchThread()) {
+ synchronized (querier) {
+ if (!querier.done()) {
+ try {
querier.wait(WAIT_TIME);
- }
- catch (InterruptedException e)
- {
+ } catch (InterruptedException e) {
}
}
}
@@ -8542,15 +7860,13 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
//Offscreen rendering methods below -----------------------
- static boolean isOffscreenLayerSurfaceEnabled(Canvas3D cv)
- {
+ static boolean isOffscreenLayerSurfaceEnabled(Canvas3D cv) {
if (cv.drawable == null || cv.offScreen)
return false;
- JoglDrawable joglDrawble = (JoglDrawable) cv.drawable;
- if (joglDrawble.getNativeWindow() instanceof OffscreenLayerOption)
- {
- OffscreenLayerOption olo = (OffscreenLayerOption) joglDrawble.getNativeWindow();
+ JoglDrawable joglDrawble = (JoglDrawable)cv.drawable;
+ if (joglDrawble.getNativeWindow() instanceof OffscreenLayerOption) {
+ OffscreenLayerOption olo = (OffscreenLayerOption)joglDrawble.getNativeWindow();
if (olo == null)
return false;
else
@@ -8559,12 +7875,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
return false;
}
- static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height)
- {
+ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height) {
if (!(jdraw.getGLDrawable() instanceof GLFBODrawable))
return false;
- FBObject fboBack = ((GLFBODrawable) jdraw.getGLDrawable()).getFBObject(GL.GL_BACK);
+ FBObject fboBack = ((GLFBODrawable)jdraw.getGLDrawable()).getFBObject(GL.GL_BACK);
if (fboBack == null)
return false;
@@ -8575,12 +7890,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Implementation follows the approach in
// jogamp.opengl.GLDrawableHelper.resizeOffscreenDrawable(..)
@Override
- void resizeOffscreenLayer(Canvas3D cv, int cvWidth, int cvHeight)
- {
+ void resizeOffscreenLayer(Canvas3D cv, int cvWidth, int cvHeight) {
if (!isOffscreenLayerSurfaceEnabled(cv))
return;
- JoglDrawable joglDrawable = (JoglDrawable) cv.drawable;
+ JoglDrawable joglDrawable = (JoglDrawable)cv.drawable;
if (!hasFBObjectSizeChanged(joglDrawable, cvWidth, cvHeight))
return;
@@ -8593,19 +7907,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Assuming glContext != null
final NativeSurface surface = glDrawble.getNativeSurface();
- final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface) surface : null;
+ final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface)surface : null;
final int lockRes = surface.lockSurface();
- try
- {
+ try {
// propagate new size - seems not relevant here
- if (proxySurface != null)
- {
+ if (proxySurface != null) {
final UpstreamSurfaceHook ush = proxySurface.getUpstreamSurfaceHook();
- if (ush instanceof UpstreamSurfaceHook.MutableSize)
- {
- ((UpstreamSurfaceHook.MutableSize) ush).setSurfaceSize(newWidth, newHeight);
+ if (ush instanceof UpstreamSurfaceHook.MutableSize) {
+ ((UpstreamSurfaceHook.MutableSize)ush).setSurfaceSize(newWidth, newHeight);
}
}
/*
@@ -8618,8 +7929,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
GL2ES2 gl = glContext.getGL().getGL2ES2();
// FBO : should be the default case on Mac OS X
- if (glDrawble instanceof GLFBODrawable)
- {
+ if (glDrawble instanceof GLFBODrawable) {
// Resize GLFBODrawable
// TODO msaa gets lost
@@ -8628,8 +7938,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Alternative: resize GL_BACK FBObject directly,
// if multisampled the FBO sink (GL_FRONT) will be resized
// before the swap is executed
- int numSamples = ((GLFBODrawable) glDrawble).getChosenGLCapabilities().getNumSamples();
- FBObject fboObjectBack = ((GLFBODrawable) glDrawble).getFBObject(GL.GL_BACK);
+ int numSamples = ((GLFBODrawable)glDrawble).getChosenGLCapabilities().getNumSamples();
+ FBObject fboObjectBack = ((GLFBODrawable)glDrawble).getFBObject(GL.GL_BACK);
fboObjectBack.reset(gl, newWidth, newHeight, numSamples/* , false */); // false = don't reset
// SamplingSinkFBO
// immediately
@@ -8639,8 +7949,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// will be resized by glDrawble after the next swap-call
}
// pbuffer - not tested because Mac OS X 10.7+ supports FBO
- else
- {
+ else {
// Create new GLDrawable (pbuffer) and update the coresponding
// GLContext
@@ -8648,31 +7957,25 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
final GLDrawableFactory factory = glDrawble.getFactory();
// Ensure to sync GL command stream
- if (currentContext != glContext)
- {
+ if (currentContext != glContext) {
glContext.makeCurrent();
}
gl.glFinish();
glContext.release();
- if (proxySurface != null)
- {
+ if (proxySurface != null) {
proxySurface.enableUpstreamSurfaceHookLifecycle(false);
}
- try
- {
+ try {
glDrawble.setRealized(false);
// New GLDrawable
glDrawble = factory.createGLDrawable(surface);
glDrawble.setRealized(true);
joglDrawable.setGLDrawable(glDrawble);
- }
- finally
- {
- if (proxySurface != null)
- {
+ } finally {
+ if (proxySurface != null) {
proxySurface.enableUpstreamSurfaceHookLifecycle(true);
}
}
@@ -8680,22 +7983,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
glContext.setGLDrawable(glDrawble, true); // re-association
// make current last current context
- if (currentContext != null)
- {
+ if (currentContext != null) {
currentContext.makeCurrent();
}
}
- }
- finally
- {
+ } finally {
surface.unlockSurface();
}
}
// This is the native for creating an offscreen buffer
@Override
- Drawable createOffScreenBuffer(Canvas3D cv, Context ctx, int width, int height)
- {
+ Drawable createOffScreenBuffer(Canvas3D cv, Context ctx, int width, int height) {
//OK general problem, 2 calls to setOffscreen buffer o a canvas3d will call this method once, attaching a
// a new drawable all good, but
@@ -8707,14 +8006,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// ctx unused, doesn't exist yet
// Offscreen Canvas3D's JoglGraphicsConfiguration
- JoglGraphicsConfiguration jgc = (JoglGraphicsConfiguration) cv.graphicsConfiguration;
+ JoglGraphicsConfiguration jgc = (JoglGraphicsConfiguration)cv.graphicsConfiguration;
// Retrieve the offscreen Canvas3D's GraphicsConfigInfo
GraphicsConfigInfo gcInf0 = Canvas3D.graphicsConfigTable.get(jgc);
// Offscreen Canvas3D's graphics configuration, determined in
// 'getBestConfiguration'
- AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) gcInf0.getPrivateData();
+ AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration)gcInf0.getPrivateData();
// TODO Offscreen Canvas3D's graphics devise, determined in
// 'getBestConfiguration'
@@ -8725,7 +8024,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Offscreen Canvas3D's capabilites, determined in
// 'getBestConfiguration'
- GLCapabilities canvasCaps = (GLCapabilities) awtConfig.getChosenCapabilities();
+ GLCapabilities canvasCaps = (GLCapabilities)awtConfig.getChosenCapabilities();
// For further investigations : the user's GraphicsConfigTemplate3D (not
// used yet)
@@ -8740,8 +8039,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// double bufffering only if scene antialiasing is required/preferred
// and supported
- if (offCaps.getSampleBuffers() == false)
- {
+ if (offCaps.getSampleBuffers() == false) {
offCaps.setDoubleBuffered(false);
offCaps.setNumSamples(0);
}
@@ -8758,7 +8056,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// offscreen drawable
// If FBO : 'offDrawable' is of type com.jogamp.opengl.GLFBODrawable
- GLDrawable offDrawable = GLDrawableFactory.getFactory(profile).createOffscreenDrawable(device, offCaps, null, width, height);
+ GLDrawable offDrawable = GLDrawableFactory.getFactory(profile).createOffscreenDrawable(device, offCaps, null,
+ width, height);
// !! these chosen caps are not final as long as the corresponding
// context is made current
@@ -8770,41 +8069,34 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// 'destroyContext' is called first if context exists
@Override
- void destroyOffScreenBuffer(Canvas3D cv, Context ctx, Drawable drawable)
- {
+ void destroyOffScreenBuffer(Canvas3D cv, Context ctx, Drawable drawable) {
if (VERBOSE)
System.err.println("JoglPipeline.destroyOffScreenBuffer()");
// it is done in 'destroyContext'
}
-
// Setup the full scene antialising in D3D and ogl when GL_ARB_multisamle supported
@Override
// looks like one time call in renderer.doWork
- void setFullSceneAntialiasing(Context ctx, boolean enable)
- {
+ void setFullSceneAntialiasing(Context ctx, boolean enable) {
if (VERBOSE)
System.err.println("JoglPipeline.setFullSceneAntialiasing()");
if (OUTPUT_PER_FRAME_STATS)
- ((Jogl2es2Context) ctx).perFrameStats.setFullSceneAntialiasing++;
+ ((Jogl2es2Context)ctx).perFrameStats.setFullSceneAntialiasing++;
- JoglContext joglctx = (JoglContext) ctx;
- GL2ES2 gl = ((Jogl2es2Context) ctx).gl2es2();
+ JoglContext joglctx = (JoglContext)ctx;
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
// not supported in ES2, possibly just part of context generally
// http://stackoverflow.com/questions/27035893/antialiasing-in-opengl-es-2-0
// FIXME: This is working under GL2ES2 but will need to change I think
// https://github.com/adrian110288/gdc2011-android-opengl/blob/master/src/com/example/gdc11/GDC11Activity.java
- if (joglctx.getHasMultisample() && !VirtualUniverse.mc.implicitAntialiasing)
- {
- if (enable)
- {
+ if (joglctx.getHasMultisample() && !VirtualUniverse.mc.implicitAntialiasing) {
+ if (enable) {
System.out.println("I just set MULTISAMPLE just then");
gl.glEnable(GL2ES2.GL_MULTISAMPLE);
- }
- else
- {
+ } else {
gl.glDisable(GL2ES2.GL_MULTISAMPLE);
}
}
@@ -8813,8 +8105,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Native method to update separate specular color control
// looks like a one time call at the start of renderer.doWork
@Override
- void updateSeparateSpecularColorEnable(Context ctx, boolean enable)
- {
+ void updateSeparateSpecularColorEnable(Context ctx, boolean enable) {
if (VERBOSE)
System.err.println("JoglPipeline.updateSeparateSpecularColorEnable()");
@@ -8839,12 +8130,11 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
//
@Override
- void destroyContext(Drawable drawable, Context ctx)
- {
+ void destroyContext(Drawable drawable, Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.destroyContext()");
- JoglDrawable joglDrawable = (JoglDrawable) drawable;
+ JoglDrawable joglDrawable = (JoglDrawable)drawable;
GLContext context = context(ctx);
// google below and see its a bug on marshmallow
@@ -8856,10 +8146,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// gets a
// com.jogamp.opengl.GLException: Error swapping buffers, eglError 0x300d, jogamp.opengl.egl.EGLDrawable[realized true,
- if (joglDrawable != null)
- {
- if (GLContext.getCurrent() == context)
- {
+ if (joglDrawable != null) {
+ if (GLContext.getCurrent() == context) {
context.release();
}
context.destroy();
@@ -8874,8 +8162,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// This is the native method for getting the number of lights the underlying
// native library can support.
@Override
- int getNumCtxLights(Context ctx)
- {
+ int getNumCtxLights(Context ctx) {
if (VERBOSE)
System.err.println("JoglPipeline.getNumCtxLights()");
@@ -8892,8 +8179,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// False under windows when display mode <= 8 bit
@Override
// probably pointless?
- boolean validGraphicsMode()
- {
+ boolean validGraphicsMode() {
if (VERBOSE)
System.err.println("JoglPipeline.validGraphicsMode()");
@@ -8914,8 +8200,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Native method for eye lighting
@Override
- void ctxUpdateEyeLightingEnable(Context ctx, boolean localEyeLightingEnable)
- {
+ void ctxUpdateEyeLightingEnable(Context ctx, boolean localEyeLightingEnable) {
if (VERBOSE)
System.err.println("JoglPipeline.ctxUpdateEyeLightingEnable()");
@@ -8941,8 +8226,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Method to construct a new DrawingSurfaceObject
@Override
- DrawingSurfaceObject createDrawingSurfaceObject(Canvas3D cv)
- {
+ DrawingSurfaceObject createDrawingSurfaceObject(Canvas3D cv) {
if (VERBOSE)
System.err.println("JoglPipeline.createDrawingSurfaceObject()");
return new JoglDrawingSurfaceObject(cv);
@@ -8951,8 +8235,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Method to free the drawing surface object
@Override
// NOOP
- void freeDrawingSurface(Canvas3D cv, DrawingSurfaceObject drawingSurfaceObject)
- {
+ void freeDrawingSurface(Canvas3D cv, DrawingSurfaceObject drawingSurfaceObject) {
if (VERBOSE)
System.err.println("JoglPipeline.freeDrawingSurface()");
// This method is a no-op
@@ -8961,8 +8244,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Method to free the native drawing surface object
@Override
// NOOP
- void freeDrawingSurfaceNative(Object o)
- {
+ void freeDrawingSurfaceNative(Object o) {
if (VERBOSE)
System.err.println("JoglPipeline.freeDrawingSurfaceNative()");
// This method is a no-op
@@ -8974,168 +8256,138 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Helper used everywhere
// USED heaps
- private static GLContext context(Context ctx)
- {
+ private static GLContext context(Context ctx) {
if (ctx == null)
return null;
- return ((JoglContext) ctx).getGLContext();
+ return ((JoglContext)ctx).getGLContext();
}
// Helper used everywhere
// USED a small amount
- private static GLDrawable drawable(Drawable drawable)
- {
+ private static GLDrawable drawable(Drawable drawable) {
if (drawable == null)
return null;
- return ((JoglDrawable) drawable).getGLDrawable();
+ return ((JoglDrawable)drawable).getGLDrawable();
}
// ----------------------------------------------------------------------
// General helper routines
//
- private static ThreadLocal<ShortBuffer> nioIndexTemp = new ThreadLocal<ShortBuffer>();
- private static ThreadLocal<FloatBuffer> nioVertexTemp = new ThreadLocal<FloatBuffer>();
- private static ThreadLocal<DoubleBuffer> nioVertexDoubleTemp = new ThreadLocal<DoubleBuffer>();
- private static ThreadLocal<FloatBuffer> nioColorTemp = new ThreadLocal<FloatBuffer>();
- private static ThreadLocal<ByteBuffer> nioColorByteTemp = new ThreadLocal<ByteBuffer>();
- private static ThreadLocal<FloatBuffer> nioNormalTemp = new ThreadLocal<FloatBuffer>();
- private static ThreadLocal<FloatBuffer[]> nioTexCoordSetTemp = new ThreadLocal<FloatBuffer[]>();
- private static ThreadLocal<FloatBuffer[]> nioVertexAttrSetTemp = new ThreadLocal<FloatBuffer[]>();
+ private static ThreadLocal<ShortBuffer> nioIndexTemp = new ThreadLocal<ShortBuffer>();
+ private static ThreadLocal<FloatBuffer> nioVertexTemp = new ThreadLocal<FloatBuffer>();
+ private static ThreadLocal<DoubleBuffer> nioVertexDoubleTemp = new ThreadLocal<DoubleBuffer>();
+ private static ThreadLocal<FloatBuffer> nioColorTemp = new ThreadLocal<FloatBuffer>();
+ private static ThreadLocal<ByteBuffer> nioColorByteTemp = new ThreadLocal<ByteBuffer>();
+ private static ThreadLocal<FloatBuffer> nioNormalTemp = new ThreadLocal<FloatBuffer>();
+ private static ThreadLocal<FloatBuffer[]> nioTexCoordSetTemp = new ThreadLocal<FloatBuffer[]>();
+ private static ThreadLocal<FloatBuffer[]> nioVertexAttrSetTemp = new ThreadLocal<FloatBuffer[]>();
// I think these are not used often as nio buffers sort it out
// but they are used a bit mind you
-
- private static ShortBuffer getIndexArrayBuffer(int[] indexArray)
- {
+
+ private static ShortBuffer getIndexArrayBuffer(int[] indexArray) {
return getIndexArrayBuffer(indexArray, true);
}
- private static ShortBuffer getIndexArrayBuffer(int[] indexArray, boolean copyData)
- {
+ private static ShortBuffer getIndexArrayBuffer(int[] indexArray, boolean copyData) {
return getNIOBuffer(indexArray, nioIndexTemp, copyData);
}
-
- private static FloatBuffer getVertexArrayBuffer(float[] vertexArray)
- {
+
+ private static FloatBuffer getVertexArrayBuffer(float[] vertexArray) {
return getVertexArrayBuffer(vertexArray, true);
}
- private static FloatBuffer getVertexArrayBuffer(float[] vertexArray, boolean copyData)
- {
+ private static FloatBuffer getVertexArrayBuffer(float[] vertexArray, boolean copyData) {
return getNIOBuffer(vertexArray, nioVertexTemp, copyData);
}
- private static DoubleBuffer getVertexArrayBuffer(double[] vertexArray)
- {
+ private static DoubleBuffer getVertexArrayBuffer(double[] vertexArray) {
return getVertexArrayBuffer(vertexArray, true);
}
- private static DoubleBuffer getVertexArrayBuffer(double[] vertexArray, boolean copyData)
- {
+ private static DoubleBuffer getVertexArrayBuffer(double[] vertexArray, boolean copyData) {
return getNIOBuffer(vertexArray, nioVertexDoubleTemp, true);
}
- private static FloatBuffer getColorArrayBuffer(float[] colorArray)
- {
+ private static FloatBuffer getColorArrayBuffer(float[] colorArray) {
return getColorArrayBuffer(colorArray, true);
}
- private static FloatBuffer getColorArrayBuffer(float[] colorArray, boolean copyData)
- {
+ private static FloatBuffer getColorArrayBuffer(float[] colorArray, boolean copyData) {
return getNIOBuffer(colorArray, nioColorTemp, true);
}
- private static ByteBuffer getColorArrayBuffer(byte[] colorArray)
- {
+ private static ByteBuffer getColorArrayBuffer(byte[] colorArray) {
return getColorArrayBuffer(colorArray, true);
}
- private static ByteBuffer getColorArrayBuffer(byte[] colorArray, boolean copyData)
- {
+ private static ByteBuffer getColorArrayBuffer(byte[] colorArray, boolean copyData) {
return getNIOBuffer(colorArray, nioColorByteTemp, true);
}
- private static FloatBuffer getNormalArrayBuffer(float[] normalArray)
- {
+ private static FloatBuffer getNormalArrayBuffer(float[] normalArray) {
return getNormalArrayBuffer(normalArray, true);
}
- private static FloatBuffer getNormalArrayBuffer(float[] normalArray, boolean copyData)
- {
+ private static FloatBuffer getNormalArrayBuffer(float[] normalArray, boolean copyData) {
return getNIOBuffer(normalArray, nioNormalTemp, true);
}
- private static FloatBuffer[] getTexCoordSetBuffer(Object[] texCoordSet)
- {
+ private static FloatBuffer[] getTexCoordSetBuffer(Object[] texCoordSet) {
return getNIOBuffer(texCoordSet, nioTexCoordSetTemp);
}
- private static FloatBuffer[] getVertexAttrSetBuffer(Object[] vertexAttrSet)
- {
+ private static FloatBuffer[] getVertexAttrSetBuffer(Object[] vertexAttrSet) {
return getNIOBuffer(vertexAttrSet, nioVertexAttrSetTemp);
}
-
+
//NOTE! int array copied, ShortBuffer returned
- private static ShortBuffer getNIOBuffer(int[] array, ThreadLocal<ShortBuffer> threadLocal, boolean copyData)
- {
- if (array == null)
- {
- return null;
- }
- ShortBuffer buf = threadLocal.get();
- if (buf == null)
- {
- buf = Buffers.newDirectShortBuffer(array.length);
+ private static ShortBuffer getNIOBuffer(int[] array, ThreadLocal<ShortBuffer> threadLocal, boolean copyData) {
+ if (array == null) {
+ return null;
+ }
+ ShortBuffer buf = threadLocal.get();
+ if (buf == null) {
+ buf = Buffers.newDirectShortBuffer(array.length);
+ threadLocal.set(buf);
+ } else {
+ buf.rewind();
+ if (buf.remaining() < array.length) {
+ int newSize = Math.max(2 * buf.remaining(), array.length);
+ buf = Buffers.newDirectShortBuffer(newSize);
threadLocal.set(buf);
}
- else
- {
- buf.rewind();
- if (buf.remaining() < array.length)
- {
- int newSize = Math.max(2 * buf.remaining(), array.length);
- buf = Buffers.newDirectShortBuffer(newSize);
- threadLocal.set(buf);
- }
- }
- if (copyData)
- {
- //NOTE! int array copied
- short[] shorts = new short[array.length];
- for(int i=0;i<array.length;i++)
- shorts[i] = (short)array[i];
-
- buf.put(shorts);
- buf.rewind();
- buf.limit(array.length);
- }
- return buf;
}
+ if (copyData) {
+ //NOTE! int array copied
+ short[] shorts = new short[array.length];
+ for (int i = 0; i < array.length; i++)
+ shorts [i] = (short)array [i];
- private static FloatBuffer getNIOBuffer(float[] array, ThreadLocal<FloatBuffer> threadLocal, boolean copyData)
- {
- if (array == null)
- {
+ buf.put(shorts);
+ buf.rewind();
+ buf.limit(array.length);
+ }
+ return buf;
+ }
+
+ private static FloatBuffer getNIOBuffer(float[] array, ThreadLocal<FloatBuffer> threadLocal, boolean copyData) {
+ if (array == null) {
return null;
}
FloatBuffer buf = threadLocal.get();
- if (buf == null)
- {
+ if (buf == null) {
buf = Buffers.newDirectFloatBuffer(array.length);
threadLocal.set(buf);
- }
- else
- {
+ } else {
buf.rewind();
- if (buf.remaining() < array.length)
- {
+ if (buf.remaining() < array.length) {
int newSize = Math.max(2 * buf.remaining(), array.length);
buf = Buffers.newDirectFloatBuffer(newSize);
threadLocal.set(buf);
}
}
- if (copyData)
- {
+ if (copyData) {
buf.put(array);
buf.rewind();
buf.limit(array.length);
@@ -9143,30 +8395,23 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
return buf;
}
- private static DoubleBuffer getNIOBuffer(double[] array, ThreadLocal<DoubleBuffer> threadLocal, boolean copyData)
- {
- if (array == null)
- {
+ private static DoubleBuffer getNIOBuffer(double[] array, ThreadLocal<DoubleBuffer> threadLocal, boolean copyData) {
+ if (array == null) {
return null;
}
DoubleBuffer buf = threadLocal.get();
- if (buf == null)
- {
+ if (buf == null) {
buf = Buffers.newDirectDoubleBuffer(array.length);
threadLocal.set(buf);
- }
- else
- {
+ } else {
buf.rewind();
- if (buf.remaining() < array.length)
- {
+ if (buf.remaining() < array.length) {
int newSize = Math.max(2 * buf.remaining(), array.length);
buf = Buffers.newDirectDoubleBuffer(newSize);
threadLocal.set(buf);
}
}
- if (copyData)
- {
+ if (copyData) {
buf.put(array);
buf.rewind();
buf.limit(array.length);
@@ -9174,30 +8419,23 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
return buf;
}
- private static ByteBuffer getNIOBuffer(byte[] array, ThreadLocal<ByteBuffer> threadLocal, boolean copyData)
- {
- if (array == null)
- {
+ private static ByteBuffer getNIOBuffer(byte[] array, ThreadLocal<ByteBuffer> threadLocal, boolean copyData) {
+ if (array == null) {
return null;
}
ByteBuffer buf = threadLocal.get();
- if (buf == null)
- {
+ if (buf == null) {
buf = Buffers.newDirectByteBuffer(array.length);
threadLocal.set(buf);
- }
- else
- {
+ } else {
buf.rewind();
- if (buf.remaining() < array.length)
- {
+ if (buf.remaining() < array.length) {
int newSize = Math.max(2 * buf.remaining(), array.length);
buf = Buffers.newDirectByteBuffer(newSize);
threadLocal.set(buf);
}
}
- if (copyData)
- {
+ if (copyData) {
buf.put(array);
buf.rewind();
buf.limit(array.length);
@@ -9205,22 +8443,17 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
return buf;
}
- private static FloatBuffer[] getNIOBuffer(Object[] array, ThreadLocal<FloatBuffer[]> threadLocal)
- {
- if (array == null)
- {
+ private static FloatBuffer[] getNIOBuffer(Object[] array, ThreadLocal<FloatBuffer[]> threadLocal) {
+ if (array == null) {
return null;
}
FloatBuffer[] bufs = threadLocal.get();
// First resize array of FloatBuffers
- if (bufs == null)
- {
+ if (bufs == null) {
bufs = new FloatBuffer[array.length];
threadLocal.set(bufs);
- }
- else if (bufs.length < array.length)
- {
+ } else if (bufs.length < array.length) {
FloatBuffer[] newBufs = new FloatBuffer[array.length];
System.arraycopy(bufs, 0, newBufs, 0, bufs.length);
bufs = newBufs;
@@ -9228,23 +8461,18 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// Now go down array of arrays, converting each into a direct FloatBuffer
- for (int i = 0; i < array.length; i++)
- {
- float[] cur = (float[]) array[i];
- FloatBuffer buf = bufs[i];
- if (buf == null)
- {
+ for (int i = 0; i < array.length; i++) {
+ float[] cur = (float[])array [i];
+ FloatBuffer buf = bufs [i];
+ if (buf == null) {
buf = Buffers.newDirectFloatBuffer(cur.length);
- bufs[i] = buf;
- }
- else
- {
+ bufs [i] = buf;
+ } else {
buf.rewind();
- if (buf.remaining() < cur.length)
- {
+ if (buf.remaining() < cur.length) {
int newSize = Math.max(2 * buf.remaining(), cur.length);
buf = Buffers.newDirectFloatBuffer(newSize);
- bufs[i] = buf;
+ bufs [i] = buf;
}
}
buf.put(cur);
@@ -9259,12 +8487,10 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// times, so we use a variable that is lazy initialized for each
private isExtensionAvailable isExtensionAvailable = new isExtensionAvailable();
- private class isExtensionAvailable
- {
+ private class isExtensionAvailable {
private int GL_EXT_abgr = 0;
- private boolean GL_EXT_abgr(GL2ES2 gl)
- {
+ private boolean GL_EXT_abgr(GL2ES2 gl) {
if (GL_EXT_abgr == 0)
GL_EXT_abgr = gl.isExtensionAvailable("GL_EXT_abgr") ? 1 : -1;
@@ -9273,8 +8499,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
private int GL_ARB_imaging = 0;
- private boolean GL_ARB_imaging(GL2ES2 gl)
- {
+ private boolean GL_ARB_imaging(GL2ES2 gl) {
if (GL_ARB_imaging == 0)
GL_ARB_imaging = gl.isExtensionAvailable("GL_ARB_imaging") ? 1 : -1;
@@ -9285,8 +8510,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Methods to get actual capabilities from Canvas3D
@Override
- boolean hasDoubleBuffer(Canvas3D cv)
- {
+ boolean hasDoubleBuffer(Canvas3D cv) {
if (VERBOSE)
System.err.println("JoglPipeline.hasDoubleBuffer()");
if (VERBOSE)
@@ -9295,8 +8519,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- boolean hasStereo(Canvas3D cv)
- {
+ boolean hasStereo(Canvas3D cv) {
if (VERBOSE)
System.err.println("JoglPipeline.hasStereo()");
if (VERBOSE)
@@ -9305,8 +8528,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- int getStencilSize(Canvas3D cv)
- {
+ int getStencilSize(Canvas3D cv) {
if (VERBOSE)
System.err.println("JoglPipeline.getStencilSize()");
if (VERBOSE)
@@ -9315,8 +8537,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- boolean hasSceneAntialiasingMultisample(Canvas3D cv)
- {
+ boolean hasSceneAntialiasingMultisample(Canvas3D cv) {
if (VERBOSE)
System.err.println("JoglPipeline.hasSceneAntialiasingMultisample()");
if (VERBOSE)
@@ -9326,8 +8547,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- boolean hasSceneAntialiasingAccum(Canvas3D cv)
- {
+ boolean hasSceneAntialiasingAccum(Canvas3D cv) {
if (VERBOSE)
System.err.println("JoglPipeline.hasSceneAntialiasingAccum()");
// Accum style antialiasing is gone
@@ -9342,17 +8562,13 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// Used to get caps for the canvas3d
- private static GLCapabilities caps(Canvas3D ctx)
- {
- if (ctx.drawable != null)
- {
+ private static GLCapabilities caps(Canvas3D ctx) {
+ if (ctx.drawable != null) {
// latest state for on- and offscreen drawables
- return (GLCapabilities) drawable(ctx.drawable).getChosenGLCapabilities();
- }
- else
- {
+ return (GLCapabilities)drawable(ctx.drawable).getChosenGLCapabilities();
+ } else {
// state at the time of 'getBestConfiguration'
- return ((JoglGraphicsConfiguration) ctx.graphicsConfiguration).getGLCapabilities();
+ return ((JoglGraphicsConfiguration)ctx.graphicsConfiguration).getGLCapabilities();
}
}
@@ -9362,8 +8578,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Determine whether specified graphics config is supported by pipeline
@Override
- boolean isGraphicsConfigSupported(GraphicsConfigTemplate3D gct, GraphicsConfiguration gc)
- {
+ boolean isGraphicsConfigSupported(GraphicsConfigTemplate3D gct, GraphicsConfiguration gc) {
if (VERBOSE)
System.err.println("JoglPipeline.isGraphicsConfigSupported()");
@@ -9396,33 +8611,30 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// This method must return a valid GraphicsConfig, or else it must throw
// an exception if one cannot be returned.
@Override
- GraphicsConfiguration getGraphicsConfig(GraphicsConfiguration gconfig)
- {
+ GraphicsConfiguration getGraphicsConfig(GraphicsConfiguration gconfig) {
if (VERBOSE)
System.err.println("JoglPipeline.getGraphicsConfig()");
GraphicsConfigInfo gcInf0 = Canvas3D.graphicsConfigTable.get(gconfig);
- AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration) gcInf0.getPrivateData();
+ AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration)gcInf0.getPrivateData();
return awtConfig.getAWTGraphicsConfiguration();
}
- private enum DisabledCaps
- {
+ private enum DisabledCaps {
STEREO, AA, DOUBLE_BUFFER,
}
// Get best graphics config from pipeline
@Override
- GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D gct, GraphicsConfiguration[] gc)
- {
+ GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D gct, GraphicsConfiguration[] gc) {
if (VERBOSE)
System.err.println("JoglPipeline.getBestConfiguration()");
-
+
//PJ this bug turns up in web start from 7u25 onwards, this fix should have been called from here from the beginning
- // as getBestConfiguration calls new Component eventually where the bug surfaces
- checkAppContext();
+ // as getBestConfiguration calls new Component eventually where the bug surfaces
+ checkAppContext();
// Create a GLCapabilities based on the GraphicsConfigTemplate3D
final GLCapabilities caps = new GLCapabilities(profile);
@@ -9432,14 +8644,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
caps.setStereo(gct.getStereo() != GraphicsConfigTemplate.UNNECESSARY);
// Scene antialiasing only if double buffering
- if (gct.getSceneAntialiasing() != GraphicsConfigTemplate.UNNECESSARY && gct.getDoubleBuffer() != GraphicsConfigTemplate.UNNECESSARY)
- {
+ if (gct.getSceneAntialiasing() != GraphicsConfigTemplate.UNNECESSARY
+ && gct.getDoubleBuffer() != GraphicsConfigTemplate.UNNECESSARY) {
caps.setSampleBuffers(true);
int numSamples = MasterControl.getIntegerProperty("j3d.numSamples", 2);
caps.setNumSamples(numSamples);
- }
- else
- {
+ } else {
caps.setSampleBuffers(false);
caps.setNumSamples(0);
}
@@ -9452,8 +8662,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
caps.setBlueBits(Math.max(5, gct.getBlueSize()));
// Issue 399: Request alpha buffer if transparentOffScreen is set
- if (VirtualUniverse.mc.transparentOffScreen)
- {
+ if (VirtualUniverse.mc.transparentOffScreen) {
caps.setAlphaBits(1);
}
@@ -9461,26 +8670,24 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// we will try disabling them
ArrayList<DisabledCaps> capsToDisable = new ArrayList<DisabledCaps>();
- if (gct.getStereo() == GraphicsConfigTemplate.PREFERRED)
- {
+ if (gct.getStereo() == GraphicsConfigTemplate.PREFERRED) {
capsToDisable.add(DisabledCaps.STEREO);
}
- if (gct.getSceneAntialiasing() == GraphicsConfigTemplate.PREFERRED)
- {
+ if (gct.getSceneAntialiasing() == GraphicsConfigTemplate.PREFERRED) {
capsToDisable.add(DisabledCaps.AA);
}
// if AA is required, so is double buffering.
- if (gct.getSceneAntialiasing() != GraphicsConfigTemplate.REQUIRED && gct.getDoubleBuffer() == GraphicsConfigTemplate.PREFERRED)
- {
+ if (gct.getSceneAntialiasing() != GraphicsConfigTemplate.REQUIRED
+ && gct.getDoubleBuffer() == GraphicsConfigTemplate.PREFERRED) {
capsToDisable.add(DisabledCaps.DOUBLE_BUFFER);
}
// Pick an arbitrary graphics device.
- GraphicsDevice device = gc[0].getDevice();
- AbstractGraphicsScreen screen = (device != null) ? AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT)
- : AWTGraphicsScreen.createDefault();
+ GraphicsDevice device = gc [0].getDevice();
+ AbstractGraphicsScreen screen = (device != null) ? AWTGraphicsScreen.createScreenDevice(device,
+ AbstractGraphicsDevice.DEFAULT_UNIT) : AWTGraphicsScreen.createDefault();
// Create a Frame and dummy GLCanvas to perform eager pixel format
// selection
@@ -9491,38 +8698,29 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
boolean tryAgain = true;
CapabilitiesCapturer capturer = null;
AWTGraphicsConfiguration awtConfig = null;
- while (tryAgain)
- {
+ while (tryAgain) {
Frame f = new Frame();
Dialog d = new Dialog(f);
d.setUndecorated(true);
d.setLayout(new BorderLayout());
capturer = new CapabilitiesCapturer();
- try
- {
+ try {
awtConfig = createAwtGraphicsConfiguration(caps, capturer, screen);
QueryCanvas canvas = new QueryCanvas(awtConfig, capturer);
d.add(canvas, BorderLayout.CENTER);
d.setSize(MIN_FRAME_SIZE, MIN_FRAME_SIZE);
d.setVisible(true);
canvas.doQuery();
- if (DEBUG_CONFIG)
- {
+ if (DEBUG_CONFIG) {
System.err.println("Waiting for CapabilitiesCapturer");
}
// Try to wait for result without blocking EDT
- if (!EventQueue.isDispatchThread())
- {
- synchronized (capturer)
- {
- if (!capturer.done())
- {
- try
- {
+ if (!EventQueue.isDispatchThread()) {
+ synchronized (capturer) {
+ if (!capturer.done()) {
+ try {
capturer.wait(WAIT_TIME);
- }
- catch (InterruptedException e)
- {
+ } catch (InterruptedException e) {
}
}
}
@@ -9530,28 +8728,22 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
disposeOnEDT(d);
disposeOnEDT(f);
tryAgain = false;
- }
- catch (GLException e)
- {
+ } catch (GLException e) {
// Failure to select a pixel format; try switching off one
// of the only-preferred capabilities
- if (capsToDisable.size() == 0)
- {
+ if (capsToDisable.size() == 0) {
tryAgain = false;
- }
- else
- {
- switch (capsToDisable.remove(0))
- {
- case STEREO:
- caps.setStereo(false);
- break;
- case AA:
- caps.setSampleBuffers(false);
- break;
- case DOUBLE_BUFFER:
- caps.setDoubleBuffered(false);
- break;
+ } else {
+ switch (capsToDisable.remove(0)) {
+ case STEREO:
+ caps.setStereo(false);
+ break;
+ case AA:
+ caps.setSampleBuffers(false);
+ break;
+ case DOUBLE_BUFFER:
+ caps.setDoubleBuffered(false);
+ break;
}
awtConfig = null;
}
@@ -9559,21 +8751,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
int chosenIndex = capturer.getChosenIndex();
GLCapabilities chosenCaps = null;
- if (chosenIndex < 0)
- {
- if (DEBUG_CONFIG)
- {
+ if (chosenIndex < 0) {
+ if (DEBUG_CONFIG) {
System.err.println("CapabilitiesCapturer returned invalid index");
}
// It's possible some platforms or implementations might not
// support the GLCapabilitiesChooser mechanism; feed in the
// same GLCapabilities later which we gave to the selector
chosenCaps = caps;
- }
- else
- {
- if (DEBUG_CONFIG)
- {
+ } else {
+ if (DEBUG_CONFIG) {
System.err.println("CapabilitiesCapturer returned index=" + chosenIndex);
}
chosenCaps = capturer.getCapabilities();
@@ -9593,42 +8780,35 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
GraphicsConfigInfo gcInf0 = new GraphicsConfigInfo(gct);
gcInf0.setPrivateData(awtConfig);
- synchronized (Canvas3D.graphicsConfigTable)
- {
+ synchronized (Canvas3D.graphicsConfigTable) {
Canvas3D.graphicsConfigTable.put(config, gcInf0);
}
return config;
}
- private boolean checkedForGetScreenMethod = false;
- private Method getScreenMethod = null;
+ private boolean checkedForGetScreenMethod = false;
+ private Method getScreenMethod = null;
@Override
// Screen3D class calls during init and that init is only called in the init
// of Canvas3D
// Notice this is using reflection on the GraphicsDevice!
- int getScreen(final GraphicsDevice graphicsDevice)
- {
+ int getScreen(final GraphicsDevice graphicsDevice) {
if (VERBOSE)
System.err.println("JoglPipeline.getScreen()");
- if (!checkedForGetScreenMethod)
- {
+ if (!checkedForGetScreenMethod) {
// All of the Sun GraphicsDevice implementations have a method
// int getScreen();
// which we want to call reflectively if it's available.
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
- public Object run()
- {
- try
- {
+ public Object run() {
+ try {
getScreenMethod = graphicsDevice.getClass().getDeclaredMethod("getScreen", new Class[] {});
getScreenMethod.setAccessible(true);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
}
checkedForGetScreenMethod = true;
return null;
@@ -9636,14 +8816,10 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
});
}
- if (getScreenMethod != null)
- {
- try
- {
- return ((Integer) getScreenMethod.invoke(graphicsDevice, (Object[]) null)).intValue();
- }
- catch (Exception e)
- {
+ if (getScreenMethod != null) {
+ try {
+ return ((Integer)getScreenMethod.invoke(graphicsDevice, (Object[])null)).intValue();
+ } catch (Exception e) {
throw new RuntimeException(e);
}
}
@@ -9660,8 +8836,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// and pixel format selection
// Used by Query Canvas apabilitiesCapturer and therefore only get best
// configuration
- private interface ExtendedCapabilitiesChooser extends GLCapabilitiesChooser
- {
+ private interface ExtendedCapabilitiesChooser extends GLCapabilitiesChooser {
public void init(GLContext context);
}
@@ -9673,18 +8848,16 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// single-threaded mode isn't enough to do this.
// Used by get best configuration
- private final class QueryCanvas extends Canvas
- {
+ private final class QueryCanvas extends Canvas {
- private GLDrawable glDrawable;
- private ExtendedCapabilitiesChooser chooser;
- private boolean alreadyRan;
+ private GLDrawable glDrawable;
+ private ExtendedCapabilitiesChooser chooser;
+ private boolean alreadyRan;
- private AWTGraphicsConfiguration awtConfig = null;
- private JAWTWindow nativeWindow = null;
+ private AWTGraphicsConfiguration awtConfig = null;
+ private JAWTWindow nativeWindow = null;
- private QueryCanvas(AWTGraphicsConfiguration awtConfig, ExtendedCapabilitiesChooser chooser)
- {
+ private QueryCanvas(AWTGraphicsConfiguration awtConfig, ExtendedCapabilitiesChooser chooser) {
// The platform-specific GLDrawableFactory will only provide a
// non-null GraphicsConfiguration on platforms where this is
// necessary (currently only X11, as Windows allows the pixel
@@ -9701,18 +8874,14 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
@Override
- public void addNotify()
- {
+ public void addNotify() {
super.addNotify();
- nativeWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig);
+ nativeWindow = (JAWTWindow)NativeWindowFactory.getNativeWindow(this, awtConfig);
nativeWindow.lockSurface();
- try
- {
+ try {
glDrawable = GLDrawableFactory.getFactory(profile).createGLDrawable(nativeWindow);
- }
- finally
- {
+ } finally {
nativeWindow.unlockSurface();
}
@@ -9722,20 +8891,15 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// It seems that at least on Mac OS X we need to do the OpenGL
// context-related work outside of the addNotify call because the
// Canvas hasn't been resized to a non-zero size by that point
- private void doQuery()
- {
+ private void doQuery() {
if (alreadyRan)
return;
GLContext context = glDrawable.createContext(null);
int res = context.makeCurrent();
- if (res != GLContext.CONTEXT_NOT_CURRENT)
- {
- try
- {
+ if (res != GLContext.CONTEXT_NOT_CURRENT) {
+ try {
chooser.init(context);
- }
- finally
- {
+ } finally {
context.release();
}
}
@@ -9748,12 +8912,13 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// Used by get best configuration
- private static AWTGraphicsConfiguration createAwtGraphicsConfiguration(GLCapabilities capabilities, CapabilitiesChooser chooser,
- AbstractGraphicsScreen screen)
- {
- GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilities.class);
- AWTGraphicsConfiguration awtGraphicsConfiguration = (AWTGraphicsConfiguration) factory.chooseGraphicsConfiguration(capabilities,
- capabilities, chooser, screen, VisualIDHolder.VID_UNDEFINED);
+ private static AWTGraphicsConfiguration createAwtGraphicsConfiguration( GLCapabilities capabilities,
+ CapabilitiesChooser chooser,
+ AbstractGraphicsScreen screen) {
+ GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class,
+ GLCapabilities.class);
+ AWTGraphicsConfiguration awtGraphicsConfiguration = (AWTGraphicsConfiguration)factory
+ .chooseGraphicsConfiguration(capabilities, capabilities, chooser, screen, VisualIDHolder.VID_UNDEFINED);
return awtGraphicsConfiguration;
}
@@ -9761,56 +8926,48 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// selection -- see getBestConfiguration
// Used by getBestConfiguration
- private static class CapabilitiesCapturer extends DefaultGLCapabilitiesChooser implements ExtendedCapabilitiesChooser
- {
- private boolean done;
- private GLCapabilities capabilities;
- private int chosenIndex = -1;
+ private static class CapabilitiesCapturer
+ extends DefaultGLCapabilitiesChooser implements ExtendedCapabilitiesChooser {
+ private boolean done;
+ private GLCapabilities capabilities;
+ private int chosenIndex = -1;
- public boolean done()
- {
+ public boolean done() {
return done;
}
- public GLCapabilities getCapabilities()
- {
+ public GLCapabilities getCapabilities() {
return capabilities;
}
- public int getChosenIndex()
- {
+ public int getChosenIndex() {
return chosenIndex;
}
- public int chooseCapabilities(GLCapabilities desired, GLCapabilities[] available, int windowSystemRecommendedChoice)
- {
+ public int chooseCapabilities( GLCapabilities desired, GLCapabilities[] available,
+ int windowSystemRecommendedChoice) {
int res = super.chooseCapabilities(desired, Arrays.asList(available), windowSystemRecommendedChoice);
- capabilities = available[res];
+ capabilities = available [res];
chosenIndex = res;
markDone();
return res;
}
@Override
- public void init(GLContext context)
- {
+ public void init(GLContext context) {
// Avoid hanging things up for several seconds
kick();
}
- private void markDone()
- {
- synchronized (this)
- {
+ private void markDone() {
+ synchronized (this) {
done = true;
notifyAll();
}
}
- private void kick()
- {
- synchronized (this)
- {
+ private void kick() {
+ synchronized (this) {
notifyAll();
}
}
@@ -9822,39 +8979,32 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// ONLY used by createQuerycontext above, hence unused
// What possibly invoked via some sort of crazy reflect, do not delete
// can't seem to get it invoked now?
- private final class ContextQuerier extends DefaultGLCapabilitiesChooser implements ExtendedCapabilitiesChooser
- {
- private Canvas3D canvas;
- private boolean done;
+ private final class ContextQuerier extends DefaultGLCapabilitiesChooser implements ExtendedCapabilitiesChooser {
+ private Canvas3D canvas;
+ private boolean done;
- public ContextQuerier(Canvas3D canvas)
- {
+ public ContextQuerier(Canvas3D canvas) {
this.canvas = canvas;
}
- public boolean done()
- {
+ public boolean done() {
return done;
}
@Override
- public void init(GLContext context)
- {
+ public void init(GLContext context) {
// This is basically a temporary, NOTE not JoglesContext either
JoglContext jctx = new JoglContext(context);
GL2ES2 gl = context.getGL().getGL2ES2();
// Set up various properties
- if (getPropertiesFromCurrentContext(jctx, gl))
- {
+ if (getPropertiesFromCurrentContext(jctx, gl)) {
setupCanvasProperties(canvas, jctx, gl);
}
markDone();
}
- private void markDone()
- {
- synchronized (this)
- {
+ private void markDone() {
+ synchronized (this) {
done = true;
notifyAll();
}
@@ -9862,24 +9012,174 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// used by getBestConfiguration above
- private static void disposeOnEDT(final Window f)
- {
+ private static void disposeOnEDT(final Window f) {
Runnable r = new Runnable() {
@Override
- public void run()
- {
+ public void run() {
f.setVisible(false);
f.dispose();
}
};
- if (!EventQueue.isDispatchThread())
- {
+ if (!EventQueue.isDispatchThread()) {
EventQueue.invokeLater(r);
- }
- else
- {
+ } else {
r.run();
}
}
+ static int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
+
+ public void bindToShadowDepthBuffer(Context ctx, LightRetained light) {
+
+ //Create the depth buffer to depth texture binding
+ if (light.shadowMapSamplerId == -1) {
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+ light.shadowMapFBOId = generateFrameBufferID(ctx);
+
+ //Next we create a 2D texture that we'll use as the framebuffer's depth buffer:
+
+ light.shadowMapSamplerId = generateTexID(ctx);
+ gl.glBindTexture(GL.GL_TEXTURE_2D, light.shadowMapSamplerId);
+ gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL2ES2.GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0,
+ GL2ES2.GL_DEPTH_COMPONENT, GL.GL_FLOAT, null);
+ gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
+ gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
+ gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL2ES2.GL_CLAMP_TO_BORDER);
+ gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL2ES2.GL_CLAMP_TO_BORDER);
+ float borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ gl.glTexParameterfv(GL.GL_TEXTURE_2D, GL2ES2.GL_TEXTURE_BORDER_COLOR, borderColor, 0);
+ //Generating the depth map shouldn't look too complicated. Because we only care about depth values we specify the texture's formats as GL_DEPTH_COMPONENT.
+ //We also give the texture a width and height of 1024: this is the resolution of the depth map.
+ //With the generated depth texture we can attach it as the framebuffer's depth buffer:
+
+ gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, light.shadowMapFBOId);
+ gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_TEXTURE_2D, light.shadowMapSamplerId, 0);
+ gl.glDrawBuffers(0, null, 0); //no color writes allowed 1, new int[]{GL.GL_NONE},0
+ //possibly ES3 only gl.glReadBuffer(GL.GL_NONE);
+ gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);
+ }
+ }
+
+
+
+ int generateFrameBufferID(Context ctx) {
+ if (VERBOSE)
+ System.err.println("JoglPipeline.generateFrameBufferID()");
+ if (OUTPUT_PER_FRAME_STATS)
+ ((Jogl2es2Context) ctx).perFrameStats.generateTexID++;
+
+ GL2ES2 gl = ((Jogl2es2Context)ctx).gl2es2();
+
+ int[] tmp = new int[] {-1};
+ gl.glGenFramebuffers(1, tmp, 0);
+
+ if (tmp [0] < 1)
+ return -1;
+
+ return tmp [0];
+ }
+
+ public ShaderProgramId shadowShaderId = null;
+ public boolean useShadowShaderOverride;
+
+ public void enableOverrideShadowDepthShader(Context ctx, LightRetained light, boolean enable) {
+
+ Jogl2es2Context joglesContext = (Jogl2es2Context)ctx;
+ GL2ES2 gl = joglesContext.gl2es2();
+ if (shadowShaderId == null) {
+ //GL2ES2.GL_SAMPLER_2D_SHADOW; // this is the way we sample the shadow texture see tutorial 16
+
+ String vertShad = "#version 330 core\n"
+ + "// Input vertex data, different for all executions of this shader.\n"
+ + "layout (location = 0) in vec4 glVertex;\n"
+ + "// Values that stay constant for the whole mesh.\n"
+ + "uniform mat4 glModelViewProjectionMatrix;\n" //
+ + "void main(){\n" //
+ + " gl_Position = glModelViewProjectionMatrix * glVertex;\n" //
+ + "}";//
+
+ int vertShaderHandleId = gl.glCreateShader(GL2ES2.GL_VERTEX_SHADER);
+ gl.glShaderSource(vertShaderHandleId, 1, new String[] {vertShad}, null, 0);
+ gl.glCompileShader(vertShaderHandleId);
+ int[] status = new int[1];
+ gl.glGetShaderiv(vertShaderHandleId, GL2ES2.GL_COMPILE_STATUS, status, 0);
+ if (status [0] == 0) {
+ String detailMsg = getShaderInfoLog(gl, vertShaderHandleId);
+ System.err.println(detailMsg);
+ }
+
+ String fragShad = "#version 330 core\n" + "// Ouput data\n"
+ + "layout(location = 0) out float fragmentdepth;\n" //
+ + "void main(){\n"//
+ + " // Not really needed, OpenGL does it anyway\n"
+ + " fragmentdepth = gl_FragCoord.z;\n" //
+ + "}";//
+ int fragShaderHandleId = gl.glCreateShader(GL2ES2.GL_FRAGMENT_SHADER);
+ gl.glShaderSource(fragShaderHandleId, 1, new String[] {fragShad}, null, 0);
+ gl.glCompileShader(fragShaderHandleId);
+ gl.glGetShaderiv(fragShaderHandleId, GL2ES2.GL_COMPILE_STATUS, status, 0);
+ if (status [0] == 0) {
+ String detailMsg = getShaderInfoLog(gl, fragShaderHandleId);
+ System.err.println(detailMsg);
+ }
+
+ int shaderProgramHandle = gl.glCreateProgram();
+ if (shaderProgramHandle == 0) {
+ System.err.println("Unable to create native shader program object");
+ }
+ shadowShaderId = new JoglShaderObject(shaderProgramHandle);
+
+ gl.glAttachShader(shaderProgramHandle, vertShaderHandleId);
+ gl.glAttachShader(shaderProgramHandle, fragShaderHandleId);
+
+ gl.glLinkProgram(shaderProgramHandle);
+ gl.glGetProgramiv(shaderProgramHandle, GL2ES2.GL_LINK_STATUS, status, 0);
+ if (status [0] == 0) {
+ String detailMsg = getProgramInfoLog(gl, shaderProgramHandle);
+ System.err.println(detailMsg);
+ }
+
+ joglesContext.setShaderProgram((JoglShaderObject)shadowShaderId);
+ loadLocs(joglesContext, gl);
+ }
+
+ useShadowShaderOverride = enable;
+
+ if (enable) {
+ gl.glUseProgram(unbox(shadowShaderId));
+ joglesContext.setShaderProgram((JoglShaderObject)shadowShaderId);
+ loadLocs(joglesContext, gl);
+ if (DO_OUTPUT_ERRORS)
+ outputErrors(ctx);
+
+ //make render out to depth buffer not screen
+ gl.glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
+ gl.glBindFramebuffer(GL2ES2.GL_FRAMEBUFFER, light.shadowMapFBOId);
+ gl.glClear(GL2ES2.GL_DEPTH_BUFFER_BIT);
+ gl.glCullFace(GL2.GL_FRONT);
+
+ } else {
+ // unset the override of shaders
+ gl.glUseProgram(0);
+ joglesContext.setShaderProgram(null);
+
+ if (DO_OUTPUT_ERRORS)
+ outputErrors(ctx);
+
+ // set render back to screen
+ gl.glBindFramebuffer(GL2ES2.GL_FRAMEBUFFER, 0);
+
+ //clear
+ gl.glClear(GL2ES2.GL_DEPTH_BUFFER_BIT | GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_STENCIL_BUFFER_BIT);
+ gl.glCullFace(GL2.GL_BACK);
+
+ //debug!!! output the depth buffer
+ //gl.glActiveTexture(GL2ES2.GL_TEXTURE0);
+ //gl.glBindTexture(GL2ES2.GL_TEXTURE_2D, light.shadowMapSamplerId);
+ //renderTexturedQuad(ctx, 0, 1, 0, 1, -0.2f, 0, -0.2f, 0, -0.5f);
+
+ }
+
+ }
+
}
diff --git a/src/main/java/org/jogamp/java3d/JoglPipeline.java b/src/main/java/org/jogamp/java3d/JoglPipeline.java
index 2c5e4b6..7ecbfc6 100644
--- a/src/main/java/org/jogamp/java3d/JoglPipeline.java
+++ b/src/main/java/org/jogamp/java3d/JoglPipeline.java
@@ -3426,7 +3426,8 @@ class JoglPipeline extends Pipeline {
@Override
void updateDirectionalLight(Context ctx,
int lightSlot, float red, float green,
- float blue, float dirx, float diry, float dirz) {
+ float blue, float dirx, float diry, float dirz,
+ int shadowMapSamplerId, double[] projMatrix) {
if (VERBOSE) System.err.println("JoglPipeline.updateDirectionalLight()");
GL2 gl = context(ctx).getGL().getGL2();
@@ -3464,7 +3465,8 @@ class JoglPipeline extends Pipeline {
void updatePointLight(Context ctx,
int lightSlot, float red, float green,
float blue, float attenx, float atteny, float attenz,
- float posx, float posy, float posz) {
+ float posx, float posy, float posz,
+ int shadowMapSamplerId, double[] projMatrix) {
if (VERBOSE) System.err.println("JoglPipeline.updatePointLight()");
GL2 gl = context(ctx).getGL().getGL2();
@@ -3503,7 +3505,7 @@ class JoglPipeline extends Pipeline {
float blue, float attenx, float atteny, float attenz,
float posx, float posy, float posz, float spreadAngle,
float concentration, float dirx, float diry,
- float dirz) {
+ float dirz, int shadowMapSamplerId, double[] projMatrix) {
if (VERBOSE) System.err.println("JoglPipeline.updateSpotLight()");
GL2 gl = context(ctx).getGL().getGL2();
diff --git a/src/main/java/org/jogamp/java3d/Light.java b/src/main/java/org/jogamp/java3d/Light.java
index 05c643c..e989b86 100644
--- a/src/main/java/org/jogamp/java3d/Light.java
+++ b/src/main/java/org/jogamp/java3d/Light.java
@@ -29,6 +29,7 @@ package org.jogamp.java3d;
import java.util.Iterator;
import org.jogamp.vecmath.Color3f;
+import org.jogamp.vecmath.Vector3f;
/**
* The Light leaf node is an abstract class that defines a set of
@@ -631,10 +632,31 @@ return ((LightRetained)this.retained).getAllScopes();
if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_READ))
throw new CapabilityNotSetException(J3dI18N.getString("Light12"));
- return ((LightRetained)this.retained).getInfluencingBoundingLeaf();
+ return ((LightRetained)this.retained).getInfluencingBoundingLeaf();
}
+ public void setShadowMap(boolean generateShadowMap) {
+ //FIXME: give it a shadow map cap bits
+ if (isLiveOrCompiled())
+ if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_WRITE))
+ throw new CapabilityNotSetException("setShadowMap" +
+ J3dI18N.getString("Light11"));
+ if (isLive())
+ ((LightRetained)this.retained).setShadowMap(generateShadowMap);
+ else
+ ((LightRetained)this.retained).initShadowMap(generateShadowMap);
+ }
+
+ public boolean hasShadowMap() {
+ //FIXME: give it a shadow map cap bits
+ if (isLiveOrCompiled())
+ if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_READ))
+ throw new CapabilityNotSetException(
+ J3dI18N.getString("Light12"));
+
+ return ((LightRetained)this.retained).hasShadowMap();
+ }
/**
* Copies all Light information from
diff --git a/src/main/java/org/jogamp/java3d/LightBin.java b/src/main/java/org/jogamp/java3d/LightBin.java
index 14bf38d..b021cba 100644
--- a/src/main/java/org/jogamp/java3d/LightBin.java
+++ b/src/main/java/org/jogamp/java3d/LightBin.java
@@ -76,11 +76,10 @@ class LightBin extends Object implements ObjectUpdate {
*/
EnvironmentSet environmentSetList = null;
-/**
- * List of envSet to be added for the next iteration
- */
-ArrayList<EnvironmentSet> insertEnvSet = new ArrayList<EnvironmentSet>();
-
+ /**
+ * List of envSet to be added for the next iteration
+ */
+ ArrayList<EnvironmentSet> insertEnvSet = new ArrayList<EnvironmentSet>();
/**
* cache of the canvasDirty
@@ -99,11 +98,11 @@ ArrayList<EnvironmentSet> insertEnvSet = new ArrayList<EnvironmentSet>();
*/
int lightDirtyMask = 0;
-/**
- * List of pointLts in this lightbin Need to reload these lights when vworld
- * scale changes
- */
-ArrayList<PointLightRetained> pointLts = new ArrayList<PointLightRetained>();
+ /**
+ * List of pointLts in this lightbin Need to reload these lights when vworld
+ * scale changes
+ */
+ ArrayList<PointLightRetained> pointLts = new ArrayList<PointLightRetained>();
int[] pointLtsSlotIndex;
// OrderedGroup info
@@ -114,29 +113,27 @@ ArrayList<PointLightRetained> pointLts = new ArrayList<PointLightRetained>();
// background node that contains geometry
BackgroundRetained geometryBackground = null;
-
-
LightBin(int maxLights, RenderBin rb, boolean isOpaque) {
this.maxLights = maxLights;
this.numEmptySlots = maxLights;
- lights = new LightRetained[maxLights];
- lightsRef = new int[maxLights];
- renderBin = rb;
+ lights = new LightRetained[maxLights];
+ lightsRef = new int[maxLights];
+ renderBin = rb;
}
void reset(boolean inOpaque) {
- prev = null;
- next = null;
- orderedCollection = null;
- environmentSetList = null;
- onUpdateList = false;
+ prev = null;
+ next = null;
+ orderedCollection = null;
+ environmentSetList = null;
+ onUpdateList = false;
geometryBackground = null;
- // No need to reset the lights and lightRef
+ // No need to reset the lights and lightRef
if (J3dDebug.devPhase && J3dDebug.debug) {
- for (int i=0; i<maxLights; i++) {
- J3dDebug.doAssert(lights[i] == null, "lights[i] == null");
- J3dDebug.doAssert(lightsRef[i] == 0, "lightsRef[i] == 0");
- }
+ for (int i=0; i<maxLights; i++) {
+ J3dDebug.doAssert(lights[i] == null, "lights[i] == null");
+ J3dDebug.doAssert(lightsRef[i] == 0, "lightsRef[i] == 0");
+ }
}
}
@@ -443,22 +440,30 @@ ArrayList<PointLightRetained> pointLts = new ArrayList<PointLightRetained>();
cv.canvasDirty &= ~Canvas3D.LIGHTBIN_DIRTY;
}
- else if ((pointLts.size() > 0) && ((cv.canvasDirty & Canvas3D.VIEW_MATRIX_DIRTY) != 0 )) {
- if (geometryBackground == null) {
- scale = cv.canvasViewCache.getVworldToCoexistenceScale();
- cv.setModelViewMatrix(cv.ctx, cv.vpcToEc.mat,
- renderBin.vworldToVpc);
- } else {
- scale = cv.canvasViewCache.getInfVworldToCoexistenceScale();
- cv.setModelViewMatrix(cv.ctx, cv.vpcToEc.mat,
- renderBin.infVworldToVpc);
- }
- for (i = 0; i < pointLts.size(); i++) {
+
+ // all lights require updating on view changes, including directionals now
+ else if ((cv.canvasDirty & Canvas3D.VIEW_MATRIX_DIRTY) != 0 ) {
+ if (geometryBackground == null) {
+ scale = cv.canvasViewCache.getVworldToCoexistenceScale();
+ cv.setModelViewMatrix(cv.ctx, cv.vpcToEc.mat, renderBin.vworldToVpc);
+ } else {
+ scale = cv.canvasViewCache.getInfVworldToCoexistenceScale();
+ cv.setModelViewMatrix(cv.ctx, cv.vpcToEc.mat, renderBin.infVworldToVpc);
+ }
+
+ for (i = 0; i < maxLights; i++) {
+ if (lights [i] != null) {
+ cv.lights [i] = lights [i];
+ cv.frameCount [i] = frameCount;
+ lights [i].update(cv.ctx, i, scale);
+ }
+ }
+ /* for (i = 0; i < pointLts.size(); i++) {
PointLightRetained lt = pointLts.get(i);
- lt.update(cv.ctx, pointLtsSlotIndex[i], scale);
+ lt.update(cv.ctx, pointLtsSlotIndex[i], scale);
cv.lights[pointLtsSlotIndex[i]] = lt;
cv.frameCount[pointLtsSlotIndex[i]] = frameCount;
- }
+ }*/
}
}
}
diff --git a/src/main/java/org/jogamp/java3d/LightRetained.java b/src/main/java/org/jogamp/java3d/LightRetained.java
index 8001f59..1d7c8bf 100644
--- a/src/main/java/org/jogamp/java3d/LightRetained.java
+++ b/src/main/java/org/jogamp/java3d/LightRetained.java
@@ -55,10 +55,10 @@ abstract class LightRetained extends LeafRetained {
// The color of the light (white by default).
Color3f color = new Color3f(1.0f, 1.0f, 1.0f);
-// This node which specifies the hierarchical scope of the
-// light. A null reference means that this light has universal
-// scope.
-Vector<GroupRetained> scopes = new Vector<GroupRetained>();
+ // This node which specifies the hierarchical scope of the
+ // light. A null reference means that this light has universal
+ // scope.
+ Vector<GroupRetained> scopes = new Vector<GroupRetained>();
/**
* The Boundary object defining the lights's region of influence.
@@ -69,6 +69,16 @@ Vector<GroupRetained> scopes = new Vector<GroupRetained>();
* The bounding leaf reference
*/
BoundingLeafRetained boundingLeaf = null;
+
+ /**
+ * Indicates the renderer should do a loop and generate a shadow map depth texture
+ * to hand into the lighting data of shaders
+ */
+ boolean hasShadowMap = false;
+
+ int shadowMapSamplerId = -1;
+ int shadowMapFBOId = -1;
+ double[] projMatrix;
/**
* The transformed value of the applicationRegion.
@@ -125,10 +135,10 @@ Vector<GroupRetained> scopes = new Vector<GroupRetained>();
boolean isViewScoped = false;
-/**
- * Temporary list of newly added mirror lights, during any setlive
- */
-ArrayList<LightRetained> newlyAddedMirrorLights = new ArrayList<LightRetained>();
+ /**
+ * Temporary list of newly added mirror lights, during any setlive
+ */
+ ArrayList<LightRetained> newlyAddedMirrorLights = new ArrayList<LightRetained>();
// Target threads to be notified when light changes
static final int targetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT |
@@ -495,6 +505,31 @@ Iterator<Group> getAllScopes() {
return (boundingLeaf != null ?
(BoundingLeaf)boundingLeaf.source : null);
}
+
+
+
+ void initShadowMap(boolean generateShadowMap) {
+ hasShadowMap = generateShadowMap;
+ }
+
+ /**
+ *
+ */
+ void setShadowMap(boolean generateShadowMap) {
+ initShadowMap(generateShadowMap);
+
+ //FIXME: generate message id
+ sendMessage(BOUNDINGLEAF_CHANGED,
+ (boundingLeaf != null ?
+ boundingLeaf.mirrorBoundingLeaf : null));
+ }
+
+ /**
+ *
+ */
+ boolean hasShadowMap() {
+ return hasShadowMap;
+ }
/**
* This sets the immedate mode context flag
diff --git a/src/main/java/org/jogamp/java3d/NoopPipeline.java b/src/main/java/org/jogamp/java3d/NoopPipeline.java
index bb2e900..a009bc0 100644
--- a/src/main/java/org/jogamp/java3d/NoopPipeline.java
+++ b/src/main/java/org/jogamp/java3d/NoopPipeline.java
@@ -558,7 +558,8 @@ class NoopPipeline extends Pipeline {
@Override
void updateDirectionalLight(Context ctx,
int lightSlot, float red, float green,
- float blue, float x, float y, float z) {
+ float blue, float x, float y, float z,
+ int shadowMapSamplerId, double[] projMatrix) {
}
@@ -572,7 +573,8 @@ class NoopPipeline extends Pipeline {
void updatePointLight(Context ctx,
int lightSlot, float red, float green,
float blue, float ax, float ay, float az,
- float px, float py, float pz) {
+ float px, float py, float pz,
+ int shadowMapSamplerId, double[] projMatrix) {
}
@@ -588,7 +590,7 @@ class NoopPipeline extends Pipeline {
float blue, float ax, float ay, float az,
float px, float py, float pz, float spreadAngle,
float concentration, float dx, float dy,
- float dz) {
+ float dz, int shadowMapSamplerId, double[] projMatrix) {
}
diff --git a/src/main/java/org/jogamp/java3d/Pipeline.java b/src/main/java/org/jogamp/java3d/Pipeline.java
index e13d0cb..87a597f 100644
--- a/src/main/java/org/jogamp/java3d/Pipeline.java
+++ b/src/main/java/org/jogamp/java3d/Pipeline.java
@@ -578,7 +578,8 @@ public Pipeline run() {
abstract void updateDirectionalLight(Context ctx,
int lightSlot, float red, float green,
- float blue, float x, float y, float z);
+ float blue, float x, float y, float z,
+ int shadowMapSamplerId, double[] projMatrix);
// ---------------------------------------------------------------------
@@ -590,7 +591,8 @@ public Pipeline run() {
abstract void updatePointLight(Context ctx,
int lightSlot, float red, float green,
float blue, float ax, float ay, float az,
- float px, float py, float pz);
+ float px, float py, float pz,
+ int shadowMapSamplerId, double[] projMatrix);
// ---------------------------------------------------------------------
@@ -604,7 +606,7 @@ public Pipeline run() {
float blue, float ax, float ay, float az,
float px, float py, float pz, float spreadAngle,
float concentration, float dx, float dy,
- float dz);
+ float dz, int shadowMapSamplerId, double[] projMatrix);
// ---------------------------------------------------------------------
diff --git a/src/main/java/org/jogamp/java3d/PointLightRetained.java b/src/main/java/org/jogamp/java3d/PointLightRetained.java
index 4946fc0..0e5561a 100644
--- a/src/main/java/org/jogamp/java3d/PointLightRetained.java
+++ b/src/main/java/org/jogamp/java3d/PointLightRetained.java
@@ -193,7 +193,7 @@ class PointLightRetained extends LightRetained {
attenuation.x, linearAttenuationInEc,
quadraticAttenuationInEc,
xformPosition.x, xformPosition.y,
- xformPosition.z);
+ xformPosition.z, shadowMapSamplerId, projMatrix);
}
@Override
diff --git a/src/main/java/org/jogamp/java3d/Renderer.java b/src/main/java/org/jogamp/java3d/Renderer.java
index 058b4f3..f47f5f1 100644
--- a/src/main/java/org/jogamp/java3d/Renderer.java
+++ b/src/main/java/org/jogamp/java3d/Renderer.java
@@ -35,16 +35,11 @@ import java.util.Iterator;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
-class Renderer extends J3dThread {
-
- // This action causes this thread to wait
- static final int WAIT = 0;
-
- // This action causes this thread to notify the view, and then wait.
- static final int NOTIFY_AND_WAIT = 1;
+import org.jogamp.vecmath.Point3d;
+import org.jogamp.vecmath.Vector3d;
+import org.jogamp.vecmath.Vector3f;
- // This action causes this thread to be notified
- static final int NOTIFY = 2;
+class Renderer extends J3dThread {
// The following are DecalGroup rendering states
static final int DECAL_NONE = 0;
@@ -52,15 +47,15 @@ class Renderer extends J3dThread {
static final int DECAL_NTH_CHILD = 2;
// stuff for scene antialiasing
-// static final int NUM_ACCUMULATION_SAMPLES = 8;
+ // static final int NUM_ACCUMULATION_SAMPLES = 8;
-// static final float ACCUM_SAMPLES_X[] = {-0.54818f, 0.56438f, 0.39462f, -0.54498f, -0.83790f,
-// -0.39263f, 0.32254f, 0.84216f};
+ // static final float ACCUM_SAMPLES_X[] = {-0.54818f, 0.56438f, 0.39462f, -0.54498f, -0.83790f,
+ // -0.39263f, 0.32254f, 0.84216f};
-// static final float ACCUM_SAMPLES_Y[] = {0.55331f, -0.53495f, 0.41540f, -0.52829f, 0.82102f,
-// -0.27383f, 0.09133f, -0.84399f};
+ // static final float ACCUM_SAMPLES_Y[] = {0.55331f, -0.53495f, 0.41540f, -0.52829f, 0.82102f,
+ // -0.27383f, 0.09133f, -0.84399f};
-// static final float accumValue = 1.0f / NUM_ACCUMULATION_SAMPLES;
+ // static final float accumValue = 1.0f / NUM_ACCUMULATION_SAMPLES;
// The following are Render arguments
static final int RENDER = 0;
@@ -133,10 +128,10 @@ class Renderer extends J3dThread {
Screen3D offScreen;
// full screen anti-aliasing projection matrices
-// Transform3D accumLeftProj = new Transform3D();
-// Transform3D accumRightProj = new Transform3D();
-// Transform3D accumInfLeftProj = new Transform3D();
-// Transform3D accumInfRightProj = new Transform3D();
+ // Transform3D accumLeftProj = new Transform3D();
+ // Transform3D accumRightProj = new Transform3D();
+ // Transform3D accumInfLeftProj = new Transform3D();
+ // Transform3D accumInfRightProj = new Transform3D();
// rendering messages
J3dMessage m[];
@@ -196,7 +191,7 @@ class Renderer extends J3dThread {
Object firstArg;
View view = null;
int stereo_mode;
- int num_stereo_passes=1;//, num_accum_passes = 1;
+ int num_stereo_passes = 1;//, num_accum_passes = 1;
int pass, i, j;
//boolean doAccum = false;
//double accumDx = 0.0f, accumDy = 0.0f;
@@ -915,7 +910,6 @@ class Renderer extends J3dThread {
}
canvas.drawingSurfaceObject.unLock();
} else {
-
if (canvas.isRunning) {
canvas.makeCtxCurrent();
}
@@ -1021,62 +1015,6 @@ class Renderer extends J3dThread {
sharedStereoZBuffer = false;
}
- // full screen anti-aliasing setup
- /*if (canvas.view.getSceneAntialiasingEnable() && canvas.sceneAntialiasingAvailable) {
-
- if (((canvas.extensionsSupported & Canvas3D.MULTISAMPLE) == 0)
- || !canvas.sceneAntialiasingMultiSamplesAvailable) {
- doAccum = true;
- num_accum_passes = NUM_ACCUMULATION_SAMPLES;
-
- System.arraycopy(cvCache.getLeftProjection().mat, 0, accumLeftProj.mat, 0, 16);
-
- accumDxFactor = (canvas.canvasViewCache.getPhysicalWindowWidth()
- / canvas.canvasViewCache.getCanvasWidth())
- * canvas.view.fieldOfView;
-
- accumDyFactor = (canvas.canvasViewCache.getPhysicalWindowHeight()
- / canvas.canvasViewCache.getCanvasHeight())
- * canvas.view.fieldOfView;
-
- accumLeftX = accumLeftProj.mat [3];
- accumLeftY = accumLeftProj.mat [7];
-
- if (useStereo) {
- System.arraycopy(cvCache.getRightProjection().mat, 0, accumRightProj.mat, 0,
- 16);
- accumRightX = accumRightProj.mat [3];
- accumRightY = accumRightProj.mat [7];
- }
-
- if (renderBin.geometryBackground != null) {
- System.arraycopy(cvCache.getInfLeftProjection().mat, 0, accumInfLeftProj.mat, 0,
- 16);
- accumInfLeftX = accumInfLeftProj.mat [3];
- accumInfLeftY = accumInfLeftProj.mat [7];
- if (useStereo) {
- System.arraycopy(cvCache.getInfRightProjection().mat, 0,
- accumInfRightProj.mat, 0, 16);
- accumInfRightX = accumInfRightProj.mat [3];
- accumInfRightY = accumInfRightProj.mat [7];
- }
- }
- } else {
-
- if (!canvas.isAntialiasingSet()) {
- // System.err.println("Renderer : Enable FullSceneAntialiasing");
-
- canvas.setFullSceneAntialiasing(canvas.ctx, true);
- }
- }
- } else {
-
- if (canvas.isAntialiasingSet()) {
- // System.err.println("Renderer : Disable SceneAntialiasing");
- canvas.setFullSceneAntialiasing(canvas.ctx, false);
- }
- }*/
-
// background geometry setup
if (renderBin.geometryBackground != null) {
renderBin.updateInfVworldToVpc();
@@ -1084,14 +1022,11 @@ class Renderer extends J3dThread {
// setup default render mode - render to both eyes
canvas.setRenderMode(canvas.ctx, Canvas3D.FIELD_ALL, canvas.useDoubleBuffer);
-
- // clear background if not full screen antialiasing
- // and not in stereo mode
+
+ // clear background if not in stereo mode
if (!sharedStereoZBuffer) {
BackgroundRetained bg = renderBin.background;
-
canvas.clear(bg, cvWidth, cvHeight);
-
}
// handle preRender callback
@@ -1119,162 +1054,218 @@ class Renderer extends J3dThread {
canvas.offScreenRendering = false;
break doneRender;
}
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////
+ //TODO:(and I guess a water reflection loop too?
+ //Water reflection is per canvas3D and view as it requires the current camera projection
+
+
+ // Note that lights are a renderbin issue as they are environmental (and frustum clipped for scope)
+ // so light maps can be added to the light itself per render loop
+ // not the scope of lights is based on visible geometry but the geometry required for renderering
+ // must be the frustum plus the frustum projected at the light
+
+ //TODO: check if shadowmap enabled, by having a variable based on shadow enabled lights in scene
+ boolean doShadowPass = Pipeline.getPipeline() instanceof Jogl2es2Pipeline;
+ if (doShadowPass) {
+
+ ArrayList<LightRetained> mappedLts = new ArrayList<LightRetained>();
+ // get all lights from renderbin that influence view frustum render atoms
+ int sz = renderBin.renderAtoms.size();
+ //TODO: is this just enormous?
+ for (int n = 0; n < sz; n++) {
+ RenderAtom ra = renderBin.renderAtoms.get(n);
+
+ if (!ra.inRenderBin())
+ continue;
+
+ LightRetained[] lights = renderBin.universe.renderingEnvironmentStructure.getInfluencingLights(ra, view);
+ for (i=0; i < lights.length; i++) {
+ LightRetained light = lights[i];
+ if (!mappedLts.contains(light)) {
+ mappedLts.add(light);
+ if(light.hasShadowMap) {
+ if( light instanceof DirectionalLightRetained) {
+ DirectionalLightRetained dlr = (DirectionalLightRetained)light;
+
+ //FIXME: all calls here taht use the pipeline should ask teh canvas3d to do the actual call
+ //TODO: check if shadow map supported on pipeline (not for ffp)
+ Jogl2es2Pipeline jogl2es2Pipeline = ((Jogl2es2Pipeline)Pipeline.getPipeline());
+
+ // TODO :give the canvas the depth buffer details so we are rendering to aFBO not the screen
+ jogl2es2Pipeline.bindToShadowDepthBuffer(canvas.ctx, light);
+
+
+
+
+ //TODO:canvas3d frustum are used by the rendermethod for culling
+ //TODO: dirty hack instead of setting the canvas to a no clip plane set
+ VirtualUniverse.mc.viewFrustumCulling = false;
+
+ //tell things to use a special depth only shader
+ jogl2es2Pipeline.enableOverrideShadowDepthShader(canvas.ctx, light, true);
+
+
+ Transform3D lightLocation = new Transform3D();
+ // flip direction to position
+ Point3d eye = new Point3d(dlr.xformDirection);
+ eye.scale(-10f);// used to flip dir if -1
+ Point3d center = new Point3d(0,0,0);
+ Vector3d up = new Vector3d(0, 0, -1);
+ // to make sure the up is not collinear with z only eye
+ if (eye.x == 0 && eye.y == 0) {
+ up.y = 1;
+ }
+ lightLocation.lookAt( eye, center, up);
+ canvas.vpcToEc = new Transform3D(lightLocation);
+ canvas.vworldToEc.mul(canvas.vpcToEc, cvCache.getInfVworldToVpc());
+
+
+ //this bad boy is a nice directional light orthographic projection from eye to screen
+ Transform3D lightProj = new Transform3D();
+ float near_plane = 0.1f, far_plane = 64.0f;
+
+ // see the JavaDoc for this method regarding opengl difference
+ lightProj.ortho(-5.0f, 5.0f, -5.0f, 5.0f, near_plane, far_plane);
+ canvas.setProjectionMatrix(canvas.ctx, lightProj);
+
+ // now combine and set for the shaders to receive
+ //java proj matrix have reverse z clips vs opengl!! @see setProjectionMatrix
+ lightProj.set(new double[] {
+ lightProj.mat[0],lightProj.mat[1],lightProj.mat[2],lightProj.mat[3],
+ lightProj.mat[4],lightProj.mat[5],lightProj.mat[6],lightProj.mat[7],
+ -lightProj.mat[8],-lightProj.mat[9],-lightProj.mat[10],-lightProj.mat[11],
+ lightProj.mat[12],lightProj.mat[13],lightProj.mat[14],lightProj.mat[15], }
+ );
+ // we add the projection and view into one (called proj becuse we project to it)
+ lightProj.mul(lightLocation);
+
+ // don't point take copy, possibly not needed
+ light.projMatrix = new double[] {
+ lightProj.mat[0],lightProj.mat[1],lightProj.mat[2],lightProj.mat[3],
+ lightProj.mat[4],lightProj.mat[5],lightProj.mat[6],lightProj.mat[7],
+ lightProj.mat[8],lightProj.mat[9],lightProj.mat[10],lightProj.mat[11],
+ lightProj.mat[12],lightProj.mat[13],lightProj.mat[14],lightProj.mat[15], };
+
+ // render opaque geometry
+ renderBin.renderOpaque(canvas);
+
+ // render ordered geometry
+ renderBin.renderOrdered(canvas);
+
+ //TODO: tell things to use a special depth and color type shader(for transparent textures)
+
+ // render transparent geometry
+ renderBin.renderTransparent(canvas);
+
+ //Restore
+ VirtualUniverse.mc.viewFrustumCulling = true;
+ jogl2es2Pipeline.enableOverrideShadowDepthShader(canvas.ctx, light, false);
+
+
+
+ } else if( light instanceof PointLightRetained) {
+
+ //TODO: and spot light? or is that just a variation on the way the cube map is shaded?
+
+ }
+ //ambient light skipped obviously
+ }
+ }
+ }
+ }
+
+ // lights etc all need to be recalc as we are changing the view
+ canvas.canvasDirty |= Canvas3D.VIEW_MATRIX_DIRTY;
+
+ // reset the viewport
+ canvas.setViewport(canvas.ctx, 0, 0, cvWidth, cvHeight);
+
+ }
+///////////////////////////////////////////////////////////////////////////////////////////////
// render loop
for (pass = 0; pass < num_stereo_passes; pass++) {
- //if (doAccum) {
- // canvas.clearAccum(canvas.ctx);
- //}
canvas.setRenderMode(canvas.ctx, stereo_mode, canvas.useDoubleBuffer);
- //for (apass = 0; apass < 1; apass++) {
-
- // jitter projection matrix and clear background
- // for full screen anti-aliasing rendering
- /*if (doAccum) {
- accumDx = ACCUM_SAMPLES_X [apass] * accumDxFactor;
- accumDy = ACCUM_SAMPLES_Y [apass] * accumDyFactor;
-
- accumLeftProj.mat [3] = accumLeftX + accumLeftProj.mat [0] * accumDx
- + accumLeftProj.mat [1] * accumDy;
-
- accumLeftProj.mat [7] = accumLeftY + accumLeftProj.mat [4] * accumDx
- + accumLeftProj.mat [5] * accumDy;
-
- if (useStereo) {
- accumRightProj.mat [3] = accumRightX + accumRightProj.mat [0] * accumDx
- + accumRightProj.mat [1] * accumDy;
-
- accumRightProj.mat [7] = accumRightY + accumRightProj.mat [4] * accumDx
- + accumRightProj.mat [5] * accumDy;
- }
-
- if (renderBin.geometryBackground != null) {
- accumInfLeftProj.mat [3] = accumInfLeftX
- + accumInfLeftProj.mat [0] * accumDx
- + accumInfLeftProj.mat [1] * accumDy;
-
- accumInfLeftProj.mat [7] = accumInfLeftY
- + accumInfLeftProj.mat [4] * accumDx
- + accumInfLeftProj.mat [5] * accumDy;
-
- if (useStereo) {
- accumInfRightProj.mat [3] = accumInfRightX
- + accumInfRightProj.mat [0] * accumDx
- + accumInfRightProj.mat [1] * accumDy;
-
- accumInfRightProj.mat [7] = accumInfRightY
- + accumInfRightProj.mat [4] * accumDx
- + accumInfRightProj.mat [5] * accumDy;
- }
- }
- }*/
-
- // clear background for stereo and
- // accumulation buffer cases
- if (sharedStereoZBuffer) {
- BackgroundRetained bg = renderBin.background;
-
- canvas.clear(bg, cvWidth, cvHeight);
+ // clear background for stereo
+ if (sharedStereoZBuffer) {
+ BackgroundRetained bg = renderBin.background;
+ canvas.clear(bg, cvWidth, cvHeight);
+ }
+ // render background geometry
+ if (renderBin.geometryBackground != null) {
+ // setup rendering matrices
+ if (pass == 0) {
+ canvas.vpcToEc = cvCache.getInfLeftVpcToEc();
+ canvas.setProjectionMatrix(canvas.ctx, cvCache.getInfLeftProjection());
+ } else {
+ canvas.vpcToEc = cvCache.getInfRightVpcToEc();
+ canvas.setProjectionMatrix(canvas.ctx, cvCache.getInfRightProjection());
}
+ canvas.vworldToEc.mul(canvas.vpcToEc, cvCache.getInfVworldToVpc());
// render background geometry
- if (renderBin.geometryBackground != null) {
-
- // setup rendering matrices
- if (pass == 0) {
- canvas.vpcToEc = cvCache.getInfLeftVpcToEc();
- //if (doAccum) {
- // canvas.setProjectionMatrix(canvas.ctx, accumInfLeftProj);
- //} else {
- canvas.setProjectionMatrix(canvas.ctx, cvCache.getInfLeftProjection());
- //}
- } else {
- canvas.vpcToEc = cvCache.getInfRightVpcToEc();
- //if (doAccum) {
- // canvas.setProjectionMatrix(canvas.ctx, accumInfRightProj);
- //} else {
- canvas.setProjectionMatrix(canvas.ctx, cvCache.getInfRightProjection());
- //}
- }
- canvas.vworldToEc.mul(canvas.vpcToEc, cvCache.getInfVworldToVpc());
+ renderBin.renderBackground(canvas);
+ }
- // render background geometry
- renderBin.renderBackground(canvas);
- }
+ // setup rendering matrices
+ if (pass == 0) {
+ canvas.vpcToEc = cvCache.getLeftVpcToEc();
+ canvas.setProjectionMatrix(canvas.ctx, cvCache.getLeftProjection());
+ } else {
+ canvas.vpcToEc = cvCache.getRightVpcToEc();
+ canvas.setProjectionMatrix(canvas.ctx, cvCache.getRightProjection());
+ }
+ canvas.vworldToEc.mul(canvas.vpcToEc, cvCache.getVworldToVpc());
- // setup rendering matrices
+ synchronized (cvCache) {
if (pass == 0) {
- canvas.vpcToEc = cvCache.getLeftVpcToEc();
- //if (doAccum) {
- // canvas.setProjectionMatrix(canvas.ctx, accumLeftProj);
- //} else {
- canvas.setProjectionMatrix(canvas.ctx, cvCache.getLeftProjection());
- //}
+ canvas.setFrustumPlanes(cvCache.getLeftFrustumPlanesInVworld());
} else {
- canvas.vpcToEc = cvCache.getRightVpcToEc();
- //if (doAccum) {
- // canvas.setProjectionMatrix(canvas.ctx, accumRightProj);
- //} else {
- canvas.setProjectionMatrix(canvas.ctx, cvCache.getRightProjection());
- //}
- }
- canvas.vworldToEc.mul(canvas.vpcToEc, cvCache.getVworldToVpc());
-
- synchronized (cvCache) {
- if (pass == 0) {
- canvas.setFrustumPlanes(cvCache.getLeftFrustumPlanesInVworld());
- } else {
- canvas.setFrustumPlanes(cvCache.getRightFrustumPlanesInVworld());
- }
+ canvas.setFrustumPlanes(cvCache.getRightFrustumPlanesInVworld());
}
+ }
- // Force view matrix dirty for each eye.
- if (useStereo) {
- canvas.canvasDirty |= Canvas3D.VIEW_MATRIX_DIRTY;
- }
+ // Force view matrix dirty for each eye.
+ if (useStereo) {
+ canvas.canvasDirty |= Canvas3D.VIEW_MATRIX_DIRTY;
+ }
- // render opaque geometry
- renderBin.renderOpaque(canvas);
+ // render opaque geometry
+ renderBin.renderOpaque(canvas);
- // render ordered geometry
- renderBin.renderOrdered(canvas);
+ // render ordered geometry
+ renderBin.renderOrdered(canvas);
- // handle renderField callback
- if (VirtualUniverse.mc.doDsiRenderLock) {
- canvas.drawingSurfaceObject.unLock();
- }
- canvas.view.inCanvasCallback = true;
- try {
- canvas.renderField(stereo_mode);
- } catch (RuntimeException e) {
- System.err.println("Exception occurred during Canvas3D callback:");
- e.printStackTrace();
- } catch (Error e) {
- // Issue 264 - catch Error so Renderer doesn't die
- System.err.println("Error occurred during Canvas3D callback:");
- e.printStackTrace();
- }
- canvas.view.inCanvasCallback = false;
- if ((VirtualUniverse.mc.doDsiRenderLock)
- && (!canvas.drawingSurfaceObject.renderLock())) {
- if ((offBufRetained != null) && offBufRetained.isByReference()) {
- offBufRetained.geomLock.unLock();
- }
- canvas.offScreenRendering = false;
- break doneRender;
+ // handle renderField callback
+ if (VirtualUniverse.mc.doDsiRenderLock) {
+ canvas.drawingSurfaceObject.unLock();
+ }
+ canvas.view.inCanvasCallback = true;
+ try {
+ canvas.renderField(stereo_mode);
+ } catch (RuntimeException e) {
+ System.err.println("Exception occurred during Canvas3D callback:");
+ e.printStackTrace();
+ } catch (Error e) {
+ // Issue 264 - catch Error so Renderer doesn't die
+ System.err.println("Error occurred during Canvas3D callback:");
+ e.printStackTrace();
+ }
+ canvas.view.inCanvasCallback = false;
+ if ((VirtualUniverse.mc.doDsiRenderLock)
+ && (!canvas.drawingSurfaceObject.renderLock())) {
+ if ((offBufRetained != null) && offBufRetained.isByReference()) {
+ offBufRetained.geomLock.unLock();
}
+ canvas.offScreenRendering = false;
+ break doneRender;
+ }
- // render transparent geometry
- renderBin.renderTransparent(canvas);
-
- //if (doAccum)
- // canvas.accum(canvas.ctx, accumValue);
- //}
+ // render transparent geometry
+ renderBin.renderTransparent(canvas);
- //if (doAccum)
- // canvas.accumReturn(canvas.ctx);
if (useStereo) {
stereo_mode = Canvas3D.FIELD_RIGHT;
canvas.rightStereoPass = true;
diff --git a/src/main/java/org/jogamp/java3d/SpotLightRetained.java b/src/main/java/org/jogamp/java3d/SpotLightRetained.java
index 0a2d145..6b9f89b 100644
--- a/src/main/java/org/jogamp/java3d/SpotLightRetained.java
+++ b/src/main/java/org/jogamp/java3d/SpotLightRetained.java
@@ -208,7 +208,8 @@ class SpotLightRetained extends PointLightRetained {
xformPosition.x, xformPosition.y,
xformPosition.z, spreadAngle, concentration,
xformDirection.x, xformDirection.y,
- xformDirection.z);
+ xformDirection.z, shadowMapSamplerId,
+ projMatrix);
}