int numActiveTexUnitState,
int texStride,
FloatBuffer[] texCoords,
int cDirty, int[] indexCoord, int[] sarray, int strip_len) {
JoglContext ctx = (JoglContext) absCtx;
GL2 gl = context(ctx).getGL().getGL2();
boolean floatCoordDefined = ((vdefined & GeometryArrayRetained.COORD_FLOAT) != 0);
boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE) != 0);
boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT) != 0);
boolean byteColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_BYTE) != 0);
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(GL2.GL_NORMALIZE);
}
// Define the data pointers
if (floatCoordDefined) {
fverts.position(0);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, fverts);
} else if (doubleCoordDefined){
dverts.position(0);
gl.glVertexPointer(3, GL2.GL_DOUBLE, 0, dverts);
}
if (floatColorsDefined) {
fclrs.position(0);
if ((vformat & GeometryArray.WITH_ALPHA) != 0) {
gl.glColorPointer(4, GL.GL_FLOAT, 0, fclrs);
} else {
gl.glColorPointer(3, GL.GL_FLOAT, 0, fclrs);
}
} else if (byteColorsDefined) {
bclrs.position(0);
if ((vformat & GeometryArray.WITH_ALPHA) != 0) {
gl.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, bclrs);
} else {
gl.glColorPointer(3, GL.GL_UNSIGNED_BYTE, 0, bclrs);
}
}
if (normalsDefined) {
norms.position(0);
gl.glNormalPointer(GL.GL_FLOAT, 0, norms);
}
if (vattrDefined) {
for (int i = 0; i < vertexAttrCount; i++) {
FloatBuffer vertexAttrs = vertexAttrBufs[i];
int sz = vertexAttrSizes[i];
ctx.enableVertexAttrArray(gl, i);
vertexAttrs.position(0);
ctx.vertexAttrPointer(gl, i, sz, GL.GL_FLOAT, 0, vertexAttrs);
}
}
if (textureDefined) {
int texSet = 0;
for (int i = 0; i < numActiveTexUnitState; i++) {
if ((i < texCoordSetCount) &&
((texSet = texCoordSetMap[i]) != -1)) {
FloatBuffer buf = texCoords[texSet];
buf.position(0);
enableTexCoordPointer(gl, i, texStride,
GL.GL_FLOAT, 0, buf);
} else {
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) {
int primType = 0;
switch (geo_type) {
case GeometryRetained.GEO_TYPE_INDEXED_TRI_STRIP_SET:
primType = GL.GL_TRIANGLE_STRIP;
break;
case GeometryRetained.GEO_TYPE_INDEXED_TRI_FAN_SET:
primType = GL.GL_TRIANGLE_FAN;
break;
case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET:
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
int offset = initialIndexIndex;
IntBuffer indicesBuffer = IntBuffer.wrap(indexCoord);
for (int i = 0; i < strip_len; i++) {
indicesBuffer.position(offset);
int count = sarray[i];
gl.glDrawElements(primType, count, GL.GL_UNSIGNED_INT, indicesBuffer);
offset += count;
}
} else {
IntBuffer buf = IntBuffer.wrap(indexCoord);
buf.position(initialIndexIndex);
switch (geo_type){
case GeometryRetained.GEO_TYPE_INDEXED_QUAD_SET : gl.glDrawElements(GL2.GL_QUADS, validIndexCount, GL.GL_UNSIGNED_INT, buf); break;
case GeometryRetained.GEO_TYPE_INDEXED_TRI_SET : gl.glDrawElements(GL.GL_TRIANGLES, validIndexCount, GL.GL_UNSIGNED_INT, buf); break;
case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET: gl.glDrawElements(GL.GL_POINTS, validIndexCount, GL.GL_UNSIGNED_INT, buf); break;
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(GL2.GL_NORMALIZE);
}
if (vattrDefined) {
resetVertexAttrs(gl, ctx, vertexAttrCount);
}