Skip to content

Commit 46157fa

Browse files
committed
updated to latest gl changes
1 parent 8ea7a90 commit 46157fa

File tree

2 files changed

+88
-11
lines changed

2 files changed

+88
-11
lines changed

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,9 @@ public void dispose() { // PGraphics
655655
@Override
656656
protected void finalize() throws Throwable {
657657
try {
658-
deletePolyBuffers();
659-
deleteLineBuffers();
660-
deletePointBuffers();
658+
finalizePolyBuffers();
659+
finalizeLineBuffers();
660+
finalizePointBuffers();
661661

662662
deleteSurfaceTextures();
663663
if (!primarySurface) {
@@ -1412,6 +1412,45 @@ protected void deletePolyBuffers() {
14121412
}
14131413

14141414

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+
14151454
protected void createLineBuffers() {
14161455
if (!lineBuffersCreated || lineBufferContextIsOutdated()) {
14171456
lineBuffersContext = pgl.getCurrentContext();
@@ -1506,6 +1545,25 @@ protected void deleteLineBuffers() {
15061545
}
15071546

15081547

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+
15091567
protected void createPointBuffers() {
15101568
if (!pointBuffersCreated || pointBuffersContextIsOutdated()) {
15111569
pointBuffersContext = pgl.getCurrentContext();
@@ -1599,6 +1657,25 @@ protected void deletePointBuffers() {
15991657
}
16001658

16011659

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+
16021679
@Override
16031680
public void requestFocus() { // ignore
16041681
pgl.requestFocus();
@@ -1620,7 +1697,7 @@ public void requestDraw() {
16201697
if (primarySurface) {
16211698
if (initialized) {
16221699
if (sized) pgl.reinitSurface();
1623-
pgl.requestDraw();
1700+
if (parent.canDraw()) pgl.requestDraw();
16241701
} else {
16251702
initPrimary();
16261703
}

core/src/processing/opengl/PShader.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public class PShader implements PConstants {
117117
protected int modelviewMatLoc;
118118
protected int projectionMatLoc;
119119
protected int ppixelsLoc;
120-
protected int bufferUnit;
120+
protected int ppixelsUnit;
121121
protected int viewportLoc;
122122

123123
// Uniforms only for lines and points
@@ -1210,12 +1210,12 @@ protected void setCommonUniforms() {
12101210
}
12111211

12121212
if (-1 < ppixelsLoc) {
1213-
bufferUnit = getLastTexUnit() + 1;
1214-
setUniformValue(ppixelsLoc, bufferUnit);
1215-
pgl.activeTexture(PGL.TEXTURE0 + bufferUnit);
1213+
ppixelsUnit = getLastTexUnit() + 1;
1214+
setUniformValue(ppixelsLoc, ppixelsUnit);
1215+
pgl.activeTexture(PGL.TEXTURE0 + ppixelsUnit);
12161216
currentPG.bindFrontTexture();
12171217
} else {
1218-
bufferUnit = -1;
1218+
ppixelsUnit = -1;
12191219
}
12201220
}
12211221

@@ -1306,7 +1306,7 @@ protected void unbindTyped() {
13061306

13071307
if (-1 < ppixelsLoc) {
13081308
pgl.requestFBOLayer();
1309-
pgl.activeTexture(PGL.TEXTURE0 + bufferUnit);
1309+
pgl.activeTexture(PGL.TEXTURE0 + ppixelsUnit);
13101310
currentPG.unbindFrontTexture();
13111311
pgl.activeTexture(PGL.TEXTURE0);
13121312
}
@@ -1341,7 +1341,7 @@ protected void setTexture(Texture tex) {
13411341
setUniformValue(texOffsetLoc, 1.0f / tex.width, 1.0f / tex.height);
13421342

13431343
if (-1 < textureLoc) {
1344-
texUnit = -1 < bufferUnit ? bufferUnit + 1 : getLastTexUnit() + 1;
1344+
texUnit = -1 < ppixelsUnit ? ppixelsUnit + 1 : getLastTexUnit() + 1;
13451345
setUniformValue(textureLoc, texUnit);
13461346
pgl.activeTexture(PGL.TEXTURE0 + texUnit);
13471347
tex.bind();

0 commit comments

Comments
 (0)