@@ -655,9 +655,9 @@ public void dispose() { // PGraphics
655
655
@ Override
656
656
protected void finalize () throws Throwable {
657
657
try {
658
- deletePolyBuffers ();
659
- deleteLineBuffers ();
660
- deletePointBuffers ();
658
+ finalizePolyBuffers ();
659
+ finalizeLineBuffers ();
660
+ finalizePointBuffers ();
661
661
662
662
deleteSurfaceTextures ();
663
663
if (!primarySurface ) {
@@ -1412,6 +1412,45 @@ protected void deletePolyBuffers() {
1412
1412
}
1413
1413
1414
1414
1415
+ protected void finalizePolyBuffers () {
1416
+ if (glPolyVertex != 0 ) {
1417
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPolyVertex , polyBuffersContext );
1418
+ }
1419
+
1420
+ if (glPolyColor != 0 ) {
1421
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPolyColor , polyBuffersContext );
1422
+ }
1423
+
1424
+ if (glPolyNormal != 0 ) {
1425
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPolyNormal , polyBuffersContext );
1426
+ }
1427
+
1428
+ if (glPolyTexcoord != 0 ) {
1429
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPolyTexcoord , polyBuffersContext );
1430
+ }
1431
+
1432
+ if (glPolyAmbient != 0 ) {
1433
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPolyAmbient , polyBuffersContext );
1434
+ }
1435
+
1436
+ if (glPolySpecular != 0 ) {
1437
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPolySpecular , polyBuffersContext );
1438
+ }
1439
+
1440
+ if (glPolyEmissive != 0 ) {
1441
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPolyEmissive , polyBuffersContext );
1442
+ }
1443
+
1444
+ if (glPolyShininess != 0 ) {
1445
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPolyShininess , polyBuffersContext );
1446
+ }
1447
+
1448
+ if (glPolyIndex != 0 ) {
1449
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPolyIndex , polyBuffersContext );
1450
+ }
1451
+ }
1452
+
1453
+
1415
1454
protected void createLineBuffers () {
1416
1455
if (!lineBuffersCreated || lineBufferContextIsOutdated ()) {
1417
1456
lineBuffersContext = pgl .getCurrentContext ();
@@ -1506,6 +1545,25 @@ protected void deleteLineBuffers() {
1506
1545
}
1507
1546
1508
1547
1548
+ protected void finalizeLineBuffers () {
1549
+ if (glLineVertex != 0 ) {
1550
+ PGraphicsOpenGL .finalizeVertexBufferObject (glLineVertex , lineBuffersContext );
1551
+ }
1552
+
1553
+ if (glLineColor != 0 ) {
1554
+ PGraphicsOpenGL .finalizeVertexBufferObject (glLineColor , lineBuffersContext );
1555
+ }
1556
+
1557
+ if (glLineAttrib != 0 ) {
1558
+ PGraphicsOpenGL .finalizeVertexBufferObject (glLineAttrib , lineBuffersContext );
1559
+ }
1560
+
1561
+ if (glLineIndex != 0 ) {
1562
+ PGraphicsOpenGL .finalizeVertexBufferObject (glLineIndex , lineBuffersContext );
1563
+ }
1564
+ }
1565
+
1566
+
1509
1567
protected void createPointBuffers () {
1510
1568
if (!pointBuffersCreated || pointBuffersContextIsOutdated ()) {
1511
1569
pointBuffersContext = pgl .getCurrentContext ();
@@ -1599,6 +1657,25 @@ protected void deletePointBuffers() {
1599
1657
}
1600
1658
1601
1659
1660
+ protected void finalizePointBuffers () {
1661
+ if (glPointVertex != 0 ) {
1662
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPointVertex , pointBuffersContext );
1663
+ }
1664
+
1665
+ if (glPointColor != 0 ) {
1666
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPointColor , pointBuffersContext );
1667
+ }
1668
+
1669
+ if (glPointAttrib != 0 ) {
1670
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPointAttrib , pointBuffersContext );
1671
+ }
1672
+
1673
+ if (glPointIndex != 0 ) {
1674
+ PGraphicsOpenGL .finalizeVertexBufferObject (glPointIndex , pointBuffersContext );
1675
+ }
1676
+ }
1677
+
1678
+
1602
1679
@ Override
1603
1680
public void requestFocus () { // ignore
1604
1681
pgl .requestFocus ();
@@ -1620,7 +1697,7 @@ public void requestDraw() {
1620
1697
if (primarySurface ) {
1621
1698
if (initialized ) {
1622
1699
if (sized ) pgl .reinitSurface ();
1623
- pgl .requestDraw ();
1700
+ if ( parent . canDraw ()) pgl .requestDraw ();
1624
1701
} else {
1625
1702
initPrimary ();
1626
1703
}
0 commit comments