diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index e5e794fd6..397a64435 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -13575,23 +13575,13 @@ public class PApplet extends Applet } - public PShape createGroup() { - return g.createGroup(); + public PShape createShape() { + return g.createShape(); } - public PShape createGeometry() { - return g.createGeometry(); - } - - - public PShape createGeometry(int kind) { - return g.createGeometry(kind); - } - - - public PShape createPrimitive(int kind) { - return g.createPrimitive(kind); + public PShape createShape(int type) { + return g.createShape(type); } diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index a6b6e155d..bf4098e4f 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -7393,23 +7393,13 @@ public class PGraphics extends PImage implements PConstants { // New API: - public PShape createGroup() { - showMissingWarning("createGroup"); + public PShape createShape() { + showMissingWarning("createShape"); return null; } - public PShape createGeometry() { - showMissingWarning("createGeometry"); - return null; - } - - public PShape createGeometry(int kind) { - showMissingWarning("createGeometry"); - return null; - } - - public PShape createPrimitive(int kind) { - showMissingWarning("createPrimitive"); + public PShape createShape(int type) { + showMissingWarning("createShape"); return null; } diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index 7de5ea9f1..c669d948a 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -1554,27 +1554,46 @@ public class PGraphicsOpenGL extends PGraphics { // SHAPE CREATORS - public PShape createGroup() { - return new PShape3D(parent, PShape.GROUP); + public PShape createShape() { + return createShape(POLYGON); } - public PShape createGeometry() { - PShape3D shape = new PShape3D(parent, PShape.GEOMETRY); - shape.setKind(POLYGON); - return shape; - } - - public PShape createGeometry(int kind) { - PShape3D shape = new PShape3D(parent, PShape.GEOMETRY); - shape.setKind(kind); + public PShape createShape(int type) { + PShape3D shape; + if (type == PShape.GROUP) { + shape = new PShape3D(parent, PShape.GROUP); + } else if (type == POINTS) { + shape = new PShape3D(parent, PShape.GEOMETRY); + shape.setKind(POINTS); + } else if (type == LINES) { + shape = new PShape3D(parent, PShape.GEOMETRY); + shape.setKind(LINES); + } else if (type == TRIANGLES) { + shape = new PShape3D(parent, PShape.GEOMETRY); + shape.setKind(TRIANGLES); + } else if (type == TRIANGLE_FAN) { + shape = new PShape3D(parent, PShape.GEOMETRY); + shape.setKind(TRIANGLE_FAN); + } else if (type == TRIANGLE_STRIP) { + shape = new PShape3D(parent, PShape.GEOMETRY); + shape.setKind(TRIANGLE_STRIP); + } else if (type == QUADS) { + shape = new PShape3D(parent, PShape.GEOMETRY); + shape.setKind(QUADS); + } else if (type == QUAD_STRIP) { + shape = new PShape3D(parent, PShape.GEOMETRY); + shape.setKind(QUAD_STRIP); + } else if (type == POLYGON) { + shape = new PShape3D(parent, PShape.GEOMETRY); + shape.setKind(POLYGON); + } else if (type == SPHERE) { + shape = new PShape3D(parent, PShape.PRIMITIVE); + shape.setKind(SPHERE); + } else { + shape = null; + } return shape; } - - public PShape createPrimitive(int kind) { - PShape3D shape = new PShape3D(parent, PShape.PRIMITIVE); - shape.setKind(kind); - return shape; - } ////////////////////////////////////////////////////////////// diff --git a/java/libraries/opengl/src/processing/opengl/PShape3D.java b/java/libraries/opengl/src/processing/opengl/PShape3D.java index c4f0a0944..ab229d2f9 100644 --- a/java/libraries/opengl/src/processing/opengl/PShape3D.java +++ b/java/libraries/opengl/src/processing/opengl/PShape3D.java @@ -69,6 +69,8 @@ public class PShape3D extends PShape { protected PImage texture; + protected boolean is3D; + // ........................................................ // OpenGL buffers @@ -183,6 +185,7 @@ public class PShape3D extends PShape { this.root = this; this.parent = null; this.modified = false; + this.is3D = true; tess = ogl.newTessGeometry(RETAINED); if (family == GEOMETRY || family == PRIMITIVE || family == PATH) { @@ -206,6 +209,14 @@ public class PShape3D extends PShape { this.kind = kind; } + public void set2D() { + is3D = false; + } + + public void set3D() { + is3D = true; + } + public void setMode(int mode) { if (mode == STATIC) { glMode = GL.GL_STATIC_DRAW; @@ -329,6 +340,10 @@ public class PShape3D extends PShape { strokeCap = cap; } + public void end() { + // ? + } + /////////////////////////////////////////////////////////// // @@ -1285,8 +1300,16 @@ public class PShape3D extends PShape { texSet.addAll(childSet); } - } else { - texSet.add(texture); + } else { + if (!is3D) { + // if is stroked and textured: + // texSet.add(texture); for the textured fill + // texSet.add(null); for the stroke + // else + texSet.add(texture); + } else { + texSet.add(texture); + } } return texSet;