Skip to content

Commit 5516b17

Browse files
committed
some minor changes from desktop
1 parent c200575 commit 5516b17

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ public class PGraphicsOpenGL extends PGraphics {
7676
"for the rest of the sketch's execution";
7777
static final String UNSUPPORTED_SHAPE_FORMAT_ERROR =
7878
"Unsupported shape format";
79+
static final String MISSING_UV_TEXCOORDS_ERROR =
80+
"No uv texture coordinates supplied with vertex() call";
7981
static final String INVALID_FILTER_SHADER_ERROR =
8082
"Your shader needs to be of TEXTURE type to be used as a filter";
8183
static final String INCONSISTENT_SHADER_TYPES =
@@ -2114,6 +2116,7 @@ public void endContour() {
21142116
@Override
21152117
public void vertex(float x, float y) {
21162118
vertexImpl(x, y, 0, 0, 0);
2119+
if (textureImage != null) PGraphics.showWarning(MISSING_UV_TEXCOORDS_ERROR);
21172120
}
21182121

21192122

@@ -2126,6 +2129,7 @@ public void vertex(float x, float y, float u, float v) {
21262129
@Override
21272130
public void vertex(float x, float y, float z) {
21282131
vertexImpl(x, y, z, 0, 0);
2132+
if (textureImage != null) PGraphics.showWarning(MISSING_UV_TEXCOORDS_ERROR);
21292133
}
21302134

21312135

@@ -5036,6 +5040,11 @@ protected void backgroundImpl(PImage image) {
50365040
if (0 < parent.frameCount) {
50375041
clearColorBuffer = true;
50385042
}
5043+
// Setting the background as opaque. If this an offscreen surface, the
5044+
// alpha channel will be set to 1 in endOffscreenDraw(), even if
5045+
// blending operations during draw create translucent areas in the
5046+
// color buffer.
5047+
backgroundA = 1;
50395048
}
50405049

50415050

@@ -5324,17 +5333,17 @@ protected void setImpl(PImage sourceImage,
53245333
setgetPixels = true;
53255334
super.setImpl(sourceImage, sourceX, sourceY, sourceWidth, sourceHeight,
53265335
targetX, targetY);
5327-
// do we need this?
5328-
// see https://github.com/processing/processing/issues/2125
5329-
// if (sourceImage.format == RGB) {
5330-
// int targetOffset = targetY * width + targetX;
5331-
// for (int y = sourceY; y < sourceY + sourceHeight; y++) {
5332-
// for (int x = targetOffset; x < targetOffset + sourceWidth; x++) {
5333-
// pixels[x] |= 0xff000000;
5334-
// }
5335-
// targetOffset += width;
5336-
// }
5337-
// }
5336+
// do we need this?
5337+
// see https://github.com/processing/processing/issues/2125
5338+
// if (sourceImage.format == RGB) {
5339+
// int targetOffset = targetY * width + targetX;
5340+
// for (int y = sourceY; y < sourceY + sourceHeight; y++) {
5341+
// for (int x = targetOffset; x < targetOffset + sourceWidth; x++) {
5342+
// pixels[x] |= 0xff000000;
5343+
// }
5344+
// targetOffset += width;
5345+
// }
5346+
// }
53385347
}
53395348

53405349

@@ -6097,6 +6106,15 @@ protected void beginOffscreenDraw() {
60976106

60986107

60996108
protected void endOffscreenDraw() {
6109+
// Set alpha channel to opaque in order to match behavior of JAVA2D:
6110+
// https://github.com/processing/processing/issues/1844
6111+
// but still not working as expected. Some strange artifacts with multismapled
6112+
// surfaces (see second code example in the issue above).
6113+
// pgl.colorMask(false, false, false, true);
6114+
// pgl.clearColor(0, 0, 0, 1);
6115+
// pgl.clear(PGL.COLOR_BUFFER_BIT);
6116+
// pgl.colorMask(true, true, true, true);
6117+
61006118
if (offscreenMultisample) {
61016119
multisampleFramebuffer.copy(offscreenFramebuffer, currentFramebuffer);
61026120
}

core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,8 @@ protected void endContourImpl() {
10031003
@Override
10041004
public void vertex(float x, float y) {
10051005
vertexImpl(x, y, 0, 0, 0);
1006+
if (image != null)
1007+
PGraphics.showWarning(PGraphicsOpenGL.MISSING_UV_TEXCOORDS_ERROR);
10061008
}
10071009

10081010

@@ -1015,6 +1017,8 @@ public void vertex(float x, float y, float u, float v) {
10151017
@Override
10161018
public void vertex(float x, float y, float z) {
10171019
vertexImpl(x, y, z, 0, 0);
1020+
if (image != null)
1021+
PGraphics.showWarning(PGraphicsOpenGL.MISSING_UV_TEXCOORDS_ERROR);
10181022
}
10191023

10201024

0 commit comments

Comments
 (0)