Rendering many lines quickly

edited January 2015 in How To...

Hi,

I'm trying to render roughly 50k lines at 60 fps. They will have static geometry, but I want to be able to zoom in and translate.

I tried using PShape, but it scales the stroke as well, which makes it unusable. Is there a way to get around this?

I noticed other threads mentioned GLModel, but this library has not been updated for a few years.

I could use a custom shader and a VBO, but I was wondering if there was another, better, way before going into low level OpenGL.

Any ideas?

Thanks!

Tagged:

Answers

  • edited January 2015

    Maybe you can scale the stroke weight down:

    PShape s;
    
    void setup() {
      size(600, 600);
    
      s = createShape();
    
      s.beginShape();
      s.vertex(10, 10);
      s.vertex(50, 10);
      s.vertex(50, 50);
      s.vertex(10, 50);
      s.endShape();
    }
    
    
    void draw() {
      background(255);
      s.beginShape();
      s.strokeWeight(1.0);
      s.endShape();
      shape(s);
    
      float scale = 10;
      scale(scale);
      s.beginShape();
      s.strokeWeight(1.0/scale);
      s.endShape();
      shape(s);
    }
    
  • edited January 2015

    maybe you can enter all the lines (when they are constant) in a GROUP PShape in setup() and work with this. See tutorial on PShape please

Sign In or Register to comment.