synch with opengl2

This commit is contained in:
codeanticode
2011-02-21 12:24:29 +00:00
parent 957593d92b
commit cfb7566f71
@@ -3546,7 +3546,6 @@ public class PGraphicsAndroid3D extends PGraphics {
public void pushMatrix() {
if (USE_GEO_BUFFER && GEO_BUFFER_ACCUM_ALL && UPDATE_GEO_BUFFER_MATRIX_STACK) {
geoBuffer.stack.push();
return;
}
gl.glPushMatrix();
@@ -3562,7 +3561,6 @@ public class PGraphicsAndroid3D extends PGraphics {
public void popMatrix() {
if (USE_GEO_BUFFER && GEO_BUFFER_ACCUM_ALL && UPDATE_GEO_BUFFER_MATRIX_STACK) {
geoBuffer.stack.pop();
return;
}
gl.glPopMatrix();
@@ -3588,7 +3586,6 @@ public class PGraphicsAndroid3D extends PGraphics {
public void translate(float tx, float ty, float tz) {
if (USE_GEO_BUFFER && GEO_BUFFER_ACCUM_ALL && UPDATE_GEO_BUFFER_MATRIX_STACK) {
geoBuffer.stack.translate(tx, ty, tz);
return;
}
gl.glTranslatef(tx, ty, tz);
@@ -3632,7 +3629,6 @@ public class PGraphicsAndroid3D extends PGraphics {
public void rotate(float angle, float v0, float v1, float v2) {
if (USE_GEO_BUFFER && GEO_BUFFER_ACCUM_ALL && UPDATE_GEO_BUFFER_MATRIX_STACK) {
geoBuffer.stack.rotate(angle, v0, v1, v2);
return;
}
gl.glRotatef(PApplet.degrees(angle), v0, v1, v2);
@@ -3667,7 +3663,6 @@ public class PGraphicsAndroid3D extends PGraphics {
public void scale(float sx, float sy, float sz) {
if (USE_GEO_BUFFER && GEO_BUFFER_ACCUM_ALL && UPDATE_GEO_BUFFER_MATRIX_STACK) {
geoBuffer.stack.scale(sx, sy, sz);
return;
}
if (manipulatingCamera) {
@@ -6981,6 +6976,44 @@ public class PGraphicsAndroid3D extends PGraphics {
// the buffer but also being applied in order to affect other geometry
// that is not accumulated (PShape3D, for instance).
if (GEO_BUFFER_ACCUM_ALL && UPDATE_GEO_BUFFER_MATRIX_STACK) {
pushMatrix();
// we need to set the modelview matrix to the camera state
// to eliminate the transformations that are duplicated in GL's
// modelview and the vertices.
// In the finished code handling general scenarios, using the camera
// matrix might not be enough (maybe we need to save the current modelview
// matrix at the moment of applying the transformation to the vertices of
// the buffer), not sure though.
// It is also worth noting that these calculations makes the accumulation
// method slower under certain scenarios (lots of geometry buffers sent per
// frame and lots of geometric tranformations)... This is to say that in the
// limit whe the accumulator doesn't actually accumulate because the buffer
// is sent at each beginShape/endShape call, then this additional modelview
// stack manipulation takes away around 10-12 fps
gltemp[0] = camera.m00;
gltemp[1] = camera.m10;
gltemp[2] = camera.m20;
gltemp[3] = camera.m30;
gltemp[4] = camera.m01;
gltemp[5] = camera.m11;
gltemp[6] = camera.m21;
gltemp[7] = camera.m31;
gltemp[8] = camera.m02;
gltemp[9] = camera.m12;
gltemp[10] = camera.m22;
gltemp[11] = camera.m32;
gltemp[12] = camera.m03;
gltemp[13] = camera.m13;
gltemp[14] = camera.m23;
gltemp[15] = camera.m33;
gl.glLoadMatrixf(gltemp, 0);
}
indicesBuffer.position(0);
verticesBuffer.position(0);
colorsBuffer.position(0);
@@ -6999,6 +7032,10 @@ public class PGraphicsAndroid3D extends PGraphics {
gl.glDrawElements(GL11.GL_TRIANGLES, idxCount, GL11.GL_UNSIGNED_SHORT, indicesBuffer);
if (GEO_BUFFER_ACCUM_ALL && UPDATE_GEO_BUFFER_MATRIX_STACK) {
popMatrix();
}
// Using glDrawRangeElements doesn't make any difference:
//gl2x.glDrawRangeElements(GL.GL_TRIANGLES, minVertIndex, maxVertIndex, idxCount, GL2.GL_UNSIGNED_INT, indicesBuffer);
}