Hi folks,
I'm using a QPainter to draw a 2D-Scene on a QBitmap, and this bitmap is later used by openGL as a texture. The re-drawing occurs about 20 times/second and performance matters, because it is a soft-realtime system.
What is the correct way for the rendering function to clear the entire image and start drawing?
Simply overpaint?
void SceneRenderer::render()
{
painter.fillRect(bitmap.rect(), brush_background);
doRendering();
}
void SceneRenderer::render()
{
painter.fillRect(bitmap.rect(), brush_background);
doRendering();
}
To copy to clipboard, switch view to plain text mode
cancel painting at the end in re-initialize everytime?
void SceneRenderer::render()
{
painter.begin(&bitmap);
painter.fillRect(bitmap.rect(), brush_background);
doRendering();
painter.end();
}
void SceneRenderer::render()
{
painter.begin(&bitmap);
painter.fillRect(bitmap.rect(), brush_background);
doRendering();
painter.end();
}
To copy to clipboard, switch view to plain text mode
clear the bitmap?
void SceneRenderer::render()
{
bitmap.fill(0);
painter.fillRect(bitmap.rect(), brush_background);
doRendering();
}
void SceneRenderer::render()
{
bitmap.fill(0);
painter.fillRect(bitmap.rect(), brush_background);
doRendering();
}
To copy to clipboard, switch view to plain text mode
First solution seems obvious, but I fear that all the painting from the previous calls is still stored "underneath" the visible sceen and costs time and memory despite being invisible.
Second solution seems to not have this problem, but I fear the cost of resource releasing and allocation every cycle.
Third solution is probably nonsense.
Any insight is appreciated.
Philipp
Bookmarks