Fill not total?
in
Programming Questions
•
9 months ago
Short form question: I have a PShape made with custom vertices. Each time I draw the PShape I may need to change the colour of. I would like to do:
- PShape aShape;
- method A(){
- aShape=createShape(triangles);
- //add vertices from float array with aShape.vertex(.,.,..)
- aShape.end();
- }
And in the draw, I'd like to do something like
- fill(....) or aShape.fill(....)
- shape(aShape);
but doing so, I only get the last triangle of the PShape getting a fill change!
I can hack this by
- method A(){
- fill(...);
- drawSphere();
- }
- method drawSphere(){
- beginShape();
- //vertex info
- endShape();
- }
but I'm actually displaying many of these shapes per frame, on the order of a few ten thousand. So I'd prefer only to create the shape once.
Background:
I'm basically trying to emulate something I could do in OpenGL 3.0/C++. I could send the shape(s) to the GPU once for the duration of the program, send a new colour and matrixes to the vertex shader when needed. I know I can basically write pure OpenGL 2.0/Java code but I want to avoid this overkill (how the code looks and its simplicity is equally important). I'm looking for as simplistic away to just send the one colour to the change the fill of my pshape.
Looking at the source and other documentation though, I'm unsure if I'm actually getting a speed up with the one shape (it seems to send the whole object each time?). Maybe someone with OpenGL 2.0/Processing experience could atleast say this is mote because the sphere is being sent each time anyway?
1