paysages3d/src/interface/commandline/render.cpp

43 lines
958 B
C++
Raw Normal View History

2015-09-09 22:40:47 +00:00
#include "Thread.h"
#include "SoftwareCanvasRenderer.h"
class RenderThread: public Thread
{
public:
RenderThread(SoftwareCanvasRenderer *renderer, const char *outputpath):
renderer(renderer), outputpath(outputpath)
{
}
virtual void run() override
{
renderer->render();
}
private:
SoftwareCanvasRenderer *renderer;
const char *outputpath;
};
void startRender(SoftwareCanvasRenderer *renderer, const char *outputpath)
{
RenderThread thread(renderer, outputpath);
printf("\rRendering %s ... \n", outputpath);
thread.start();
while (thread.isWorking())
{
Thread::timeSleepMs(200);
printf("\rProgress : %0.1f%% ", renderer->getProgress() * 100.0);
fflush(stdout);
}
thread.join();
printf("\rSaving %s ... \n", outputpath);
remove(outputpath);
renderer->saveToDisk(outputpath);
}