diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index f77495143..c4436ec02 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -2485,6 +2485,7 @@ public class PGraphicsOpenGL extends PGraphics { void rawPoints() { raw.colorMode(RGB); raw.noFill(); + raw.strokeCap(strokeCap); raw.beginShape(POINTS); float[] vertices = tessGeo.pointVertices; @@ -2492,26 +2493,26 @@ public class PGraphicsOpenGL extends PGraphics { float[] attribs = tessGeo.pointSizes; short[] indices = tessGeo.pointIndices; - IndexCache cache = tessGeo.lineIndexCache; + IndexCache cache = tessGeo.pointIndexCache; for (int n = 0; n < cache.size; n++) { int ioffset = cache.indexOffset[n]; int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; int pt = ioffset; - while (pt < ioffset + icount) { + while (pt < (ioffset + icount) / 3) { float size = attribs[2 * pt + 2]; float weight; int perim; - if (0 < size) { // Square point + if (0 < size) { // round point weight = +size / 0.5f; - perim = PApplet.max(MIN_POINT_ACCURACY, (int) (TWO_PI * weight / 20)); - } else { // round point + perim = PApplet.max(MIN_POINT_ACCURACY, (int) (TWO_PI * weight / 20)) + 1; + } else { // Square point weight = -size / 0.5f; - perim = 5; + perim = 5; } - int i0 = voffset + indices[pt]; + int i0 = voffset + indices[3 * pt]; int argb0 = PGL.nativeToJavaARGB(color[i0]); float[] pt0 = {0, 0, 0, 0}; @@ -2569,6 +2570,8 @@ public class PGraphicsOpenGL extends PGraphics { void rawLines() { raw.colorMode(RGB); raw.noFill(); + raw.strokeCap(strokeCap); + raw.strokeJoin(strokeJoin); raw.beginShape(LINES); float[] vertices = tessGeo.lineVertices; diff --git a/java/libraries/opengl/src/processing/opengl/PShape3D.java b/java/libraries/opengl/src/processing/opengl/PShape3D.java index 90e4205c4..de0a5040c 100644 --- a/java/libraries/opengl/src/processing/opengl/PShape3D.java +++ b/java/libraries/opengl/src/processing/opengl/PShape3D.java @@ -4059,8 +4059,62 @@ public class PShape3D extends PShape { } - // TODO: finish when points are properly re-implemented. protected void rawPoints(PGraphicsOpenGL g) { + PGraphics raw = g.getRaw(); + + raw.colorMode(RGB); + raw.noFill(); + raw.strokeCap(strokeCap); + raw.beginShape(POINTS); + + float[] vertices = tessGeo.pointVertices; + int[] color = tessGeo.pointColors; + float[] attribs = tessGeo.pointSizes; + short[] indices = tessGeo.pointIndices; + + IndexCache cache = tessGeo.pointIndexCache; + for (int n = 0; n < cache.size; n++) { + int ioffset = cache.indexOffset[n]; + int icount = cache.indexCount[n]; + int voffset = cache.vertexOffset[n]; + + int pt = ioffset; + while (pt < (ioffset + icount) / 3) { + float size = attribs[2 * pt + 2]; + float weight; + int perim; + if (0 < size) { // round point + weight = +size / 0.5f; + perim = PApplet.max(PGraphicsOpenGL.MIN_POINT_ACCURACY, (int) (TWO_PI * weight / 20)) + 1; + } else { // Square point + weight = -size / 0.5f; + perim = 5; + } + + int i0 = voffset + indices[3 * pt]; + int argb0 = PGL.nativeToJavaARGB(color[i0]); + float[] pt0 = {0, 0, 0, 0}; + + float[] src0 = {0, 0, 0, 0}; + PApplet.arrayCopy(vertices, 4 * i0, src0, 0, 4); + g.modelview.mult(src0, pt0); + + if (raw.is3D()) { + raw.strokeWeight(weight); + raw.stroke(argb0); + raw.vertex(pt0[X], pt0[Y], pt0[Z]); + } else if (raw.is2D()) { + float sx0 = g.screenX(pt0[0], pt0[1], pt0[2], pt0[3]), sy0 = g.screenY(pt0[0], pt0[1], pt0[2], pt0[3]); + raw.strokeWeight(weight); + raw.stroke(argb0); + raw.vertex(sx0, sy0); + } + + pt += perim; + } + } + + raw.endShape(); } @@ -4092,6 +4146,8 @@ public class PShape3D extends PShape { raw.colorMode(RGB); raw.noFill(); + raw.strokeCap(strokeCap); + raw.strokeJoin(strokeJoin); raw.beginShape(LINES); float[] vertices = tessGeo.lineVertices;