Added maxTextureUnits static variable to PGraphicsAndroid3D

This commit is contained in:
codeanticode
2010-11-18 02:50:06 +00:00
parent 8ed10cedb6
commit ad276c22aa
4 changed files with 37 additions and 30 deletions
@@ -419,6 +419,12 @@ public interface PConstants {
public static final int NORMALS = 1;
public static final int COLORS = 2;
public static final int TEXTURES = 3;
/*
public static final int TEXTURES1 = 3;
public static final int TEXTURES2 = 4;
public static final int TEXTURES3 = 5;
public static final int TEXTURES4 = 6;
*/
public static final int GROUPS = 4;
@@ -109,13 +109,6 @@ import android.graphics.Color;
* them for their separate audiences. Ouch.
*/
public class PGraphics extends PImage implements PConstants {
// These three are only for debugging/benchmarking purposes. I will remove soon (Andres):
public int VERTEXCOUNT = 0;
public int TRIANGLECOUNT = 0;
public int FACECOUNT = 0;
// ........................................................
// width and height are already inherited from PImage
@@ -342,9 +342,12 @@ public class PGraphicsAndroid3D extends PGraphics {
static protected boolean vboSupported;
static protected boolean fboSupported;
static protected boolean blendEqSupported;
// Some OpenGL limits
static protected int maxTextureSize;
static protected float maxPointSize;
static protected float maxLineWidth;
static protected int maxTextureUnits;
// ........................................................
@@ -757,10 +760,6 @@ public class PGraphicsAndroid3D extends PGraphics {
// }
public void beginDraw() {
VERTEXCOUNT = 0;
TRIANGLECOUNT = 0;
FACECOUNT = 0;
if (!primarySurface) {
PGraphicsAndroid3D a3d = (PGraphicsAndroid3D)parent.g;
a3d.saveGLState();
@@ -1854,7 +1853,6 @@ public class PGraphicsAndroid3D extends PGraphics {
for (int j = start; j < stop; j++) {
int i = faceOffset[j];
FACECOUNT++;
if (faceTexture[j] != null) {
tex = faceTexture[j].getTexture();
@@ -1890,8 +1888,6 @@ public class PGraphicsAndroid3D extends PGraphics {
int n = 0;
for (int k = 0; k < faceLength[j]; k++) {
TRIANGLECOUNT++;
float a[] = vertices[triangles[i][VERTEX1]];
float b[] = vertices[triangles[i][VERTEX2]];
float c[] = vertices[triangles[i][VERTEX3]];
@@ -1972,8 +1968,6 @@ public class PGraphicsAndroid3D extends PGraphics {
texCoordArray[2 * n + 0] = toFixed32((cx + sx * a[U]) * uscale);
texCoordArray[2 * n + 1] = toFixed32((cy + sy * a[V]) * vscale);
n++;
VERTEXCOUNT++;
}
// Adding vertex B.
@@ -1996,8 +1990,6 @@ public class PGraphicsAndroid3D extends PGraphics {
texCoordArray[2 * n + 0] = toFixed32((cx + sx * b[U]) * uscale);
texCoordArray[2 * n + 1] = toFixed32((cy + sy * b[V]) * vscale);
n++;
VERTEXCOUNT++;
}
// Adding vertex C.
@@ -2020,8 +2012,6 @@ public class PGraphicsAndroid3D extends PGraphics {
texCoordArray[2 * n + 0] = toFixed32((cx + sx * c[U]) * uscale);
texCoordArray[2 * n + 1] = toFixed32((cy + sy * c[V]) * vscale);
n++;
VERTEXCOUNT++;
}
i++;
@@ -5296,7 +5286,7 @@ public class PGraphicsAndroid3D extends PGraphics {
usingModelviewStack = gl11 == null || !matrixGetSupported;
int temp[] = new int[2];
gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, temp, 0);
maxTextureSize = temp[0];
@@ -5306,6 +5296,9 @@ public class PGraphicsAndroid3D extends PGraphics {
gl.glGetIntegerv(GL10.GL_ALIASED_POINT_SIZE_RANGE, temp, 0);
maxPointSize = temp[1];
gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_UNITS, temp, 0);
maxTextureUnits = temp[0];
recreateResources();
gl = null;
gl11 = null;
+24 -9
View File
@@ -1937,10 +1937,6 @@ public class PShape3D extends PShape implements PConstants {
PTexture tex;
float pointSize;
g.VERTEXCOUNT = vertexBuffer.capacity() / 3;
g.FACECOUNT = groups.size();
g.TRIANGLECOUNT = g.VERTEXCOUNT / 3;
// Setting line width and point size from stroke value.
// TODO: Here the stroke weight from the g renderer is used. Normally, no issue here, but
// in the case the shape is being rendered from an offscreen A3D surface, then this might
@@ -1975,14 +1971,24 @@ public class PShape3D extends PShape implements PConstants {
tex = null;
if (img != null && img.getTexture() != null) {
tex = img.getTexture();
// Binding texture units.
texTarget = tex.getGLTarget();
gl.glEnable(texTarget);
// Binding texture units.
gl.glActiveTexture(GL11.GL_TEXTURE0);
gl.glBindTexture(texTarget, tex.getGLID());
/*
img = group.textures;
for (int n = 0; n < img.length.; n++) {
tex = img[n].getTexture();
texTarget = tex.getGLTarget();
gl.glEnable(texTarget);
gl.glActiveTexture(GL.GL_TEXTURE0 + n);
gl.glBindTexture(GL.GL_TEXTURE_2D, tex.getGLID());
}
*/
if (pointSprites) {
// Texturing with point sprites.
@@ -1992,8 +1998,8 @@ public class PShape3D extends PShape implements PConstants {
// The alpha of a point is calculated to allow the fading of points
// instead of shrinking them past a defined threshold size. The threshold
// is defined by GL_POINT_FADE_THRESHOLD_SIZE_ARB and is not clamped to
// the minimum and maximum point sizes.
// is defined by GL_POINT_FADE_THRESHOLD_SIZE and is not clamped to the
// minimum and maximum point sizes.
gl.glPointParameterf(GL11.GL_POINT_FADE_THRESHOLD_SIZE, 0.6f * pointSize);
gl.glPointParameterf(GL11.GL_POINT_SIZE_MIN, 1.0f);
gl.glPointParameterf(GL11.GL_POINT_SIZE_MAX, PGraphicsAndroid3D.maxPointSize);
@@ -2009,6 +2015,15 @@ public class PShape3D extends PShape implements PConstants {
gl.glClientActiveTexture(GL11.GL_TEXTURE0);
gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, glTexCoordBufferID[0]);
gl.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
/*
gl.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
for (int n = 0; n < img.length.; n++) {
gl.glClientActiveTexture(GL11.GL_TEXTURE0 + n);
gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, glTexCoordBufferID[n]);
gl.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
}
*/
}
}