Skip to content

Commit f20506e

Browse files
committed
gl updates
1 parent 11f0685 commit f20506e

File tree

5 files changed

+8
-342
lines changed

5 files changed

+8
-342
lines changed

core/src/processing/opengl/FrameBuffer.java

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,11 @@ protected void allocate() {
331331
dispose(); // Just in the case this object is being re-allocated.
332332

333333
context = pgl.getCurrentContext();
334-
glres = new GLResourceFrameBuffer(this);
334+
glres = new GLResourceFrameBuffer(this); // create the FBO resources...
335335

336336
if (screenFb) {
337337
glFbo = 0;
338338
} else {
339-
//create the FBO object...
340-
// glFbo = PGraphicsOpenGL.createFrameBufferObject(context, pgl);
341-
342-
// ... and then create the rest of the stuff.
343339
if (multisample) {
344340
initColorBufferMultisample();
345341
}
@@ -369,28 +365,6 @@ protected void dispose() {
369365
glDepthStencil = 0;
370366
glres = null;
371367
}
372-
373-
374-
// if (glFbo != 0) {
375-
// PGraphicsOpenGL.finalizeFrameBufferObject(glFbo, context);
376-
// glFbo = 0;
377-
// }
378-
// if (glDepth != 0) {
379-
// PGraphicsOpenGL.finalizeRenderBufferObject(glDepth, context);
380-
// glDepth = 0;
381-
// }
382-
// if (glStencil != 0) {
383-
// PGraphicsOpenGL.finalizeRenderBufferObject(glStencil, context);
384-
// glStencil = 0;
385-
// }
386-
// if (glMultisample != 0) {
387-
// PGraphicsOpenGL.finalizeRenderBufferObject(glMultisample, context);
388-
// glMultisample = 0;
389-
// }
390-
// if (glDepthStencil != 0) {
391-
// PGraphicsOpenGL.finalizeRenderBufferObject(glDepthStencil, context);
392-
// glDepthStencil = 0;
393-
// }
394368
}
395369

396370

@@ -400,18 +374,6 @@ protected boolean contextIsOutdated() {
400374
boolean outdated = !pgl.contextIsCurrent(context);
401375
if (outdated) {
402376
dispose();
403-
// PGraphicsOpenGL.removeFrameBufferObject(glFbo, context);
404-
// PGraphicsOpenGL.removeRenderBufferObject(glDepth, context);
405-
// PGraphicsOpenGL.removeRenderBufferObject(glStencil, context);
406-
// PGraphicsOpenGL.removeRenderBufferObject(glDepthStencil, context);
407-
// PGraphicsOpenGL.removeRenderBufferObject(glMultisample, context);
408-
//
409-
// glFbo = 0;
410-
// glDepth = 0;
411-
// glStencil = 0;
412-
// glDepthStencil = 0;
413-
// glMultisample = 0;
414-
415377
for (int i = 0; i < numColorBuffers; i++) {
416378
colorBufferTex[i] = null;
417379
}
@@ -426,7 +388,6 @@ protected void initColorBufferMultisample() {
426388
pg.pushFramebuffer();
427389
pg.setFramebuffer(this);
428390

429-
// glMultisample = PGraphicsOpenGL.createRenderBufferObject(context, pgl);
430391
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glMultisample);
431392
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples,
432393
PGL.RGBA8, width, height);
@@ -447,7 +408,6 @@ protected void initPackedDepthStencilBuffer() {
447408
pg.pushFramebuffer();
448409
pg.setFramebuffer(this);
449410

450-
// glDepthStencil = PGraphicsOpenGL.createRenderBufferObject(context, pgl);
451411
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepthStencil);
452412

453413
if (multisample) {
@@ -477,7 +437,6 @@ protected void initDepthBuffer() {
477437
pg.pushFramebuffer();
478438
pg.setFramebuffer(this);
479439

480-
// glDepth = PGraphicsOpenGL.createRenderBufferObject(context, pgl);
481440
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepth);
482441

483442
int glConst = PGL.DEPTH_COMPONENT16;
@@ -513,7 +472,6 @@ protected void initStencilBuffer() {
513472
pg.pushFramebuffer();
514473
pg.setFramebuffer(this);
515474

516-
// glStencil = PGraphicsOpenGL.createRenderBufferObject(context, pgl);
517475
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glStencil);
518476

519477
int glConst = PGL.STENCIL_INDEX1;

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 6 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -602,27 +602,13 @@ public void setSize(int iwidth, int iheight) {
602602

603603
@Override
604604
public void dispose() { // PGraphics
605-
super.dispose();
606-
607-
if (primaryGraphics) {
608-
// Swap buffers the end to make sure that no
609-
// garbage is shown on the screen, this particularly
610-
// affects non-interactive sketches on windows that
611-
// render only 1 frame, so no enough rendering
612-
// iterations have been conducted so far to properly
613-
// initialize all the buffers.
614-
pgl.swapBuffers();
615-
}
616-
617605
if (asyncPixelReader != null) {
618606
asyncPixelReader.dispose();
619607
asyncPixelReader = null;
620608
}
621609

622-
deleteSurfaceTextures();
623-
if (primaryGraphics) {
624-
deleteDefaultShaders();
625-
} else {
610+
if (!primaryGraphics) {
611+
deleteSurfaceTextures();
626612
FrameBuffer ofb = offscreenFramebuffer;
627613
FrameBuffer mfb = multisampleFramebuffer;
628614
if (ofb != null) {
@@ -634,6 +620,8 @@ public void dispose() { // PGraphics
634620
}
635621

636622
pgl.dispose();
623+
624+
super.dispose();
637625
}
638626

639627

@@ -700,7 +688,8 @@ public PSurface createSurface() { // ignore
700688

701689
public boolean saveImpl(String filename) {
702690
return super.save(filename); // ASYNC save frame using PBOs not yet available on Android
703-
/*
691+
692+
/*
704693
if (getHint(DISABLE_ASYNC_SAVEFRAME)) {
705694
// Act as an opaque surface for the purposes of saving.
706695
if (primaryGraphics) {
@@ -1242,11 +1231,6 @@ protected void createPolyBuffers() {
12421231
if (!polyBuffersCreated || polyBuffersContextIsOutdated()) {
12431232
polyBuffersContext = pgl.getCurrentContext();
12441233

1245-
// int sizef = INIT_VERTEX_BUFFER_SIZE * PGL.SIZEOF_FLOAT;
1246-
// int sizei = INIT_VERTEX_BUFFER_SIZE * PGL.SIZEOF_INT;
1247-
// int sizex = INIT_INDEX_BUFFER_SIZE * PGL.SIZEOF_INDEX;
1248-
1249-
12501234
bufPolyVertex = new VertexBuffer(this, PGL.ARRAY_BUFFER, 3, PGL.SIZEOF_FLOAT);
12511235
bufPolyColor = new VertexBuffer(this, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT);
12521236
bufPolyNormal = new VertexBuffer(this, PGL.ARRAY_BUFFER, 3, PGL.SIZEOF_FLOAT);
@@ -1259,44 +1243,6 @@ protected void createPolyBuffers() {
12591243
bufPolyIndex = new VertexBuffer(this, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, true);
12601244
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
12611245

1262-
1263-
// glPolyVertex = createVertexBufferObject(polyBuffersContext, pgl);
1264-
// pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyVertex);
1265-
// pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW);
1266-
//
1267-
// glPolyColor = createVertexBufferObject(polyBuffersContext, pgl);
1268-
// pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyColor);
1269-
// pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
1270-
//
1271-
// glPolyNormal = createVertexBufferObject(polyBuffersContext, pgl);
1272-
// pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyNormal);
1273-
// pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW);
1274-
//
1275-
// glPolyTexcoord = createVertexBufferObject(polyBuffersContext, pgl);
1276-
// pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyTexcoord);
1277-
// pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, null, PGL.STATIC_DRAW);
1278-
//
1279-
// glPolyAmbient = createVertexBufferObject(polyBuffersContext, pgl);
1280-
// pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyAmbient);
1281-
// pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
1282-
//
1283-
// glPolySpecular = createVertexBufferObject(polyBuffersContext, pgl);
1284-
// pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolySpecular);
1285-
// pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
1286-
//
1287-
// glPolyEmissive = createVertexBufferObject(polyBuffersContext, pgl);
1288-
// pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyEmissive);
1289-
// pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW);
1290-
//
1291-
// glPolyShininess = createVertexBufferObject(polyBuffersContext, pgl);
1292-
// pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyShininess);
1293-
// pgl.bufferData(PGL.ARRAY_BUFFER, sizef, null, PGL.STATIC_DRAW);
1294-
// pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
1295-
// glPolyIndex = createVertexBufferObject(polyBuffersContext, pgl);
1296-
// pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPolyIndex);
1297-
// pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, sizex, null, PGL.STATIC_DRAW);
1298-
// pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
1299-
13001246
polyBuffersCreated = true;
13011247
}
13021248

@@ -7007,20 +6953,6 @@ public void resetShader(int kind) {
70076953
}
70086954

70096955

7010-
protected void deleteDefaultShaders() {
7011-
// The default shaders contains references to the PGraphics object that
7012-
// creates them, so when restarting the renderer, those references should
7013-
// dissapear.
7014-
defColorShader = null;
7015-
defTextureShader = null;
7016-
defLightShader = null;
7017-
defTexlightShader = null;
7018-
defLineShader = null;
7019-
defPointShader = null;
7020-
maskShader = null;
7021-
}
7022-
7023-
70246956
protected PShader getPolyShader(boolean lit, boolean tex) {
70256957
PShader shader;
70266958
PGraphicsOpenGL ppg = getPrimaryPG();

core/src/processing/opengl/PShader.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,6 @@ public void init() {
903903
protected void create() {
904904
context = pgl.getCurrentContext();
905905
glres = new GLResourceShader(this);
906-
907-
// glProgram = PGraphicsOpenGL.createGLSLProgramObject(context, pgl);
908-
// glVertex = PGraphicsOpenGL.createGLSLVertShaderObject(context, pgl);
909-
// glFragment = PGraphicsOpenGL.createGLSLFragShaderObject(context, pgl);
910906
}
911907

912908

@@ -950,9 +946,6 @@ protected void validate() {
950946
protected boolean contextIsOutdated() {
951947
boolean outdated = !pgl.contextIsCurrent(context);
952948
if (outdated) {
953-
// PGraphicsOpenGL.removeGLSLProgramObject(glProgram, context);
954-
// PGraphicsOpenGL.removeGLSLVertShaderObject(glVertex, context);
955-
// PGraphicsOpenGL.removeGLSLFragShaderObject(glFragment, context);
956949
dispose();
957950
}
958951
return outdated;
@@ -974,8 +967,6 @@ protected boolean hasFragmentShader() {
974967
* @param shaderSource a string containing the shader's code
975968
*/
976969
protected boolean compileVertexShader() {
977-
// glVertex = PGraphicsOpenGL.createGLSLVertShaderObject(context, pgl);
978-
979970
pgl.shaderSource(glVertex, PApplet.join(vertexShaderSource, "\n"));
980971
pgl.compileShader(glVertex);
981972

@@ -995,8 +986,6 @@ protected boolean compileVertexShader() {
995986
* @param shaderSource a string containing the shader's code
996987
*/
997988
protected boolean compileFragmentShader() {
998-
// glFragment = PGraphicsOpenGL.createGLSLFragShaderObject(context, pgl);
999-
1000989
pgl.shaderSource(glFragment, PApplet.join(fragmentShaderSource, "\n"));
1001990
pgl.compileShader(glFragment);
1002991

@@ -1020,18 +1009,6 @@ protected void dispose() {
10201009
glProgram = 0;
10211010
glres = null;
10221011
}
1023-
// if (glVertex != 0) {
1024-
// PGraphicsOpenGL.deleteGLSLVertShaderObject(glVertex, context, pgl);
1025-
// glVertex = 0;
1026-
// }
1027-
// if (glFragment != 0) {
1028-
// PGraphicsOpenGL.deleteGLSLFragShaderObject(glFragment, context, pgl);
1029-
// glFragment = 0;
1030-
// }
1031-
// if (glProgram != 0) {
1032-
// PGraphicsOpenGL.deleteGLSLProgramObject(glProgram, context, pgl);
1033-
// glProgram = 0;
1034-
// }
10351012
}
10361013

10371014

0 commit comments

Comments
 (0)