diff --git a/android/core/src/processing/core/PApplet.java b/android/core/src/processing/core/PApplet.java index 42de3bb51..197a9c782 100644 --- a/android/core/src/processing/core/PApplet.java +++ b/android/core/src/processing/core/PApplet.java @@ -3797,16 +3797,6 @@ public class PApplet extends Activity implements PConstants, Runnable { return null; } - - /** - * Creates an empty shape, with the specified size and parameters. - * The actual type will depend on the renderer. - */ - public PShape createShape(int size, Object params) { - return g.createShape(size, params); - } - - ////////////////////////////////////////////////////////////// @@ -7295,8 +7285,8 @@ public class PApplet extends Activity implements PConstants, Runnable { } - public void vertexFields(float[] v) { - g.vertexFields(v); + public void vertex(float[] v) { + g.vertex(v); } @@ -8273,7 +8263,34 @@ public class PApplet extends Activity implements PConstants, Runnable { return g.displayable(); } + /** + * Return true if this renderer does rendering through OpenGL. Defaults to false. + */ + public boolean isGL() { + return g.isGL(); + } + + public PShape createShape() { + return g.createShape(); + } + + + public PShape createShape(int type) { + return g.createShape(type); + } + + + public PShape createShape(int kind, float... p) { + return g.createShape(kind, p); + } + + + public void blendMode(int mode) { + g.blendMode(mode); + } + + public void setCache(PGraphics renderer, Object storage) { g.setCache(renderer, storage); } @@ -8378,69 +8395,5 @@ public class PApplet extends Activity implements PConstants, Runnable { int dx, int dy, int dw, int dh, int mode) { g.blend(src, sx, sy, sw, sh, dx, dy, dw, dh, mode); } - - ////////////////////////////////////////////////////////////// - - // New API: - - - public void screenBlend(int mode) { - g.screenBlend(mode); - } - - - public void textureBlend(int mode) { - g.textureBlend(mode); - } - - - public PShape beginRecord() { - return g.beginRecord(); - } - - - public void endRecord() { - g.endRecord(); - } - - - public void mergeShapes(boolean val) { - g.mergeShapes(val); - } - - - public void shapeName(String name) { - g.shapeName(name); - } - - - public void autoNormal(boolean auto) { - g.autoNormal(auto); - } - - - public void matrixMode(int mode) { - g.matrixMode(mode); - } - - - public void beginText() { - g.beginText(); - } - - - public void endText() { - g.endText(); - } - - - public void texture(PImage... images) { - g.texture(images); - } - - - public void vertex(float... values) { - g.vertex(values); - } } diff --git a/android/core/src/processing/core/PGL.java b/android/core/src/processing/core/PGL.java index c97c0e44c..5ae39e0f7 100644 --- a/android/core/src/processing/core/PGL.java +++ b/android/core/src/processing/core/PGL.java @@ -27,15 +27,17 @@ import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.nio.ShortBuffer; + import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.opengles.*; import android.opengl.GLSurfaceView.EGLConfigChooser; import android.opengl.GLSurfaceView.Renderer; +import android.opengl.GLSurfaceView; import android.opengl.GLU; - /** * How the P3D renderer handles the different OpenGL profiles? Basically, * P3D has two pipeline modes: fixed or programmable. In the fixed mode, @@ -185,11 +187,11 @@ public class PGL { static public void shutdown() { } - public void updateGLPrimary() { + public void updatePrimary() { } - public void updateGLOffscreen(PGL primary) { + public void updateOffscreen(PGL primary) { gl = primary.gl; gl11 = primary.gl11; gl11x = primary.gl11x; @@ -197,7 +199,7 @@ public class PGL { } - public void initPrimary(int antialias) { + public void initPrimarySurface(int antialias) { /* offscreenTexCrop = new int[4]; @@ -208,23 +210,14 @@ public class PGL { offscreenImages = new PImage[2]; offscreenParams = new PTexture.Parameters[2]; - if (primarySurface) { - // Nearest filtering is used for the primary surface, otherwise some - // artifacts appear (diagonal line when blending, for instance). This - // might deserve further examination. - offscreenParams[0] = new PTexture.Parameters(ARGB, POINT); - offscreenParams[1] = new PTexture.Parameters(ARGB, POINT); - offscreenImages[0] = parent.createImage(width, height, ARGB, offscreenParams[0]); - offscreenImages[1] = parent.createImage(width, height, ARGB, offscreenParams[1]); - } else { - // Linear filtering is needed to keep decent image quality when rendering - // texture at a size different from its original resolution. This is expected - // to happen for offscreen rendering. - offscreenParams[0] = new PTexture.Parameters(ARGB, BILINEAR); - offscreenParams[1] = new PTexture.Parameters(ARGB, BILINEAR); - offscreenImages[0] = parent.createImage(width, height, ARGB, offscreenParams[0]); - offscreenImages[1] = parent.createImage(width, height, ARGB, offscreenParams[1]); - } + + // Nearest filtering is used for the primary surface, otherwise some + // artifacts appear (diagonal line when blending, for instance). This + // might deserve further examination. + offscreenParams[0] = new PTexture.Parameters(ARGB, POINT); + offscreenParams[1] = new PTexture.Parameters(ARGB, POINT); + offscreenImages[0] = parent.createImage(width, height, ARGB, offscreenParams[0]); + offscreenImages[1] = parent.createImage(width, height, ARGB, offscreenParams[1]); offscreenTextures = new PTexture[2]; offscreenTextures[0] = addTexture(offscreenImages[0]); @@ -251,7 +244,7 @@ public class PGL { initialized = true; } - public void initOffscreen(PGL primary) { + public void initOffscreenSurface(PGL primary) { /* offscreenTexCrop = new int[4]; @@ -262,23 +255,13 @@ public class PGL { offscreenImages = new PImage[2]; offscreenParams = new PTexture.Parameters[2]; - if (primarySurface) { - // Nearest filtering is used for the primary surface, otherwise some - // artifacts appear (diagonal line when blending, for instance). This - // might deserve further examination. - offscreenParams[0] = new PTexture.Parameters(ARGB, POINT); - offscreenParams[1] = new PTexture.Parameters(ARGB, POINT); - offscreenImages[0] = parent.createImage(width, height, ARGB, offscreenParams[0]); - offscreenImages[1] = parent.createImage(width, height, ARGB, offscreenParams[1]); - } else { - // Linear filtering is needed to keep decent image quality when rendering - // texture at a size different from its original resolution. This is expected - // to happen for offscreen rendering. - offscreenParams[0] = new PTexture.Parameters(ARGB, BILINEAR); - offscreenParams[1] = new PTexture.Parameters(ARGB, BILINEAR); - offscreenImages[0] = parent.createImage(width, height, ARGB, offscreenParams[0]); - offscreenImages[1] = parent.createImage(width, height, ARGB, offscreenParams[1]); - } + // Linear filtering is needed to keep decent image quality when rendering + // texture at a size different from its original resolution. This is expected + // to happen for offscreen rendering. + offscreenParams[0] = new PTexture.Parameters(ARGB, BILINEAR); + offscreenParams[1] = new PTexture.Parameters(ARGB, BILINEAR); + offscreenImages[0] = parent.createImage(width, height, ARGB, offscreenParams[0]); + offscreenImages[1] = parent.createImage(width, height, ARGB, offscreenParams[1]); offscreenTextures = new PTexture[2]; offscreenTextures[0] = addTexture(offscreenImages[0]); @@ -305,7 +288,7 @@ public class PGL { initialized = true; } - public void updateOffscreen(PGL primary) { + public void updateOffscreenSurface(PGL primary) { } protected void detainContext() { @@ -321,7 +304,14 @@ public class PGL { return other.same(/*context*/); } - public boolean beginOnscreenDraw() { + public boolean initOnscreenDraw() { + return true; + } + + public void beginOnscreenDraw() { + gl.glClearColor(0, 0, 0, 0); + gl.glClear(GL10.GL_COLOR_BUFFER_BIT); + /* if (clearColorBuffer) { // Simplest scenario: clear mode means we clear both the color and depth buffers. @@ -362,8 +352,6 @@ public class PGL { } } */ - - return true; } public void endOnscreenDraw() { @@ -421,6 +409,12 @@ public class PGL { return true; } + public void requestDraw() { + if (pg.parent.looping) { // This "if" is needed to avoid flickering when looping is disabled. + ((GLSurfaceView) pg.parent.surfaceView).requestRender(); + } + } + /////////////////////////////////////////////////////////////////////////////////// // Caps query @@ -817,19 +811,19 @@ public class PGL { } public void initIndexBuffer(int size, int mode) { - gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, size * SIZEOF_INT, null, mode); + gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, size * SIZEOF_SHORT, null, mode); } - public void copyIndexBufferData(int[] data, int size, int mode) { - gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, size * SIZEOF_INT, IntBuffer.wrap(data, 0, size), mode); + public void copyIndexBufferData(short[] data, int size, int mode) { + gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, size * SIZEOF_SHORT, ShortBuffer.wrap(data, 0, size), mode); } - public void copyIndexBufferData(int[] data, int offset, int size, int mode) { - gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, size * SIZEOF_INT, IntBuffer.wrap(data, offset, size), mode); + public void copyIndexBufferData(short[] data, int offset, int size, int mode) { + gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, size * SIZEOF_SHORT, ShortBuffer.wrap(data, offset, size), mode); } - public void copyIndexBufferSubData(int[] data, int offset, int size, int mode) { - gl11.glBufferSubData(GL11.GL_ELEMENT_ARRAY_BUFFER, offset * SIZEOF_INT, size * SIZEOF_INT, IntBuffer.wrap(data, 0, size)); + public void copyIndexBufferSubData(short[] data, int offset, int size, int mode) { + gl11.glBufferSubData(GL11.GL_ELEMENT_ARRAY_BUFFER, offset * SIZEOF_SHORT, size * SIZEOF_SHORT, ShortBuffer.wrap(data, 0, size)); } public void renderIndexBuffer(int size) { @@ -837,7 +831,7 @@ public class PGL { } public void renderIndexBuffer(int offset, int size) { - gl11.glDrawElements(GL10.GL_TRIANGLES, size, GL10.GL_UNSIGNED_SHORT, offset * SIZEOF_INT); + gl11.glDrawElements(GL10.GL_TRIANGLES, size, GL10.GL_UNSIGNED_SHORT, offset * SIZEOF_SHORT); } public void unbindIndexBuffer() { diff --git a/android/core/src/processing/core/PGraphics.java b/android/core/src/processing/core/PGraphics.java index e294be595..54c51d035 100644 --- a/android/core/src/processing/core/PGraphics.java +++ b/android/core/src/processing/core/PGraphics.java @@ -1121,7 +1121,7 @@ public class PGraphics extends PImage implements PConstants { * formatted vertex information. * @param v vertex parameters, as a float array of length VERTEX_FIELD_COUNT */ - public void vertexFields(float[] v) { + public void vertex(float[] v) { vertexCheck(); curveVertexCount = 0; float[] vertex = vertices[vertexCount]; @@ -5108,90 +5108,45 @@ public class PGraphics extends PImage implements PConstants { public boolean is3D() { return false; } + + + /** + * Return true if this renderer does rendering through OpenGL. Defaults to false. + */ + public boolean isGL() { + return false; + } + ////////////////////////////////////////////////////////////// // New API: + public PShape createShape() { + showMissingWarning("createShape"); + return null; + } + + public PShape createShape(int type) { + showMissingWarning("createShape"); + return null; + } + + public PShape createShape(int kind, float... p) { + showMissingWarning("createShape"); + return null; + } + protected String[] getSupportedShapeFormats() { showMissingWarning("getSupportedShapeFormats"); return null; } - protected PShape loadShape(String filename, Object params) { showMissingWarning("loadShape"); return null; } - - protected PShape createShape(int size, Object params) { - showMissingWarning("createShape"); - return null; - } - - public void screenBlend(int mode) { - showMissingWarning("screenBlend"); - } - - - public void textureBlend(int mode) { - showMissingWarning("textureBlend"); - } - - - public PShape beginRecord() { - showMissingWarning("beginRecord"); - return null; - } - - - public void endRecord() { - showMissingWarning("endRecord"); - } - - - public boolean isRecordingShape() { - //showMissingWarning("isRecording"); - return false; - } - - - public void mergeShapes(boolean val) { - showMissingWarning("mergeShapes"); - } - - - public void shapeName(String name) { - showMissingWarning("shapeName"); - } - - - public void autoNormal(boolean auto) { - this.autoNormal = auto; - } - - - public void matrixMode(int mode) { - showMissingWarning("matrixMode"); - } - - - public void beginText() { - showMissingWarning("beginText"); - } - - - public void endText() { - showMissingWarning("endText"); - } - - - public void texture(PImage... images) { - showMissingWarning("texture"); - } - - - public void vertex(float... values) { - showMissingWarning("vertex"); + public void blendMode(int mode) { + showMissingWarning("blendMode"); } } diff --git a/android/core/src/processing/core/PGraphicsAndroid3D.java b/android/core/src/processing/core/PGraphicsAndroid3D.java index 29ffd74e7..d64c40adb 100644 --- a/android/core/src/processing/core/PGraphicsAndroid3D.java +++ b/android/core/src/processing/core/PGraphicsAndroid3D.java @@ -30,6 +30,7 @@ import java.util.Set; import java.util.HashSet; import java.util.Stack; import javax.microedition.khronos.opengles.*; +import android.opengl.GLSurfaceView; // drawPixels is missing...calls to glDrawPixels are commented out @@ -1138,7 +1139,7 @@ public class PGraphicsAndroid3D extends PGraphics { pgl.destroyContext(); restartSurface(); pgl.detainContext(); - updateGLInterfaces(); + updatePGL(); } protected void createFillBuffers() { @@ -1281,6 +1282,11 @@ public class PGraphicsAndroid3D extends PGraphics { } + public void requestDraw() { + pgl.requestDraw(); + } + + public void beginDraw() { if (drawing) { showWarning("P3D: Already called beginDraw()."); @@ -1290,9 +1296,11 @@ public class PGraphicsAndroid3D extends PGraphics { if (primarySurface) { if (!pgl.initialized) { initPrimary(); - } - boolean res = pgl.beginOnscreenDraw(); - if (!res) return; + } + + if (!pgl.initOnscreenDraw()) { + return; + } pgl.detainContext(); } else { if (!pgl.initialized) { @@ -1306,11 +1314,9 @@ public class PGraphicsAndroid3D extends PGraphics { } else { setFramebuffer(offscreenFramebuffer); } - - pgl.beginOffscreenDraw(); } - updateGLInterfaces(); + updatePGL(); if (!glParamsRead) { getGLParameters(); @@ -1420,27 +1426,16 @@ public class PGraphicsAndroid3D extends PGraphics { normalX = normalY = 0; normalZ = 0; - - /* - if (primarySurface) { - // This instance of PGraphicsOpenGL is the primary (onscreen) drawing surface. - // Nothing else needs setup here. - } else { - pushFramebuffer(); - if (offscreenMultisample) { - setFramebuffer(offscreenFramebufferMultisample); - pgl.setDrawBuffer(0); - } else { - setFramebuffer(offscreenFramebuffer); - } - } - */ - - // Clear depth and stencil buffers. pgl.setClearColor(0, 0, 0, 0); pgl.clearDepthAndStencilBuffers(); + if (primarySurface) { + pgl.beginOnscreenDraw(); + } else { + pgl.beginOffscreenDraw(); + } + drawing = true; report("bot beginDraw()"); @@ -1508,9 +1503,9 @@ public class PGraphicsAndroid3D extends PGraphics { } - public void updateGLInterfaces() { + public void updatePGL() { if (primarySurface) { - pgl.updateGLPrimary(); + pgl.updatePrimary(); } else { pgl.updateOffscreen(pg.pgl); } @@ -1646,7 +1641,7 @@ public class PGraphicsAndroid3D extends PGraphics { // buffer. protected void beginGLOp() { pgl.detainContext(); - updateGLInterfaces(); + updatePGL(); } @@ -5882,16 +5877,16 @@ public class PGraphicsAndroid3D extends PGraphics { } protected void initPrimary() { - pgl.initPrimary(antialias); + pgl.initPrimarySurface(antialias); pg = this; } protected void initOffscreen() { // Getting the context and capabilities from the main renderer. pg = (PGraphicsAndroid3D)parent.g; - pgl.initOffscreen(pg.pgl); + pgl.initOffscreenSurface(pg.pgl); - updateGLInterfaces(); + updatePGL(); loadTextureImpl(BILINEAR); // In case of reinitialization (for example, when the smooth level @@ -5936,8 +5931,8 @@ public class PGraphicsAndroid3D extends PGraphics { } protected void updateOffscreenContext() { - pgl.updateOffscreen(pg.pgl); - updateGLInterfaces(); + pgl.updateOffscreenSurface(pg.pgl); + updatePGL(); } protected void getGLParameters() { @@ -6762,7 +6757,7 @@ public class PGraphicsAndroid3D extends PGraphics { public int fillIndexCount; public int firstFillIndex; public int lastFillIndex; - public int[] fillIndices; + public short[] fillIndices; // Tessellated line data public int lineVertexCount; @@ -6776,7 +6771,7 @@ public class PGraphicsAndroid3D extends PGraphics { public int lineIndexCount; public int firstLineIndex; public int lastLineIndex; - public int[] lineIndices; + public short[] lineIndices; // Tessellated point data public int pointVertexCount; @@ -6790,7 +6785,7 @@ public class PGraphicsAndroid3D extends PGraphics { public int pointIndexCount; public int firstPointIndex; public int lastPointIndex; - public int[] pointIndices; + public short[] pointIndices; public boolean isStroked; @@ -6817,19 +6812,19 @@ public class PGraphicsAndroid3D extends PGraphics { fillColors = new float[4 * DEFAULT_TESS_VERTICES]; fillNormals = new float[3 * DEFAULT_TESS_VERTICES]; fillTexcoords = new float[2 * DEFAULT_TESS_VERTICES]; - fillIndices = new int[DEFAULT_TESS_VERTICES]; + fillIndices = new short[DEFAULT_TESS_VERTICES]; lineVertices = new float[3 * DEFAULT_TESS_VERTICES]; lineColors = new float[4 * DEFAULT_TESS_VERTICES]; lineNormals = new float[3 * DEFAULT_TESS_VERTICES]; lineAttributes = new float[4 * DEFAULT_TESS_VERTICES]; - lineIndices = new int[DEFAULT_TESS_VERTICES]; + lineIndices = new short[DEFAULT_TESS_VERTICES]; pointVertices = new float[3 * DEFAULT_TESS_VERTICES]; pointColors = new float[4 * DEFAULT_TESS_VERTICES]; pointNormals = new float[3 * DEFAULT_TESS_VERTICES]; pointAttributes = new float[2 * DEFAULT_TESS_VERTICES]; - pointIndices = new int[DEFAULT_TESS_VERTICES]; + pointIndices = new short[DEFAULT_TESS_VERTICES]; reset(); } @@ -6987,14 +6982,14 @@ public class PGraphicsAndroid3D extends PGraphics { } public void expandFillIndices(int n) { - int temp[] = new int[n]; + short temp[] = new short[n]; PApplet.arrayCopy(fillIndices, 0, temp, 0, fillIndexCount); fillIndices = temp; } public void addFillIndex(int idx) { fillIndexCheck(); - fillIndices[fillIndexCount] = idx; + fillIndices[fillIndexCount] = (short)idx; fillIndexCount++; lastFillIndex = fillIndexCount - 1; } @@ -7168,7 +7163,7 @@ public class PGraphicsAndroid3D extends PGraphics { } public void expandLineIndices(int n) { - int temp[] = new int[n]; + short temp[] = new short[n]; PApplet.arrayCopy(lineIndices, 0, temp, 0, lineIndexCount); lineIndices = temp; } @@ -7227,7 +7222,7 @@ public class PGraphicsAndroid3D extends PGraphics { } public void expandPointIndices(int n) { - int temp[] = new int[n]; + short temp[] = new short[n]; PApplet.arrayCopy(pointIndices, 0, temp, 0, pointIndexCount); pointIndices = temp; } @@ -7955,14 +7950,14 @@ public class PGraphicsAndroid3D extends PGraphics { // Adding vert0 to take into account the triangles of all // the preceding points. for (int k = 1; k < nvert - 1; k++) { - tess.pointIndices[indIdx++] = firstVert + 0; - tess.pointIndices[indIdx++] = firstVert + k; - tess.pointIndices[indIdx++] = firstVert + k + 1; + tess.pointIndices[indIdx++] = (short)(firstVert + 0); + tess.pointIndices[indIdx++] = (short)(firstVert + k); + tess.pointIndices[indIdx++] = (short)(firstVert + k + 1); } // Final triangle between the last and first point: - tess.pointIndices[indIdx++] = firstVert + 0; - tess.pointIndices[indIdx++] = firstVert + 1; - tess.pointIndices[indIdx++] = firstVert + nvert - 1; + tess.pointIndices[indIdx++] = (short)(firstVert + 0); + tess.pointIndices[indIdx++] = (short)(firstVert + 1); + tess.pointIndices[indIdx++] = (short)(firstVert + nvert - 1); firstVert = vertIdx; } @@ -8016,14 +8011,14 @@ public class PGraphicsAndroid3D extends PGraphics { // Adding firstVert to take into account the triangles of all // the preceding points. for (int k = 1; k < nvert - 1; k++) { - tess.pointIndices[indIdx++] = firstVert + 0; - tess.pointIndices[indIdx++] = firstVert + k; - tess.pointIndices[indIdx++] = firstVert + k + 1; + tess.pointIndices[indIdx++] = (short)(firstVert + 0); + tess.pointIndices[indIdx++] = (short)(firstVert + k); + tess.pointIndices[indIdx++] = (short)(firstVert + k + 1); } // Final triangle between the last and first point: - tess.pointIndices[indIdx++] = firstVert + 0; - tess.pointIndices[indIdx++] = firstVert + 1; - tess.pointIndices[indIdx++] = firstVert + nvert - 1; + tess.pointIndices[indIdx++] = (short)(firstVert + 0); + tess.pointIndices[indIdx++] = (short)(firstVert + 1); + tess.pointIndices[indIdx++] = (short)(firstVert + nvert - 1); firstVert = vertIdx; } @@ -8068,7 +8063,7 @@ public class PGraphicsAndroid3D extends PGraphics { int idx0 = tess.firstFillIndex; int offset = tess.firstFillVertex; for (int i = in.firstVertex; i <= in.lastVertex; i++) { - tess.fillIndices[idx0 + i] = offset + i; + tess.fillIndices[idx0 + i] = (short)(offset + i); } } @@ -8088,9 +8083,9 @@ public class PGraphicsAndroid3D extends PGraphics { int idx = tess.firstFillIndex; int offset = tess.firstFillVertex; for (int i = in.firstVertex + 1; i < in.lastVertex; i++) { - tess.fillIndices[idx++] = offset + in.firstVertex; - tess.fillIndices[idx++] = offset + i; - tess.fillIndices[idx++] = offset + i + 1; + tess.fillIndices[idx++] = (short)(offset + in.firstVertex); + tess.fillIndices[idx++] = (short)(offset + i); + tess.fillIndices[idx++] = (short)(offset + i + 1); } } @@ -8114,13 +8109,13 @@ public class PGraphicsAndroid3D extends PGraphics { int idx = tess.firstFillIndex; int offset = tess.firstFillVertex; for (int i = in.firstVertex + 1; i < in.lastVertex; i++) { - tess.fillIndices[idx++] = offset + i; + tess.fillIndices[idx++] = (short)(offset + i); if (i % 2 == 0) { - tess.fillIndices[idx++] = offset + i - 1; - tess.fillIndices[idx++] = offset + i + 1; + tess.fillIndices[idx++] = (short)(offset + i - 1); + tess.fillIndices[idx++] = (short)(offset + i + 1); } else { - tess.fillIndices[idx++] = offset + i + 1; - tess.fillIndices[idx++] = offset + i - 1; + tess.fillIndices[idx++] = (short)(offset + i + 1); + tess.fillIndices[idx++] = (short)(offset + i - 1); } } } @@ -8148,13 +8143,13 @@ public class PGraphicsAndroid3D extends PGraphics { int i2 = offset + 4 * qd + 2; int i3 = offset + 4 * qd + 3; - tess.fillIndices[idx++] = i0; - tess.fillIndices[idx++] = i1; - tess.fillIndices[idx++] = i3; + tess.fillIndices[idx++] = (short)i0; + tess.fillIndices[idx++] = (short)i1; + tess.fillIndices[idx++] = (short)i3; - tess.fillIndices[idx++] = i1; - tess.fillIndices[idx++] = i2; - tess.fillIndices[idx++] = i3; + tess.fillIndices[idx++] = (short)i1; + tess.fillIndices[idx++] = (short)i2; + tess.fillIndices[idx++] = (short)i3; } } @@ -8182,13 +8177,13 @@ public class PGraphicsAndroid3D extends PGraphics { int i2 = offset + 2 * qd + 1; int i3 = offset + 2 * qd; - tess.fillIndices[idx++] = i0; - tess.fillIndices[idx++] = i1; - tess.fillIndices[idx++] = i3; + tess.fillIndices[idx++] = (short)i0; + tess.fillIndices[idx++] = (short)i1; + tess.fillIndices[idx++] = (short)i3; - tess.fillIndices[idx++] = i1; - tess.fillIndices[idx++] = i2; - tess.fillIndices[idx++] = i3; + tess.fillIndices[idx++] = (short)i1; + tess.fillIndices[idx++] = (short)i2; + tess.fillIndices[idx++] = (short)i3; } } @@ -8249,26 +8244,26 @@ public class PGraphicsAndroid3D extends PGraphics { tess.putLineVertex(in, i0, i1, vcount); tess.lineAttributes[4 * vcount + 3] = +strokeWeight; - tess.lineIndices[icount++] = vcount; + tess.lineIndices[icount++] = (short)vcount; vcount++; tess.putLineVertex(in, i0, i1, vcount); tess.lineAttributes[4 * vcount + 3] = -strokeWeight; - tess.lineIndices[icount++] = vcount; + tess.lineIndices[icount++] = (short)vcount; vcount++; tess.putLineVertex(in, i1, i0, vcount); tess.lineAttributes[4 * vcount + 3] = -strokeWeight; - tess.lineIndices[icount++] = vcount; + tess.lineIndices[icount++] = (short)vcount; // Starting a new triangle re-using prev vertices. - tess.lineIndices[icount++] = vcount; - tess.lineIndices[icount++] = vcount - 1; + tess.lineIndices[icount++] = (short)vcount; + tess.lineIndices[icount++] = (short)(vcount - 1); vcount++; tess.putLineVertex(in, i1, i0, vcount); tess.lineAttributes[4 * vcount + 3] = +strokeWeight; - tess.lineIndices[icount++] = vcount; + tess.lineIndices[icount++] = (short)vcount; } public void tessellateEdges() { diff --git a/android/core/src/processing/core/PShape3D.java b/android/core/src/processing/core/PShape3D.java index 37eb33db6..c0c67322e 100644 --- a/android/core/src/processing/core/PShape3D.java +++ b/android/core/src/processing/core/PShape3D.java @@ -1893,7 +1893,7 @@ public class PShape3D extends PShape { return tess.fillTexcoords; } - public int[] fillIndices() { + public short[] fillIndices() { updateTesselation(); return tess.fillIndices; } @@ -1948,7 +1948,7 @@ public class PShape3D extends PShape { return tess.lineAttributes; } - public int[] lineIndices() { + public short[] lineIndices() { updateTesselation(); return tess.lineIndices; } @@ -2003,7 +2003,7 @@ public class PShape3D extends PShape { return tess.pointAttributes; } - public int[] pointIndices() { + public short[] pointIndices() { updateTesselation(); return tess.pointIndices; } @@ -2873,7 +2873,7 @@ public class PShape3D extends PShape { } - protected void copyFillIndices(int offset, int size, int[] indices) { + protected void copyFillIndices(int offset, int size, short[] indices) { pgl.bindIndexBuffer(glFillIndexBufferID); pgl.copyIndexBufferSubData(indices, offset, size, glMode); pgl.unbindIndexBuffer(); @@ -2972,7 +2972,7 @@ public class PShape3D extends PShape { } - protected void copyLineIndices(int offset, int size, int[] indices) { + protected void copyLineIndices(int offset, int size, short[] indices) { pgl.bindIndexBuffer(glLineIndexBufferID); pgl.copyIndexBufferSubData(indices, offset, size, glMode); pgl.unbindIndexBuffer(); @@ -3071,7 +3071,7 @@ public class PShape3D extends PShape { } - protected void copyPointIndices(int offset, int size, int[] indices) { + protected void copyPointIndices(int offset, int size, short[] indices) { pgl.bindIndexBuffer(glPointIndexBufferID); pgl.copyIndexBufferSubData(indices, offset, size, glMode); pgl.unbindIndexBuffer(); @@ -3764,7 +3764,7 @@ public class PShape3D extends PShape { renderer.stroke = false; // Normals are automatically computed if not specified in the OBJ file. - renderer.autoNormal(true); + //renderer.autoNormal(true); // Using normal mode for texture coordinates (i.e.: normalized between 0 and 1). renderer.textureMode = NORMAL; @@ -3802,7 +3802,7 @@ public class PShape3D extends PShape { renderer.beginShape(); } - renderer.shapeName(face.name); + //renderer.shapeName(face.name); for (int j = 0; j < face.vertIdx.size(); j++){ int vertIdx, normIdx; diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 495bd645e..e7c6be8ef 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -2047,7 +2047,7 @@ public class PApplet extends Applet } } - + ////////////////////////////////////////////////////////////// @@ -9401,12 +9401,6 @@ public class PApplet extends Applet recorder.beginDraw(); } - public PShape beginRecord() { - if (!g.isRecordingShape()) { - return g.beginRecord(); - } - return null; - } /** * ( begin auto-generated from endRecord.xml ) @@ -9424,9 +9418,6 @@ public class PApplet extends Applet recorder.dispose(); recorder = null; } - if (g.isRecordingShape()) { - g.endRecord(); - } } @@ -13681,47 +13672,6 @@ public class PApplet extends Applet } - public boolean isRecordingShape() { - return g.isRecordingShape(); - } - - - public void mergeShapes(boolean val) { - if (recorder != null) recorder.mergeShapes(val); - g.mergeShapes(val); - } - - - public void shapeName(String name) { - if (recorder != null) recorder.shapeName(name); - g.shapeName(name); - } - - - public void autoNormal(boolean auto) { - if (recorder != null) recorder.autoNormal(auto); - g.autoNormal(auto); - } - - - public void matrixMode(int mode) { - if (recorder != null) recorder.matrixMode(mode); - g.matrixMode(mode); - } - - - public void beginText() { - if (recorder != null) recorder.beginText(); - g.beginText(); - } - - - public void endText() { - if (recorder != null) recorder.endText(); - g.endText(); - } - - public void delete() { if (recorder != null) recorder.delete(); g.delete(); diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index c0d1074e8..6a6dcf88c 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -657,6 +657,12 @@ public class PGraphics extends PImage implements PConstants { return true; } + /** + * Try to draw, or put a draw request on the queue. + */ +// public void requestDraw() { // ignore +// } + /** * ( begin auto-generated from PGraphics_beginDraw.xml ) @@ -7459,73 +7465,12 @@ public class PGraphics extends PImage implements PConstants { return null; } - protected PShape loadShape(String filename, Object params) { showMissingWarning("loadShape"); return null; } -/* - protected PShape createShape(int size, Object params) { - showMissingWarning("createShape"); - return null; - } - */ -/* - protected PShape createGroup(String name) { - showMissingWarning("createShape"); - return null; - } - */ - public void blendMode(int mode) { showMissingWarning("blendMode"); } - - - public PShape beginRecord() { // ignore - showMissingWarning("beginRecord"); - return null; - } - - - public void endRecord() { // ignore - showMissingWarning("endRecord"); - } - - - public boolean isRecordingShape() { - //showMissingWarning("isRecording"); - return false; - } - - - public void mergeShapes(boolean val) { - showMissingWarning("mergeShapes"); - } - - - public void shapeName(String name) { - showMissingWarning("shapeName"); - } - - - public void autoNormal(boolean auto) { - this.autoNormal = auto; - } - - - public void matrixMode(int mode) { - showMissingWarning("matrixMode"); - } - - - public void beginText() { - showMissingWarning("beginText"); - } - - - public void endText() { - showMissingWarning("endText"); - } } diff --git a/java/libraries/opengl/src/processing/opengl/PGL.java b/java/libraries/opengl/src/processing/opengl/PGL.java index 064f09c20..f9e9ebedc 100644 --- a/java/libraries/opengl/src/processing/opengl/PGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGL.java @@ -227,7 +227,7 @@ public class PGL { GLProfile.shutdown(); } - public void updateGLPrimary() { + public void updatePrimary() { gl = context.getGL(); if (pipeline == PROG_GL4) { @@ -258,7 +258,7 @@ public class PGL { } catch (GLException e) {} } - public void updateGLOffscreen(PGL primary) { + public void updateOffscreen(PGL primary) { gl = primary.gl; gl4p = primary.gl4p; gl3p = primary.gl3p; @@ -267,7 +267,7 @@ public class PGL { } - public void initPrimary(int antialias) { + public void initPrimarySurface(int antialias) { if (pg.parent.online) { // RCP Application (Applet's, Webstart, Netbeans, ..) using JOGL may not // be able to initialize JOGL before the first UI action, so initSingleton() @@ -351,14 +351,14 @@ public class PGL { initialized = true; } - public void initOffscreen(PGL primary) { + public void initOffscreenSurface(PGL primary) { context = primary.context; capabilities = primary.capabilities; drawable = null; initialized = true; } - public void updateOffscreen(PGL primary) { + public void updateOffscreenSurface(PGL primary) { context = primary.context; capabilities = primary.capabilities; drawable = null; @@ -393,7 +393,7 @@ public class PGL { return other.same(context); } - public boolean beginOnscreenDraw() { + public boolean initOnscreenDraw() { if (drawable != null) { // Call setRealized() after addNotify() has been called drawable.setRealized(pg.parent.isDisplayable()); @@ -404,7 +404,11 @@ public class PGL { return false; // Should have called canDraw() anyway } } - return false; + return false; + } + + public void beginOnscreenDraw() { + } public void endOnscreenDraw() { @@ -425,6 +429,10 @@ public class PGL { return pg.parent.isDisplayable(); } + public void requestDraw() { + + } + /////////////////////////////////////////////////////////////////////////////////// // Caps query diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index bb6519b3f..2d3cbaf31 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -512,33 +512,6 @@ public class PGraphicsOpenGL extends PGraphics { currentLightSpecular = new float[4]; lightsAllocated = true; } - - if (primarySurface) { - // Allocation of the main renderer, which mainly involves initializing OpenGL. -// if (context == null) { -// initPrimary(); -// } else { -// reapplySettings(); -// } - - if (pgl.initialized) { - reapplySettings(); - } - } else { - // Allocation of an offscreen renderer. -// if (context == null) { -// initOffscreen(); -// } else { -// // Updating OpenGL context associated to this offscreen -// // surface, to take into account a context recreation situation. -// updateOffscreenContext(); -// reapplySettings(); -// } - if (pgl.initialized) { - updateOffscreenContext(); - reapplySettings(); - } - } } @@ -1147,7 +1120,7 @@ public class PGraphicsOpenGL extends PGraphics { pgl.destroyContext(); restartSurface(); pgl.detainContext(); - updateGLInterfaces(); + updatePGL(); } protected void createFillBuffers() { @@ -1290,6 +1263,11 @@ public class PGraphicsOpenGL extends PGraphics { } + public void requestDraw() { + + } + + public void beginDraw() { if (drawing) { showWarning("P3D: Already called beginDraw()."); @@ -1299,9 +1277,11 @@ public class PGraphicsOpenGL extends PGraphics { if (primarySurface) { if (!pgl.initialized) { initPrimary(); - } - boolean res = pgl.beginOnscreenDraw(); - if (!res) return; + } + + if (!pgl.initOnscreenDraw()) { + return; + } pgl.detainContext(); } else { if (!pgl.initialized) { @@ -1319,7 +1299,7 @@ public class PGraphicsOpenGL extends PGraphics { pgl.beginOffscreenDraw(); } - updateGLInterfaces(); + updatePGL(); if (!glParamsRead) { getGLParameters(); @@ -1429,27 +1409,16 @@ public class PGraphicsOpenGL extends PGraphics { normalX = normalY = 0; normalZ = 0; - - /* - if (primarySurface) { - // This instance of PGraphicsOpenGL is the primary (onscreen) drawing surface. - // Nothing else needs setup here. - } else { - pushFramebuffer(); - if (offscreenMultisample) { - setFramebuffer(offscreenFramebufferMultisample); - pgl.setDrawBuffer(0); - } else { - setFramebuffer(offscreenFramebuffer); - } - } - */ - - // Clear depth and stencil buffers. pgl.setClearColor(0, 0, 0, 0); pgl.clearDepthAndStencilBuffers(); + if (primarySurface) { + pgl.beginOnscreenDraw(); + } else { + pgl.beginOffscreenDraw(); + } + drawing = true; report("bot beginDraw()"); @@ -1517,9 +1486,9 @@ public class PGraphicsOpenGL extends PGraphics { } - public void updateGLInterfaces() { + public void updatePGL() { if (primarySurface) { - pgl.updateGLPrimary(); + pgl.updatePrimary(); } else { pgl.updateOffscreen(pg.pgl); } @@ -1655,7 +1624,7 @@ public class PGraphicsOpenGL extends PGraphics { // buffer. protected void beginGLOp() { pgl.detainContext(); - updateGLInterfaces(); + updatePGL(); } @@ -5891,16 +5860,16 @@ public class PGraphicsOpenGL extends PGraphics { } protected void initPrimary() { - pgl.initPrimary(antialias); + pgl.initPrimarySurface(antialias); pg = this; } protected void initOffscreen() { // Getting the context and capabilities from the main renderer. pg = (PGraphicsOpenGL)parent.g; - pgl.initOffscreen(pg.pgl); + pgl.initOffscreenSurface(pg.pgl); - updateGLInterfaces(); + updatePGL(); loadTextureImpl(BILINEAR); // In case of reinitialization (for example, when the smooth level @@ -5943,8 +5912,8 @@ public class PGraphicsOpenGL extends PGraphics { } protected void updateOffscreenContext() { - pgl.updateOffscreen(pg.pgl); - updateGLInterfaces(); + pgl.updateOffscreenSurface(pg.pgl); + updatePGL(); } protected void getGLParameters() { diff --git a/java/libraries/opengl/src/processing/opengl/PShape3D.java b/java/libraries/opengl/src/processing/opengl/PShape3D.java index d2d6df537..fa9928189 100644 --- a/java/libraries/opengl/src/processing/opengl/PShape3D.java +++ b/java/libraries/opengl/src/processing/opengl/PShape3D.java @@ -3789,7 +3789,7 @@ public class PShape3D extends PShape { pg.stroke = false; // Normals are automatically computed if not specified in the OBJ file. - pg.autoNormal(true); + //pg.autoNormal(true); // Using normal mode for texture coordinates (i.e.: normalized between 0 and 1). pg.textureMode = NORMAL; @@ -3827,7 +3827,7 @@ public class PShape3D extends PShape { pg.beginShape(); } - pg.shapeName(face.name); + //pg.shapeName(face.name); for (int j = 0; j < face.vertIdx.size(); j++){ int vertIdx, normIdx;