Load and Update pixels inside a function

Inside the function line() there is an Load and Update pixels rigth?

Is possible to use those functions (rect, line, point etc) but loading the pixels at the start of the draw function and updating at the end?

I need to use a for loop to draw a lot of lines, and my perfomance is dropping, so maybe removig the load and update pixels from the functions may increase performance.

Thank you!

1 Like

Hi,

Welcome to the forum! :wink:

If you take a look at the source code for the line() function, it looks like this :

// processing/core/src/processing/core/PGraphics.java

public void line(float x1, float y1, float x2, float y2) {
  beginShape(LINES);
  vertex(x1, y1);
  vertex(x2, y2);
  endShape(); 
}

So it’s calling the beginShape() function in addition to the endShape() function to draw a line.

I also found that the endShape() function is doing nothing (lines 1729, 1730) :

// processing/core/src/processing/core/PGraphics.java

public void endShape(int mode) {
}

Maybe someone can help to figure out how Processing really render a line?

1 Like

Look in PGraphics2D or whatever the renderer is – the render-specific PGraphics should implement endShape for OpenGL or PDF etc etc.

2 Likes

Instead of using line(), perhaps try beginShape(LINES)

1 Like