@@ -5282,22 +5282,11 @@ protected void backgroundImpl(PImage image) {
5282
5282
protected void backgroundImpl () {
5283
5283
flush ();
5284
5284
5285
- pgl .depthMask (true );
5286
- pgl .clearDepth (1 );
5287
- pgl .clear (PGL .DEPTH_BUFFER_BIT );
5288
- if (hints [DISABLE_DEPTH_MASK ]) {
5289
- pgl .depthMask (false );
5290
- } else {
5291
- pgl .depthMask (true );
5285
+ if (!hints [DISABLE_DEPTH_MASK ]) {
5286
+ pgl .clearDepth (1 );
5287
+ pgl .clear (PGL .DEPTH_BUFFER_BIT );
5292
5288
}
5293
5289
5294
- // Code to use instead in order to fix
5295
- // https://github.com/processing/processing/issues/2296
5296
- // if (!hints[DISABLE_DEPTH_MASK]) {
5297
- // pgl.clearDepth(1);
5298
- // pgl.clear(PGL.DEPTH_BUFFER_BIT);
5299
- // }
5300
-
5301
5290
pgl .clearColor (backgroundR , backgroundG , backgroundB , backgroundA );
5302
5291
pgl .clear (PGL .COLOR_BUFFER_BIT );
5303
5292
if (0 < parent .frameCount ) {
@@ -6381,14 +6370,13 @@ protected void beginOffscreenDraw() {
6381
6370
6382
6371
6383
6372
protected void endOffscreenDraw () {
6384
- // Set alpha channel to opaque in order to match behavior of JAVA2D:
6385
- // https://github.com/processing/processing/issues/1844
6386
- // but still not working as expected. Some strange artifacts with multismapled
6387
- // surfaces (see second code example in the issue above).
6388
- // pgl.colorMask(false, false, false, true);
6389
- // pgl.clearColor(0, 0, 0, 1);
6390
- // pgl.clear(PGL.COLOR_BUFFER_BIT);
6391
- // pgl.colorMask(true, true, true, true);
6373
+ if (backgroundA == 1 ) {
6374
+ // Set alpha channel to opaque in order to match behavior of JAVA2D:
6375
+ pgl .colorMask (false , false , false , true );
6376
+ pgl .clearColor (0 , 0 , 0 , backgroundA );
6377
+ pgl .clear (PGL .COLOR_BUFFER_BIT );
6378
+ pgl .colorMask (true , true , true , true );
6379
+ }
6392
6380
6393
6381
if (offscreenMultisample ) {
6394
6382
multisampleFramebuffer .copyColor (offscreenFramebuffer );
@@ -6454,7 +6442,12 @@ protected void setDrawDefaults() {
6454
6442
6455
6443
// To avoid having garbage in the screen after a resize,
6456
6444
// in the case background is not called in draw().
6457
- background (backgroundColor );
6445
+ if (primarySurface ) {
6446
+ background (backgroundColor );
6447
+ } else {
6448
+ // offscreen surfaces are transparent by default.
6449
+ background (0x00 << 24 | (backgroundColor & 0xFFFFFF ));
6450
+ }
6458
6451
6459
6452
// Sets the default projection and camera (initializes modelview).
6460
6453
// If the user has setup up their own projection, they'll need
@@ -11916,7 +11909,6 @@ public void begin(int type) {
11916
11909
vertFirst = cache .vertexCount [cacheIndex ];
11917
11910
vertOffset = cache .vertexOffset [cacheIndex ];
11918
11911
vertCount = 0 ;
11919
- System .out .println (vertFirst + " " + vertOffset );
11920
11912
11921
11913
if (type == PGL .TRIANGLE_FAN ) primitive = TRIANGLE_FAN ;
11922
11914
else if (type == PGL .TRIANGLE_STRIP ) primitive = TRIANGLE_STRIP ;
0 commit comments