New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example 'Topics/Shader/Convay' crashes #3973

Closed
toniholzer opened this Issue Oct 8, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@toniholzer

toniholzer commented Oct 8, 2015

The 'Conway' example crashes under processing v3.0 at line 25 'pg.endDraw();'
with the error message 'NullPointerException'.
That's strange because 'pg' is used many times before and it's not crashing with processing 2.x !

There is another shaky coding in this example:
Call of 'size' uses P3D and 'createGraphics' uses P2D as renderer.
Because it's a 2d example, 'size' should use P2D too.
Nevertheless correcting this inadequacy let crash the example too!

Btw. the example link should be corrected to http://glslsandbox.com/e#207.4

Here's the original code:


// GLSL version of Conway's game of life, ported from GLSL sandbox:
// http://glsl.heroku.com/e#207.3
// Exemplifies the use of the ppixels uniform in the shader, that gives
// access to the pixels of the previous frame.
PShader conway;
PGraphics pg;
void setup() {
  size(400, 400, P3D);    
  pg = createGraphics(400, 400, P2D);
  pg.noSmooth();
  conway = loadShader("conway.glsl");
  conway.set("resolution", float(pg.width), float(pg.height));  
}
void draw() {
  conway.set("time", millis()/1000.0);
  float x = map(mouseX, 0, width, 0, 1);
  float y = map(mouseY, 0, height, 1, 0);
  conway.set("mouse", x, y);  
  pg.beginDraw();
  pg.background(0);
  pg.shader(conway);
  pg.rect(0, 0, pg.width, pg.height);
  pg.endDraw();                                        // v3.0 -> NullPointerException
  image(pg, 0, 0, width, height);
}
@toniholzer

This comment has been minimized.

Show comment
Hide comment
@toniholzer

toniholzer Oct 8, 2015

In the meantime I found that it must have something to do with the 'back buffer' of the shader.
It's used by writing the statement: uniform sampler2D backbuffer; into the shader file.
if we change the word 'ppixels' of shader file 'data/convay.glsl' to 'bufferbuffer'
the error message changes to:
'OpenGL error 1282 at bot endDraw(): invalid operation'
(what means 'bot' of this error message ??? Should it be 'line ###: ' ?)
May be the 'back buffer' of the shader is not created right ?

toniholzer commented Oct 8, 2015

In the meantime I found that it must have something to do with the 'back buffer' of the shader.
It's used by writing the statement: uniform sampler2D backbuffer; into the shader file.
if we change the word 'ppixels' of shader file 'data/convay.glsl' to 'bufferbuffer'
the error message changes to:
'OpenGL error 1282 at bot endDraw(): invalid operation'
(what means 'bot' of this error message ??? Should it be 'line ###: ' ?)
May be the 'back buffer' of the shader is not created right ?

@codeanticode

This comment has been minimized.

Show comment
Hide comment
@codeanticode

codeanticode Oct 8, 2015

Member

This is a duplicate of #3947

It has been fixed in the repo, 3.0.1 will incorporate the fix.

Member

codeanticode commented Oct 8, 2015

This is a duplicate of #3947

It has been fixed in the repo, 3.0.1 will incorporate the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment