@@ -76,6 +76,8 @@ public class PGraphicsOpenGL extends PGraphics {
76
76
"for the rest of the sketch's execution" ;
77
77
static final String UNSUPPORTED_SHAPE_FORMAT_ERROR =
78
78
"Unsupported shape format" ;
79
+ static final String MISSING_UV_TEXCOORDS_ERROR =
80
+ "No uv texture coordinates supplied with vertex() call" ;
79
81
static final String INVALID_FILTER_SHADER_ERROR =
80
82
"Your shader needs to be of TEXTURE type to be used as a filter" ;
81
83
static final String INCONSISTENT_SHADER_TYPES =
@@ -624,13 +626,15 @@ protected void allocate() {
624
626
public void dispose () { // PGraphics
625
627
super .dispose ();
626
628
627
- // Swap buffers the end to make sure that no
628
- // garbage is shown on the screen, this particularly
629
- // affects non-interactive sketches on windows that
630
- // render only 1 frame, so no enough rendering
631
- // iterations have been conducted so far to properly
632
- // initialize all the buffers.
633
- pgl .swapBuffers ();
629
+ if (primarySurface ) {
630
+ // Swap buffers the end to make sure that no
631
+ // garbage is shown on the screen, this particularly
632
+ // affects non-interactive sketches on windows that
633
+ // render only 1 frame, so no enough rendering
634
+ // iterations have been conducted so far to properly
635
+ // initialize all the buffers.
636
+ pgl .swapBuffers ();
637
+ }
634
638
635
639
deletePolyBuffers ();
636
640
deleteLineBuffers ();
@@ -2114,6 +2118,7 @@ public void endContour() {
2114
2118
@ Override
2115
2119
public void vertex (float x , float y ) {
2116
2120
vertexImpl (x , y , 0 , 0 , 0 );
2121
+ if (textureImage != null ) PGraphics .showWarning (MISSING_UV_TEXCOORDS_ERROR );
2117
2122
}
2118
2123
2119
2124
@@ -2126,6 +2131,7 @@ public void vertex(float x, float y, float u, float v) {
2126
2131
@ Override
2127
2132
public void vertex (float x , float y , float z ) {
2128
2133
vertexImpl (x , y , z , 0 , 0 );
2134
+ if (textureImage != null ) PGraphics .showWarning (MISSING_UV_TEXCOORDS_ERROR );
2129
2135
}
2130
2136
2131
2137
@@ -5036,6 +5042,11 @@ protected void backgroundImpl(PImage image) {
5036
5042
if (0 < parent .frameCount ) {
5037
5043
clearColorBuffer = true ;
5038
5044
}
5045
+ // Setting the background as opaque. If this an offscreen surface, the
5046
+ // alpha channel will be set to 1 in endOffscreenDraw(), even if
5047
+ // blending operations during draw create translucent areas in the
5048
+ // color buffer.
5049
+ backgroundA = 1 ;
5039
5050
}
5040
5051
5041
5052
@@ -5324,17 +5335,17 @@ protected void setImpl(PImage sourceImage,
5324
5335
setgetPixels = true ;
5325
5336
super .setImpl (sourceImage , sourceX , sourceY , sourceWidth , sourceHeight ,
5326
5337
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
- // }
5338
+ // do we need this?
5339
+ // see https://github.com/processing/processing/issues/2125
5340
+ // if (sourceImage.format == RGB) {
5341
+ // int targetOffset = targetY * width + targetX;
5342
+ // for (int y = sourceY; y < sourceY + sourceHeight; y++) {
5343
+ // for (int x = targetOffset; x < targetOffset + sourceWidth; x++) {
5344
+ // pixels[x] |= 0xff000000;
5345
+ // }
5346
+ // targetOffset += width;
5347
+ // }
5348
+ // }
5338
5349
}
5339
5350
5340
5351
@@ -6097,6 +6108,15 @@ protected void beginOffscreenDraw() {
6097
6108
6098
6109
6099
6110
protected void endOffscreenDraw () {
6111
+ // Set alpha channel to opaque in order to match behavior of JAVA2D:
6112
+ // https://github.com/processing/processing/issues/1844
6113
+ // but still not working as expected. Some strange artifacts with multismapled
6114
+ // surfaces (see second code example in the issue above).
6115
+ // pgl.colorMask(false, false, false, true);
6116
+ // pgl.clearColor(0, 0, 0, 1);
6117
+ // pgl.clear(PGL.COLOR_BUFFER_BIT);
6118
+ // pgl.colorMask(true, true, true, true);
6119
+
6100
6120
if (offscreenMultisample ) {
6101
6121
multisampleFramebuffer .copy (offscreenFramebuffer , currentFramebuffer );
6102
6122
}
0 commit comments