We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › beginShape() and endShape()
Page Index Toggle Pages: 1
beginShape() and endShape() (Read 663 times)
beginShape() and endShape()
Jan 24th, 2007, 7:12pm
 
Is there a limit to the number of times a begin/endShape() block can be used inside of draw()?  Just for kicks, I'm trying to define my own Mesh, considering it to simply be a collection of Faces, each of which have any number of vertices. So to draw the mesh I just iterate through the faces and ask each of them to draw themselves. So a face does this:

Code:

void draw()
{
for (int i = 0; i < verts.length; i++)
{
verts[i].vert();
}
}


Where the vert() function is simply calling normal() and vertex() with values stored in vert[i].

The problem I am having is that only the first two faces wind up being filled with the fill color I set out in the main draw() loop. All the rest wind up wireframe as if noFill() was called after the first two faces had been drawn.

If this isn't sufficient info, I can post an applet to the web demostrating the problem.
Re: beginShape() and endShape()
Reply #1 - Jan 24th, 2007, 9:18pm
 
As far as I know, there's no limit to begin/endShape.

I think you may have to provide a complete example that shows the issue.
Re: beginShape() and endShape()
Reply #2 - Jan 26th, 2007, 11:23am
 
Make sure you have the right parameter to beginShape.

If calling...

beginShape(TRIANGLES);
vertex(30, 20);
vertex(85, 20);
vertex(85, 75);
vertex(30, 75);
endShape();


...the last vertex will be ignored. If you have four verticies you need to use TRIANGLE_STRIP, TRIANGLE_FAN, QUAD ...

Post your code it this is not the problem.


tooteloo



Page Index Toggle Pages: 1