Real time graphics best practices


Hi guys,
I need to create some real time graphic components and the first one will be an oscilloscope to draw some lissajous shapes. What is the best practice to draw such kind of graphics without killing the cpu? I remember setPixel is a no go.

Thank you!


The trick is to draw the graphics on a background thread.

This could be done via an OpenGL-thread (which is maybe not stable enough for plugins at the moment) or just through an ordinary thread:
Draw the graphics periodically on a image in a background-thread, add the pointer of the image to a FIFO, trigger repaint, and than in the components paint-method, read the image from the FIFO and paint it.



I’m planing something similar, so thank you for the Information.
If the background, consisting of a solid color and probably some kind of grid lines is static, is there any possibility or benefit in layering a background image, created once in the resize function and a transparent image rendered by the background thread, just containing the line(s) of the plot?


Hello guys !

For me, drawing an image in a thread (and rendering it then with the repaint call) is probably going to help the visualisation component to work whatever happens around it (other plug-ins using a lot of CPU for example) without any important slowdown.

However, I don’t see why doing that could save some extra CPU in the ideal situation, when the component is the only thing alive in the DAW context. If the refresh rate is 60 FPS, you still need to draw the content of the image and to draw the image on the Graphics context 60 times per second.

And obviously if the operations that had to be done on the Graphics context are less hungry than drawing an image, it could be better to do everything directly in the paint function.