Hello,
So I want to play with different algorithms I have found on the web: fluid dynamics, particle systems, etc. Things that will process a 2D array, and then write out the results.
There was a Graphics::setPixel() but in this thread Jules claims it was only calling fillRect (x, y, 1, 1)
anyway.
So I look in the documentation for the Graphics class, and it says
If you have a lot of rectangles to draw, it may be more efficient to create a RectangleList and use this method [fillRectList()] than to call fillRect() multiple times.
So armed with that information: I have a single component of setSize(200, 200);
and put this into the paint method:
void paint(Graphics& g) override
{
RectangleList<int> dots;
for (int i = 0; i < cols-1; ++i)
for (int j = 0; j < rows-1; ++j)
{
dots.add(i,j,1,1);
}
g.fillRectList(dots);
}
I call repaint()
at 1Hz and my CPU goes into meltdown. App freezes.
I try adding the OpenGL module, adding an OpenGLContext context;
to my component and setting context.attachTo (*this);
in the constructor, but that makes no difference.
Am I doing anything wrong?
What’s the generally accepted right way of doing what I want to be doing?
I’ve attached the full source for completeness, but there really isn’t any more to it.