aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/jogl
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2011-12-31 14:24:45 -0800
committerHarvey Harrison <[email protected]>2011-12-31 14:24:45 -0800
commiteb264491b0a923610888684fc6134e0f430932f8 (patch)
tree05daae868277d30d11f94b5b6370be30250243ae /src/classes/jogl
parentf7b4d86b7f02174bafe4006144d4f54dbbd55df7 (diff)
j3dcore: remove trailing whitespace from all files
Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/classes/jogl')
-rw-r--r--src/classes/jogl/javax/media/j3d/JoglContext.java2
-rw-r--r--src/classes/jogl/javax/media/j3d/JoglDrawingSurfaceObject.java10
-rw-r--r--src/classes/jogl/javax/media/j3d/JoglPipeline.java2372
3 files changed, 1192 insertions, 1192 deletions
diff --git a/src/classes/jogl/javax/media/j3d/JoglContext.java b/src/classes/jogl/javax/media/j3d/JoglContext.java
index 9aabda0..b25ff19 100644
--- a/src/classes/jogl/javax/media/j3d/JoglContext.java
+++ b/src/classes/jogl/javax/media/j3d/JoglContext.java
@@ -165,7 +165,7 @@ class JoglContext implements Context {
private int glslVertexAttrOffset;
// Only used when Cg shader library is active
- private CGcontext cgContext;
+ private CGcontext cgContext;
private int cgVertexProfile;
private int cgFragmentProfile;
diff --git a/src/classes/jogl/javax/media/j3d/JoglDrawingSurfaceObject.java b/src/classes/jogl/javax/media/j3d/JoglDrawingSurfaceObject.java
index 0da2a6f..439213e 100644
--- a/src/classes/jogl/javax/media/j3d/JoglDrawingSurfaceObject.java
+++ b/src/classes/jogl/javax/media/j3d/JoglDrawingSurfaceObject.java
@@ -32,13 +32,13 @@
package javax.media.j3d;
/**
- * The DrawingSurfaceObject class is used to manage native drawing surface
+ * The DrawingSurfaceObject class is used to manage native drawing surface
*/
class JoglDrawingSurfaceObject extends DrawingSurfaceObject {
-
+
JoglDrawingSurfaceObject(Canvas3D cv) {
super(cv);
-
+
// System.err.println("JoglDrawingSurfaceObject constructed");
}
@@ -56,9 +56,9 @@ class JoglDrawingSurfaceObject extends DrawingSurfaceObject {
synchronized void getDrawingSurfaceObjectInfo() {
// FIXME: we don't have all of the information we need here to
// create a GLDrawable for the Canvas3D, so for now, do nothing
-
+
// FIXME: this mechanism is much too complicated
-
+
/*
System.err.println("JoglDrawingSurfaceObject.getDrawingSurfaceObjectInfo()");
diff --git a/src/classes/jogl/javax/media/j3d/JoglPipeline.java b/src/classes/jogl/javax/media/j3d/JoglPipeline.java
index 30d1dab..b174183 100644
--- a/src/classes/jogl/javax/media/j3d/JoglPipeline.java
+++ b/src/classes/jogl/javax/media/j3d/JoglPipeline.java
@@ -49,10 +49,10 @@ import com.sun.opengl.util.*;
* pipeline.
*/
class JoglPipeline extends Pipeline {
-
+
// Flags indicating whether the Cg or GLSL libraries are available.
private boolean cgLibraryAvailable = false;
-
+
// Currently prints for entry points not yet implemented
private static final boolean DEBUG = true;
// Currently prints for entry points already implemented
@@ -65,27 +65,27 @@ class JoglPipeline extends Pipeline {
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;
-
+
/**
* Constructor for singleton JoglPipeline instance
*/
protected JoglPipeline() {
}
-
+
/**
* Initialize the pipeline
*/
void initialize(Pipeline.Type pipelineType) {
super.initialize(pipelineType);
-
+
assert pipelineType == Pipeline.Type.JOGL;
-
+
// Java3D maintains strict control over which threads perform OpenGL work
Threading.disableSingleThreading();
-
+
// TODO: finish this with any other needed initialization
}
-
+
/**
* Load all of the required libraries
*/
@@ -105,7 +105,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
/**
* Returns true if the Cg library is loaded and available. Note that this
* does not necessarily mean that Cg is supported by the graphics card.
@@ -113,7 +113,7 @@ class JoglPipeline extends Pipeline {
boolean isCgLibraryAvailable() {
return cgLibraryAvailable;
}
-
+
/**
* Returns true if the GLSL library is loaded and available. Note that this
* does not necessarily mean that GLSL is supported by the graphics card.
@@ -121,19 +121,19 @@ class JoglPipeline extends Pipeline {
boolean isGLSLLibraryAvailable() {
return true;
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// GeometryArrayRetained methods
//
-
+
// Used by D3D to free vertex buffer
void freeD3DArray(GeometryArrayRetained geo, boolean deleteVB) {
// Nothing to do
}
-
+
// used for GeometryArrays by Copy or interleaved
void execute(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -148,7 +148,7 @@ class JoglPipeline extends Pipeline {
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,
@@ -156,7 +156,7 @@ class JoglPipeline extends Pipeline {
vertexAttrCount, vertexAttrSizes,
varray, null, carray, cDirty);
}
-
+
// used by GeometryArray by Reference with java arrays
void executeVA(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -176,7 +176,7 @@ class JoglPipeline extends Pipeline {
int[] texIndex, int texstride, Object[] texCoords,
int cdirty) {
if (VERBOSE) System.err.println("JoglPipeline.executeVA()");
-
+
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0);
@@ -184,7 +184,7 @@ class JoglPipeline extends Pipeline {
boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0);
boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0);
boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);
-
+
FloatBuffer fverts = null;
DoubleBuffer dverts = null;
FloatBuffer fclrs = null;
@@ -192,36 +192,36 @@ class JoglPipeline extends Pipeline {
FloatBuffer[] texCoordBufs = null;
FloatBuffer norms = null;
FloatBuffer[] vertexAttrBufs = null;
-
+
// Get vertex attribute arrays
if (vattrDefined) {
vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);
}
-
+
// get texture arrays
if (textureDefined) {
texCoordBufs = getTexCoordSetBuffer(texCoords);
}
-
+
// get coordinate array
if (floatCoordDefined) {
fverts = getVertexArrayBuffer(vfcoords);
} else if (doubleCoordDefined) {
dverts = getVertexArrayBuffer(vdcoords);
}
-
+
// get color array
if (floatColorsDefined) {
fclrs = getColorArrayBuffer(cfdata);
} else if (byteColorsDefined) {
bclrs = getColorArrayBuffer(cbdata);
}
-
+
// get normal array
if (normalsDefined) {
norms = getNormalArrayBuffer(ndata);
}
-
+
int[] sarray = null;
int[] start_array = null;
int strip_len = 0;
@@ -232,7 +232,7 @@ class JoglPipeline extends Pipeline {
strip_len = sarray.length;
start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices;
}
-
+
executeGeometryArrayVA(ctx, geo, geo_type,
isNonUniformScale, ignoreVertexColors,
vcount, vformat, vdefined,
@@ -246,7 +246,7 @@ class JoglPipeline extends Pipeline {
texIndex, texstride, texCoordBufs, cdirty,
sarray, strip_len, start_array);
}
-
+
// used by GeometryArray by Reference with NIO buffer
void executeVABuffer(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -269,7 +269,7 @@ class JoglPipeline extends Pipeline {
int[] texIndex, int texstride, Object[] texCoords,
int cdirty) {
if (VERBOSE) System.err.println("JoglPipeline.executeVABuffer()");
-
+
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0);
@@ -277,7 +277,7 @@ class JoglPipeline extends Pipeline {
boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0);
boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0);
boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);
-
+
FloatBuffer fverts = null;
DoubleBuffer dverts = null;
FloatBuffer fclrs = null;
@@ -285,12 +285,12 @@ class JoglPipeline extends Pipeline {
FloatBuffer[] texCoordBufs = null;
FloatBuffer norms = null;
FloatBuffer[] vertexAttrBufs = null;
-
+
// Get vertex attribute arrays
if (vattrDefined) {
vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);
}
-
+
// get texture arrays
if (textureDefined) {
texCoordBufs = new FloatBuffer[texCoords.length];
@@ -298,18 +298,18 @@ class JoglPipeline extends Pipeline {
texCoordBufs[i] = (FloatBuffer) texCoords[i];
}
}
-
+
// get coordinate array
if (floatCoordDefined) {
fverts = (FloatBuffer) vcoords;
} else if (doubleCoordDefined) {
dverts = (DoubleBuffer) vcoords;
}
-
+
if (fverts == null && dverts == null) {
return;
}
-
+
// get color array
if (floatColorsDefined) {
if (cfdata != null)
@@ -322,12 +322,12 @@ class JoglPipeline extends Pipeline {
else
bclrs = (ByteBuffer) cdataBuffer;
}
-
+
// get normal array
if (normalsDefined) {
norms = (FloatBuffer) ndata;
}
-
+
int[] sarray = null;
int[] start_array = null;
int strip_len = 0;
@@ -338,7 +338,7 @@ class JoglPipeline extends Pipeline {
strip_len = sarray.length;
start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices;
}
-
+
executeGeometryArrayVA(ctx, geo, geo_type,
isNonUniformScale, ignoreVertexColors,
vcount, vformat, vdefined,
@@ -352,7 +352,7 @@ class JoglPipeline extends Pipeline {
texIndex, texstride, texCoordBufs, cdirty,
sarray, strip_len, start_array);
}
-
+
// used by GeometryArray by Reference in interleaved format with NIO buffer
void executeInterleavedBuffer(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -366,7 +366,7 @@ class JoglPipeline extends Pipeline {
int numActiveTexUnit,
Object varray, float[] cdata, int cdirty) {
if (VERBOSE) System.err.println("JoglPipeline.executeInterleavedBuffer()");
-
+
executeGeometryArray(ctx, geo, geo_type,
isNonUniformScale, useAlpha, ignoreVertexColors,
startVIndex, vcount, vformat,
@@ -374,13 +374,13 @@ class JoglPipeline extends Pipeline {
texUnitOffset, numActiveTexUnit, 0, null,
null, (Buffer) varray, cdata, cdirty);
}
-
+
void setVertexFormat(Context ctx, GeometryArrayRetained geo,
int vformat, boolean useAlpha, boolean ignoreVertexColors) {
if (VERBOSE) System.err.println("JoglPipeline.setVertexFormat()");
-
+
GL gl = context(ctx).getGL();
-
+
// Enable and disable the appropriate pointers
if ((vformat & GeometryArray.NORMALS) != 0) {
gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
@@ -392,7 +392,7 @@ class JoglPipeline extends Pipeline {
} else {
gl.glDisableClientState(GL.GL_COLOR_ARRAY);
}
-
+
if (gl.isExtensionAvailable("GL_SUN_global_alpha")) {
if (useAlpha) {
gl.glEnable(GL.GL_GLOBAL_ALPHA_SUN);
@@ -400,20 +400,20 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_GLOBAL_ALPHA_SUN);
}
}
-
+
if ((vformat & GeometryArray.COORDINATES) != 0) {
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
} else {
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
}
}
-
+
void disableGlobalAlpha(Context ctx, GeometryArrayRetained geo, int vformat,
boolean useAlpha, boolean ignoreVertexColors) {
if (VERBOSE) System.err.println("JoglPipeline.disableGlobalAlpha()");
-
+
GL gl = context(ctx).getGL();
-
+
if (gl.isExtensionAvailable("GL_SUN_global_alpha")) {
if (!ignoreVertexColors && ((vformat & GeometryArray.COLOR) != 0)) {
if (useAlpha) {
@@ -422,7 +422,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
// used for GeometryArrays
void buildGA(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -450,7 +450,7 @@ class JoglPipeline extends Pipeline {
stride += 3;
coordoff += 3;
}
-
+
if ((vformat & GeometryArray.COLOR) != 0) {
if ((vformat & GeometryArray.BY_REFERENCE) != 0) {
if ((vformat & GeometryArray.WITH_ALPHA) != 0) {
@@ -468,7 +468,7 @@ class JoglPipeline extends Pipeline {
coordoff += 4;
}
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) {
texStride = 2 * texCoordSetCount;
@@ -482,7 +482,7 @@ class JoglPipeline extends Pipeline {
coloroff += texStride;
coordoff += texStride;
}
-
+
int vAttrStride = 0;
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
for (int i = 0; i < vertexAttrCount; i++) {
@@ -494,7 +494,7 @@ class JoglPipeline extends Pipeline {
coordoff += vAttrStride;
texCoordoff += vAttrStride;
}
-
+
int bstride = stride * BufferUtil.SIZEOF_FLOAT;
// Start sending down from the startVIndex
int initialOffset = startVIndex * stride;
@@ -503,18 +503,18 @@ class JoglPipeline extends Pipeline {
coordoff += initialOffset;
texCoordoff += initialOffset;
vAttrOff += initialOffset;
-
+
// process alpha for geometryArray without alpha
boolean useAlpha = false;
if (updateAlpha && !ignoreVertexColors) {
useAlpha = true;
}
-
+
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) {
int[] sarray = ((GeometryStripArrayRetained) geo).stripVertexCounts;
-
+
int primType = 0;
switch (geo_type) {
case GeometryRetained.GEO_TYPE_TRI_STRIP_SET :
@@ -527,11 +527,11 @@ class JoglPipeline extends Pipeline {
primType = GL.GL_LINE_STRIP;
break;
}
-
+
if (ignoreVertexColors) {
vformat &= ~GeometryArray.COLOR;
}
-
+
for (int i = 0; i < sarray.length; i++) {
gl.glBegin(primType);
for (int j = 0; j < sarray[i]; j++) {
@@ -570,7 +570,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
int vaOff = vAttrOff;
if (verts == null) {
@@ -595,11 +595,11 @@ class JoglPipeline extends Pipeline {
jctx.vertexAttr4fv(gl, vaIdx, verts);
break;
}
-
+
vaOff += vertexAttrSizes[vaIdx];
}
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
if (texCoordSetMapLen > 0) {
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
@@ -650,7 +650,7 @@ class JoglPipeline extends Pipeline {
// texCoordSetMapLen can't be 0 if texture coordinates
// is to be specified
}
-
+
if ((vformat & GeometryArray.COORDINATES) != 0) {
if (xform != null) {
// transform the vertex data with the static transform
@@ -703,11 +703,11 @@ class JoglPipeline extends Pipeline {
primType = GL.GL_LINES;
break;
}
-
+
if (ignoreVertexColors) {
vformat &= ~GeometryArray.COLOR;
}
-
+
gl.glBegin(primType);
for (int j = 0; j < vcount; j++) {
if ((vformat & GeometryArray.NORMALS) != 0) {
@@ -754,7 +754,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
int vaOff = vAttrOff;
if (verts == null) {
@@ -779,11 +779,11 @@ class JoglPipeline extends Pipeline {
jctx.vertexAttr4fv(gl, vaIdx, verts);
break;
}
-
+
vaOff += vertexAttrSizes[vaIdx];
}
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
if (texCoordSetMapLen > 0) {
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
@@ -834,7 +834,7 @@ class JoglPipeline extends Pipeline {
// texCoordSetMapLen can't be 0 if texture coordinates is
// to be specified
}
-
+
if ((vformat & GeometryArray.COORDINATES) != 0) {
if (xform != null) {
// transform the vertex data with the static transform
@@ -869,7 +869,7 @@ class JoglPipeline extends Pipeline {
gl.glEnd();
}
}
-
+
// used to Build Dlist GeometryArray by Reference with java arrays
void buildGAForByRef(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -889,9 +889,9 @@ class JoglPipeline extends Pipeline {
int[] texIndices, int texStride, Object[] texCoords,
double[] xform, double[] nxform) {
if (VERBOSE) System.err.println("JoglPipeline.buildGAForByRef()");
-
+
GL gl = context(ctx).getGL();
-
+
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0);
@@ -899,7 +899,7 @@ class JoglPipeline extends Pipeline {
boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0);
boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0);
boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);
-
+
FloatBuffer fverts = null;
DoubleBuffer dverts = null;
FloatBuffer fclrs = null;
@@ -907,23 +907,23 @@ class JoglPipeline extends Pipeline {
FloatBuffer[] texCoordBufs = null;
FloatBuffer norms = null;
FloatBuffer[] vertexAttrBufs = null;
-
+
// Get vertex attribute arrays
if (vattrDefined) {
vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);
}
-
+
// get texture arrays
if (textureDefined) {
texCoordBufs = getTexCoordSetBuffer(texCoords);
}
-
+
// process alpha for geometryArray without alpha
boolean useAlpha = false;
if (updateAlpha && !ignoreVertexColors) {
useAlpha = true;
}
-
+
int[] sarray = null;
int[] start_array = null;
int strip_len = 0;
@@ -934,13 +934,13 @@ class JoglPipeline extends Pipeline {
strip_len = sarray.length;
start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices;
}
-
+
if (ignoreVertexColors) {
vformat &= ~GeometryArray.COLOR;
floatColorsDefined = false;
byteColorsDefined = false;
}
-
+
// get coordinate array
if (floatCoordDefined) {
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
@@ -979,7 +979,7 @@ class JoglPipeline extends Pipeline {
} else {
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
}
-
+
// get color array
if (floatColorsDefined) {
gl.glEnableClientState(GL.GL_COLOR_ARRAY);
@@ -1030,7 +1030,7 @@ class JoglPipeline extends Pipeline {
} else {
gl.glDisableClientState(GL.GL_COLOR_ARRAY);
}
-
+
// get normal array
if (normalsDefined) {
gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
@@ -1052,7 +1052,7 @@ class JoglPipeline extends Pipeline {
} else {
gl.glDisableClientState(GL.GL_NORMAL_ARRAY);
}
-
+
executeGeometryArrayVA(ctx, geo, geo_type,
isNonUniformScale, ignoreVertexColors,
vcount, vformat, vdefined,
@@ -1066,11 +1066,11 @@ class JoglPipeline extends Pipeline {
texIndices, texStride, texCoordBufs, 0,
sarray, strip_len, start_array);
}
-
+
//----------------------------------------------------------------------
// Private helper methods for GeometryArrayRetained
//
-
+
private void
testForInterleavedArrays(int vformat,
boolean[] useInterleavedArrays,
@@ -1096,7 +1096,7 @@ class JoglPipeline extends Pipeline {
useInterleavedArrays[0] = false; break;
}
}
-
+
private void
enableTexCoordPointer(GL gl,
int texUnit,
@@ -1109,7 +1109,7 @@ class JoglPipeline extends Pipeline {
gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
gl.glTexCoordPointer(texSize, texDataType, stride, pointer);
}
-
+
private void
disableTexCoordPointer(GL gl,
int texUnit) {
@@ -1117,7 +1117,7 @@ class JoglPipeline extends Pipeline {
clientActiveTextureUnit(gl, texUnit);
gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
}
-
+
private void
clientActiveTextureUnit(GL gl,
int texUnit) {
@@ -1126,8 +1126,8 @@ class JoglPipeline extends Pipeline {
gl.glClientActiveTexture(texUnit + GL.GL_TEXTURE0);
}
}
-
-
+
+
private void
executeTexture(int texCoordSetMapLen,
int texSize, int bstride, int texCoordoff,
@@ -1136,11 +1136,11 @@ class JoglPipeline extends Pipeline {
FloatBuffer verts, GL gl) {
if (VERBOSE) System.err.println("JoglPipeline.executeTexture()");
int tus = 0; /* texture unit state index */
-
+
for (int i = 0; i < numActiveTexUnit; i++) {
-
+
tus = i;
-
+
/*
* it's possible thattexture unit state index (tus)
* is greater than the texCoordSetMapOffsetLen, in this
@@ -1160,7 +1160,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
private void
resetTexture(GL gl, JoglContext ctx) {
if (VERBOSE) System.err.println("JoglPipeline.resetTexture()");
@@ -1171,7 +1171,7 @@ class JoglPipeline extends Pipeline {
/* Reset client active texture unit to 0 */
clientActiveTextureUnit(gl, 0);
}
-
+
private void
executeGeometryArray(Context absCtx,
GeometryArrayRetained geo, int geo_type,
@@ -1190,7 +1190,7 @@ class JoglPipeline extends Pipeline {
JoglContext ctx = (JoglContext) absCtx;
GLContext context = context(ctx);
GL gl = context.getGL();
-
+
boolean useInterleavedArrays;
int iaFormat = 0;
int primType = 0;
@@ -1203,7 +1203,7 @@ class JoglPipeline extends Pipeline {
FloatBuffer clrs = null;
int[] sarray = null;
int[] start_array = null;
-
+
if (EXTRA_DEBUGGING) {
System.err.println("Vertex format: " + getVertexDescription(vformat));
System.err.println("Geometry type: " + getGeometryDescription(geo_type));
@@ -1213,7 +1213,7 @@ class JoglPipeline extends Pipeline {
System.err.println(" Colors (if any) interleaved");
}
}
-
+
if ((vformat & GeometryArray.COORDINATES) != 0) {
stride += 3;
}
@@ -1261,16 +1261,16 @@ class JoglPipeline extends Pipeline {
coordoff += vAttrStride;
texCoordoff += vAttrStride;
}
-
+
bstride = stride * BufferUtil.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;
}
-
+
// We have to copy if the data isn't specified using NIO
if (varray != null) {
verts = getVertexArrayBuffer(varray);
@@ -1280,7 +1280,7 @@ class JoglPipeline extends Pipeline {
// This should never happen
throw new AssertionError("Unable to get vertex pointer");
}
-
+
// using byRef interleaved array and has a separate pointer, then ..
int cstride = stride;
if (carray != null) {
@@ -1290,20 +1290,20 @@ class JoglPipeline extends Pipeline {
// FIXME: need to "auto-slice" this buffer later
clrs = verts;
}
-
+
cbstride = cstride * BufferUtil.SIZEOF_FLOAT;
-
+
// Enable normalize for non-uniform scale (which rescale can't handle)
if (isNonUniformScale) {
gl.glEnable(GL.GL_NORMALIZE);
}
-
+
int startVertex = stride * startVIndex;
int startClrs = cstride * startVIndex;
if (clrs == verts) {
startClrs += coloroff;
}
-
+
/*** Handle non-indexed strip GeometryArray first *******/
if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET ||
geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET ||
@@ -1342,7 +1342,7 @@ class JoglPipeline extends Pipeline {
verts.position(startVertex + coordoff);
gl.glVertexPointer(3, GL.GL_FLOAT, bstride, verts);
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
executeTexture(texCoordSetMapLen,
texSize, bstride, texCoordoff,
@@ -1350,7 +1350,7 @@ class JoglPipeline extends Pipeline {
numActiveTexUnitState,
verts, gl);
}
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
int vAttrOffset = startVertex + vAttrOff;
for (int i = 0; i < vertexAttrCount; i++) {
@@ -1362,7 +1362,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
switch (geo_type) {
case GeometryRetained.GEO_TYPE_TRI_STRIP_SET:
primType = GL.GL_TRIANGLE_STRIP;
@@ -1374,7 +1374,7 @@ class JoglPipeline extends Pipeline {
primType = GL.GL_LINE_STRIP;
break;
}
-
+
if (gl.isExtensionAvailable("GL_EXT_multi_draw_arrays")) {
gl.glMultiDrawArraysEXT(primType, start_array, 0, sarray, 0, sarray.length);
} else {
@@ -1398,7 +1398,7 @@ class JoglPipeline extends Pipeline {
useInterleavedArrays = tmp[0];
iaFormat = tmp2[0];
}
-
+
if (useInterleavedArrays) {
verts.position(startVertex);
gl.glInterleavedArrays(iaFormat, bstride, verts);
@@ -1428,7 +1428,7 @@ class JoglPipeline extends Pipeline {
verts.position(startVertex + coordoff);
gl.glVertexPointer(3, GL.GL_FLOAT, bstride, verts);
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
executeTexture(texCoordSetMapLen,
texSize, bstride, texCoordoff,
@@ -1436,7 +1436,7 @@ class JoglPipeline extends Pipeline {
numActiveTexUnitState,
verts, gl);
}
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
int vAttrOffset = startVertex + vAttrOff;
for (int i = 0; i < vertexAttrCount; i++) {
@@ -1455,22 +1455,22 @@ class JoglPipeline extends Pipeline {
case GeometryRetained.GEO_TYPE_LINE_SET : gl.glDrawArrays(GL.GL_LINES, 0, vcount); break;
}
}
-
+
/* clean up if we turned on normalize */
if (isNonUniformScale) {
gl.glDisable(GL.GL_NORMALIZE);
}
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
resetVertexAttrs(gl, ctx, vertexAttrCount);
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
resetTexture(gl, ctx);
}
}
-
-
+
+
// glLockArrays() is invoked only for indexed geometry, and the
// vertexCount is guarenteed to be >= 0.
private void lockArray(GL gl, int vertexCount) {
@@ -1478,13 +1478,13 @@ class JoglPipeline extends Pipeline {
gl.glLockArraysEXT(0, vertexCount);
}
}
-
+
private void unlockArray(GL gl) {
if (gl.isExtensionAvailable("GL_EXT_compiled_vertex_array")) {
gl.glUnlockArraysEXT();
}
}
-
+
private void
executeGeometryArrayVA(Context absCtx,
GeometryArrayRetained geo,
@@ -1510,7 +1510,7 @@ class JoglPipeline extends Pipeline {
JoglContext ctx = (JoglContext) absCtx;
GLContext context = context(ctx);
GL gl = context.getGL();
-
+
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0);
@@ -1518,12 +1518,12 @@ class JoglPipeline extends Pipeline {
boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0);
boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0);
boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);
-
+
// Enable normalize for non-uniform scale (which rescale can't handle)
if (isNonUniformScale) {
gl.glEnable(GL.GL_NORMALIZE);
}
-
+
int coordoff = 3 * initialCoordIndex;
// Define the data pointers
if (floatCoordDefined) {
@@ -1533,7 +1533,7 @@ class JoglPipeline extends Pipeline {
dverts.position(coordoff);
gl.glVertexPointer(3, GL.GL_DOUBLE, 0, dverts);
}
-
+
if (floatColorsDefined) {
int coloroff;
int sz;
@@ -1564,7 +1564,7 @@ class JoglPipeline extends Pipeline {
norms.position(normoff);
gl.glNormalPointer(GL.GL_FLOAT, 0, norms);
}
-
+
if (vattrDefined) {
for (int i = 0; i < vertexAttrCount; i++) {
FloatBuffer vertexAttrs = vertexAttrData[i];
@@ -1575,7 +1575,7 @@ class JoglPipeline extends Pipeline {
ctx.vertexAttrPointer(gl, i, sz, GL.GL_FLOAT, 0, vertexAttrs);
}
}
-
+
if (textureDefined) {
int texSet = 0;
for (int i = 0; i < numActiveTexUnit; i++) {
@@ -1589,11 +1589,11 @@ class JoglPipeline extends Pipeline {
disableTexCoordPointer(gl, i);
}
}
-
+
// Reset client active texture unit to 0
clientActiveTextureUnit(gl, 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) {
@@ -1626,21 +1626,21 @@ class JoglPipeline extends Pipeline {
case GeometryRetained.GEO_TYPE_LINE_SET : gl.glDrawArrays(GL.GL_LINES, 0, vcount); break;
}
}
-
+
// clean up if we turned on normalize
if (isNonUniformScale) {
gl.glDisable(GL.GL_NORMALIZE);
}
-
+
if (vattrDefined) {
resetVertexAttrs(gl, ctx, vertexAttrCount);
}
-
+
if (textureDefined) {
resetTexture(gl, ctx);
}
}
-
+
private String getVertexDescription(int vformat) {
String res = "";
if ((vformat & GeometryArray.COORDINATES) != 0) res += "COORDINATES ";
@@ -1654,7 +1654,7 @@ class JoglPipeline extends Pipeline {
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) res += "VERTEX_ATTRIBUTES ";
return res;
}
-
+
private String getGeometryDescription(int geo_type) {
switch (geo_type) {
case GeometryRetained.GEO_TYPE_TRI_STRIP_SET : return "GEO_TYPE_TRI_STRIP_SET";
@@ -1667,21 +1667,21 @@ class JoglPipeline extends Pipeline {
default: return "(unknown " + geo_type + ")";
}
}
-
+
private void resetVertexAttrs(GL gl, JoglContext ctx, int vertexAttrCount) {
// Disable specified vertex attr arrays
for (int i = 0; i < vertexAttrCount; i++) {
ctx.disableVertexAttrArray(gl, i);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// IndexedGeometryArrayRetained methods
//
-
+
// by-copy or interleaved, by reference, Java arrays
void executeIndexedGeometry(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -1700,7 +1700,7 @@ class JoglPipeline extends Pipeline {
int cdirty,
int[] indexCoord) {
if (VERBOSE) System.err.println("JoglPipeline.executeIndexedGeometry()");
-
+
executeIndexedGeometryArray(ctx, geo, geo_type,
isNonUniformScale, useAlpha, ignoreVertexColors,
initialIndexIndex, indexCount,
@@ -1712,7 +1712,7 @@ class JoglPipeline extends Pipeline {
varray, null, carray,
cdirty, indexCoord);
}
-
+
// interleaved, by reference, nio buffer
void executeIndexedGeometryBuffer(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -1730,7 +1730,7 @@ class JoglPipeline extends Pipeline {
int cDirty,
int[] indexCoord) {
if (VERBOSE) System.err.println("JoglPipeline.executeIndexedGeometryBuffer()");
-
+
executeIndexedGeometryArray(ctx, geo, geo_type,
isNonUniformScale, useAlpha, ignoreVertexColors,
initialIndexIndex, indexCount, vertexCount, vformat,
@@ -1740,7 +1740,7 @@ class JoglPipeline extends Pipeline {
null, (FloatBuffer) vdata, carray,
cDirty, indexCoord);
}
-
+
// non interleaved, by reference, Java arrays
void executeIndexedGeometryVA(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -1763,7 +1763,7 @@ class JoglPipeline extends Pipeline {
int cdirty,
int[] indexCoord) {
if (VERBOSE) System.err.println("JoglPipeline.executeIndexedGeometryVA()");
-
+
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0);
@@ -1771,7 +1771,7 @@ class JoglPipeline extends Pipeline {
boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0);
boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0);
boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);
-
+
FloatBuffer fverts = null;
DoubleBuffer dverts = null;
FloatBuffer fclrs = null;
@@ -1779,17 +1779,17 @@ class JoglPipeline extends Pipeline {
FloatBuffer[] texCoordBufs = null;
FloatBuffer norms = null;
FloatBuffer[] vertexAttrBufs = null;
-
+
// Get vertex attribute arrays
if (vattrDefined) {
vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);
}
-
+
// get texture arrays
if (textureDefined) {
texCoordBufs = getTexCoordSetBuffer(texCoords);
}
-
+
int[] sarray = null;
int strip_len = 0;
if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET ||
@@ -1798,26 +1798,26 @@ class JoglPipeline extends Pipeline {
sarray = ((IndexedGeometryStripArrayRetained) geo).stripIndexCounts;
strip_len = sarray.length;
}
-
+
// get coordinate array
if (floatCoordDefined) {
fverts = getVertexArrayBuffer(vfcoords);
} else if (doubleCoordDefined) {
dverts = getVertexArrayBuffer(vdcoords);
}
-
+
// get color array
if (floatColorsDefined) {
fclrs = getColorArrayBuffer(cfdata);
} else if (byteColorsDefined) {
bclrs = getColorArrayBuffer(cbdata);
}
-
+
// get normal array
if (normalsDefined) {
norms = getNormalArrayBuffer(ndata);
}
-
+
executeIndexedGeometryArrayVA(ctx, geo, geo_type,
isNonUniformScale, ignoreVertexColors,
initialIndexIndex, validIndexCount, vertexCount,
@@ -1832,7 +1832,7 @@ class JoglPipeline extends Pipeline {
cdirty, indexCoord,
sarray, strip_len);
}
-
+
// non interleaved, by reference, nio buffer
void executeIndexedGeometryVABuffer(Context ctx,
GeometryArrayRetained geo, int geo_type,
@@ -1856,7 +1856,7 @@ class JoglPipeline extends Pipeline {
int cdirty,
int[] indexCoord) {
if (VERBOSE) System.err.println("JoglPipeline.executeIndexedGeometryVABuffer()");
-
+
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0);
@@ -1864,7 +1864,7 @@ class JoglPipeline extends Pipeline {
boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0);
boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0);
boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);
-
+
FloatBuffer fverts = null;
DoubleBuffer dverts = null;
FloatBuffer fclrs = null;
@@ -1872,12 +1872,12 @@ class JoglPipeline extends Pipeline {
FloatBuffer[] texCoordBufs = null;
FloatBuffer norms = null;
FloatBuffer[] vertexAttrBufs = null;
-
+
// Get vertex attribute arrays
if (vattrDefined) {
vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);
}
-
+
// get texture arrays
if (textureDefined) {
texCoordBufs = new FloatBuffer[texCoords.length];
@@ -1885,18 +1885,18 @@ class JoglPipeline extends Pipeline {
texCoordBufs[i] = (FloatBuffer) texCoords[i];
}
}
-
+
// get coordinate array
if (floatCoordDefined) {
fverts = (FloatBuffer) vcoords;
} else if (doubleCoordDefined) {
dverts = (DoubleBuffer) vcoords;
}
-
+
if (fverts == null && dverts == null) {
return;
}
-
+
int[] sarray = null;
int strip_len = 0;
if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET ||
@@ -1905,7 +1905,7 @@ class JoglPipeline extends Pipeline {
sarray = ((IndexedGeometryStripArrayRetained) geo).stripIndexCounts;
strip_len = sarray.length;
}
-
+
// get color array
if (floatColorsDefined) {
if (cfdata != null)
@@ -1918,12 +1918,12 @@ class JoglPipeline extends Pipeline {
else
bclrs = (ByteBuffer) cdataBuffer;
}
-
+
// get normal array
if (normalsDefined) {
norms = (FloatBuffer) ndata;
}
-
+
executeIndexedGeometryArrayVA(ctx, geo, geo_type,
isNonUniformScale, ignoreVertexColors,
initialIndexIndex, validIndexCount, vertexCount,
@@ -1938,7 +1938,7 @@ class JoglPipeline extends Pipeline {
cdirty, indexCoord,
sarray, strip_len);
}
-
+
// by-copy geometry
void buildIndexedGeometry(Context absCtx,
GeometryArrayRetained geo, int geo_type,
@@ -1956,10 +1956,10 @@ class JoglPipeline extends Pipeline {
double[] xform, double[] nxform,
float[] varray, int[] indexCoord) {
if (VERBOSE) System.err.println("JoglPipeline.buildIndexedGeometry()");
-
+
JoglContext ctx = (JoglContext) absCtx;
GL gl = context(ctx).getGL();
-
+
boolean useInterleavedArrays;
int iaFormat = 0;
int primType = 0;
@@ -1973,14 +1973,14 @@ class JoglPipeline extends Pipeline {
int[] sarray = null;
int strip_len = 0;
boolean useAlpha = false;
-
+
if ((vformat & GeometryArray.COORDINATES) != 0) {
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
stride += 3;
} else {
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
}
-
+
if ((vformat & GeometryArray.NORMALS) != 0) {
gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
stride += 3;
@@ -1988,7 +1988,7 @@ class JoglPipeline extends Pipeline {
} else {
gl.glDisableClientState(GL.GL_NORMAL_ARRAY);
}
-
+
if ((vformat & GeometryArray.COLOR) != 0) {
gl.glEnableClientState(GL.GL_COLOR_ARRAY);
stride += 4;
@@ -1997,7 +1997,7 @@ class JoglPipeline extends Pipeline {
} else {
gl.glDisableClientState(GL.GL_COLOR_ARRAY);
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) {
texSize = 2;
@@ -2014,7 +2014,7 @@ class JoglPipeline extends Pipeline {
coloroff += texStride;
coordoff += texStride;
}
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
for (int i = 0; i < vertexAttrCount; i++) {
vAttrStride += vertexAttrSizes[i];
@@ -2025,24 +2025,24 @@ class JoglPipeline extends Pipeline {
coordoff += vAttrStride;
texCoordoff += vAttrStride;
}
-
+
bstride = stride * BufferUtil.SIZEOF_FLOAT;
-
+
// process alpha for geometryArray without alpha
if (updateAlpha && !ignoreVertexColors) {
useAlpha = true;
}
-
+
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;
}
-
+
// Copy data into NIO array
verts = getVertexArrayBuffer(varray);
-
+
// Apply normal transform if necessary
if ((vformat & GeometryArray.NORMALS) != 0 && nxform != null) {
int off = normoff;
@@ -2059,7 +2059,7 @@ class JoglPipeline extends Pipeline {
off += stride;
}
}
-
+
// Apply coordinate transform if necessary
if ((vformat & GeometryArray.COORDINATES) != 0 && xform != null) {
int off = coordoff;
@@ -2076,7 +2076,7 @@ class JoglPipeline extends Pipeline {
off += stride;
}
}
-
+
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) {
@@ -2094,7 +2094,7 @@ class JoglPipeline extends Pipeline {
useInterleavedArrays = tmp[0];
iaFormat = tmp2[0];
}
-
+
if (useInterleavedArrays) {
verts.position(0);
gl.glInterleavedArrays(iaFormat, bstride, verts);
@@ -2133,7 +2133,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
switch (geo_type) {
case GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET:
primType = GL.GL_TRIANGLE_STRIP;
@@ -2145,9 +2145,9 @@ class JoglPipeline extends Pipeline {
primType = GL.GL_LINE_STRIP;
break;
}
-
+
lockArray(gl, vertexCount);
-
+
// Note: using MultiDrawElements is probably more expensive than
// not in this case due to the need to allocate more temporary
// direct buffers and slice up the incoming indices array
@@ -2177,7 +2177,7 @@ class JoglPipeline extends Pipeline {
useInterleavedArrays = tmp[0];
iaFormat = tmp2[0];
}
-
+
if (useInterleavedArrays) {
verts.position(0);
gl.glInterleavedArrays(iaFormat, bstride, verts);
@@ -2186,7 +2186,7 @@ class JoglPipeline extends Pipeline {
verts.position(normoff);
gl.glNormalPointer(GL.GL_FLOAT, bstride, verts);
}
-
+
if (!ignoreVertexColors && ((vformat & GeometryArray.COLOR) != 0)) {
verts.position(coloroff);
if (((vformat & GeometryArray.WITH_ALPHA) != 0) || useAlpha) {
@@ -2216,7 +2216,7 @@ class JoglPipeline extends Pipeline {
vAttrOffset += vertexAttrSizes[i];
}
}
-
+
switch (geo_type) {
case GeometryRetained.GEO_TYPE_INDEXED_QUAD_SET :
primType = GL.GL_QUADS;
@@ -2231,32 +2231,32 @@ class JoglPipeline extends Pipeline {
primType = GL.GL_LINES;
break;
}
-
+
lockArray(gl, vertexCount);
-
+
IntBuffer indicesBuffer = IntBuffer.wrap(indexCoord);
indicesBuffer.position(initialIndexIndex);
gl.glDrawElements(primType, validIndexCount, GL.GL_UNSIGNED_INT, indicesBuffer);
}
}
-
+
unlockArray(gl);
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
resetVertexAttrs(gl, ctx, vertexAttrCount);
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
resetTexture(gl, ctx);
}
}
-
-
+
+
//----------------------------------------------------------------------
//
// Helper routines for IndexedGeometryArrayRetained
//
-
+
private void executeIndexedGeometryArray(Context absCtx,
GeometryArrayRetained geo, int geo_type,
boolean isNonUniformScale,
@@ -2275,7 +2275,7 @@ class JoglPipeline extends Pipeline {
int[] indexCoord) {
JoglContext ctx = (JoglContext) absCtx;
GL gl = context(ctx).getGL();
-
+
boolean useInterleavedArrays;
int iaFormat = 0;
int primType = 0;
@@ -2288,7 +2288,7 @@ class JoglPipeline extends Pipeline {
FloatBuffer clrs = null;
int[] sarray = null;
int strip_len = 0;
-
+
if ((vformat & GeometryArray.COORDINATES) != 0) {
stride += 3;
}
@@ -2296,7 +2296,7 @@ class JoglPipeline extends Pipeline {
stride += 3;
coordoff += 3;
}
-
+
if ((vformat & GeometryArray.COLOR) != 0) {
if ((vformat & GeometryArray.WITH_ALPHA) != 0) {
stride += 4;
@@ -2308,7 +2308,7 @@ class JoglPipeline extends Pipeline {
coordoff += 3;
}
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) {
texSize = 2;
@@ -2325,7 +2325,7 @@ class JoglPipeline extends Pipeline {
coloroff += texStride;
coordoff += texStride;
}
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
for (int i = 0; i < vertexAttrCount; i++) {
vAttrStride += vertexAttrSizes[i];
@@ -2336,16 +2336,16 @@ class JoglPipeline extends Pipeline {
coordoff += vAttrStride;
texCoordoff += vAttrStride;
}
-
+
bstride = stride * BufferUtil.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;
strip_len = sarray.length;
}
-
+
// We have to copy if the data isn't specified using NIO
if (varray != null) {
verts = getVertexArrayBuffer(varray);
@@ -2355,7 +2355,7 @@ class JoglPipeline extends Pipeline {
// This should never happen
throw new AssertionError("Unable to get vertex pointer");
}
-
+
// using byRef interleaved array and has a separate pointer, then ..
int cstride = stride;
if (carray != null) {
@@ -2365,14 +2365,14 @@ class JoglPipeline extends Pipeline {
// FIXME: need to "auto-slice" this buffer later
clrs = verts;
}
-
+
cbstride = cstride * BufferUtil.SIZEOF_FLOAT;
-
+
// Enable normalize for non-uniform scale (which rescale can't handle)
if (isNonUniformScale) {
gl.glEnable(GL.GL_NORMALIZE);
}
-
+
/*** Handle non-indexed strip GeometryArray first *******/
if (geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET ||
geo_type == GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET ||
@@ -2410,7 +2410,7 @@ class JoglPipeline extends Pipeline {
verts.position(coordoff);
gl.glVertexPointer(3, GL.GL_FLOAT, bstride, verts);
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
/* XXXX: texCoordoff == 0 ???*/
executeTexture(texCoordSetMapLen,
@@ -2419,7 +2419,7 @@ class JoglPipeline extends Pipeline {
numActiveTexUnitState,
verts, gl);
}
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
int vAttrOffset = vAttrOff;
for (int i = 0; i < vertexAttrCount; i++) {
@@ -2431,7 +2431,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
switch (geo_type) {
case GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET:
primType = GL.GL_TRIANGLE_STRIP;
@@ -2443,9 +2443,9 @@ class JoglPipeline extends Pipeline {
primType = GL.GL_LINE_STRIP;
break;
}
-
+
lockArray(gl, vertexCount);
-
+
// Note: using MultiDrawElements is probably more expensive than
// not in this case due to the need to allocate more temporary
// direct buffers and slice up the incoming indices array
@@ -2473,7 +2473,7 @@ class JoglPipeline extends Pipeline {
useInterleavedArrays = tmp[0];
iaFormat = tmp2[0];
}
-
+
if (useInterleavedArrays) {
verts.position(0);
gl.glInterleavedArrays(iaFormat, bstride, verts);
@@ -2482,7 +2482,7 @@ class JoglPipeline extends Pipeline {
verts.position(normoff);
gl.glNormalPointer(GL.GL_FLOAT, bstride, verts);
}
-
+
if (!ignoreVertexColors && (vformat & GeometryArray.COLOR) != 0) {
if (clrs == verts) {
clrs.position(coloroff);
@@ -2497,7 +2497,7 @@ class JoglPipeline extends Pipeline {
verts.position(coordoff);
gl.glVertexPointer(3, GL.GL_FLOAT, bstride, verts);
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
/* XXXX: texCoordoff == 0 ???*/
executeTexture(texCoordSetMapLen,
@@ -2506,7 +2506,7 @@ class JoglPipeline extends Pipeline {
numActiveTexUnitState,
verts, gl);
}
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
int vAttrOffset = vAttrOff;
for (int i = 0; i < vertexAttrCount; i++) {
@@ -2518,7 +2518,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
lockArray(gl, vertexCount);
IntBuffer buf = IntBuffer.wrap(indexCoord);
buf.position(initialIndexIndex);
@@ -2529,24 +2529,24 @@ class JoglPipeline extends Pipeline {
case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET : gl.glDrawElements(GL.GL_LINES, indexCount, GL.GL_UNSIGNED_INT, buf); break;
}
}
-
+
unlockArray(gl);
-
+
if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {
resetVertexAttrs(gl, ctx, vertexAttrCount);
}
-
+
if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {
resetTexture(gl, ctx);
}
-
+
// clean up if we turned on normalize
if (isNonUniformScale) {
gl.glDisable(GL.GL_NORMALIZE);
}
}
-
-
+
+
private void executeIndexedGeometryArrayVA(Context absCtx,
GeometryArrayRetained geo, int geo_type,
boolean isNonUniformScale,
@@ -2565,7 +2565,7 @@ class JoglPipeline extends Pipeline {
int cDirty, int[] indexCoord, int[] sarray, int strip_len) {
JoglContext ctx = (JoglContext) absCtx;
GL gl = context(ctx).getGL();
-
+
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0);
@@ -2573,12 +2573,12 @@ class JoglPipeline extends Pipeline {
boolean normalsDefined = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT) != 0);
boolean vattrDefined = ((vdefined & GeometryArrayRetained.VATTR_FLOAT) != 0);
boolean textureDefined = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);
-
+
// Enable normalize for non-uniform scale (which rescale can't handle)
if (isNonUniformScale) {
gl.glEnable(GL.GL_NORMALIZE);
}
-
+
// Define the data pointers
if (floatCoordDefined) {
fverts.position(0);
@@ -2606,7 +2606,7 @@ class JoglPipeline extends Pipeline {
norms.position(0);
gl.glNormalPointer(GL.GL_FLOAT, 0, norms);
}
-
+
if (vattrDefined) {
for (int i = 0; i < vertexAttrCount; i++) {
FloatBuffer vertexAttrs = vertexAttrBufs[i];
@@ -2616,7 +2616,7 @@ class JoglPipeline extends Pipeline {
ctx.vertexAttrPointer(gl, i, sz, GL.GL_FLOAT, 0, vertexAttrs);
}
}
-
+
if (textureDefined) {
int texSet = 0;
for (int i = 0; i < numActiveTexUnitState; i++) {
@@ -2630,13 +2630,13 @@ class JoglPipeline extends Pipeline {
disableTexCoordPointer(gl, i);
}
}
-
+
// Reset client active texture unit to 0
clientActiveTextureUnit(gl, 0);
}
-
+
lockArray(gl, vertexCount);
-
+
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) {
@@ -2652,7 +2652,7 @@ class JoglPipeline extends Pipeline {
primType = GL.GL_LINE_STRIP;
break;
}
-
+
// Note: using MultiDrawElements is probably more expensive than
// not in this case due to the need to allocate more temporary
// direct buffers and slice up the incoming indices array
@@ -2674,26 +2674,26 @@ class JoglPipeline extends Pipeline {
case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET : gl.glDrawElements(GL.GL_LINES, validIndexCount, GL.GL_UNSIGNED_INT, buf); break;
}
}
-
+
unlockArray(gl);
-
+
// clean up if we turned on normalize
if (isNonUniformScale) {
gl.glDisable(GL.GL_NORMALIZE);
}
-
+
if (vattrDefined) {
resetVertexAttrs(gl, ctx, vertexAttrCount);
}
-
+
if (textureDefined) {
resetTexture(gl, ctx);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// GraphicsContext3D methods
//
@@ -2790,23 +2790,23 @@ class JoglPipeline extends Pipeline {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 0.0f);
gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f);
}
-
+
gl.glReadPixels(xSrcOffset, yAdjusted, width, height,
oglFormat, intType, IntBuffer.wrap((int[]) imageBuffer));
-
+
/* Restore Alpha scale and bias */
if(forceAlphaToOne) {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 1.0f);
gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 0.0f);
}
-
+
} else {
assert false;
}
}
-
+
if ((type & Raster.RASTER_DEPTH) != 0) {
-
+
if (depthFormat == DepthComponentRetained.DEPTH_COMPONENT_TYPE_INT) {
// yOffset is adjusted for OpenGL - Y upward
gl.glReadPixels(xSrcOffset, yAdjusted, width, height,
@@ -2817,414 +2817,414 @@ class JoglPipeline extends Pipeline {
gl.glReadPixels(xSrcOffset, yAdjusted, width, height,
GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, FloatBuffer.wrap((float[]) depthBuffer));
}
- }
-
- }
-
+ }
+
+ }
+
// ---------------------------------------------------------------------
-
+
//
// CgShaderProgramRetained methods
//
-
+
// ShaderAttributeValue methods
-
+
ShaderError setCgUniform1i(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform1i()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgSetParameter1i(param.vParam(), value);
}
-
+
if (param.fParam() != null) {
CgGL.cgSetParameter1i(param.fParam(), value);
}
-
+
return null;
}
-
+
ShaderError setCgUniform1f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform1f()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgSetParameter1f(param.vParam(), value);
}
-
+
if (param.fParam() != null) {
CgGL.cgSetParameter1f(param.fParam(), value);
}
-
+
return null;
}
-
+
ShaderError setCgUniform2i(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform2i()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgSetParameter2i(param.vParam(), value[0], value[1]);
}
-
+
if (param.fParam() != null) {
CgGL.cgSetParameter2i(param.fParam(), value[0], value[1]);
}
-
+
return null;
}
-
+
ShaderError setCgUniform2f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform2f()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgSetParameter2f(param.vParam(), value[0], value[1]);
}
-
+
if (param.fParam() != null) {
CgGL.cgSetParameter2f(param.fParam(), value[0], value[1]);
}
-
+
return null;
}
-
+
ShaderError setCgUniform3i(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform3i()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgSetParameter3i(param.vParam(), value[0], value[1], value[2]);
}
-
+
if (param.fParam() != null) {
CgGL.cgSetParameter3i(param.fParam(), value[0], value[1], value[2]);
}
-
+
return null;
}
-
+
ShaderError setCgUniform3f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform3f()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgSetParameter3f(param.vParam(), value[0], value[1], value[2]);
}
-
+
if (param.fParam() != null) {
CgGL.cgSetParameter3f(param.fParam(), value[0], value[1], value[2]);
}
-
+
return null;
}
-
+
ShaderError setCgUniform4i(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform4i()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgSetParameter4i(param.vParam(), value[0], value[1], value[2], value[3]);
}
-
+
if (param.fParam() != null) {
CgGL.cgSetParameter4i(param.fParam(), value[0], value[1], value[2], value[3]);
}
-
+
return null;
}
-
+
ShaderError setCgUniform4f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform4f()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgSetParameter4f(param.vParam(), value[0], value[1], value[2], value[3]);
}
-
+
if (param.fParam() != null) {
CgGL.cgSetParameter4f(param.fParam(), value[0], value[1], value[2], value[3]);
}
-
+
return null;
}
-
+
ShaderError setCgUniformMatrix3f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniformMatrix3f()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetMatrixParameterfr(param.vParam(), value, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetMatrixParameterfr(param.fParam(), value, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniformMatrix4f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniformMatrix4f()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetMatrixParameterfr(param.vParam(), value, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetMatrixParameterfr(param.fParam(), value, 0);
}
-
+
return null;
}
-
+
// ShaderAttributeArray methods
-
+
ShaderError setCgUniform1iArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform1iArray()");
-
+
float[] fval = new float[value.length];
for (int i = 0; i < value.length; i++) {
fval[i] = value[i];
}
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetParameterArray1f(param.vParam(), 0, numElements, fval, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetParameterArray1f(param.fParam(), 0, numElements, fval, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniform1fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform1fArray()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetParameterArray1f(param.vParam(), 0, numElements, value, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetParameterArray1f(param.fParam(), 0, numElements, value, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniform2iArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform2iArray()");
-
+
float[] fval = new float[value.length];
for (int i = 0; i < value.length; i++) {
fval[i] = value[i];
}
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetParameterArray2f(param.vParam(), 0, numElements, fval, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetParameterArray2f(param.fParam(), 0, numElements, fval, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniform2fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform2fArray()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetParameterArray2f(param.vParam(), 0, numElements, value, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetParameterArray2f(param.fParam(), 0, numElements, value, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniform3iArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform3iArray()");
-
+
float[] fval = new float[value.length];
for (int i = 0; i < value.length; i++) {
fval[i] = value[i];
}
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetParameterArray3f(param.vParam(), 0, numElements, fval, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetParameterArray3f(param.fParam(), 0, numElements, fval, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniform3fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform3fArray()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetParameterArray2f(param.vParam(), 0, numElements, value, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetParameterArray2f(param.fParam(), 0, numElements, value, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniform4iArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform4iArray()");
-
+
float[] fval = new float[value.length];
for (int i = 0; i < value.length; i++) {
fval[i] = value[i];
}
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetParameterArray4f(param.vParam(), 0, numElements, fval, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetParameterArray4f(param.fParam(), 0, numElements, fval, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniform4fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniform4fArray()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetParameterArray2f(param.vParam(), 0, numElements, value, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetParameterArray2f(param.fParam(), 0, numElements, value, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniformMatrix3fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniformMatrix3fArray()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetMatrixParameterArrayfr(param.vParam(), 0, numElements, value, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetMatrixParameterArrayfr(param.fParam(), 0, numElements, value, 0);
}
-
+
return null;
}
-
+
ShaderError setCgUniformMatrix4fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setCgUniformMatrix4fArray()");
-
+
JoglCgShaderParameter param = (JoglCgShaderParameter) uniformLocation;
if (param.vParam() != null) {
CgGL.cgGLSetMatrixParameterArrayfr(param.vParam(), 0, numElements, value, 0);
}
-
+
if (param.fParam() != null) {
CgGL.cgGLSetMatrixParameterArrayfr(param.fParam(), 0, numElements, value, 0);
}
-
+
return null;
}
-
+
// interfaces for shader compilation, etc.
ShaderError createCgShader(Context ctx, int shaderType, ShaderId[] shaderId) {
if (VERBOSE) System.err.println("JoglPipeline.createCgShader()");
-
+
JoglContext jctx = (JoglContext) ctx;
JoglCgShaderInfo info = new JoglCgShaderInfo();
info.setJ3DShaderType(shaderType);
@@ -3240,7 +3240,7 @@ class JoglPipeline extends Pipeline {
}
ShaderError destroyCgShader(Context ctx, ShaderId shaderId) {
if (VERBOSE) System.err.println("JoglPipeline.destroyCgShader()");
-
+
JoglCgShaderInfo info = (JoglCgShaderInfo) shaderId;
CGprogram program = info.getCgShader();
if (program != null) {
@@ -3250,7 +3250,7 @@ class JoglPipeline extends Pipeline {
}
ShaderError compileCgShader(Context ctx, ShaderId shaderId, String programString) {
if (VERBOSE) System.err.println("JoglPipeline.compileCgShader()");
-
+
if (programString == null)
throw new AssertionError("shader program string is null");
JoglCgShaderInfo info = (JoglCgShaderInfo) shaderId;
@@ -3271,10 +3271,10 @@ class JoglPipeline extends Pipeline {
info.setCgShader(program);
return null;
}
-
+
ShaderError createCgShaderProgram(Context ctx, ShaderProgramId[] shaderProgramId) {
if (VERBOSE) System.err.println("JoglPipeline.createCgShaderProgram()");
-
+
JoglCgShaderProgramInfo info = new JoglCgShaderProgramInfo();
shaderProgramId[0] = info;
return null;
@@ -3287,7 +3287,7 @@ class JoglPipeline extends Pipeline {
ShaderError linkCgShaderProgram(Context ctx, ShaderProgramId shaderProgramId,
ShaderId[] shaderIds) {
if (VERBOSE) System.err.println("JoglPipeline.linkCgShaderProgram()");
-
+
JoglCgShaderProgramInfo shaderProgramInfo = (JoglCgShaderProgramInfo) shaderProgramId;
// NOTE: we assume that the caller has already verified that there
// is at most one vertex program and one fragment program
@@ -3300,7 +3300,7 @@ class JoglPipeline extends Pipeline {
} else {
shaderProgramInfo.setFragmentShader(shader);
}
-
+
CgGL.cgGLLoadProgram(shader.getCgShader());
int lastError = 0;
if ((lastError = CgGL.cgGetError()) != 0) {
@@ -3310,7 +3310,7 @@ class JoglPipeline extends Pipeline {
lastError));
return err;
}
-
+
CgGL.cgGLBindProgram(shader.getCgShader());
if ((lastError = CgGL.cgGetError()) != 0) {
ShaderError err = new ShaderError(ShaderError.LINK_ERROR,
@@ -3320,13 +3320,13 @@ class JoglPipeline extends Pipeline {
return err;
}
}
-
+
return null;
}
void lookupCgVertexAttrNames(Context ctx, ShaderProgramId shaderProgramId,
int numAttrNames, String[] attrNames, boolean[] errArr) {
if (VERBOSE) System.err.println("JoglPipeline.lookupCgVertexAttrNames()");
-
+
JoglCgShaderProgramInfo shaderProgramInfo = (JoglCgShaderProgramInfo) shaderProgramId;
if (shaderProgramInfo.getVertexShader() == null) {
// If there if no vertex shader, no attributes can be looked up, so all fail
@@ -3335,7 +3335,7 @@ class JoglPipeline extends Pipeline {
}
return;
}
-
+
shaderProgramInfo.setVertexAttributes(new CGparameter[numAttrNames]);
for (int i = 0; i < numAttrNames; i++) {
String attrName = attrNames[i];
@@ -3351,26 +3351,26 @@ class JoglPipeline extends Pipeline {
int numAttrNames, String[] attrNames, ShaderAttrLoc[] locArr,
int[] typeArr, int[] sizeArr, boolean[] isArrayArr) {
if (VERBOSE) System.err.println("JoglPipeline.lookupCgShaderAttrNames()");
-
+
JoglCgShaderProgramInfo shaderProgramInfo =
(JoglCgShaderProgramInfo) shaderProgramId;
-
+
// Set the loc, type, and size arrays to out-of-bounds values
for (int i = 0; i < numAttrNames; i++) {
locArr[i] = null;
typeArr[i] = -1;
sizeArr[i] = -1;
}
-
+
int[] vType = new int[1];
int[] vSize = new int[1];
boolean[] vIsArray = new boolean[1];
int[] fType = new int[1];
int[] fSize = new int[1];
boolean[] fIsArray = new boolean[1];
-
+
boolean err = false;
-
+
// Now lookup the location of each name in the attrNames array
for (int i = 0; i < numAttrNames; i++) {
String attrName = attrNames[i];
@@ -3399,7 +3399,7 @@ class JoglPipeline extends Pipeline {
typeArr[i] = cgToJ3dType(vType[0]);
}
}
-
+
CGparameter fLoc = null;
if (shaderProgramInfo.getVertexShader() != null) {
fLoc = lookupCgParams(shaderProgramInfo.getFragmentShader(),
@@ -3411,7 +3411,7 @@ class JoglPipeline extends Pipeline {
typeArr[i] = cgToJ3dType(fType[0]);
}
}
-
+
// If the name lookup found an entry in both vertex and
// fragment program, verify that the type and size are the
// same.
@@ -3424,7 +3424,7 @@ class JoglPipeline extends Pipeline {
err = true;
}
}
-
+
// Report an error if we got a mismatch or if the attribute
// was not found in either the vertex or the fragment program
if (err || (vLoc == null && fLoc == null)) {
@@ -3440,14 +3440,14 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
ShaderError useCgShaderProgram(Context ctx, ShaderProgramId shaderProgramId) {
if (VERBOSE) System.err.println("JoglPipeline.useCgShaderProgram()");
-
+
JoglCgShaderProgramInfo shaderProgramInfo =
(JoglCgShaderProgramInfo) shaderProgramId;
JoglContext jctx = (JoglContext) ctx;
-
+
// Disable shader profiles
CgGL.cgGLDisableProfile(jctx.getCgVertexProfile());
CgGL.cgGLDisableProfile(jctx.getCgFragmentProfile());
@@ -3458,7 +3458,7 @@ class JoglPipeline extends Pipeline {
} else {
CgGL.cgGLUnbindProgram(jctx.getCgVertexProfile());
}
-
+
if (shaderProgramInfo.getFragmentShader() != null) {
CgGL.cgGLBindProgram(shaderProgramInfo.getFragmentShader().getCgShader());
CgGL.cgGLEnableProfile(shaderProgramInfo.getFragmentShader().getShaderProfile());
@@ -3469,11 +3469,11 @@ class JoglPipeline extends Pipeline {
CgGL.cgGLUnbindProgram(jctx.getCgVertexProfile());
CgGL.cgGLUnbindProgram(jctx.getCgFragmentProfile());
}
-
+
jctx.setShaderProgram(shaderProgramInfo);
return null;
}
-
+
//
// Helper methods for above
//
@@ -3484,7 +3484,7 @@ class JoglPipeline extends Pipeline {
String listing = CgGL.cgGetLastListing(ctx.getCgContext());
return (errString + System.getProperty("line.separator") + listing);
}
-
+
private int cgToJ3dType(int type) {
switch (type) {
case CgGL.CG_BOOL:
@@ -3496,7 +3496,7 @@ class JoglPipeline extends Pipeline {
case CgGL.CG_INT:
case CgGL.CG_INT1:
return ShaderAttributeObjectRetained.TYPE_INTEGER;
-
+
// XXXX: add ShaderAttribute support for setting samplers. In the
// mean time, the binding between sampler and texture unit will
// need to be specified in the shader itself (which it already is
@@ -3505,53 +3505,53 @@ class JoglPipeline extends Pipeline {
// case CgGL.CG_SAMPLER2D:
// case CgGL.CG_SAMPLER3D:
// case CgGL.CG_SAMPLERCUBE:
-
+
case CgGL.CG_BOOL2:
case CgGL.CG_FIXED2:
case CgGL.CG_HALF2:
case CgGL.CG_INT2:
return ShaderAttributeObjectRetained.TYPE_TUPLE2I;
-
+
case CgGL.CG_BOOL3:
case CgGL.CG_FIXED3:
case CgGL.CG_HALF3:
case CgGL.CG_INT3:
return ShaderAttributeObjectRetained.TYPE_TUPLE3I;
-
+
case CgGL.CG_BOOL4:
case CgGL.CG_FIXED4:
case CgGL.CG_HALF4:
case CgGL.CG_INT4:
return ShaderAttributeObjectRetained.TYPE_TUPLE4I;
-
+
case CgGL.CG_FLOAT:
case CgGL.CG_FLOAT1:
return ShaderAttributeObjectRetained.TYPE_FLOAT;
-
+
case CgGL.CG_FLOAT2:
return ShaderAttributeObjectRetained.TYPE_TUPLE2F;
-
+
case CgGL.CG_FLOAT3:
return ShaderAttributeObjectRetained.TYPE_TUPLE3F;
-
+
case CgGL.CG_FLOAT4:
return ShaderAttributeObjectRetained.TYPE_TUPLE4F;
-
+
case CgGL.CG_FLOAT3x3:
return ShaderAttributeObjectRetained.TYPE_MATRIX3F;
-
+
case CgGL.CG_FLOAT4x4:
return ShaderAttributeObjectRetained.TYPE_MATRIX4F;
-
+
// Java 3D does not support the following sampler types:
//
// case CgGL.CG_SAMPLER1D:
// case CgGL.CG_SAMPLERRECT:
}
-
+
return -1;
}
-
+
private CGparameter lookupCgParams(JoglCgShaderInfo shader,
String attrNameString,
int[] type,
@@ -3572,277 +3572,277 @@ class JoglPipeline extends Pipeline {
}
return loc;
}
-
-
-
+
+
+
// ---------------------------------------------------------------------
-
+
//
// GLSLShaderProgramRetained methods
//
-
+
// ShaderAttributeValue methods
-
+
ShaderError setGLSLUniform1i(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform1i()");
-
+
context(ctx).getGL().glUniform1iARB(unbox(uniformLocation), value);
return null;
}
-
+
ShaderError setGLSLUniform1f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform1f()");
-
+
context(ctx).getGL().glUniform1fARB(unbox(uniformLocation), value);
return null;
}
-
+
ShaderError setGLSLUniform2i(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform2i()");
-
+
context(ctx).getGL().glUniform2iARB(unbox(uniformLocation), value[0], value[1]);
return null;
}
-
+
ShaderError setGLSLUniform2f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform2f()");
-
+
context(ctx).getGL().glUniform2fARB(unbox(uniformLocation), value[0], value[1]);
return null;
}
-
+
ShaderError setGLSLUniform3i(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform3i()");
-
+
context(ctx).getGL().glUniform3iARB(unbox(uniformLocation), value[0], value[1], value[2]);
return null;
}
-
+
ShaderError setGLSLUniform3f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform3f()");
-
+
context(ctx).getGL().glUniform3fARB(unbox(uniformLocation), value[0], value[1], value[2]);
return null;
}
-
+
ShaderError setGLSLUniform4i(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform4i()");
-
+
context(ctx).getGL().glUniform4iARB(unbox(uniformLocation), value[0], value[1], value[2], value[3]);
return null;
}
-
+
ShaderError setGLSLUniform4f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform4f()");
-
+
context(ctx).getGL().glUniform4fARB(unbox(uniformLocation), value[0], value[1], value[2], value[3]);
return null;
}
-
+
ShaderError setGLSLUniformMatrix3f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniformMatrix3f()");
-
+
// Load attribute
// transpose is true : each matrix is supplied in row major order
context(ctx).getGL().glUniformMatrix3fvARB(unbox(uniformLocation), 1, true, value, 0);
return null;
}
-
+
ShaderError setGLSLUniformMatrix4f(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniformMatrix4f()");
-
+
// Load attribute
// transpose is true : each matrix is supplied in row major order
context(ctx).getGL().glUniformMatrix4fvARB(unbox(uniformLocation), 1, true, value, 0);
return null;
}
-
+
// ShaderAttributeArray methods
-
+
ShaderError setGLSLUniform1iArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform1iArray()");
-
+
context(ctx).getGL().glUniform1ivARB(unbox(uniformLocation), numElements, value, 0);
return null;
}
-
+
ShaderError setGLSLUniform1fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform1fArray()");
-
+
context(ctx).getGL().glUniform1fvARB(unbox(uniformLocation), numElements, value, 0);
return null;
}
-
+
ShaderError setGLSLUniform2iArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform2iArray()");
-
+
context(ctx).getGL().glUniform2ivARB(unbox(uniformLocation), numElements, value, 0);
return null;
}
-
+
ShaderError setGLSLUniform2fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform2fArray()");
-
+
context(ctx).getGL().glUniform2fvARB(unbox(uniformLocation), numElements, value, 0);
return null;
}
-
+
ShaderError setGLSLUniform3iArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform3iArray()");
-
+
context(ctx).getGL().glUniform3ivARB(unbox(uniformLocation), numElements, value, 0);
return null;
}
-
+
ShaderError setGLSLUniform3fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform3fArray()");
-
+
context(ctx).getGL().glUniform3fvARB(unbox(uniformLocation), numElements, value, 0);
return null;
}
-
+
ShaderError setGLSLUniform4iArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
int[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform4iArray()");
-
+
context(ctx).getGL().glUniform4ivARB(unbox(uniformLocation), numElements, value, 0);
return null;
}
-
+
ShaderError setGLSLUniform4fArray(Context ctx,
ShaderProgramId shaderProgramId,
ShaderAttrLoc uniformLocation,
int numElements,
float[] value) {
if (VERBOSE) System.err.println("JoglPipeline.setGLSLUniform4fArray()");
-
+
context(ctx).getGL().glUniform4fvARB(unbox(uniformLocation), numElements, value, 0);
return null;
}
-
+
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
context(ctx).getGL().glUniformMatrix3fvARB(unbox(uniformLocation), numElements, true, value, 0);
return null;
}
-
+
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
context(ctx).getGL().glUniformMatrix4fvARB(unbox(uniformLocation), numElements, true, value, 0);
return null;
}
-
+
// interfaces for shader compilation, etc.
ShaderError createGLSLShader(Context ctx, int shaderType, ShaderId[] shaderId) {
if (VERBOSE) System.err.println("JoglPipeline.createGLSLShader()");
-
+
GL gl = context(ctx).getGL();
-
+
int shaderHandle = 0;
if (shaderType == Shader.SHADER_TYPE_VERTEX) {
shaderHandle = gl.glCreateShaderObjectARB(GL.GL_VERTEX_SHADER_ARB);
} else if (shaderType == Shader.SHADER_TYPE_FRAGMENT) {
shaderHandle = gl.glCreateShaderObjectARB(GL.GL_FRAGMENT_SHADER_ARB);
}
-
+
if (shaderHandle == 0) {
return new ShaderError(ShaderError.COMPILE_ERROR,
"Unable to create native shader object");
}
-
+
shaderId[0] = new JoglShaderObject(shaderHandle);
return null;
}
ShaderError destroyGLSLShader(Context ctx, ShaderId shaderId) {
if (VERBOSE) System.err.println("JoglPipeline.destroyGLSLShader()");
-
+
GL gl = context(ctx).getGL();
gl.glDeleteObjectARB(unbox(shaderId));
return null;
}
ShaderError compileGLSLShader(Context ctx, ShaderId shaderId, String program) {
if (VERBOSE) System.err.println("JoglPipeline.compileGLSLShader()");
-
+
int id = unbox(shaderId);
if (id == 0) {
throw new AssertionError("shaderId == 0");
}
-
+
if (program == null) {
throw new AssertionError("shader program string is null");
}
-
+
GL gl = context(ctx).getGL();
gl.glShaderSourceARB(id, 1, new String[] { program }, null, 0);
gl.glCompileShaderARB(id);
@@ -3857,12 +3857,12 @@ class JoglPipeline extends Pipeline {
}
return null;
}
-
+
ShaderError createGLSLShaderProgram(Context ctx, ShaderProgramId[] shaderProgramId) {
if (VERBOSE) System.err.println("JoglPipeline.createGLSLShaderProgram()");
-
+
GL gl = context(ctx).getGL();
-
+
int shaderProgramHandle = gl.glCreateProgramObjectARB();
if (shaderProgramHandle == 0) {
return new ShaderError(ShaderError.LINK_ERROR,
@@ -3879,7 +3879,7 @@ class JoglPipeline extends Pipeline {
ShaderError linkGLSLShaderProgram(Context ctx, ShaderProgramId shaderProgramId,
ShaderId[] shaderIds) {
if (VERBOSE) System.err.println("JoglPipeline.linkGLSLShaderProgram()");
-
+
GL gl = context(ctx).getGL();
int id = unbox(shaderProgramId);
for (int i = 0; i < shaderIds.length; i++) {
@@ -3900,7 +3900,7 @@ class JoglPipeline extends Pipeline {
ShaderError bindGLSLVertexAttrName(Context ctx, ShaderProgramId shaderProgramId,
String attrName, int attrIndex) {
if (VERBOSE) System.err.println("JoglPipeline.bindGLSLVertexAttrName()");
-
+
JoglContext jctx = (JoglContext) ctx;
context(ctx).getGL().glBindAttribLocationARB(unbox(shaderProgramId),
attrIndex + VirtualUniverse.mc.glslVertexAttrOffset,
@@ -3911,14 +3911,14 @@ class JoglPipeline extends Pipeline {
int numAttrNames, String[] attrNames, ShaderAttrLoc[] locArr,
int[] typeArr, int[] sizeArr, boolean[] isArrayArr) {
if (VERBOSE) System.err.println("JoglPipeline.lookupGLSLShaderAttrNames()");
-
+
// 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;
}
-
+
// Loop through the list of active uniform variables, one at a
// time, searching for a match in the attrNames array.
//
@@ -3942,7 +3942,7 @@ class JoglPipeline extends Pipeline {
tmp, 0);
int maxStrLen = tmp[0];
byte[] nameBuf = new byte[maxStrLen];
-
+
for (int i = 0; i < numActiveUniforms; i++) {
gl.glGetActiveUniformARB(id, i, maxStrLen, tmp3, 0,
tmp, 0,
@@ -3957,7 +3957,7 @@ class JoglPipeline extends Pipeline {
} 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("]")) {
@@ -3968,7 +3968,7 @@ class JoglPipeline extends Pipeline {
continue;
}
}
-
+
// Now try to find the name
for (int j = 0; j < numAttrNames; j++) {
if (name.equals(attrNames[j])) {
@@ -3979,7 +3979,7 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
// Now lookup the location of each name in the attrNames array
for (int i = 0; i < numAttrNames; i++) {
// Get uniform attribute location
@@ -3987,15 +3987,15 @@ class JoglPipeline extends Pipeline {
locArr[i] = new JoglShaderObject(loc);
}
}
-
+
ShaderError useGLSLShaderProgram(Context ctx, ShaderProgramId shaderProgramId) {
if (VERBOSE) System.err.println("JoglPipeline.useGLSLShaderProgram()");
-
+
context(ctx).getGL().glUseProgramObjectARB(unbox(shaderProgramId));
((JoglContext) ctx).setShaderProgram((JoglShaderObject) shaderProgramId);
return null;
}
-
+
//----------------------------------------------------------------------
// Helper methods for above shader routines
//
@@ -4004,19 +4004,19 @@ class JoglPipeline extends Pipeline {
return 0;
return ((JoglShaderObject) loc).getValue();
}
-
+
private int unbox(ShaderProgramId id) {
if (id == null)
return 0;
return ((JoglShaderObject) id).getValue();
}
-
+
private int unbox(ShaderId id) {
if (id == null)
return 0;
return ((JoglShaderObject) id).getValue();
}
-
+
private String getInfoLog(GL gl, int id) {
int[] infoLogLength = new int[1];
gl.glGetObjectParameterivARB(id, GL.GL_OBJECT_INFO_LOG_LENGTH_ARB, infoLogLength, 0);
@@ -4033,7 +4033,7 @@ class JoglPipeline extends Pipeline {
}
return null;
}
-
+
private int glslToJ3dType(int type) {
switch (type) {
case GL.GL_BOOL_ARB:
@@ -4042,39 +4042,39 @@ class JoglPipeline extends Pipeline {
case GL.GL_SAMPLER_3D_ARB:
case GL.GL_SAMPLER_CUBE_ARB:
return ShaderAttributeObjectRetained.TYPE_INTEGER;
-
+
case GL.GL_FLOAT:
return ShaderAttributeObjectRetained.TYPE_FLOAT;
-
+
case GL.GL_INT_VEC2_ARB:
case GL.GL_BOOL_VEC2_ARB:
return ShaderAttributeObjectRetained.TYPE_TUPLE2I;
-
+
case GL.GL_FLOAT_VEC2_ARB:
return ShaderAttributeObjectRetained.TYPE_TUPLE2F;
-
+
case GL.GL_INT_VEC3_ARB:
case GL.GL_BOOL_VEC3_ARB:
return ShaderAttributeObjectRetained.TYPE_TUPLE3I;
-
+
case GL.GL_FLOAT_VEC3_ARB:
return ShaderAttributeObjectRetained.TYPE_TUPLE3F;
-
+
case GL.GL_INT_VEC4_ARB:
case GL.GL_BOOL_VEC4_ARB:
return ShaderAttributeObjectRetained.TYPE_TUPLE4I;
-
+
case GL.GL_FLOAT_VEC4_ARB:
return ShaderAttributeObjectRetained.TYPE_TUPLE4F;
-
+
// case GL.GL_FLOAT_MAT2_ARB:
-
+
case GL.GL_FLOAT_MAT3_ARB:
return ShaderAttributeObjectRetained.TYPE_MATRIX3F;
-
+
case GL.GL_FLOAT_MAT4_ARB:
return ShaderAttributeObjectRetained.TYPE_MATRIX4F;
-
+
// Java 3D does not support the following sampler types:
//
// case GL.GL_SAMPLER_1D_ARB:
@@ -4083,27 +4083,27 @@ class JoglPipeline extends Pipeline {
// case GL.GL_SAMPLER_2D_RECT_ARB:
// case GL.GL_SAMPLER_2D_RECT_SHADOW_ARB:
}
-
+
return -1;
}
-
+
// ---------------------------------------------------------------------
-
+
//
// Renderer methods
//
-
+
void cleanupRenderer() {
// Nothing to do
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// ColoringAttributesRetained methods
//
-
+
void updateColoringAttributes(Context ctx,
float dRed, float dGreen, float dBlue,
float red, float green, float blue,
@@ -4111,11 +4111,11 @@ class JoglPipeline extends Pipeline {
boolean lightEnable,
int shadeModel) {
if (VERBOSE) System.err.println("JoglPipeline.updateColoringAttributes()");
-
+
GL gl = context(ctx).getGL();
-
+
float cr, cg, cb;
-
+
if (lightEnable) {
cr = dRed; cg = dGreen; cb = dBlue;
} else {
@@ -4128,25 +4128,25 @@ class JoglPipeline extends Pipeline {
gl.glShadeModel(GL.GL_SMOOTH);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// DirectionalLightRetained methods
//
-
+
private static final float[] black = new float[4];
void updateDirectionalLight(Context ctx,
int lightSlot, float red, float green,
float blue, float dirx, float diry, float dirz) {
if (VERBOSE) System.err.println("JoglPipeline.updateDirectionalLight()");
-
+
GL gl = context(ctx).getGL();
-
+
int lightNum = GL.GL_LIGHT0 + lightSlot;
float[] values = new float[4];
-
+
values[0] = red;
values[1] = green;
values[2] = blue;
@@ -4165,25 +4165,25 @@ class JoglPipeline extends Pipeline {
gl.glLightf(lightNum, GL.GL_SPOT_EXPONENT, 0.0f);
gl.glLightf(lightNum, GL.GL_SPOT_CUTOFF, 180.0f);
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// PointLightRetained methods
//
-
+
void updatePointLight(Context ctx,
int lightSlot, float red, float green,
float blue, float attenx, float atteny, float attenz,
float posx, float posy, float posz) {
if (VERBOSE) System.err.println("JoglPipeline.updatePointLight()");
-
+
GL gl = context(ctx).getGL();
-
+
int lightNum = GL.GL_LIGHT0 + lightSlot;
float[] values = new float[4];
-
+
values[0] = red;
values[1] = green;
values[2] = blue;
@@ -4201,14 +4201,14 @@ class JoglPipeline extends Pipeline {
gl.glLightf(lightNum, GL.GL_SPOT_EXPONENT, 0.0f);
gl.glLightf(lightNum, GL.GL_SPOT_CUTOFF, 180.0f);
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// SpotLightRetained methods
//
-
+
void updateSpotLight(Context ctx,
int lightSlot, float red, float green,
float blue, float attenx, float atteny, float attenz,
@@ -4216,12 +4216,12 @@ class JoglPipeline extends Pipeline {
float concentration, float dirx, float diry,
float dirz) {
if (VERBOSE) System.err.println("JoglPipeline.updateSpotLight()");
-
+
GL gl = context(ctx).getGL();
-
+
int lightNum = GL.GL_LIGHT0 + lightSlot;
float[] values = new float[4];
-
+
values[0] = red;
values[1] = green;
values[2] = blue;
@@ -4243,21 +4243,21 @@ class JoglPipeline extends Pipeline {
gl.glLightf(lightNum, GL.GL_SPOT_EXPONENT, concentration);
gl.glLightf(lightNum, GL.GL_SPOT_CUTOFF, (float) (spreadAngle * 180.0f / Math.PI));
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// ExponentialFogRetained methods
//
-
+
void updateExponentialFog(Context ctx,
float red, float green, float blue,
float density) {
if (VERBOSE) System.err.println("JoglPipeline.updateExponentialFog()");
-
+
GL gl = context(ctx).getGL();
-
+
float[] color = new float[3];
color[0] = red;
color[1] = green;
@@ -4267,21 +4267,21 @@ class JoglPipeline extends Pipeline {
gl.glFogf(GL.GL_FOG_DENSITY, density);
gl.glEnable(GL.GL_FOG);
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// LinearFogRetained methods
//
-
+
void updateLinearFog(Context ctx,
float red, float green, float blue,
double fdist, double bdist) {
if (VERBOSE) System.err.println("JoglPipeline.updateLinearFog()");
-
+
GL gl = context(ctx).getGL();
-
+
float[] color = new float[3];
color[0] = red;
color[1] = green;
@@ -4292,24 +4292,24 @@ class JoglPipeline extends Pipeline {
gl.glFogf(GL.GL_FOG_END, (float) bdist);
gl.glEnable(GL.GL_FOG);
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// LineAttributesRetained methods
//
-
+
void updateLineAttributes(Context ctx,
float lineWidth, int linePattern,
int linePatternMask,
int linePatternScaleFactor,
boolean lineAntialiasing) {
if (VERBOSE) System.err.println("JoglPipeline.updateLineAttributes()");
-
+
GL gl = context(ctx).getGL();
gl.glLineWidth(lineWidth);
-
+
if (linePattern == LineAttributes.PATTERN_SOLID) {
gl.glDisable(GL.GL_LINE_STIPPLE);
} else {
@@ -4324,7 +4324,7 @@ class JoglPipeline extends Pipeline {
}
gl.glEnable(GL.GL_LINE_STIPPLE);
}
-
+
/* XXXX: Polygon Mode check, blend enable */
if (lineAntialiasing) {
gl.glEnable(GL.GL_LINE_SMOOTH);
@@ -4332,14 +4332,14 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_LINE_SMOOTH);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// MaterialRetained methods
//
-
+
void updateMaterial(Context ctx,
float red, float green, float blue, float alpha,
float aRed, float aGreen, float aBlue,
@@ -4348,11 +4348,11 @@ class JoglPipeline extends Pipeline {
float sRed, float sGreen, float sBlue,
float shininess, int colorTarget, boolean lightEnable) {
if (VERBOSE) System.err.println("JoglPipeline.updateMaterial()");
-
+
float[] color = new float[4];
-
+
GL gl = context(ctx).getGL();
-
+
gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, shininess);
switch (colorTarget) {
case Material.DIFFUSE:
@@ -4371,18 +4371,18 @@ class JoglPipeline extends Pipeline {
gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);
break;
}
-
+
color[0] = eRed; color[1] = eGreen; color[2] = eBlue;
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, color, 0);
-
+
color[0] = aRed; color[1] = aGreen; color[2] = aBlue;
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, color, 0);
-
+
color[0] = sRed; color[1] = sGreen; color[2] = sBlue;
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, color, 0);
-
+
float cr, cg, cb;
-
+
if (lightEnable) {
color[0] = dRed; color[1] = dGreen; color[2] = dBlue;
} else {
@@ -4391,30 +4391,30 @@ class JoglPipeline extends Pipeline {
color[3] = alpha;
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, color, 0);
gl.glColor4f(color[0], color[1], color[2], color[3]);
-
+
if (lightEnable) {
gl.glEnable(GL.GL_LIGHTING);
} else {
gl.glDisable(GL.GL_LIGHTING);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// ModelClipRetained methods
//
-
+
void updateModelClip(Context ctx, int planeNum, boolean enableFlag,
double A, double B, double C, double D) {
if (VERBOSE) System.err.println("JoglPipeline.updateModelClip()");
-
+
GL gl = context(ctx).getGL();
-
+
double[] equation = new double[4];
int pl = GL.GL_CLIP_PLANE0 + planeNum;
-
+
// OpenGL clip planes are opposite to J3d clip planes
if (enableFlag) {
equation[0] = -A;
@@ -4427,20 +4427,20 @@ class JoglPipeline extends Pipeline {
gl.glDisable(pl);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// PointAttributesRetained methods
//
-
+
void updatePointAttributes(Context ctx, float pointSize, boolean pointAntialiasing) {
if (VERBOSE) System.err.println("JoglPipeline.updatePointAttributes()");
-
+
GL gl = context(ctx).getGL();
gl.glPointSize(pointSize);
-
+
// XXXX: Polygon Mode check, blend enable
if (pointAntialiasing) {
gl.glEnable(GL.GL_POINT_SMOOTH);
@@ -4448,23 +4448,23 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_POINT_SMOOTH);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// PolygonAttributesRetained methods
//
-
+
void updatePolygonAttributes(Context ctx,
int polygonMode, int cullFace,
boolean backFaceNormalFlip,
float polygonOffset,
float polygonOffsetFactor) {
if (VERBOSE) System.err.println("JoglPipeline.updatePolygonAttributes()");
-
+
GL gl = context(ctx).getGL();
-
+
if (cullFace == PolygonAttributes.CULL_NONE) {
gl.glDisable(GL.GL_CULL_FACE);
} else {
@@ -4475,13 +4475,13 @@ class JoglPipeline extends Pipeline {
}
gl.glEnable(GL.GL_CULL_FACE);
}
-
+
if (backFaceNormalFlip && (cullFace != PolygonAttributes.CULL_BACK)) {
gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_TRUE);
} else {
gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_FALSE);
}
-
+
if (polygonMode == PolygonAttributes.POLYGON_POINT) {
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_POINT);
} else if (polygonMode == PolygonAttributes.POLYGON_LINE) {
@@ -4489,9 +4489,9 @@ class JoglPipeline extends Pipeline {
} else {
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
}
-
+
gl.glPolygonOffset(polygonOffsetFactor, polygonOffset);
-
+
if ((polygonOffsetFactor != 0.0) || (polygonOffset != 0.0)) {
switch (polygonMode) {
case PolygonAttributes.POLYGON_POINT:
@@ -4516,14 +4516,14 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// RenderingAttributesRetained methods
//
-
+
void updateRenderingAttributes(Context ctx,
boolean depthBufferWriteEnableOverride,
boolean depthBufferEnableOverride,
@@ -4538,9 +4538,9 @@ class JoglPipeline extends Pipeline {
int stencilFunction, int stencilReferenceValue,
int stencilCompareMask, int stencilWriteMask ) {
if (VERBOSE) System.err.println("JoglPipeline.updateRenderingAttributes()");
-
+
GL gl = context(ctx).getGL();
-
+
if (!depthBufferEnableOverride) {
if (depthBufferEnable) {
gl.glEnable(GL.GL_DEPTH_TEST);
@@ -4549,7 +4549,7 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_DEPTH_TEST);
}
}
-
+
if (!depthBufferWriteEnableOverride) {
if (depthBufferWriteEnable) {
gl.glDepthMask(true);
@@ -4557,20 +4557,20 @@ class JoglPipeline extends Pipeline {
gl.glDepthMask(false);
}
}
-
+
if (alphaTestFunction == RenderingAttributes.ALWAYS) {
gl.glDisable(GL.GL_ALPHA_TEST);
} else {
gl.glEnable(GL.GL_ALPHA_TEST);
gl.glAlphaFunc(getFunctionValue(alphaTestFunction), alphaTestValue);
}
-
+
if (ignoreVertexColors) {
gl.glDisable(GL.GL_COLOR_MATERIAL);
} else {
gl.glEnable(GL.GL_COLOR_MATERIAL);
}
-
+
if (rasterOpEnable) {
gl.glEnable(GL.GL_COLOR_LOGIC_OP);
switch (rasterOp) {
@@ -4626,26 +4626,26 @@ class JoglPipeline extends Pipeline {
} else {
gl.glDisable(GL.GL_COLOR_LOGIC_OP);
}
-
+
if (userStencilAvailable) {
if (stencilEnable) {
gl.glEnable(GL.GL_STENCIL_TEST);
-
+
gl.glStencilOp(getStencilOpValue(stencilFailOp),
getStencilOpValue(stencilZFailOp),
getStencilOpValue(stencilZPassOp));
-
+
gl.glStencilFunc(getFunctionValue(stencilFunction),
stencilReferenceValue, stencilCompareMask);
-
+
gl.glStencilMask(stencilWriteMask);
-
+
} else {
gl.glDisable(GL.GL_STENCIL_TEST);
}
}
}
-
+
private int getFunctionValue(int func) {
switch (func) {
case RenderingAttributes.ALWAYS:
@@ -4673,10 +4673,10 @@ class JoglPipeline extends Pipeline {
func = GL.GL_GEQUAL;
break;
}
-
+
return func;
}
-
+
private int getStencilOpValue(int op) {
switch (op) {
case RenderingAttributes.STENCIL_KEEP:
@@ -4698,17 +4698,17 @@ class JoglPipeline extends Pipeline {
op = GL.GL_INVERT;
break;
}
-
+
return op;
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// TexCoordGenerationRetained methods
//
-
+
/**
* This method updates the native context:
* trans contains eyeTovworld transform in d3d
@@ -4722,14 +4722,14 @@ class JoglPipeline extends Pipeline {
float planeQx, float planeQy, float planeQz, float planeQw,
double[] vworldToEc) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexCoordGeneration()");
-
+
GL gl = context(ctx).getGL();
-
+
float[] planeS = new float[4];
float[] planeT = new float[4];
float[] planeR = new float[4];
float[] planeQ = new float[4];
-
+
if (enable) {
gl.glEnable(GL.GL_TEXTURE_GEN_S);
gl.glEnable(GL.GL_TEXTURE_GEN_T);
@@ -4743,7 +4743,7 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_TEXTURE_GEN_R);
gl.glDisable(GL.GL_TEXTURE_GEN_Q);
}
-
+
if (genMode != TexCoordGeneration.SPHERE_MAP) {
planeS[0] = planeSx; planeS[1] = planeSy;
planeS[2] = planeSz; planeS[3] = planeSw;
@@ -4759,14 +4759,14 @@ class JoglPipeline extends Pipeline {
planeQ[2] = planeQz; planeQ[3] = planeQw;
}
}
-
+
switch (genMode) {
case TexCoordGeneration.OBJECT_LINEAR:
gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR);
gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR);
gl.glTexGenfv(GL.GL_S, GL.GL_OBJECT_PLANE, planeS, 0);
gl.glTexGenfv(GL.GL_T, GL.GL_OBJECT_PLANE, planeT, 0);
-
+
if (format == TexCoordGeneration.TEXTURE_COORDINATE_3) {
gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR);
gl.glTexGenfv(GL.GL_R, GL.GL_OBJECT_PLANE, planeR, 0);
@@ -4778,10 +4778,10 @@ class JoglPipeline extends Pipeline {
}
break;
case TexCoordGeneration.EYE_LINEAR:
-
+
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPushMatrix();
-
+
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glLoadTransposeMatrixd(vworldToEc, 0);
} else {
@@ -4789,12 +4789,12 @@ class JoglPipeline extends Pipeline {
copyTranspose(vworldToEc, v);
gl.glLoadMatrixd(v, 0);
}
-
+
gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR);
gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR);
gl.glTexGenfv(GL.GL_S, GL.GL_EYE_PLANE, planeS, 0);
gl.glTexGenfv(GL.GL_T, GL.GL_EYE_PLANE, planeT, 0);
-
+
if (format == TexCoordGeneration.TEXTURE_COORDINATE_3) {
gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR);
gl.glTexGenfv(GL.GL_R, GL.GL_EYE_PLANE, planeR, 0);
@@ -4815,7 +4815,7 @@ class JoglPipeline extends Pipeline {
gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_SPHERE_MAP);
gl.glTexGeni(GL.GL_Q, GL.GL_TEXTURE_GEN_MODE, GL.GL_SPHERE_MAP);
}
-
+
break;
case TexCoordGeneration.NORMAL_MAP:
gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
@@ -4845,14 +4845,14 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_TEXTURE_GEN_Q);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// TransparencyAttributesRetained methods
//
-
+
private static final int screen_door[][] = {
/* 0 / 16 */
{
@@ -5057,7 +5057,7 @@ class JoglPipeline extends Pipeline {
screen_door_table[i] = buf.slice();
}
}
-
+
private static final int[] blendFunctionTable = new int[TransparencyAttributes.MAX_BLEND_FUNC_TABLE_SIZE];
static {
blendFunctionTable[TransparencyAttributes.BLEND_ZERO] = GL.GL_ZERO;
@@ -5070,7 +5070,7 @@ class JoglPipeline extends Pipeline {
blendFunctionTable[TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR] = GL.GL_ONE_MINUS_SRC_COLOR;
blendFunctionTable[TransparencyAttributes.BLEND_CONSTANT_COLOR] = GL.GL_CONSTANT_COLOR;
}
-
+
void updateTransparencyAttributes(Context ctx,
float alpha, int geometryType,
int polygonMode,
@@ -5079,16 +5079,16 @@ class JoglPipeline extends Pipeline {
int srcBlendFunction,
int dstBlendFunction) {
if (VERBOSE) System.err.println("JoglPipeline.updateTransparencyAttributes()");
-
+
GL gl = context(ctx).getGL();
-
+
if (transparencyMode != TransparencyAttributes.SCREEN_DOOR) {
gl.glDisable(GL.GL_POLYGON_STIPPLE);
} else {
gl.glEnable(GL.GL_POLYGON_STIPPLE);
gl.glPolygonStipple(screen_door_table[(int)(alpha * 16)]);
}
-
+
if ((transparencyMode < TransparencyAttributes.SCREEN_DOOR) ||
((((geometryType & RenderMolecule.LINE) != 0) ||
(polygonMode == PolygonAttributes.POLYGON_LINE))
@@ -5103,14 +5103,14 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_BLEND);
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// TextureAttributesRetained methods
//
-
+
void updateTextureAttributes(Context ctx,
double[] transform, boolean isIdentity, int textureMode,
int perspCorrectionMode,
@@ -5120,15 +5120,15 @@ class JoglPipeline extends Pipeline {
float textureBlendColorAlpha,
int textureFormat) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureAttributes()");
-
+
GL gl = context(ctx).getGL();
gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT,
(perspCorrectionMode == TextureAttributes.NICEST) ? GL.GL_NICEST : GL.GL_FASTEST);
-
+
// set OGL texture matrix
gl.glPushAttrib(GL.GL_TRANSFORM_BIT);
gl.glMatrixMode(GL.GL_TEXTURE);
-
+
if (isIdentity) {
gl.glLoadIdentity();
} else if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
@@ -5138,9 +5138,9 @@ class JoglPipeline extends Pipeline {
copyTranspose(transform, mx);
gl.glLoadMatrixd(mx, 0);
}
-
+
gl.glPopAttrib();
-
+
// set texture color
float[] color = new float[4];
color[0] = textureBlendColorRed;
@@ -5148,9 +5148,9 @@ class JoglPipeline extends Pipeline {
color[2] = textureBlendColorBlue;
color[3] = textureBlendColorAlpha;
gl.glTexEnvfv(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_COLOR, color, 0);
-
+
// set texture environment mode
-
+
switch (textureMode) {
case TextureAttributes.MODULATE:
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE);
@@ -5168,12 +5168,12 @@ class JoglPipeline extends Pipeline {
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_COMBINE);
break;
}
-
+
if (gl.isExtensionAvailable("GL_SGI_texture_color_table")) {
gl.glDisable(GL.GL_TEXTURE_COLOR_TABLE_SGI);
}
}
-
+
void updateRegisterCombiners(Context absCtx,
double[] transform, boolean isIdentity, int textureMode,
int perspCorrectionMode,
@@ -5187,20 +5187,20 @@ class JoglPipeline extends Pipeline {
int[] combineRgbFcn, int[] combineAlphaFcn,
int combineRgbScale, int combineAlphaScale) {
if (VERBOSE) System.err.println("JoglPipeline.updateRegisterCombiners()");
-
+
JoglContext ctx = (JoglContext) absCtx;
GL gl = context(ctx).getGL();
-
+
if (perspCorrectionMode == TextureAttributes.NICEST) {
gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
} else {
gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);
}
-
+
// set OGL texture matrix
gl.glPushAttrib(GL.GL_TRANSFORM_BIT);
gl.glMatrixMode(GL.GL_TEXTURE);
-
+
if (isIdentity) {
gl.glLoadIdentity();
} else if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
@@ -5210,9 +5210,9 @@ class JoglPipeline extends Pipeline {
copyTranspose(transform, mx);
gl.glLoadMatrixd(mx, 0);
}
-
+
gl.glPopAttrib();
-
+
// set texture color
float[] color = new float[4];
color[0] = textureBlendColorRed;
@@ -5220,7 +5220,7 @@ class JoglPipeline extends Pipeline {
color[2] = textureBlendColorBlue;
color[3] = textureBlendColorAlpha;
gl.glTexEnvfv(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_COLOR, color, 0);
-
+
// set texture environment mode
gl.glEnable(GL.GL_REGISTER_COMBINERS_NV);
int textureUnit = ctx.getCurrentTextureUnit();
@@ -5231,7 +5231,7 @@ class JoglPipeline extends Pipeline {
} else {
fragment = GL.GL_SPARE0_NV;
}
-
+
switch (textureMode) {
case TextureAttributes.MODULATE:
gl.glCombinerInputNV(combinerUnit, GL.GL_RGB,
@@ -5246,7 +5246,7 @@ class JoglPipeline extends Pipeline {
gl.glCombinerInputNV(combinerUnit, GL.GL_ALPHA,
GL.GL_VARIABLE_B_NV, textureUnit,
GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_ALPHA);
-
+
gl.glCombinerOutputNV(combinerUnit, GL.GL_RGB,
GL.GL_SPARE0_NV, GL.GL_DISCARD_NV, GL.GL_DISCARD_NV,
GL.GL_NONE, GL.GL_NONE, false, false, false);
@@ -5254,7 +5254,7 @@ class JoglPipeline extends Pipeline {
GL.GL_SPARE0_NV, GL.GL_DISCARD_NV, GL.GL_DISCARD_NV,
GL.GL_NONE, GL.GL_NONE, false, false, false);
break;
-
+
case TextureAttributes.DECAL:
gl.glCombinerInputNV(combinerUnit, GL.GL_RGB,
GL.GL_VARIABLE_A_NV, fragment,
@@ -5268,14 +5268,14 @@ class JoglPipeline extends Pipeline {
gl.glCombinerInputNV(combinerUnit, GL.GL_RGB,
GL.GL_VARIABLE_D_NV, textureUnit,
GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_ALPHA);
-
+
gl.glCombinerInputNV(combinerUnit, GL.GL_ALPHA,
GL.GL_VARIABLE_A_NV, fragment,
GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_ALPHA);
gl.glCombinerInputNV(combinerUnit, GL.GL_ALPHA,
GL.GL_VARIABLE_B_NV, GL.GL_ZERO,
GL.GL_UNSIGNED_INVERT_NV, GL.GL_ALPHA);
-
+
gl.glCombinerOutputNV(combinerUnit, GL.GL_RGB,
GL.GL_DISCARD_NV, GL.GL_DISCARD_NV, GL.GL_SPARE0_NV,
GL.GL_NONE, GL.GL_NONE, false, false, false);
@@ -5283,10 +5283,10 @@ class JoglPipeline extends Pipeline {
GL.GL_SPARE0_NV, GL.GL_DISCARD_NV, GL.GL_DISCARD_NV,
GL.GL_NONE, GL.GL_NONE, false, false, false);
break;
-
+
case TextureAttributes.BLEND:
gl.glCombinerParameterfvNV(GL.GL_CONSTANT_COLOR0_NV, color, 0);
-
+
gl.glCombinerInputNV(combinerUnit, GL.GL_RGB,
GL.GL_VARIABLE_A_NV, fragment,
GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
@@ -5299,14 +5299,14 @@ class JoglPipeline extends Pipeline {
gl.glCombinerInputNV(combinerUnit, GL.GL_RGB,
GL.GL_VARIABLE_D_NV, textureUnit,
GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
-
+
gl.glCombinerInputNV(combinerUnit, GL.GL_ALPHA,
GL.GL_VARIABLE_A_NV, fragment,
GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_ALPHA);
gl.glCombinerInputNV(combinerUnit, GL.GL_ALPHA,
GL.GL_VARIABLE_B_NV, textureUnit,
GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_ALPHA);
-
+
gl.glCombinerOutputNV(combinerUnit, GL.GL_RGB,
GL.GL_DISCARD_NV, GL.GL_DISCARD_NV, GL.GL_SPARE0_NV,
GL.GL_NONE, GL.GL_NONE, false, false, false);
@@ -5314,7 +5314,7 @@ class JoglPipeline extends Pipeline {
GL.GL_SPARE0_NV, GL.GL_DISCARD_NV, GL.GL_DISCARD_NV,
GL.GL_NONE, GL.GL_NONE, false, false, false);
break;
-
+
case TextureAttributes.REPLACE:
gl.glCombinerInputNV(combinerUnit, GL.GL_RGB,
GL.GL_VARIABLE_A_NV, textureUnit,
@@ -5328,7 +5328,7 @@ class JoglPipeline extends Pipeline {
gl.glCombinerInputNV(combinerUnit, GL.GL_ALPHA,
GL.GL_VARIABLE_B_NV, GL.GL_ZERO,
GL.GL_UNSIGNED_INVERT_NV, GL.GL_ALPHA);
-
+
gl.glCombinerOutputNV(combinerUnit, GL.GL_RGB,
GL.GL_SPARE0_NV, GL.GL_DISCARD_NV, GL.GL_DISCARD_NV,
GL.GL_NONE, GL.GL_NONE, false, false, false);
@@ -5336,7 +5336,7 @@ class JoglPipeline extends Pipeline {
GL.GL_SPARE0_NV, GL.GL_DISCARD_NV, GL.GL_DISCARD_NV,
GL.GL_NONE, GL.GL_NONE, false, false, false);
break;
-
+
case TextureAttributes.COMBINE:
if (combineRgbMode == TextureAttributes.COMBINE_DOT3) {
int color1 = getCombinerArg(gl, combineRgbSrc[0], textureUnit, combinerUnit);
@@ -5353,7 +5353,7 @@ class JoglPipeline extends Pipeline {
gl.glCombinerInputNV(combinerUnit, GL.GL_ALPHA,
GL.GL_VARIABLE_B_NV, GL.GL_ZERO,
GL.GL_UNSIGNED_INVERT_NV, GL.GL_ALPHA);
-
+
gl.glCombinerOutputNV(combinerUnit, GL.GL_RGB,
GL.GL_SPARE0_NV, GL.GL_DISCARD_NV, GL.GL_DISCARD_NV,
GL.GL_NONE/*SCALE_BY_FOUR_NV*/, GL.GL_NONE, true,
@@ -5365,7 +5365,7 @@ class JoglPipeline extends Pipeline {
}
break;
}
-
+
gl.glFinalCombinerInputNV(GL.GL_VARIABLE_A_NV,
GL.GL_SPARE0_NV, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
gl.glFinalCombinerInputNV(GL.GL_VARIABLE_B_NV,
@@ -5380,17 +5380,17 @@ class JoglPipeline extends Pipeline {
GL.GL_ZERO, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
gl.glFinalCombinerInputNV(GL.GL_VARIABLE_G_NV,
GL.GL_SPARE0_NV, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_ALPHA);
-
+
if (gl.isExtensionAvailable("GL_SGI_texture_color_table"))
gl.glDisable(GL.GL_TEXTURE_COLOR_TABLE_SGI);
// GL_SGI_texture_color_table
}
-
+
void updateTextureColorTable(Context ctx, int numComponents,
int colorTableSize,
int[] textureColorTable) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureColorTable()");
-
+
GL gl = context(ctx).getGL();
if (gl.isExtensionAvailable("GL_SGI_texture_color_table")) {
if (numComponents == 3) {
@@ -5403,14 +5403,14 @@ class JoglPipeline extends Pipeline {
gl.glEnable(GL.GL_TEXTURE_COLOR_TABLE_SGI);
}
}
-
+
void updateCombiner(Context ctx,
int combineRgbMode, int combineAlphaMode,
int[] combineRgbSrc, int[] combineAlphaSrc,
int[] combineRgbFcn, int[] combineAlphaFcn,
int combineRgbScale, int combineAlphaScale) {
if (VERBOSE) System.err.println("JoglPipeline.updateCombiner()");
-
+
GL gl = context(ctx).getGL();
int[] GLrgbMode = new int[1];
int[] GLalphaMode = new int[1];
@@ -5418,7 +5418,7 @@ class JoglPipeline extends Pipeline {
GLrgbMode, GLalphaMode);
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_COMBINE_RGB, GLrgbMode[0]);
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_COMBINE_ALPHA, GLalphaMode[0]);
-
+
int nargs;
if (combineRgbMode == TextureAttributes.COMBINE_REPLACE) {
nargs = 1;
@@ -5427,14 +5427,14 @@ class JoglPipeline extends Pipeline {
} else {
nargs = 2;
}
-
+
for (int i = 0; i < nargs; i++) {
gl.glTexEnvi(GL.GL_TEXTURE_ENV, _gl_combineRgbSrcIndex[i],
_gl_combineSrc[combineRgbSrc[i]]);
gl.glTexEnvi(GL.GL_TEXTURE_ENV, _gl_combineRgbOpIndex[i],
_gl_combineFcn[combineRgbFcn[i]]);
}
-
+
if (combineAlphaMode == TextureAttributes.COMBINE_REPLACE) {
nargs = 1;
} else if (combineAlphaMode == TextureAttributes.COMBINE_INTERPOLATE) {
@@ -5442,20 +5442,20 @@ class JoglPipeline extends Pipeline {
} else {
nargs = 2;
}
-
+
for (int i = 0; i < nargs; i++) {
gl.glTexEnvi(GL.GL_TEXTURE_ENV, _gl_combineAlphaSrcIndex[i],
_gl_combineSrc[combineAlphaSrc[i]]);
gl.glTexEnvi(GL.GL_TEXTURE_ENV, _gl_combineAlphaOpIndex[i],
_gl_combineFcn[combineAlphaFcn[i]]);
}
-
+
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_RGB_SCALE, combineRgbScale);
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_ALPHA_SCALE, combineAlphaScale);
}
-
+
// Helper routines for above
-
+
private void getGLCombineMode(GL gl, int combineRgbMode, int combineAlphaMode,
int[] GLrgbMode, int[] GLalphaMode) {
switch (combineRgbMode) {
@@ -5483,7 +5483,7 @@ class JoglPipeline extends Pipeline {
default:
break;
}
-
+
switch (combineAlphaMode) {
case TextureAttributes.COMBINE_REPLACE:
GLalphaMode[0] = GL.GL_REPLACE;
@@ -5516,49 +5516,49 @@ class JoglPipeline extends Pipeline {
break;
}
}
-
+
// mapping from java enum to gl enum
private static final int[] _gl_combineRgbSrcIndex = {
GL.GL_SOURCE0_RGB,
GL.GL_SOURCE1_RGB,
GL.GL_SOURCE2_RGB,
};
-
+
private static final int[] _gl_combineAlphaSrcIndex = {
GL.GL_SOURCE0_ALPHA,
GL.GL_SOURCE1_ALPHA,
GL.GL_SOURCE2_ALPHA,
};
-
+
private static final int[] _gl_combineRgbOpIndex = {
GL.GL_OPERAND0_RGB,
GL.GL_OPERAND1_RGB,
GL.GL_OPERAND2_RGB,
};
-
+
private static final int[] _gl_combineAlphaOpIndex = {
GL.GL_OPERAND0_ALPHA,
GL.GL_OPERAND1_ALPHA,
GL.GL_OPERAND2_ALPHA,
};
-
+
private static final int[] _gl_combineSrc = {
GL.GL_PRIMARY_COLOR, // TextureAttributes.COMBINE_OBJECT_COLOR
GL.GL_TEXTURE, // TextureAttributes.COMBINE_TEXTURE
GL.GL_CONSTANT, // TextureAttributes.COMBINE_CONSTANT_COLOR
GL.GL_PREVIOUS, // TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE
};
-
+
private static final int[] _gl_combineFcn = {
GL.GL_SRC_COLOR, // TextureAttributes.COMBINE_SRC_COLOR
GL.GL_ONE_MINUS_SRC_COLOR, // TextureAttributes.COMBINE_ONE_MINUS_SRC_COLOR
GL.GL_SRC_ALPHA, // TextureAttributes.COMBINE_SRC_ALPHA
GL.GL_ONE_MINUS_SRC_ALPHA, // TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA
};
-
+
private int getCombinerArg(GL gl, int arg, int textureUnit, int combUnit) {
int comb = 0;
-
+
switch (arg) {
case TextureAttributes.COMBINE_OBJECT_COLOR:
if (combUnit == GL.GL_COMBINER0_NV) {
@@ -5577,23 +5577,23 @@ class JoglPipeline extends Pipeline {
comb = textureUnit -1;
break;
}
-
+
return comb;
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// TextureUnitStateRetained methods
//
-
+
void updateTextureUnitState(Context ctx, int index, boolean enable) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureUnitState()");
-
+
GL gl = context(ctx).getGL();
JoglContext jctx = (JoglContext) ctx;
-
+
if (index >= 0 && gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glActiveTexture(index + GL.GL_TEXTURE0);
gl.glClientActiveTexture(GL.GL_TEXTURE0 + index);
@@ -5603,7 +5603,7 @@ class JoglPipeline extends Pipeline {
gl.glCombinerParameteriNV(GL.GL_NUM_GENERAL_COMBINERS_NV, index + 1);
}
}
-
+
if (!enable) {
// if not enabled, then don't enable any tex mapping
gl.glDisable(GL.GL_TEXTURE_1D);
@@ -5611,26 +5611,26 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_TEXTURE_3D);
gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
}
-
+
// if it is enabled, the enable flag will be taken care of
// in the bindTexture call
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// TextureRetained methods
// Texture2DRetained methods
//
-
+
void bindTexture2D(Context ctx, int objectId, boolean enable) {
if (VERBOSE) System.err.println("JoglPipeline.bindTexture2D(objectId=" + objectId + ",enable=" + enable + ")");
-
+
GL gl = context(ctx).getGL();
gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
gl.glDisable(GL.GL_TEXTURE_3D);
-
+
if (!enable) {
gl.glDisable(GL.GL_TEXTURE_2D);
} else {
@@ -5638,7 +5638,7 @@ class JoglPipeline extends Pipeline {
gl.glEnable(GL.GL_TEXTURE_2D);
}
}
-
+
void updateTexture2DImage(Context ctx,
int numLevels, int level,
int textureFormat, int imageFormat,
@@ -5646,92 +5646,92 @@ class JoglPipeline extends Pipeline {
int boundaryWidth,
int dataType, Object data, boolean useAutoMipMap) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture2DImage(width=" + width + ",height=" + height + ",level=" + level + ")");
-
+
updateTexture2DImage(ctx, GL.GL_TEXTURE_2D,
numLevels, level, textureFormat, imageFormat,
width, height, boundaryWidth, dataType, data, 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, GL.GL_TEXTURE_2D,
level, xoffset, yoffset,
textureFormat, imageFormat,
imgXOffset, imgYOffset, tilew, width, height,
dataType, data);
}
-
+
void updateTexture2DLodRange(Context ctx,
int baseLevel, int maximumLevel,
float minimumLOD, float maximumLOD) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture2DLodRange()");
-
+
updateTextureLodRange(ctx, GL.GL_TEXTURE_2D,
baseLevel, maximumLevel,
minimumLOD, maximumLOD);
}
-
+
void updateTexture2DLodOffset(Context ctx,
float lodOffsetS, float lodOffsetT,
float lodOffsetR) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture2DLodOffset()");
-
+
updateTextureLodOffset(ctx, GL.GL_TEXTURE_2D,
lodOffsetS, lodOffsetT, lodOffsetR);
}
-
+
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, GL.GL_TEXTURE_2D,
boundaryModeS, boundaryModeT, -1,
boundaryRed, boundaryGreen,
boundaryBlue, boundaryAlpha);
}
-
+
void updateTexture2DFilterModes(Context ctx,
int minFilter, int magFilter) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture2DFilterModes()");
-
+
updateTextureFilterModes(ctx, GL.GL_TEXTURE_2D, minFilter, magFilter);
}
-
+
void updateTexture2DSharpenFunc(Context ctx,
int numSharpenTextureFuncPts,
float[] sharpenTextureFuncPts) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture2DSharpenFunc()");
-
+
updateTextureSharpenFunc(ctx, GL.GL_TEXTURE_2D,
numSharpenTextureFuncPts, sharpenTextureFuncPts);
}
-
+
void updateTexture2DFilter4Func(Context ctx,
int numFilter4FuncPts,
float[] filter4FuncPts) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture2DFilter4Func()");
-
+
updateTextureFilter4Func(ctx, GL.GL_TEXTURE_2D,
numFilter4FuncPts, filter4FuncPts);
}
-
+
void updateTexture2DAnisotropicFilter(Context ctx, float degree) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture2DAnisotropicFilter()");
-
+
updateTextureAnisotropicFilter(ctx, GL.GL_TEXTURE_2D, degree);
}
-
+
private void updateTextureLodRange(Context ctx,
int target,
int baseLevel, int maximumLevel,
@@ -5744,7 +5744,7 @@ class JoglPipeline extends Pipeline {
gl.glTexParameterf(target, GL.GL_TEXTURE_MIN_LOD, minimumLOD);
gl.glTexParameterf(target, GL.GL_TEXTURE_MAX_LOD, maximumLOD);
}
-
+
private void updateTextureLodOffset(Context ctx,
int target,
float lodOffsetS, float lodOffsetT,
@@ -5756,7 +5756,7 @@ class JoglPipeline extends Pipeline {
gl.glTexParameterf(target, GL.GL_TEXTURE_LOD_BIAS_T_SGIX, lodOffsetT);
gl.glTexParameterf(target, GL.GL_TEXTURE_LOD_BIAS_R_SGIX, lodOffsetR);
}
-
+
private void updateTextureAnisotropicFilter(Context ctx, int target, float degree) {
GL gl = context(ctx).getGL();
// checking of the availability of anisotropic filter functionality
@@ -5765,20 +5765,20 @@ class JoglPipeline extends Pipeline {
GL.GL_TEXTURE_MAX_ANISOTROPY_EXT,
degree);
}
-
+
// ---------------------------------------------------------------------
-
+
//
// Texture3DRetained methods
//
-
+
void bindTexture3D(Context ctx, int objectId, boolean enable) {
if (VERBOSE) System.err.println("JoglPipeline.bindTexture3D()");
-
+
GL gl = context(ctx).getGL();
// textureCubeMap will take precedure over 3D Texture
gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
-
+
if (!enable) {
gl.glDisable(GL.GL_TEXTURE_3D);
} else {
@@ -5786,18 +5786,18 @@ class JoglPipeline extends Pipeline {
gl.glEnable(GL.GL_TEXTURE_3D);
}
}
-
+
void updateTexture3DImage(Context ctx,
int numLevels, int level,
int textureFormat, int imageFormat,
int width, int height, int depth,
int boundaryWidth,
int dataType, Object data, boolean useAutoMipMap) {
-
+
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DImage()");
-
+
GL gl = context(ctx).getGL();
-
+
int format = 0;
int internalFormat = 0;
int type = GL.GL_UNSIGNED_INT_8_8_8_8;
@@ -5831,12 +5831,12 @@ class JoglPipeline extends Pipeline {
gl.glTexParameteri(GL.GL_TEXTURE_3D, GL.GL_GENERATE_MIPMAP, GL.GL_TRUE);
}
else {
- gl.glTexParameteri(GL.GL_TEXTURE_3D, GL.GL_GENERATE_MIPMAP, GL.GL_FALSE);
+ gl.glTexParameteri(GL.GL_TEXTURE_3D, GL.GL_GENERATE_MIPMAP, GL.GL_FALSE);
}
-
+
if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
-
+
switch (imageFormat) {
case ImageComponentRetained.TYPE_BYTE_BGR:
format = GL.GL_BGR;
@@ -5875,9 +5875,9 @@ class JoglPipeline extends Pipeline {
assert false;
return;
}
-
+
if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
-
+
gl.glTexImage3D(GL.GL_TEXTURE_3D,
level, internalFormat,
width, height, depth, boundaryWidth,
@@ -5889,10 +5889,10 @@ class JoglPipeline extends Pipeline {
width, height, depth, boundaryWidth,
format, GL.GL_UNSIGNED_BYTE, (ByteBuffer) data);
}
-
+
} else if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) {
-
+
switch (imageFormat) {
/* GL_BGR */
case ImageComponentRetained.TYPE_INT_BGR: /* Assume XBGR format */
@@ -5919,13 +5919,13 @@ class JoglPipeline extends Pipeline {
assert false;
return;
}
-
+
/* Force Alpha to 1.0 if needed */
if(forceAlphaToOne) {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 0.0f);
gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f);
}
-
+
if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
gl.glTexImage3D(GL.GL_TEXTURE_3D,
level, internalFormat,
@@ -5937,7 +5937,7 @@ class JoglPipeline extends Pipeline {
width, height, depth, boundaryWidth,
format, type, (Buffer) data);
}
-
+
/* Restore Alpha scale and bias */
if(forceAlphaToOne) {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 1.0f);
@@ -5947,7 +5947,7 @@ class JoglPipeline extends Pipeline {
assert false;
}
}
-
+
void updateTexture3DSubImage(Context ctx,
int level,
int xoffset, int yoffset, int zoffset,
@@ -5956,25 +5956,25 @@ class JoglPipeline extends Pipeline {
int tilew, int tileh,
int width, int height, int depth,
int dataType, Object data, boolean useAutoMipMap) {
-
+
/* Note: useAutoMipMap is not use for SubImage in the jogl pipe */
-
+
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DSubImage()");
-
+
GL gl = context(ctx).getGL();
-
+
int format = 0;
int internalFormat = 0;
int type = GL.GL_UNSIGNED_INT_8_8_8_8;
int numBytes = 0;
boolean forceAlphaToOne = false;
boolean pixelStore = false;
-
+
if (imgXOffset > 0 || (width < tilew)) {
pixelStore = true;
gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, tilew);
}
-
+
switch (textureFormat) {
case Texture.INTENSITY:
internalFormat = GL.GL_INTENSITY;
@@ -5997,10 +5997,10 @@ class JoglPipeline extends Pipeline {
default:
assert false;
}
-
+
if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
-
+
switch (imageFormat) {
case ImageComponentRetained.TYPE_BYTE_BGR:
format = GL.GL_BGR;
@@ -6045,8 +6045,8 @@ class JoglPipeline extends Pipeline {
default:
assert false;
return;
- }
-
+ }
+
ByteBuffer buf = null;
if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
buf = ByteBuffer.wrap((byte[]) data);
@@ -6063,10 +6063,10 @@ class JoglPipeline extends Pipeline {
width, height, depth,
format, GL.GL_UNSIGNED_BYTE,
buf);
-
+
} else if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) {
-
+
switch (imageFormat) {
/* GL_BGR */
case ImageComponentRetained.TYPE_INT_BGR: /* Assume XBGR format */
@@ -6093,21 +6093,21 @@ class JoglPipeline extends Pipeline {
assert false;
return;
}
-
+
/* Force Alpha to 1.0 if needed */
if(forceAlphaToOne) {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 0.0f);
gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f);
}
-
+
IntBuffer buf = null;
if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
buf = IntBuffer.wrap((int[]) data);
}
else {
buf = (IntBuffer) data;
- }
-
+ }
+
int offset = tilew * tileh * imgZOffset +
tilew * imgYOffset + imgXOffset;
buf.position(offset);
@@ -6116,7 +6116,7 @@ class JoglPipeline extends Pipeline {
width, height, depth,
format, type,
buf);
-
+
/* Restore Alpha scale and bias */
if(forceAlphaToOne) {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 1.0f);
@@ -6126,88 +6126,88 @@ class JoglPipeline extends Pipeline {
assert false;
return;
}
-
+
if (pixelStore) {
gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, 0);
}
-
+
}
-
-
+
+
void updateTexture3DLodRange(Context ctx,
int baseLevel, int maximumLevel,
float minimumLod, float maximumLod) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DLodRange()");
-
+
updateTextureLodRange(ctx, GL.GL_TEXTURE_3D,
baseLevel, maximumLevel,
minimumLod, maximumLod);
}
-
+
void updateTexture3DLodOffset(Context ctx,
float lodOffsetS, float lodOffsetT,
float lodOffsetR) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DLodOffset()");
-
+
updateTextureLodOffset(ctx, GL.GL_TEXTURE_3D,
lodOffsetS, lodOffsetT, lodOffsetR);
}
-
+
void updateTexture3DBoundary(Context ctx,
int boundaryModeS, int boundaryModeT,
int boundaryModeR, float boundaryRed,
float boundaryGreen, float boundaryBlue,
float boundaryAlpha) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DBoundary()");
-
+
updateTextureBoundary(ctx, GL.GL_TEXTURE_2D,
boundaryModeS, boundaryModeT, boundaryModeR,
boundaryRed, boundaryGreen,
boundaryBlue, boundaryAlpha);
}
-
+
void updateTexture3DFilterModes(Context ctx,
int minFilter, int magFilter) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DFilterModes()");
-
+
updateTextureFilterModes(ctx, GL.GL_TEXTURE_3D,
minFilter, magFilter);
}
-
+
void updateTexture3DSharpenFunc(Context ctx,
int numSharpenTextureFuncPts,
float[] sharpenTextureFuncPts) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DSharpenFunc()");
-
+
updateTextureSharpenFunc(ctx, GL.GL_TEXTURE_3D,
numSharpenTextureFuncPts, sharpenTextureFuncPts);
}
-
+
void updateTexture3DFilter4Func(Context ctx,
int numFilter4FuncPts,
float[] filter4FuncPts) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DFilter4Func()");
-
+
updateTextureFilter4Func(ctx, GL.GL_TEXTURE_3D,
numFilter4FuncPts, filter4FuncPts);
}
-
+
void updateTexture3DAnisotropicFilter(Context ctx, float degree) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DAnisotropicFilter()");
-
+
updateTextureAnisotropicFilter(ctx, GL.GL_TEXTURE_3D, degree);
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// TextureCubeMapRetained methods
//
-
+
void bindTextureCubeMap(Context ctx, int objectId, boolean enable) {
if (VERBOSE) System.err.println("JoglPipeline.bindTextureCubeMap()");
-
+
GL gl = context(ctx).getGL();
// TextureCubeMap will take precedure over 3D Texture so
// there is no need to disable 3D Texture here.
@@ -6218,7 +6218,7 @@ class JoglPipeline extends Pipeline {
gl.glEnable(GL.GL_TEXTURE_CUBE_MAP);
}
}
-
+
void updateTextureCubeMapImage(Context ctx,
int face, int numLevels, int level,
int textureFormat, int imageFormat,
@@ -6226,105 +6226,105 @@ class JoglPipeline extends Pipeline {
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);
}
-
+
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) {
-
+
/* Note: useAutoMipMap is not use for SubImage in the jogl pipe */
-
+
if (VERBOSE) System.err.println("JoglPipeline.updateTextureCubeMapSubImage()");
-
+
updateTexture2DSubImage(ctx, _gl_textureCubeMapFace[face],
level, xoffset, yoffset, textureFormat,
imageFormat, imgXOffset, imgYOffset, tilew,
width, height, dataType, data);
}
-
+
void updateTextureCubeMapLodRange(Context ctx,
int baseLevel, int maximumLevel,
float minimumLod, float maximumLod) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureCubeMapLodRange()");
-
+
updateTextureLodRange(ctx,
GL.GL_TEXTURE_CUBE_MAP,
baseLevel, maximumLevel,
minimumLod, maximumLod);
}
-
+
void updateTextureCubeMapLodOffset(Context ctx,
float lodOffsetS, float lodOffsetT,
float lodOffsetR) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureCubeMapLodOffset()");
-
+
updateTextureLodOffset(ctx,
GL.GL_TEXTURE_CUBE_MAP,
lodOffsetS, lodOffsetT, lodOffsetR);
}
-
+
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,
GL.GL_TEXTURE_CUBE_MAP,
boundaryModeS, boundaryModeT, -1,
boundaryRed, boundaryGreen,
boundaryBlue, boundaryAlpha);
}
-
+
void updateTextureCubeMapFilterModes(Context ctx,
int minFilter, int magFilter) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureCubeMapFilterModes()");
-
+
updateTextureFilterModes(ctx,
GL.GL_TEXTURE_CUBE_MAP,
minFilter, magFilter);
}
-
+
void updateTextureCubeMapSharpenFunc(Context ctx,
int numSharpenTextureFuncPts,
float[] sharpenTextureFuncPts) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureCubeMapSharpenFunc()");
-
+
updateTextureSharpenFunc(ctx,
GL.GL_TEXTURE_CUBE_MAP,
numSharpenTextureFuncPts, sharpenTextureFuncPts);
}
-
+
void updateTextureCubeMapFilter4Func(Context ctx,
int numFilter4FuncPts,
float[] filter4FuncPts) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureCubeMapFilter4Func()");
-
+
updateTextureFilter4Func(ctx,
GL.GL_TEXTURE_CUBE_MAP,
numFilter4FuncPts, filter4FuncPts);
}
-
+
void updateTextureCubeMapAnisotropicFilter(Context ctx, float degree) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureCubeMapAnisotropicFilter()");
-
+
updateTextureAnisotropicFilter(ctx,
GL.GL_TEXTURE_CUBE_MAP,
degree);
}
-
+
//----------------------------------------------------------------------
//
// Helper routines for above texture methods
//
-
+
private void updateTexture2DImage(Context ctx,
int target,
int numLevels,
@@ -6338,11 +6338,11 @@ class JoglPipeline extends Pipeline {
Object data,
boolean useAutoMipMap) {
GL gl = context(ctx).getGL();
-
+
int format = 0, internalFormat = 0;
int type = GL.GL_UNSIGNED_INT_8_8_8_8;
boolean forceAlphaToOne = false;
-
+
switch (textureFormat) {
case Texture.INTENSITY:
internalFormat = GL.GL_INTENSITY;
@@ -6365,17 +6365,17 @@ class JoglPipeline extends Pipeline {
default:
assert false;
}
-
+
if (useAutoMipMap) {
gl.glTexParameteri(target, GL.GL_GENERATE_MIPMAP, GL.GL_TRUE);
}
else {
- gl.glTexParameteri(target, GL.GL_GENERATE_MIPMAP, GL.GL_FALSE);
+ gl.glTexParameteri(target, GL.GL_GENERATE_MIPMAP, GL.GL_FALSE);
}
-
+
if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
-
+
switch (imageFormat) {
case ImageComponentRetained.TYPE_BYTE_BGR:
format = GL.GL_BGR;
@@ -6414,9 +6414,9 @@ class JoglPipeline extends Pipeline {
assert false;
return;
}
-
+
if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
-
+
gl.glTexImage2D(target, level, internalFormat,
width, height, boundaryWidth,
format, GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[])data));
@@ -6425,10 +6425,10 @@ class JoglPipeline extends Pipeline {
width, height, boundaryWidth,
format, GL.GL_UNSIGNED_BYTE, (Buffer) data);
}
-
+
} else if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) {
-
+
switch (imageFormat) {
/* GL_BGR */
case ImageComponentRetained.TYPE_INT_BGR: /* Assume XBGR format */
@@ -6455,13 +6455,13 @@ class JoglPipeline extends Pipeline {
assert false;
return;
}
-
+
/* Force Alpha to 1.0 if needed */
if(forceAlphaToOne) {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 0.0f);
gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f);
}
-
+
if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
gl.glTexImage2D(target, level, internalFormat,
width, height, boundaryWidth,
@@ -6471,7 +6471,7 @@ class JoglPipeline extends Pipeline {
width, height, boundaryWidth,
format, type, (Buffer) data);
}
-
+
/* Restore Alpha scale and bias */
if(forceAlphaToOne) {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 1.0f);
@@ -6481,7 +6481,7 @@ class JoglPipeline extends Pipeline {
assert false;
}
}
-
+
private void updateTexture2DSubImage(Context ctx,
int target,
int level, int xoffset, int yoffset,
@@ -6490,18 +6490,18 @@ class JoglPipeline extends Pipeline {
int tilew, int width, int height,
int dataType, Object data) {
GL gl = context(ctx).getGL();
-
+
int format = 0, internalFormat=0;
int numBytes = 0;
int type = GL.GL_UNSIGNED_INT_8_8_8_8;
boolean forceAlphaToOne = false;
boolean pixelStore = false;
-
+
if (imgXOffset > 0 || (width < tilew)) {
pixelStore = true;
gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, tilew);
}
-
+
switch (textureFormat) {
case Texture.INTENSITY:
internalFormat = GL.GL_INTENSITY;
@@ -6524,10 +6524,10 @@ class JoglPipeline extends Pipeline {
default:
assert false;
}
-
+
if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
-
+
switch (imageFormat) {
case ImageComponentRetained.TYPE_BYTE_BGR:
format = GL.GL_BGR;
@@ -6573,7 +6573,7 @@ class JoglPipeline extends Pipeline {
assert false;
return;
}
-
+
ByteBuffer buf = null;
if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
buf = ByteBuffer.wrap((byte[]) data);
@@ -6581,15 +6581,15 @@ class JoglPipeline extends Pipeline {
else {
buf = (ByteBuffer) data;
}
-
+
// offset by the imageOffset
buf.position((tilew * imgYOffset + imgXOffset) * numBytes);
gl.glTexSubImage2D(target, level, xoffset, yoffset, width, height,
format, GL.GL_UNSIGNED_BYTE, buf);
-
+
} else if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) {
-
+
switch (imageFormat) {
/* GL_BGR */
case ImageComponentRetained.TYPE_INT_BGR: /* Assume XBGR format */
@@ -6621,20 +6621,20 @@ class JoglPipeline extends Pipeline {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 0.0f);
gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f);
}
-
+
IntBuffer buf = null;
if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
buf = IntBuffer.wrap((int[]) data);
}
else {
buf = (IntBuffer) data;
- }
-
+ }
+
// offset by the imageOffset
buf.position(tilew * imgYOffset + imgXOffset);
gl.glTexSubImage2D(target, level, xoffset, yoffset, width, height,
format, type, buf);
-
+
/* Restore Alpha scale and bias */
if(forceAlphaToOne) {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 1.0f);
@@ -6644,29 +6644,29 @@ class JoglPipeline extends Pipeline {
assert false;
return;
}
-
+
if (pixelStore) {
gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, 0);
}
-
+
}
-
+
void updateTextureFilterModes(Context ctx,
int target,
int minFilter,
int magFilter) {
GL gl = context(ctx).getGL();
-
+
if (EXTRA_DEBUGGING) {
System.err.println("minFilter: " + getFilterName(minFilter) +
" magFilter: " + getFilterName(magFilter));
}
-
+
// FIXME: unclear whether we really need to set up the enum values
// in the JoglContext as is done in the native code depending on
// extension availability; maybe this is the defined fallback
// behavior of the various Java3D modes
-
+
// set texture min filter
switch (minFilter) {
case Texture.FASTEST:
@@ -6690,7 +6690,7 @@ class JoglPipeline extends Pipeline {
GL.GL_FILTER4_SGIS);
break;
}
-
+
// set texture mag filter
switch (magFilter) {
case Texture.FASTEST:
@@ -6731,7 +6731,7 @@ class JoglPipeline extends Pipeline {
break;
}
}
-
+
void updateTextureBoundary(Context ctx,
int target,
int boundaryModeS,
@@ -6742,7 +6742,7 @@ class JoglPipeline extends Pipeline {
float boundaryBlue,
float boundaryAlpha) {
GL gl = context(ctx).getGL();
-
+
// set texture wrap parameter
switch (boundaryModeS) {
case Texture.WRAP:
@@ -6760,7 +6760,7 @@ class JoglPipeline extends Pipeline {
GL.GL_CLAMP_TO_BORDER);
break;
}
-
+
switch (boundaryModeT) {
case Texture.WRAP:
gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
@@ -6777,7 +6777,7 @@ class JoglPipeline extends Pipeline {
GL.GL_CLAMP_TO_BORDER);
break;
}
-
+
// applies to Texture3D only
if (boundaryModeR != -1) {
switch (boundaryModeR) {
@@ -6785,7 +6785,7 @@ class JoglPipeline extends Pipeline {
gl.glTexParameteri(target,
GL.GL_TEXTURE_WRAP_R, GL.GL_REPEAT);
break;
-
+
case Texture.CLAMP:
gl.glTexParameteri(target,
GL.GL_TEXTURE_WRAP_R, GL.GL_CLAMP);
@@ -6802,7 +6802,7 @@ class JoglPipeline extends Pipeline {
break;
}
}
-
+
if (boundaryModeS == Texture.CLAMP ||
boundaryModeT == Texture.CLAMP ||
boundaryModeR == Texture.CLAMP) {
@@ -6815,7 +6815,7 @@ class JoglPipeline extends Pipeline {
gl.glTexParameterfv(target, GL.GL_TEXTURE_BORDER_COLOR, color, 0);
}
}
-
+
private static final String getFilterName(int filter) {
switch (filter) {
case Texture.FASTEST:
@@ -6848,7 +6848,7 @@ class JoglPipeline extends Pipeline {
return "(unknown)";
}
}
-
+
private void updateTextureSharpenFunc(Context ctx,
int target,
int numPts,
@@ -6858,7 +6858,7 @@ class JoglPipeline extends Pipeline {
GL gl = context(ctx).getGL();
gl.glSharpenTexFuncSGIS(target, numPts, pts, 0);
}
-
+
private void updateTextureFilter4Func(Context ctx,
int target,
int numPts,
@@ -6869,7 +6869,7 @@ class JoglPipeline extends Pipeline {
gl.glTexFilterFuncSGIS(target, GL.GL_FILTER4_SGIS,
numPts, pts, 0);
}
-
+
// mapping from java enum to gl enum
private static final int[] _gl_textureCubeMapFace = {
GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
@@ -6879,44 +6879,44 @@ class JoglPipeline extends Pipeline {
GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
};
-
+
// ---------------------------------------------------------------------
-
+
//
// MasterControl methods
//
-
+
// Method to return the AWT object
long getAWT() {
if (VERBOSE) System.err.println("JoglPipeline.getAWT()");
-
+
// FIXME: probably completely unneeded in this implementation,
// but should probably remove this dependence in the shared code
return 0;
}
-
+
// Method to initialize the native J3D library
boolean initializeJ3D(boolean disableXinerama) {
// Dummy method in JOGL pipeline
return true;
}
-
+
// Maximum lights supported by the native API
int getMaximumLights() {
if (VERBOSE) System.err.println("JoglPipeline.getMaximumLights()");
-
+
// FIXME: this isn't quite what the NativePipeline returns but
// is probably close enough
return 8;
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// Canvas3D methods - native wrappers
//
-
+
// This is the native method for creating the underlying graphics context.
Context createNewContext(Canvas3D cv, long display, Drawable drawable,
long fbConfig, Context shareCtx, boolean isSharedCtx,
@@ -6939,14 +6939,14 @@ class JoglPipeline extends Pipeline {
} else {
draw = drawable(cv.drawable);
}
-
+
// FIXME: assuming that this only gets called after addNotify has been called
draw.setRealized(true);
GLContext context = draw.createContext(context(shareCtx));
-
+
// Apparently we are supposed to make the context current at
// this point and set up a bunch of properties
-
+
// Work around for some low end graphics driver bug, such as Intel Chipset.
// Issue 324 : Lockup Java3D program and throw exception using JOGL renderer
boolean failed = false;
@@ -6967,24 +6967,24 @@ class JoglPipeline extends Pipeline {
} while (failed && (failCount < MAX_FAIL_COUNT));
if (failCount == MAX_FAIL_COUNT) {
throw new IllegalRenderingStateException("Unable to make new context current after " + failCount + "tries");
- }
-
+ }
+
GL gl = context.getGL();
JoglContext ctx = new JoglContext(context);
-
+
try {
if (!getPropertiesFromCurrentContext(ctx)) {
throw new IllegalRenderingStateException("Unable to fetch properties from current OpenGL context");
}
-
+
if(!isSharedCtx){
// Set up fields in Canvas3D
setupCanvasProperties(cv, ctx, gl, glslLibraryAvailable, cgLibraryAvailable);
}
-
+
// Enable rescale normal
gl.glEnable(GL.GL_RESCALE_NORMAL);
-
+
gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE);
gl.glDepthFunc(GL.GL_LEQUAL);
gl.glEnable(GL.GL_COLOR_MATERIAL);
@@ -6999,22 +6999,22 @@ class JoglPipeline extends Pipeline {
} finally {
context.release();
}
-
+
return ctx;
}
-
+
void createQueryContext(Canvas3D cv, long display, Drawable drawable,
long fbConfig, boolean offScreen, int width, int height,
boolean glslLibraryAvailable,
boolean cgLibraryAvailable) {
if (VERBOSE) System.err.println("JoglPipeline.createQueryContext()");
-
+
// FIXME: for now, ignoring the "offscreen" flag -- unclear how
// to create an offscreen buffer at this point -- very likely
// need Canvas3D.offScreenBufferInfo promoted to an Object --
// this logic will need to be revisited to make sure we capture
// all of the functionality of the NativePipeline
-
+
Frame f = new Frame();
f.setUndecorated(true);
f.setLayout(new BorderLayout());
@@ -7041,21 +7041,21 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
disposeOnEDT(f);
}
-
+
// This is the native for creating an offscreen buffer
Drawable createOffScreenBuffer(Canvas3D cv, Context ctx, long display, long fbConfig, int width, int height) {
if (VERBOSE) System.err.println("JoglPipeline.createOffScreenBuffer()");
-
+
// Note 1: when this is called, the incoming Context argument is
// null because (obviously) no drawable or context has been
// created for the Canvas3D yet.
-
+
// Note 2: we ignore the global j3d.usePbuffer flag; JOGL
// doesn't expose pixmap/bitmap surfaces in its public API.
-
+
// First pick up the JoglGraphicsConfiguration and from there
// the GLCapabilities from the Canvas3D
JoglGraphicsConfiguration jcfg = (JoglGraphicsConfiguration) cv.graphicsConfiguration;
@@ -7067,24 +7067,24 @@ class JoglPipeline extends Pipeline {
// FIXME: do anything else here? Throw exception?
return null;
}
-
+
GLPbuffer pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(caps, null,
width, height, null);
return new JoglDrawable(pbuffer);
}
-
+
void destroyOffScreenBuffer(Canvas3D cv, Context ctx, long display, long fbConfig, Drawable drawable) {
if (VERBOSE) System.err.println("JoglPipeline.destroyOffScreenBuffer()");
-
+
JoglDrawable jdraw = (JoglDrawable) drawable;
GLPbuffer pbuffer = (GLPbuffer) jdraw.getGLDrawable();
pbuffer.destroy();
}
-
+
// This is the native for reading the image from the offscreen buffer
void readOffScreenBuffer(Canvas3D cv, Context ctx, int format, int dataType, Object data, int width, int height) {
if (VERBOSE) System.err.println("JoglPipeline.readOffScreenBuffer()");
-
+
GL gl = context(ctx).getGL();
gl.glPixelStorei(GL.GL_PACK_ROW_LENGTH, width);
gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);
@@ -7092,7 +7092,7 @@ class JoglPipeline extends Pipeline {
int type = 0;
if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
-
+
switch (format) {
// GL_BGR
case ImageComponentRetained.TYPE_BYTE_BGR:
@@ -7113,7 +7113,7 @@ class JoglPipeline extends Pipeline {
case ImageComponentRetained.TYPE_BYTE_RGBA:
type = GL.GL_RGBA;
break;
-
+
/* This method only supports 3 and 4 components formats and BYTE types. */
case ImageComponentRetained.TYPE_BYTE_LA:
case ImageComponentRetained.TYPE_BYTE_GRAY:
@@ -7124,7 +7124,7 @@ class JoglPipeline extends Pipeline {
default:
throw new AssertionError("illegal format " + format);
}
-
+
gl.glReadPixels(0, 0, width, height, type, GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[]) data));
} else if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) ||
@@ -7158,13 +7158,13 @@ class JoglPipeline extends Pipeline {
default:
throw new AssertionError("illegal format " + format);
}
-
+
/* Force Alpha to 1.0 if needed */
if(forceAlphaToOne) {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 0.0f);
gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f);
}
-
+
gl.glReadPixels(0, 0, width, height, type, intType, IntBuffer.wrap((int[]) data));
/* Restore Alpha scale and bias */
@@ -7172,13 +7172,13 @@ class JoglPipeline extends Pipeline {
gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 1.0f);
gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 0.0f);
}
-
+
} else {
throw new AssertionError("illegal image data type " + dataType);
-
+
}
}
-
+
// The native method for swapBuffers
int swapBuffers(Canvas3D cv, Context ctx, long dpy, Drawable drawable) {
if (VERBOSE) System.err.println("JoglPipeline.swapBuffers()");
@@ -7186,28 +7186,28 @@ class JoglPipeline extends Pipeline {
draw.swapBuffers();
return 0;
}
-
+
// notify D3D that Canvas is resize
int resizeD3DCanvas(Canvas3D cv, Context ctx) {
// Dummy method in JOGL pipeline
return 0;
}
-
+
// notify D3D to toggle between FullScreen and window mode
int toggleFullScreenMode(Canvas3D cv, Context ctx) {
// Dummy method in JOGL pipeline
return 0;
}
-
+
// native method for setting Material when no material is present
void updateMaterialColor(Context ctx, float r, float g, float b, float a) {
if (VERBOSE) System.err.println("JoglPipeline.updateMaterialColor()");
-
+
GL gl = context(ctx).getGL();
gl.glColor4f(r, g, b, a);
gl.glDisable(GL.GL_LIGHTING);
}
-
+
void destroyContext(long display, Drawable drawable, Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.destroyContext()");
GLDrawable draw = drawable(drawable);
@@ -7219,48 +7219,48 @@ class JoglPipeline extends Pipeline {
// FIXME: assuming this is the right point at which to make this call
draw.setRealized(false);
}
-
+
// This is the native method for doing accumulation.
void accum(Context ctx, float value) {
if (VERBOSE) System.err.println("JoglPipeline.accum()");
-
+
GL gl = context(ctx).getGL();
gl.glReadBuffer(GL.GL_BACK);
gl.glAccum(GL.GL_ACCUM, value);
gl.glReadBuffer(GL.GL_FRONT);
}
-
+
// This is the native method for doing accumulation return.
void accumReturn(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.accumReturn()");
-
+
GL gl = context(ctx).getGL();
gl.glAccum(GL.GL_RETURN, 1.0f);
}
-
+
// This is the native method for clearing the accumulation buffer.
void clearAccum(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.clearAccum()");
-
+
GL gl = context(ctx).getGL();
gl.glClear(GL.GL_ACCUM_BUFFER_BIT);
}
-
+
// This is the native method for getting the number of lights the underlying
// native library can support.
int getNumCtxLights(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.getNumCtxLights()");
-
+
GL gl = context(ctx).getGL();
int[] res = new int[1];
gl.glGetIntegerv(GL.GL_MAX_LIGHTS, res, 0);
return res[0];
}
-
+
// Native method for decal 1st child setup
boolean decal1stChildSetup(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.decal1stChildSetup()");
-
+
GL gl = context(ctx).getGL();
gl.glEnable(GL.GL_STENCIL_TEST);
gl.glClearStencil(0x0);
@@ -7272,79 +7272,79 @@ class JoglPipeline extends Pipeline {
else
return false;
}
-
+
// Native method for decal nth child setup
void decalNthChildSetup(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.decalNthChildSetup()");
-
+
GL gl = context(ctx).getGL();
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glStencilFunc(GL.GL_EQUAL, 0x1, 0x1);
gl.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);
}
-
+
// Native method for decal reset
void decalReset(Context ctx, boolean depthBufferEnable) {
if (VERBOSE) System.err.println("JoglPipeline.decalReset()");
-
+
GL gl = context(ctx).getGL();
gl.glDisable(GL.GL_STENCIL_TEST);
if (depthBufferEnable)
gl.glEnable(GL.GL_DEPTH_TEST);
}
-
+
// Native method for eye lighting
void ctxUpdateEyeLightingEnable(Context ctx, boolean localEyeLightingEnable) {
if (VERBOSE) System.err.println("JoglPipeline.ctxUpdateEyeLightingEnable()");
-
+
GL gl = context(ctx).getGL();
-
+
if (localEyeLightingEnable) {
gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_TRUE);
} else {
gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, GL.GL_FALSE);
}
}
-
+
// The following three methods are used in multi-pass case
-
+
// native method for setting blend color
void setBlendColor(Context ctx, float red, float green,
float blue, float alpha) {
if (VERBOSE) System.err.println("JoglPipeline.setBlendColor()");
-
+
GL gl = context(ctx).getGL();
if (gl.isExtensionAvailable("GL_ARB_imaging")) {
gl.glBlendColor(red, green, blue, alpha);
}
}
-
+
// native method for setting blend func
void setBlendFunc(Context ctx, int srcBlendFunction, int dstBlendFunction) {
if (VERBOSE) System.err.println("JoglPipeline.setBlendFunc()");
-
+
GL gl = context(ctx).getGL();
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(blendFunctionTable[srcBlendFunction],
blendFunctionTable[dstBlendFunction]);
}
-
+
// native method for setting fog enable flag
void setFogEnableFlag(Context ctx, boolean enable) {
if (VERBOSE) System.err.println("JoglPipeline.setFogEnableFlag()");
-
+
GL gl = context(ctx).getGL();
-
+
if (enable)
gl.glEnable(GL.GL_FOG);
else
gl.glDisable(GL.GL_FOG);
}
-
+
// Setup the full scene antialising in D3D and ogl when GL_ARB_multisamle supported
void setFullSceneAntialiasing(Context absCtx, boolean enable) {
if (VERBOSE) System.err.println("JoglPipeline.setFullSceneAntialiasing()");
-
+
JoglContext ctx = (JoglContext) absCtx;
GL gl = context(ctx).getGL();
if (ctx.getHasMultisample() && !VirtualUniverse.mc.implicitAntialiasing) {
@@ -7355,41 +7355,41 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
void setGlobalAlpha(Context ctx, float alpha) {
if (VERBOSE) System.err.println("JoglPipeline.setGlobalAlpha()");
-
+
GL gl = context(ctx).getGL();
if (gl.isExtensionAvailable("GL_SUN_global_alpha")) {
gl.glEnable(GL.GL_GLOBAL_ALPHA_SUN);
gl.glGlobalAlphaFactorfSUN(alpha);
}
}
-
+
// Native method to update separate specular color control
void updateSeparateSpecularColorEnable(Context ctx, boolean enable) {
if (VERBOSE) System.err.println("JoglPipeline.updateSeparateSpecularColorEnable()");
-
+
GL gl = context(ctx).getGL();
-
+
if (enable) {
gl.glLightModeli(GL.GL_LIGHT_MODEL_COLOR_CONTROL, GL.GL_SEPARATE_SPECULAR_COLOR);
} else {
gl.glLightModeli(GL.GL_LIGHT_MODEL_COLOR_CONTROL, GL.GL_SINGLE_COLOR);
}
}
-
+
// Initialization for D3D when scene begins and ends
void beginScene(Context ctx) {
}
void endScene(Context ctx) {
}
-
+
// True under Solaris,
// False under windows when display mode <= 8 bit
boolean validGraphicsMode() {
if (VERBOSE) System.err.println("JoglPipeline.validGraphicsMode()");
-
+
// FIXME: believe this should do exactly what the native code
// used to, but not 100% sure (also in theory should only run
// this code on the Windows platform? What about Mac OS X?)
@@ -7397,20 +7397,20 @@ class JoglPipeline extends Pipeline {
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
// Note: on X11 platforms, a bit depth < 0 simply indicates that
// multiple visuals are supported on the current display mode
-
+
if (VERBOSE) System.err.println(" Returning " + (currentMode.getBitDepth() < 0 ||
currentMode.getBitDepth() > 8));
-
+
return (currentMode.getBitDepth() < 0 ||
currentMode.getBitDepth() > 8);
}
-
+
// native method for setting light enables
void setLightEnables(Context ctx, long enableMask, int maxLights) {
if (VERBOSE) System.err.println("JoglPipeline.setLightEnables()");
-
+
GL gl = context(ctx).getGL();
-
+
for (int i = 0; i < maxLights; i++) {
if ((enableMask & (1 << i)) != 0) {
gl.glEnable(GL.GL_LIGHT0 + i);
@@ -7419,13 +7419,13 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
// native method for setting scene ambient
void setSceneAmbient(Context ctx, float red, float green, float blue) {
if (VERBOSE) System.err.println("JoglPipeline.setSceneAmbient()");
-
+
GL gl = context(ctx).getGL();
-
+
float[] color = new float[4];
color[0] = red;
color[1] = green;
@@ -7433,21 +7433,21 @@ class JoglPipeline extends Pipeline {
color[3] = 1.0f;
gl.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, color, 0);
}
-
+
// native method for disabling fog
void disableFog(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.disableFog()");
-
+
GL gl = context(ctx).getGL();
gl.glDisable(GL.GL_FOG);
}
-
+
// native method for disabling modelClip
void disableModelClip(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.disableModelClip()");
-
+
GL gl = context(ctx).getGL();
-
+
gl.glDisable(GL.GL_CLIP_PLANE0);
gl.glDisable(GL.GL_CLIP_PLANE1);
gl.glDisable(GL.GL_CLIP_PLANE2);
@@ -7455,15 +7455,15 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_CLIP_PLANE4);
gl.glDisable(GL.GL_CLIP_PLANE5);
}
-
+
// native method for setting default RenderingAttributes
void resetRenderingAttributes(Context ctx,
boolean depthBufferWriteEnableOverride,
boolean depthBufferEnableOverride) {
if (VERBOSE) System.err.println("JoglPipeline.resetRenderingAttributes()");
-
+
GL gl = context(ctx).getGL();
-
+
if (!depthBufferWriteEnableOverride) {
gl.glDepthMask(true);
}
@@ -7475,54 +7475,54 @@ class JoglPipeline extends Pipeline {
gl.glEnable(GL.GL_COLOR_MATERIAL);
gl.glDisable(GL.GL_COLOR_LOGIC_OP);
}
-
+
// native method for setting default texture
void resetTextureNative(Context ctx, int texUnitIndex) {
if (VERBOSE) System.err.println("JoglPipeline.resetTextureNative()");
-
+
GL gl = context(ctx).getGL();
if (texUnitIndex >= 0 &&
gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glActiveTexture(texUnitIndex + GL.GL_TEXTURE0);
gl.glClientActiveTexture(texUnitIndex + GL.GL_TEXTURE0);
}
-
+
gl.glDisable(GL.GL_TEXTURE_1D);
gl.glDisable(GL.GL_TEXTURE_2D);
gl.glDisable(GL.GL_TEXTURE_3D);
gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
}
-
+
// native method for activating a particular texture unit
void activeTextureUnit(Context ctx, int texUnitIndex) {
if (VERBOSE) System.err.println("JoglPipeline.activeTextureUnit()");
-
+
GL gl = context(ctx).getGL();
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glActiveTexture(texUnitIndex + GL.GL_TEXTURE0);
gl.glClientActiveTexture(texUnitIndex + GL.GL_TEXTURE0);
}
}
-
+
// native method for setting default TexCoordGeneration
void resetTexCoordGeneration(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.resetTexCoordGeneration()");
-
+
GL gl = context(ctx).getGL();
gl.glDisable(GL.GL_TEXTURE_GEN_S);
gl.glDisable(GL.GL_TEXTURE_GEN_T);
gl.glDisable(GL.GL_TEXTURE_GEN_R);
gl.glDisable(GL.GL_TEXTURE_GEN_Q);
}
-
+
// native method for setting default TextureAttributes
void resetTextureAttributes(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.resetTextureAttributes()");
-
+
GL gl = context(ctx).getGL();
-
+
float[] color = new float[4];
-
+
gl.glPushAttrib(GL.GL_TRANSFORM_BIT);
gl.glMatrixMode(GL.GL_TEXTURE);
gl.glLoadIdentity();
@@ -7530,66 +7530,66 @@ class JoglPipeline extends Pipeline {
gl.glTexEnvfv(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_COLOR, color, 0);
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
-
+
if (gl.isExtensionAvailable("GL_NV_register_combiners")) {
gl.glDisable(GL.GL_REGISTER_COMBINERS_NV);
}
-
+
if (gl.isExtensionAvailable("GL_SGI_texture_color_table")) {
gl.glDisable(GL.GL_TEXTURE_COLOR_TABLE_SGI);
}
}
-
+
// native method for setting default PolygonAttributes
void resetPolygonAttributes(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.resetPolygonAttributes()");
-
+
GL gl = context(ctx).getGL();
-
+
gl.glCullFace(GL.GL_BACK);
gl.glEnable(GL.GL_CULL_FACE);
-
+
gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_FALSE);
-
+
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
-
+
gl.glPolygonOffset(0.0f, 0.0f);
gl.glDisable(GL.GL_POLYGON_OFFSET_POINT);
gl.glDisable(GL.GL_POLYGON_OFFSET_LINE);
gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
}
-
+
// native method for setting default LineAttributes
void resetLineAttributes(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.resetLineAttributes()");
-
+
GL gl = context(ctx).getGL();
gl.glLineWidth(1.0f);
gl.glDisable(GL.GL_LINE_STIPPLE);
-
+
// XXXX: Polygon Mode check, blend enable
gl.glDisable(GL.GL_LINE_SMOOTH);
}
-
+
// native method for setting default PointAttributes
void resetPointAttributes(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.resetPointAttributes()");
-
+
GL gl = context(ctx).getGL();
gl.glPointSize(1.0f);
-
+
// XXXX: Polygon Mode check, blend enable
gl.glDisable(GL.GL_POINT_SMOOTH);
}
-
+
// native method for setting default TransparencyAttributes
void resetTransparency(Context ctx, int geometryType,
int polygonMode, boolean lineAA,
boolean pointAA) {
if (VERBOSE) System.err.println("JoglPipeline.resetTransparency()");
-
+
GL gl = context(ctx).getGL();
-
+
if (((((geometryType & RenderMolecule.LINE) != 0) ||
(polygonMode == PolygonAttributes.POLYGON_LINE))
&& lineAA) ||
@@ -7603,37 +7603,37 @@ class JoglPipeline extends Pipeline {
}
gl.glDisable(GL.GL_POLYGON_STIPPLE);
}
-
+
// native method for setting default ColoringAttributes
void resetColoringAttributes(Context ctx,
float r, float g,
float b, float a,
boolean enableLight) {
if (VERBOSE) System.err.println("JoglPipeline.resetColoringAttributes()");
-
+
GL gl = context(ctx).getGL();
-
+
if (!enableLight) {
gl.glColor4f(r, g, b, a);
}
gl.glShadeModel(GL.GL_SMOOTH);
}
-
+
/**
* This native method makes sure that the rendering for this canvas
* gets done now.
*/
void syncRender(Context ctx, boolean wait) {
if (VERBOSE) System.err.println("JoglPipeline.syncRender()");
-
+
GL gl = context(ctx).getGL();
-
+
if (wait)
gl.glFinish();
else
gl.glFlush();
}
-
+
// The native method that sets this ctx to be the current one
boolean useCtx(Context ctx, long display, Drawable drawable) {
if (VERBOSE) System.err.println("JoglPipeline.useCtx()");
@@ -7641,7 +7641,7 @@ class JoglPipeline extends Pipeline {
int res = context.makeCurrent();
return (res != GLContext.CONTEXT_NOT_CURRENT);
}
-
+
// Optionally release the context. Returns true if the context was released.
boolean releaseCtx(Context ctx, long dpy) {
if (VERBOSE) System.err.println("JoglPipeline.releaseCtx()");
@@ -7649,7 +7649,7 @@ class JoglPipeline extends Pipeline {
context.release();
return true;
}
-
+
void clear(Context ctx, float r, float g, float b, boolean clearStencil) {
if (VERBOSE) System.err.println("JoglPipeline.clear()");
@@ -7661,7 +7661,7 @@ class JoglPipeline extends Pipeline {
/*
gl.glClearColor(r, g, b, jctx.getAlphaClearValue());
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
-
+
// Java 3D always clears the Z-buffer
gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT);
gl.glDepthMask(true);
@@ -7692,23 +7692,23 @@ class JoglPipeline extends Pipeline {
gl.glPushAttrib(GL.GL_DEPTH_BUFFER_BIT);
}
- gl.glDepthMask(true);
+ gl.glDepthMask(true);
gl.glClearColor(r, g, b, jctx.getAlphaClearValue());
gl.glClear(clearMask);
gl.glPopAttrib();
}
-
+
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()");
-
+
GLContext context = context(ctx);
GL gl = context.getGL();
-
+
// Temporarily disable fragment and most 3D operations
gl.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_TEXTURE_BIT | GL.GL_POLYGON_BIT);
-
+
disableAttribFor2D(gl);
gl.glDepthMask(false);
gl.glEnable(GL.GL_TEXTURE_2D);
@@ -7718,13 +7718,13 @@ class JoglPipeline extends Pipeline {
// System.err.println("JoglPipeline - Background : 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);
- }
-
+ }
+
// reset the polygon mode
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
-
+
gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
-
+
// load identity modelview and projection matrix
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
@@ -7734,36 +7734,36 @@ class JoglPipeline extends Pipeline {
gl.glMatrixMode(GL.GL_TEXTURE);
gl.glPushMatrix();
gl.glLoadIdentity();
-
+
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2f(texMinU, texMinV); gl.glVertex2f(mapMinX,mapMinY);
gl.glTexCoord2f(texMaxU, texMinV); gl.glVertex2f(mapMaxX,mapMinY);
gl.glTexCoord2f(texMaxU, texMaxV); gl.glVertex2f(mapMaxX,mapMaxY);
gl.glTexCoord2f(texMinU, texMaxV); gl.glVertex2f(mapMinX,mapMaxY);
gl.glEnd();
-
+
// Restore texture Matrix transform
gl.glPopMatrix();
-
+
gl.glMatrixMode(GL.GL_MODELVIEW);
// Restore attributes
gl.glPopAttrib();
-
+
}
-
+
void textureFillRaster(Context ctx, float texMinU, float texMaxU, float texMinV, float texMaxV,
- float mapMinX, float mapMaxX, float mapMinY, float mapMaxY, float mapZ, float alpha,
+ float mapMinX, float mapMaxX, float mapMinY, float mapMaxY, float mapZ, float alpha,
boolean useBilinearFilter) {
-
+
if (VERBOSE) System.err.println("JoglPipeline.textureFillRaster()");
-
+
GLContext context = context(ctx);
GL gl = context.getGL();
-
+
// Temporarily disable fragment and most 3D operations
- gl.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_TEXTURE_BIT | GL.GL_POLYGON_BIT |
+ gl.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_TEXTURE_BIT | GL.GL_POLYGON_BIT |
GL.GL_CURRENT_BIT );
-
+
disableAttribForRaster(gl);
/* Setup filter mode if needed */
@@ -7771,16 +7771,16 @@ class JoglPipeline extends Pipeline {
// 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);
- }
-
+ }
+
gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE);
gl.glColor4f(1.0f, 1.0f, 1.0f, alpha);
-
+
// reset the polygon mode
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
-
+
gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
-
+
// load identity modelview and projection matrix
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPushMatrix();
@@ -7789,7 +7789,7 @@ class JoglPipeline extends Pipeline {
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0);
-
+
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2f(texMinU, texMinV); gl.glVertex3f(mapMinX,mapMinY, mapZ);
gl.glTexCoord2f(texMaxU, texMinV); gl.glVertex3f(mapMaxX,mapMinY, mapZ);
@@ -7798,12 +7798,12 @@ class JoglPipeline extends Pipeline {
gl.glEnd();
// Restore matrices
- gl.glPopMatrix();
+ gl.glPopMatrix();
gl.glMatrixMode(GL.GL_MODELVIEW);
- gl.glPopMatrix();
+ gl.glPopMatrix();
// Restore attributes
gl.glPopAttrib();
-
+
}
void executeRasterDepth(Context ctx, float posX, float posY, float posZ,
@@ -7867,15 +7867,15 @@ class JoglPipeline extends Pipeline {
gl.glPixelStorei(GL.GL_UNPACK_SKIP_ROWS, 0);
}
-
+
// The native method for setting the ModelView matrix.
void setModelViewMatrix(Context ctx, double[] viewMatrix, double[] modelMatrix) {
if (VERBOSE) System.err.println("JoglPipeline.setModelViewMatrix()");
GLContext context = context(ctx);
GL gl = context.getGL();
-
+
gl.glMatrixMode(GL.GL_MODELVIEW);
-
+
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
gl.glLoadTransposeMatrixd(viewMatrix, 0);
gl.glMultTransposeMatrixd(modelMatrix, 0);
@@ -7888,15 +7888,15 @@ class JoglPipeline extends Pipeline {
gl.glMultMatrixd(m, 0);
}
}
-
+
// The native method for setting the Projection matrix.
void setProjectionMatrix(Context ctx, double[] projMatrix) {
if (VERBOSE) System.err.println("JoglPipeline.setProjectionMatrix()");
GLContext context = context(ctx);
GL gl = context.getGL();
-
+
gl.glMatrixMode(GL.GL_PROJECTION);
-
+
if (gl.isExtensionAvailable("GL_VERSION_1_3")) {
// Invert the Z value in clipping coordinates because OpenGL uses
// left-handed clipping coordinates, while Java3D defines right-handed
@@ -7923,31 +7923,31 @@ class JoglPipeline extends Pipeline {
gl.glLoadMatrixd(p, 0);
}
}
-
+
// The native method for setting the Viewport.
void setViewport(Context ctx, int x, int y, int width, int height) {
if (VERBOSE) System.err.println("JoglPipeline.setViewport()");
GL gl = context(ctx).getGL();
gl.glViewport(x, y, width, height);
}
-
+
// used for display Lists
void newDisplayList(Context ctx, int displayListId) {
if (VERBOSE) System.err.println("JoglPipeline.newDisplayList()");
if (displayListId <= 0) {
System.err.println("JAVA 3D ERROR : glNewList(" + displayListId + ") -- IGNORED");
}
-
+
GL gl = context(ctx).getGL();
gl.glNewList(displayListId, GL.GL_COMPILE);
}
-
+
void endDisplayList(Context ctx) {
if (VERBOSE) System.err.println("JoglPipeline.endDisplayList()");
GL gl = context(ctx).getGL();
gl.glEndList();
}
-
+
int numInvalidLists = 0;
void callDisplayList(Context ctx, int id, boolean isNonUniformScale) {
if (VERBOSE) System.err.println("JoglPipeline.callDisplayList()");
@@ -7961,35 +7961,35 @@ class JoglPipeline extends Pipeline {
}
return;
}
-
+
GL gl = context(ctx).getGL();
// Set normalization if non-uniform scale
if (isNonUniformScale) {
gl.glEnable(GL.GL_NORMALIZE);
}
-
+
gl.glCallList(id);
-
+
// Turn normalization back off
if (isNonUniformScale) {
gl.glDisable(GL.GL_NORMALIZE);
}
}
-
+
void freeDisplayList(Context ctx, int id) {
if (VERBOSE) System.err.println("JoglPipeline.freeDisplayList()");
if (id <= 0) {
System.err.println("JAVA 3D ERROR : glDeleteLists(" + id + ",1) -- IGNORED");
}
-
+
GL gl = context(ctx).getGL();
gl.glDeleteLists(id, 1);
}
void freeTexture(Context ctx, int id) {
if (VERBOSE) System.err.println("JoglPipeline.freeTexture()");
-
+
GL gl = context(ctx).getGL();
-
+
if (id > 0) {
int[] tmp = new int[1];
tmp[0] = id;
@@ -7998,8 +7998,8 @@ class JoglPipeline extends Pipeline {
System.err.println("tried to delete tex with texid <= 0");
}
}
-
-
+
+
void texturemapping(Context ctx,
int px, int py,
int minX, int minY, int maxX, int maxY,
@@ -8009,18 +8009,18 @@ class JoglPipeline extends Pipeline {
byte[] imageYdown,
int winWidth, int winHeight) {
if (VERBOSE) System.err.println("JoglPipeline.texturemapping()");
-
+
GL gl = context(ctx).getGL();
-
+
int glType = GL.GL_RGBA;
-
+
// Temporarily disable fragment and most 3D operations
gl.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_TEXTURE_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_POLYGON_BIT);
disableAttribFor2D(gl);
-
+
// Reset the polygon mode
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
-
+
gl.glDepthMask(false);
gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
gl.glBindTexture(GL.GL_TEXTURE_2D, objectId);
@@ -8029,22 +8029,22 @@ class JoglPipeline extends Pipeline {
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
-
+
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
-
+
gl.glEnable(GL.GL_TEXTURE_2D);
-
+
// loaded identity modelview and projection matrix
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
-
+
gl.glOrtho(0.0, winWidth, 0.0, winHeight, 0.0, 0.0);
-
+
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
-
+
if (gl.isExtensionAvailable("GL_EXT_abgr")) {
glType = GL.GL_ABGR_EXT;
} else {
@@ -8067,62 +8067,62 @@ class JoglPipeline extends Pipeline {
gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, 0);
gl.glPixelStorei(GL.GL_UNPACK_SKIP_PIXELS, 0);
gl.glPixelStorei(GL.GL_UNPACK_SKIP_ROWS, 0);
-
+
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 = (float)winWidth/2.0f;
float halfHeight = (float)winHeight/2.0f;
-
+
float mapMinX = (float) (((px + minX)- halfWidth)/halfWidth);
float mapMinY = (float) ((halfHeight - (py + maxY))/halfHeight);
float mapMaxX = (float) ((px + maxX - halfWidth)/halfWidth);
float mapMaxY = (float) ((halfHeight - (py + minY))/halfHeight);
-
+
gl.glBegin(GL.GL_QUADS);
-
+
gl.glTexCoord2f(texMinU, texMaxV); gl.glVertex2f(mapMinX,mapMinY);
gl.glTexCoord2f(texMaxU, texMaxV); gl.glVertex2f(mapMaxX,mapMinY);
gl.glTexCoord2f(texMaxU, texMinV); gl.glVertex2f(mapMaxX,mapMaxY);
gl.glTexCoord2f(texMinU, texMinV); gl.glVertex2f(mapMinX,mapMaxY);
gl.glEnd();
-
+
// Java 3D always clears the Z-buffer
gl.glDepthMask(true);
gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
gl.glPopAttrib();
}
-
+
boolean initTexturemapping(Context ctx, int texWidth,
int texHeight, int objectId) {
if (VERBOSE) System.err.println("JoglPipeline.initTexturemapping()");
-
+
GL gl = context(ctx).getGL();
-
+
int glType = (gl.isExtensionAvailable("GL_EXT_abgr") ? GL.GL_ABGR_EXT : GL.GL_RGBA);
-
+
gl.glBindTexture(GL.GL_TEXTURE_2D, objectId);
-
+
gl.glTexImage2D(GL.GL_PROXY_TEXTURE_2D, 0, GL.GL_RGBA, texWidth,
texHeight, 0, glType, GL.GL_UNSIGNED_BYTE, null);
-
+
int[] width = new int[1];
gl.glGetTexLevelParameteriv(GL.GL_PROXY_TEXTURE_2D, 0,
GL.GL_TEXTURE_WIDTH, width, 0);
-
+
if (width[0] <= 0) {
return false;
}
-
+
// init texture size only without filling the pixels
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, texWidth,
texHeight, 0, glType, GL.GL_UNSIGNED_BYTE, null);
-
+
return true;
}
-
-
+
+
// Set internal render mode to one of FIELD_ALL, FIELD_LEFT or
// FIELD_RIGHT. Note that it is up to the caller to ensure that
// stereo is available before setting the mode to FIELD_LEFT or
@@ -8130,7 +8130,7 @@ class JoglPipeline extends Pipeline {
// foe single buffering.
void setRenderMode(Context ctx, int mode, boolean doubleBuffer) {
if (VERBOSE) System.err.println("JoglPipeline.setRenderMode()");
-
+
GL gl = context(ctx).getGL();
int drawBuf = 0;
if (doubleBuffer) {
@@ -8160,14 +8160,14 @@ class JoglPipeline extends Pipeline {
break;
}
}
-
+
gl.glDrawBuffer(drawBuf);
}
-
+
// Set glDepthMask.
void setDepthBufferWriteEnable(Context ctx, boolean mode) {
if (VERBOSE) System.err.println("JoglPipeline.setDepthBufferWriteEnable()");
-
+
GL gl = context(ctx).getGL();
if (mode) {
gl.glDepthMask(true);
@@ -8175,11 +8175,11 @@ class JoglPipeline extends Pipeline {
gl.glDepthMask(false);
}
}
-
+
//----------------------------------------------------------------------
// Helper private functions for Canvas3D
//
-
+
private boolean getPropertiesFromCurrentContext(JoglContext ctx) {
GL gl = GLU.getCurrentGL();
// FIXME: this is a heavily abridged set of the stuff in Canvas3D.c;
@@ -8198,12 +8198,12 @@ class JoglPipeline extends Pipeline {
}
return true;
}
-
+
private int[] extractVersionInfo(String versionString) {
StringTokenizer tok = new StringTokenizer(versionString, ". ");
int major = Integer.valueOf(tok.nextToken()).intValue();
int minor = Integer.valueOf(tok.nextToken()).intValue();
-
+
// See if there's vendor-specific information which might
// imply a more recent OpenGL version
tok = new StringTokenizer(versionString, " ");
@@ -8226,12 +8226,12 @@ class JoglPipeline extends Pipeline {
}
return new int[] { major, minor };
}
-
+
private int getTextureColorTableSize(GL gl) {
if (!gl.isExtensionAvailable("GL_ARB_imaging")) {
return 0;
}
-
+
gl.glColorTable(GL.GL_PROXY_TEXTURE_COLOR_TABLE_SGI, GL.GL_RGBA, 256, GL.GL_RGB,
GL.GL_INT, null);
int[] tmp = new int[1];
@@ -8239,8 +8239,8 @@ class JoglPipeline extends Pipeline {
GL.GL_COLOR_TABLE_WIDTH, tmp, 0);
return tmp[0];
}
-
-
+
+
private void checkTextureExtensions(Canvas3D cv,
JoglContext ctx,
GL gl,
@@ -8257,11 +8257,11 @@ class JoglPipeline extends Pipeline {
cv.maxTexCoordSets = tmp[0];
}
}
-
+
if (gl.isExtensionAvailable("GL_SGI_texture_color_table") ||
gl.isExtensionAvailable("GL_ARB_imaging")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COLOR_TABLE;
-
+
// get texture color table size
// need to check later
cv.textureColorTableSize = getTextureColorTableSize(gl);
@@ -8272,62 +8272,62 @@ class JoglPipeline extends Pipeline {
cv.textureColorTableSize = 256;
}
}
-
+
if (gl.isExtensionAvailable("GL_ARB_texture_env_combine")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COMBINE;
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COMBINE_SUBTRACT;
} else if (gl.isExtensionAvailable("GL_EXT_texture_env_combine")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COMBINE;
}
-
+
if (gl.isExtensionAvailable("GL_NV_register_combiners")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_REGISTER_COMBINERS;
}
-
+
if (gl.isExtensionAvailable("GL_ARB_texture_env_dot3") ||
gl.isExtensionAvailable("GL_EXT_texture_env_dot3")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_COMBINE_DOT3;
}
-
+
if (gl13) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_CUBE_MAP;
}
-
+
if (gl.isExtensionAvailable("GL_SGIS_sharpen_texture")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_SHARPEN;
}
-
+
if (gl.isExtensionAvailable("GL_SGIS_detail_texture")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_DETAIL;
}
-
+
if (gl.isExtensionAvailable("GL_SGIS_texture_filter4")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_FILTER4;
}
-
+
if (gl.isExtensionAvailable("GL_EXT_texture_filter_anisotropic")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_ANISOTROPIC_FILTER;
float[] tmp = new float[1];
gl.glGetFloatv(GL. GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, tmp, 0);
cv.anisotropicDegreeMax = tmp[0];
}
-
+
if (gl.isExtensionAvailable("GL_SGIX_texture_lod_bias")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_LOD_OFFSET;
}
-
+
if (!VirtualUniverse.mc.enforcePowerOfTwo &&
gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO;
}
-
+
if (gl.isExtensionAvailable("GL_SGIS_generate_mipmap")) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION;
- }
-
+ }
+
}
-
-
+
+
private void checkGLSLShaderExtensions(Canvas3D cv,
JoglContext ctx,
GL gl,
@@ -8337,7 +8337,7 @@ class JoglPipeline extends Pipeline {
gl.isExtensionAvailable("GL_ARB_shading_language_100")) {
// Initialize shader vertex attribute function pointers
ctx.initGLSLVertexAttributeImpl();
-
+
// FIXME: this isn't complete and would need to set up the
// JoglContext for dispatch of various routines such as those
// related to vertex attributes
@@ -8360,10 +8360,10 @@ class JoglPipeline extends Pipeline {
cv.shadingLanguageGLSL = true;
}
}
-
+
private boolean createCgContext(JoglContext ctx) {
CGcontext cgContext = CgGL.cgCreateContext();
-
+
int err = CgGL.cgGetError();
if (err != 0) {
String detail = CgGL.cgGetErrorString(err);
@@ -8371,14 +8371,14 @@ class JoglPipeline extends Pipeline {
detail + "\"");
return false;
}
-
+
if (cgContext == null) {
System.err.println("JAVA 3D ERROR : Invalid null Cg context");
return false;
}
-
+
ctx.setCgContext(cgContext);
-
+
// Use GL_ARB_vertex_program extension if supported by video card
if (CgGL.cgGLIsProfileSupported(CgGL.CG_PROFILE_ARBVP1)) {
ctx.setCgVertexProfile(CgGL.CG_PROFILE_ARBVP1);
@@ -8389,7 +8389,7 @@ class JoglPipeline extends Pipeline {
ctx.setCgContext(null);
return false;
}
-
+
// Use GL_ARB_fragment_program extension if supported by video card
if (CgGL.cgGLIsProfileSupported(CgGL.CG_PROFILE_ARBFP1)) {
ctx.setCgFragmentProfile(CgGL.CG_PROFILE_ARBFP1);
@@ -8400,10 +8400,10 @@ class JoglPipeline extends Pipeline {
ctx.setCgContext(null);
return false;
}
-
+
return true;
}
-
+
private void checkCgShaderExtensions(Canvas3D cv,
JoglContext ctx,
GL gl,
@@ -8423,7 +8423,7 @@ class JoglPipeline extends Pipeline {
ctx.initCgVertexAttributeImpl();
}
}
-
+
private void setupCanvasProperties(Canvas3D cv,
JoglContext ctx,
GL gl,
@@ -8431,7 +8431,7 @@ class JoglPipeline extends Pipeline {
boolean cgLibraryAvailable) {
// Note: this includes relevant portions from both the
// NativePipeline's getPropertiesFromCurrentContext and setupCanvasProperties
-
+
// Reset all fields
cv.multiTexAccelerated = false;
cv.maxTextureUnits = 1;
@@ -8452,7 +8452,7 @@ class JoglPipeline extends Pipeline {
cv.texture3DDepthMax = 0;
cv.shadingLanguageGLSL = false;
cv.shadingLanguageCg = false;
-
+
// Now make queries and set up these fields
String glVersion = gl.glGetString(GL.GL_VERSION);
String glVendor = gl.glGetString(GL.GL_VENDOR);
@@ -8460,15 +8460,15 @@ class JoglPipeline extends Pipeline {
cv.nativeGraphicsVersion = glVersion;
cv.nativeGraphicsVendor = glVendor;
cv.nativeGraphicsRenderer = glRenderer;
-
+
// find out the version, major and minor version number
int[] versionNumbers = extractVersionInfo(glVersion);
int major = versionNumbers[0];
int minor = versionNumbers[1];
-
+
///////////////////////////////////////////
// setup the graphics context properties //
-
+
// NOTE: Java 3D now requires OpenGL 1.3 for full functionality.
// For backwards compatibility with certain older graphics cards and
// drivers (e.g., the Linux DRI driver for older ATI cards),
@@ -8476,21 +8476,21 @@ class JoglPipeline extends Pipeline {
// we will not attempt to use OpenGL extensions for any features that
// are available in OpenGL 1.3, specifically multitexture, multisample,
// and cube map textures.
-
+
if (major < 1 || (major == 1 && minor < 2)) {
throw new IllegalRenderingStateException(
"Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=" +
major + "." + minor + ")");
}
-
+
boolean gl20 = false;
boolean gl14 = false;
boolean gl13 = false;
-
+
if (major == 1) {
if (minor == 2) {
System.err.println("JAVA 3D: OpenGL 1.2 detected; will run with reduced functionality");
- }
+ }
if (minor >= 3) {
gl13 = true;
}
@@ -8508,27 +8508,27 @@ class JoglPipeline extends Pipeline {
assert gl14;
assert gl.isExtensionAvailable("GL_VERSION_2_0");
}
-
+
if (gl14) {
assert gl13;
assert gl.isExtensionAvailable("GL_VERSION_1_4");
}
-
+
if (gl13) {
assert gl.isExtensionAvailable("GL_VERSION_1_3");
}
-
+
// Set up properties for OpenGL 1.3
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_3D;
-
+
// Note that we don't query for GL_ARB_imaging here
-
+
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_LOD_RANGE;
if (gl14) {
cv.textureExtendedFeatures |= Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION;
}
-
+
// look for OpenGL 2.0 features
// Fix to Issue 455 : Need to disable NPOT textures for older cards that claim to support it.
// Some older cards (e.g., Nvidia fx500 and ATI 9800) claim to support OpenGL 2.0.
@@ -8541,31 +8541,31 @@ class JoglPipeline extends Pipeline {
// cv.textureExtendedFeatures |= Canvas3D.TEXTURE_NON_POWER_OF_TWO;
// }
// }
-
-
+
+
// Setup GL_EXT_abgr
if (gl.isExtensionAvailable("GL_EXT_abgr")) {
cv.extensionsSupported |= Canvas3D.EXT_ABGR;
}
-
+
// GL_BGR is always supported
cv.extensionsSupported |= Canvas3D.EXT_BGR;
-
+
// Setup multisample
// FIXME: this is not correct for the Windows platform yet
if (gl13) {
cv.extensionsSupported |= Canvas3D.MULTISAMPLE;
ctx.setHasMultisample(true);
}
-
+
if ((cv.extensionsSupported & Canvas3D.MULTISAMPLE) != 0 &&
!VirtualUniverse.mc.implicitAntialiasing) {
gl.glDisable(GL.GL_MULTISAMPLE);
}
-
+
// Check texture extensions
checkTextureExtensions(cv, ctx, gl, gl13);
-
+
// Check shader extensions
if (gl13) {
checkGLSLShaderExtensions(cv, ctx, gl, glslLibraryAvailable);
@@ -8575,19 +8575,19 @@ class JoglPipeline extends Pipeline {
checkGLSLShaderExtensions(cv, ctx, gl, false);
checkCgShaderExtensions(cv, ctx, gl, false);
}
-
+
// Setup GL_SUN_gloabl_alpha
if (gl.isExtensionAvailable("GL_SUN_gloabl_alpha")) {
cv.extensionsSupported |= Canvas3D.SUN_GLOBAL_ALPHA;
}
-
+
cv.textureBoundaryWidthMax = 1;
{
int[] tmp = new int[1];
gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, tmp, 0);
cv.textureWidthMax = tmp[0];
cv.textureHeightMax = tmp[0];
-
+
tmp[0] = -1;
gl.glGetIntegerv(GL.GL_MAX_3D_TEXTURE_SIZE, tmp, 0);
cv.texture3DWidthMax = tmp[0];
@@ -8595,7 +8595,7 @@ class JoglPipeline extends Pipeline {
cv.texture3DDepthMax = tmp[0];
}
}
-
+
/*
* Function to disable most rendering attributes when doing a 2D
* clear, image copy, or image composite operation. Note that the
@@ -8619,47 +8619,47 @@ class JoglPipeline extends Pipeline {
gl.glDisable(GL.GL_TEXTURE_GEN_R);
gl.glDisable(GL.GL_TEXTURE_GEN_S);
gl.glDisable(GL.GL_TEXTURE_GEN_T);
-
-
+
+
for (int i = 0; i < 6; i++) {
gl.glDisable(GL.GL_CLIP_PLANE0 + i);
}
-
+
gl.glDisable(GL.GL_TEXTURE_3D);
gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
-
+
if (gl.isExtensionAvailable("GL_NV_register_combiners")) {
gl.glDisable(GL.GL_REGISTER_COMBINERS_NV);
}
-
+
if (gl.isExtensionAvailable("GL_SGI_texture_color_table")) {
gl.glDisable(GL.GL_TEXTURE_COLOR_TABLE_SGI);
}
-
+
if (gl.isExtensionAvailable("GL_SUN_global_alpha")) {
gl.glDisable(GL.GL_GLOBAL_ALPHA_SUN);
}
-
+
}
-
+
private void disableAttribForRaster(GL gl) {
-
+
gl.glDisable(GL.GL_COLOR_MATERIAL);
gl.glDisable(GL.GL_CULL_FACE);
gl.glDisable(GL.GL_LIGHTING);
gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
gl.glDisable(GL.GL_POLYGON_STIPPLE);
-
+
// TODO: Disable if Raster.CLIP_POSITION is true
// for (int i = 0; i < 6; i++) {
// gl.glDisable(GL.GL_CLIP_PLANE0 + i);
// }
-
+
if (gl.isExtensionAvailable("GL_SUN_global_alpha")) {
gl.glDisable(GL.GL_GLOBAL_ALPHA_SUN);
}
}
-
+
private void copyTranspose(double[] src, double[] dst) {
dst[0] = src[0];
dst[1] = src[4];
@@ -8678,14 +8678,14 @@ class JoglPipeline extends Pipeline {
dst[14] = src[11];
dst[15] = src[15];
}
-
+
// ---------------------------------------------------------------------
-
+
//
// Canvas3D / GraphicsConfigTemplate3D methods - logic dealing with
// native graphics configuration or drawing surface
//
-
+
// Return a graphics config based on the one passed in. Note that we can
// assert that the input config is non-null and was created from a
// GraphicsConfigTemplate3D.
@@ -8698,7 +8698,7 @@ class JoglPipeline extends Pipeline {
if (config.getChosenIndex() >= 0) {
indexChooser = new IndexCapabilitiesChooser(config.getChosenIndex());
}
-
+
AbstractGraphicsConfiguration absConfig =
GLDrawableFactory.getFactory().chooseGraphicsConfiguration(config.getGLCapabilities(),
indexChooser,
@@ -8707,9 +8707,9 @@ class JoglPipeline extends Pipeline {
return null;
}
return ((AWTGraphicsConfiguration) absConfig).getGraphicsConfiguration();
-
+
/*
-
+
System.err.println("JoglPipeline.getGraphicsConfig()");
// Just return the input graphics config for now. eventually, we will
// use the input graphics config to get the GraphicsConfigTemplate3D
@@ -8717,18 +8717,18 @@ class JoglPipeline extends Pipeline {
return gconfig;
*/
}
-
+
// Get the native FBconfig pointer
long getFbConfig(GraphicsConfigInfo gcInfo) {
if (VERBOSE) System.err.println("JoglPipeline.getFbConfig()");
return 0L; // Dummy method in JOGL
}
-
-
+
+
private static final int DISABLE_STEREO = 1;
private static final int DISABLE_AA = 2;
private static final int DISABLE_DOUBLE_BUFFER = 3;
-
+
// Get best graphics config from pipeline
GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D gct,
GraphicsConfiguration[] gc) {
@@ -8742,7 +8742,7 @@ class JoglPipeline extends Pipeline {
System.err.println("gct.getBlueSize(): " + gct.getBlueSize());
System.err.println("gct.getSceneAntialiasing(): " + gct.getSceneAntialiasing());
*/
-
+
// Create a GLCapabilities based on the GraphicsConfigTemplate3D
GLCapabilities caps = new GLCapabilities();
caps.setDoubleBuffered(gct.getDoubleBuffer() <= GraphicsConfigTemplate.PREFERRED);
@@ -8756,12 +8756,12 @@ class JoglPipeline extends Pipeline {
// FIXME: should be smarter about choosing the number of samples
// (Java3D's native code has a loop trying 8, 6, 4, 3, and 2 samples)
caps.setNumSamples(4);
-
+
// Issue 399: Request alpha buffer if transparentOffScreen is set
if (VirtualUniverse.mc.transparentOffScreen) {
caps.setAlphaBits(1);
}
-
+
java.util.List<Integer> capsToDisable = new ArrayList<Integer>();
// Add PREFERRED capabilities in order we will try disabling them
if (gct.getStereo() == GraphicsConfigTemplate.PREFERRED) {
@@ -8773,12 +8773,12 @@ class JoglPipeline extends Pipeline {
if (gct.getDoubleBuffer() == GraphicsConfigTemplate.PREFERRED) {
capsToDisable.add(new Integer(DISABLE_DOUBLE_BUFFER));
}
-
+
// Pick the GraphicsDevice from a random configuration
GraphicsDevice dev = gc[0].getDevice();
-
+
// Create a Frame and dummy GLCanvas to perform eager pixel format selection
-
+
// Note that we loop in similar fashion to the NativePipeline's
// native code in the situation where we need to disable certain
// capabilities which aren't required
@@ -8822,15 +8822,15 @@ class JoglPipeline extends Pipeline {
case DISABLE_STEREO:
caps.setStereo(false);
break;
-
+
case DISABLE_AA:
caps.setSampleBuffers(false);
break;
-
+
case DISABLE_DOUBLE_BUFFER:
caps.setDoubleBuffered(false);
break;
-
+
default:
throw new AssertionError("missing case statement");
}
@@ -8853,16 +8853,16 @@ class JoglPipeline extends Pipeline {
}
chosenCaps = capturer.getCapabilities();
}
-
+
JoglGraphicsConfiguration config = new JoglGraphicsConfiguration(chosenCaps, chosenIndex, dev);
-
+
// FIXME: because of the fact that JoglGraphicsConfiguration
// doesn't override hashCode() or equals(), we will basically be
// creating a new one each time getBestConfiguration() is
// called; in theory, we should probably map the same
// GLCapabilities on the same GraphicsDevice to the same
// JoglGraphicsConfiguration object
-
+
// Cache the GraphicsTemplate3D
synchronized (Canvas3D.graphicsConfigTable) {
GraphicsConfigInfo gcInfo = new GraphicsConfigInfo(gct);
@@ -8870,18 +8870,18 @@ class JoglPipeline extends Pipeline {
// gcInfo.setPrivateData(privateData);
Canvas3D.graphicsConfigTable.put(config, gcInfo);
}
-
+
return config;
-
+
/*
-
+
// TODO: implement this
-
+
// TODO: construct a unique GraphicsConfiguration object that will be
// used the key in the hashmap so we can lookup the GraphicsTemplate3D
GraphicsConfiguration gc1 = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration();
-
+
// Cache the GraphicsTemplate3D
synchronized (Canvas3D.graphicsConfigTable) {
if (Canvas3D.graphicsConfigTable.get(gc1) == null) {
@@ -8891,15 +8891,15 @@ class JoglPipeline extends Pipeline {
}
}
return gc1;
-
+
*/
}
-
+
// Determine whether specified graphics config is supported by pipeline
boolean isGraphicsConfigSupported(GraphicsConfigTemplate3D gct,
GraphicsConfiguration gc) {
if (VERBOSE) System.err.println("JoglPipeline.isGraphicsConfigSupported()");
-
+
// FIXME: it looks like this method is implemented incorrectly
// in the existing NativePipeline in both the Windows and X11
// ports. According to the semantics of the javadoc, it looks
@@ -8918,33 +8918,33 @@ class JoglPipeline extends Pipeline {
// without breaking anything.
return true;
}
-
+
// Methods to get actual capabilities from Canvas3D
boolean hasDoubleBuffer(Canvas3D cv) {
if (VERBOSE) System.err.println("JoglPipeline.hasDoubleBuffer()");
if (VERBOSE) System.err.println(" Returning " + caps(cv).getDoubleBuffered());
return caps(cv).getDoubleBuffered();
}
-
+
boolean hasStereo(Canvas3D cv) {
if (VERBOSE) System.err.println("JoglPipeline.hasStereo()");
if (VERBOSE) System.err.println(" Returning " + caps(cv).getStereo());
return caps(cv).getStereo();
}
-
+
int getStencilSize(Canvas3D cv) {
if (VERBOSE) System.err.println("JoglPipeline.getStencilSize()");
if (VERBOSE) System.err.println(" Returning " + caps(cv).getStencilBits());
return caps(cv).getStencilBits();
}
-
+
boolean hasSceneAntialiasingMultisample(Canvas3D cv) {
if (VERBOSE) System.err.println("JoglPipeline.hasSceneAntialiasingMultisample()");
if (VERBOSE) System.err.println(" Returning " + caps(cv).getSampleBuffers());
-
+
return caps(cv).getSampleBuffers();
}
-
+
boolean hasSceneAntialiasingAccum(Canvas3D cv) {
if (VERBOSE) System.err.println("JoglPipeline.hasSceneAntialiasingAccum()");
GLCapabilities caps = caps(cv);
@@ -8955,18 +8955,18 @@ class JoglPipeline extends Pipeline {
caps.getAccumGreenBits() > 0 &&
caps.getAccumBlueBits() > 0);
}
-
+
// Methods to get native WS display and screen
long getDisplay() {
if (VERBOSE) System.err.println("JoglPipeline.getDisplay()");
return 0L; // Dummy method in JOGL
}
-
+
private boolean checkedForGetScreenMethod = false;
private Method getScreenMethod = null;
int getScreen(final GraphicsDevice graphicsDevice) {
if (VERBOSE) System.err.println("JoglPipeline.getScreen()");
-
+
if (!checkedForGetScreenMethod) {
// All of the Sun GraphicsDevice implementations have a method
// int getScreen();
@@ -8983,7 +8983,7 @@ class JoglPipeline extends Pipeline {
}
});
}
-
+
if (getScreenMethod != null) {
try {
return ((Integer) getScreenMethod.invoke(graphicsDevice, (Object[]) null)).intValue();
@@ -8991,18 +8991,18 @@ class JoglPipeline extends Pipeline {
throw new RuntimeException(e);
}
}
-
+
return 0;
}
-
+
//----------------------------------------------------------------------
// Helper classes and methods to support query context functionality
// and pixel format selection
-
+
interface ExtendedCapabilitiesChooser extends GLCapabilitiesChooser {
public void init(GLContext context);
}
-
+
// Canvas subclass to help with various query operations such as the
// "query context" mechanism and pixel format selection.
// Must defeat and simplify the single-threading behavior of JOGL's
@@ -9013,7 +9013,7 @@ class JoglPipeline extends Pipeline {
private GLDrawable drawable;
private ExtendedCapabilitiesChooser chooser;
private boolean alreadyRan;
-
+
public QueryCanvas(GLCapabilities capabilities,
ExtendedCapabilitiesChooser chooser,
GraphicsDevice device) {
@@ -9033,12 +9033,12 @@ class JoglPipeline extends Pipeline {
drawable = GLDrawableFactory.getFactory().getGLDrawable(this, capabilities, chooser);
this.chooser = chooser;
}
-
+
public void addNotify() {
super.addNotify();
drawable.setRealized(true);
}
-
+
// 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
@@ -9058,33 +9058,33 @@ class JoglPipeline extends Pipeline {
alreadyRan = true;
}
}
-
+
private static GraphicsConfiguration unwrap(AWTGraphicsConfiguration config) {
if (config == null) {
return null;
}
return config.getGraphicsConfiguration();
}
-
+
// Used in conjunction with IndexCapabilitiesChooser in pixel format
// selection -- see getBestConfiguration
class CapabilitiesCapturer extends DefaultGLCapabilitiesChooser implements ExtendedCapabilitiesChooser {
private boolean done;
private GLCapabilities capabilities;
private int chosenIndex = -1;
-
+
public boolean done() {
return done;
}
-
+
public GLCapabilities getCapabilities() {
return capabilities;
}
-
+
public int getChosenIndex() {
return chosenIndex;
}
-
+
public int chooseCapabilities(GLCapabilities desired,
GLCapabilities[] available,
int windowSystemRecommendedChoice) {
@@ -9094,26 +9094,26 @@ class JoglPipeline extends Pipeline {
markDone();
return res;
}
-
+
public void init(GLContext context) {
// Avoid hanging things up for several seconds
kick();
}
-
+
private void markDone() {
synchronized (this) {
done = true;
notifyAll();
}
}
-
+
private void kick() {
synchronized (this) {
notifyAll();
}
}
}
-
+
// Used to support the query context mechanism -- needs to be more
// than just a GLCapabilitiesChooser
class ContextQuerier extends DefaultGLCapabilitiesChooser implements ExtendedCapabilitiesChooser {
@@ -9121,7 +9121,7 @@ class JoglPipeline extends Pipeline {
private boolean glslLibraryAvailable;
private boolean cgLibraryAvailable;
private boolean done;
-
+
public ContextQuerier(Canvas3D canvas,
boolean glslLibraryAvailable,
boolean cgLibraryAvailable) {
@@ -9129,11 +9129,11 @@ class JoglPipeline extends Pipeline {
this.glslLibraryAvailable = glslLibraryAvailable;
this.cgLibraryAvailable = cgLibraryAvailable;
}
-
+
public boolean done() {
return done;
}
-
+
public void init(GLContext context) {
// This is basically a temporary
JoglContext jctx = new JoglContext(context);
@@ -9145,7 +9145,7 @@ class JoglPipeline extends Pipeline {
}
markDone();
}
-
+
private void markDone() {
synchronized (this) {
done = true;
@@ -9153,18 +9153,18 @@ class JoglPipeline extends Pipeline {
}
}
}
-
+
// Used in two phases of pixel format selection: transforming the
// JoglGraphicsConfiguration to a real AWT GraphicsConfiguration and
// during context creation to select exactly the same graphics
// configuration as was done during getBestConfiguration.
class IndexCapabilitiesChooser implements GLCapabilitiesChooser {
private int indexToChoose;
-
+
IndexCapabilitiesChooser(int indexToChoose) {
this.indexToChoose = indexToChoose;
}
-
+
public int chooseCapabilities(GLCapabilities desired,
GLCapabilities[] available,
int windowSystemRecommendedChoice) {
@@ -9174,7 +9174,7 @@ class JoglPipeline extends Pipeline {
return indexToChoose;
}
}
-
+
private void disposeOnEDT(final Frame f) {
Runnable r = new Runnable() {
public void run() {
@@ -9188,58 +9188,58 @@ class JoglPipeline extends Pipeline {
r.run();
}
}
-
-
+
+
// ---------------------------------------------------------------------
-
+
//
// DrawingSurfaceObject methods
//
-
+
// Method to construct a new DrawingSurfaceObject
DrawingSurfaceObject createDrawingSurfaceObject(Canvas3D cv) {
if (VERBOSE) System.err.println("JoglPipeline.createDrawingSurfaceObject()");
return new JoglDrawingSurfaceObject(cv);
}
-
+
// Method to free the drawing surface object
void freeDrawingSurface(Canvas3D cv, DrawingSurfaceObject drawingSurfaceObject) {
if (VERBOSE) System.err.println("JoglPipeline.freeDrawingSurface()");
// This method is a no-op
}
-
+
// Method to free the native drawing surface object
void freeDrawingSurfaceNative(Object o) {
if (VERBOSE) System.err.println("JoglPipeline.freeDrawingSurfaceNative()");
// This method is a no-op
}
-
+
//----------------------------------------------------------------------
// Context-related routines
//
-
+
// Helper used everywhere
GLContext context(Context ctx) {
if (ctx == null)
return null;
return ((JoglContext) ctx).getGLContext();
}
-
+
// Helper used everywhere
GLDrawable drawable(Drawable drawable) {
if (drawable == null)
return null;
return ((JoglDrawable) drawable).getGLDrawable();
}
-
+
GLCapabilities caps(Canvas3D ctx) {
return ((JoglGraphicsConfiguration) ctx.graphicsConfiguration).getGLCapabilities();
}
-
+
//----------------------------------------------------------------------
// General helper routines
//
-
+
private static ThreadLocal nioVertexTemp = new ThreadLocal();
private static ThreadLocal nioVertexDoubleTemp = new ThreadLocal();
private static ThreadLocal nioColorTemp = new ThreadLocal();
@@ -9247,55 +9247,55 @@ class JoglPipeline extends Pipeline {
private static ThreadLocal nioNormalTemp = new ThreadLocal();
private static ThreadLocal nioTexCoordSetTemp = new ThreadLocal();
private static ThreadLocal nioVertexAttrSetTemp = new ThreadLocal();
-
+
private static FloatBuffer getVertexArrayBuffer(float[] vertexArray) {
return getVertexArrayBuffer(vertexArray, true);
}
-
+
private static FloatBuffer getVertexArrayBuffer(float[] vertexArray, boolean copyData) {
return getNIOBuffer(vertexArray, nioVertexTemp, copyData);
}
-
+
private static DoubleBuffer getVertexArrayBuffer(double[] vertexArray) {
return getVertexArrayBuffer(vertexArray, true);
}
-
+
private static DoubleBuffer getVertexArrayBuffer(double[] vertexArray, boolean copyData) {
return getNIOBuffer(vertexArray, nioVertexDoubleTemp, true);
}
-
+
private static FloatBuffer getColorArrayBuffer(float[] colorArray) {
return getColorArrayBuffer(colorArray, true);
}
-
+
private static FloatBuffer getColorArrayBuffer(float[] colorArray, boolean copyData) {
return getNIOBuffer(colorArray, nioColorTemp, true);
}
-
+
private static ByteBuffer getColorArrayBuffer(byte[] colorArray) {
return getColorArrayBuffer(colorArray, true);
}
-
+
private static ByteBuffer getColorArrayBuffer(byte[] colorArray, boolean copyData) {
return getNIOBuffer(colorArray, nioColorByteTemp, true);
}
-
+
private static FloatBuffer getNormalArrayBuffer(float[] normalArray) {
return getNormalArrayBuffer(normalArray, true);
}
-
+
private static FloatBuffer getNormalArrayBuffer(float[] normalArray, boolean copyData) {
return getNIOBuffer(normalArray, nioNormalTemp, true);
}
-
+
private static FloatBuffer[] getTexCoordSetBuffer(Object[] texCoordSet) {
return getNIOBuffer(texCoordSet, nioTexCoordSetTemp);
}
-
+
private static FloatBuffer[] getVertexAttrSetBuffer(Object[] vertexAttrSet) {
return getNIOBuffer(vertexAttrSet, nioVertexAttrSetTemp);
}
-
+
private static FloatBuffer getNIOBuffer(float[] array, ThreadLocal threadLocal, boolean copyData) {
if (array == null) {
return null;
@@ -9318,7 +9318,7 @@ class JoglPipeline extends Pipeline {
}
return buf;
}
-
+
private static DoubleBuffer getNIOBuffer(double[] array, ThreadLocal threadLocal, boolean copyData) {
if (array == null) {
return null;
@@ -9341,7 +9341,7 @@ class JoglPipeline extends Pipeline {
}
return buf;
}
-
+
private static ByteBuffer getNIOBuffer(byte[] array, ThreadLocal threadLocal, boolean copyData) {
if (array == null) {
return null;
@@ -9364,13 +9364,13 @@ class JoglPipeline extends Pipeline {
}
return buf;
}
-
+
private static FloatBuffer[] getNIOBuffer(Object[] array, ThreadLocal threadLocal) {
if (array == null) {
return null;
}
FloatBuffer[] bufs = (FloatBuffer[]) threadLocal.get();
-
+
// First resize array of FloatBuffers
if (bufs == null) {
bufs = new FloatBuffer[array.length];
@@ -9381,7 +9381,7 @@ class JoglPipeline extends Pipeline {
bufs = newBufs;
threadLocal.set(bufs);
}
-
+
// 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];
@@ -9400,7 +9400,7 @@ class JoglPipeline extends Pipeline {
buf.put(cur);
buf.rewind();
}
-
+
return bufs;
}
}