Skip to content
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

beginShape should not require call to fill() in order to render #1678

Closed
RoelandMatthijssens opened this issue Nov 24, 2016 · 10 comments
Closed
Assignees

Comments

@RoelandMatthijssens
Copy link

I have a minimal example set up that uses the webgl renderer

function setup(){
    createCanvas(100, 100, WEBGL);
}

function draw(){
    beginShape(POINTS);
    vertex(0,0);
    endShape();
} 

Running this produces the following errors:

p5.js:31516 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of rangep5.RendererGL._bindImmediateBuffers @ p5.js:31516p5.RendererGL.endShape @ p5.js:31447p5.endShape @ p5.js:15190draw @ sketch.js:8p5.redraw @ p5.js:14256(anonymous function) @ p5.js:9143
p5.js:31520 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range

I'm using the latest version of p5.js (p5.js v0.5.4 October 01, 2016)

@lmccart
Copy link
Member

lmccart commented Dec 5, 2016

the warning shouldn't prevent drawing, but it's letting you know that you haven't set a fill color so you may not see the lines. try adding a line before that setting fill:

function setup(){
  createCanvas(500,500,WEBGL);
}

function draw(){
  beginShape();
  fill(255, 0, 0);
  vertex(100,23,-100);
  vertex(200,23,-50);
  vertex(150, 45,-100);
  endShape();
}

@indefinit @mindofmatthew I think this shouldn't be necessary in immediate mode. can we set the default colors to white for fill and black for stroke?

@pikiaboy
Copy link

Can you even make a 'wire mesh' with webGL? I'm attempting to do what Daniel Shiffman did with his procedural generated terrain, but I am also coming up with the same error as OP. However, using fill(255,0,0) will let it compile, but it won't draw the shape to screen.

@JakeSchroeder
Copy link

Hey has anyone found a fix for this issue?

@scenaristeur
Copy link

Hi, i've got the same issue for my webgl-app (https://scenaristeur.github.io/graphe/):

p5.js:31517 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
p5.RendererGL._bindImmediateBuffers @ p5.js:31517
p5.js:31521 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range 

but when i had

	fill(0, 0, 0);

on the line 177 of my script https://github.com/scenaristeur/graphe/blob/master/js/sketch.js

my canvas is very, very slow, as described in this issue : #1727

I don't think it's a good solution :-/

@JakeSchroeder
Copy link

Man this sucks, I want to use p5 for webgl and this bug is preventing me. Does anyone else know of any alternatives for building 3d webgl content? Maybe three.js or something?

@limzykenneth
Copy link
Member

@JakeSchroeder WebGL mode in p5.js is still pretty much work in progress. If you are looking for something more established now, three.js is a pretty good and popular library to deal with WebGL, you can start there.

@pikiaboy
Copy link

pikiaboy commented Apr 18, 2017 via email

@bifocalpirate
Copy link

The minimal example given by the OP will work if the WEBGL parameter is omitted. However any 3d-oriented functions such as rotateX will then fail.

@pikiaboy
Copy link

pikiaboy commented Apr 18, 2017 via email

@lmccart lmccart changed the title vertexAttribPointer: index out of range for beginShape with vertexes beginShape should not require call to fill() in order to render May 10, 2017
kjhollen added a commit to kjhollen/p5.js that referenced this issue Jul 10, 2017
…enderer.

uses this.stroke and this.fill methods when the renderer is initialized,
so that all necessary gl context side effects also happen.
kjhollen added a commit to kjhollen/p5.js that referenced this issue Jul 10, 2017
… housekeeping.

made the camera tests use normalMaterial(), instead of default
stroke and fill colors.

some tests were using basicMaterial(), which no longer exists. Changed
to fill() or normalMaterial() as appropriate.

remove trailing whitespaces in tests.
kjhollen added a commit to kjhollen/p5.js that referenced this issue Jul 11, 2017
…enderer.

uses this.stroke and this.fill methods when the renderer is initialized,
so that all necessary gl context side effects also happen.
kjhollen added a commit to kjhollen/p5.js that referenced this issue Jul 11, 2017
… housekeeping.

made the camera tests use normalMaterial(), instead of default
stroke and fill colors.

some tests were using basicMaterial(), which no longer exists. Changed
to fill() or normalMaterial() as appropriate.

remove trailing whitespaces in tests.
kjhollen added a commit to kjhollen/p5.js that referenced this issue Jul 20, 2017
…enderer.

uses this.stroke and this.fill methods when the renderer is initialized,
so that all necessary gl context side effects also happen.
kjhollen added a commit to kjhollen/p5.js that referenced this issue Jul 20, 2017
… housekeeping.

made the camera tests use normalMaterial(), instead of default
stroke and fill colors.

some tests were using basicMaterial(), which no longer exists. Changed
to fill() or normalMaterial() as appropriate.

remove trailing whitespaces in tests.
kjhollen added a commit to kjhollen/p5.js that referenced this issue Jul 21, 2017
…enderer.

uses this.stroke and this.fill methods when the renderer is initialized,
so that all necessary gl context side effects also happen.

clean up gl tests:

- made the camera tests use normalMaterial(), instead of default
  stroke and fill colors.
- some tests were using basicMaterial(), which no longer exists. Changed
  to fill() or normalMaterial() as appropriate.
- remove trailing whitespaces in tests.

update conditional in _getCurShader to reflect that interleaving
immediate mode and retain mode calls requires changing shaders,
even if no change is made to fill color.
kjhollen added a commit to kjhollen/p5.js that referenced this issue Jul 21, 2017
…enderer.

uses this.stroke and this.fill methods when the renderer is initialized,
so that all necessary gl context side effects also happen.

clean up gl tests:

- made the camera tests use normalMaterial(), instead of default
  stroke and fill colors.
- some tests were using basicMaterial(), which no longer exists. Changed
  to fill() or normalMaterial() as appropriate.
- remove trailing whitespaces in tests.

update conditional in _getCurShader to reflect that interleaving
immediate mode and retain mode calls requires changing shaders,
even if no change is made to fill color.
kjhollen added a commit to kjhollen/p5.js that referenced this issue Jul 21, 2017
…enderer.

uses this.stroke and this.fill methods when the renderer is initialized,
so that all necessary gl context side effects also happen.

clean up gl tests:

- made the camera tests use normalMaterial(), instead of default
  stroke and fill colors.
- some tests were using basicMaterial(), which no longer exists. Changed
  to fill() or normalMaterial() as appropriate.
- remove trailing whitespaces in tests.

update conditional in _getCurShader to reflect that interleaving
immediate mode and retain mode calls requires changing shaders,
even if no change is made to fill color (so it is not sufficient
to just change the shader in fill; would require user to call
fill in between rect() and box() calls, for example).
@lmccart
Copy link
Member

lmccart commented Aug 4, 2017

closed with #2088 (comment)

@lmccart lmccart closed this as completed Aug 4, 2017
kjhollen added a commit to kjhollen/p5.js that referenced this issue Aug 24, 2017
…enderer.

uses this.stroke and this.fill methods when the renderer is initialized,
so that all necessary gl context side effects also happen.

clean up gl tests:

- made the camera tests use normalMaterial(), instead of default
  stroke and fill colors.
- some tests were using basicMaterial(), which no longer exists. Changed
  to fill() or normalMaterial() as appropriate.
- remove trailing whitespaces in tests.

update conditional in _getCurShader to reflect that interleaving
immediate mode and retain mode calls requires changing shaders,
even if no change is made to fill color (so it is not sufficient
to just change the shader in fill; would require user to call
fill in between rect() and box() calls, for example).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants