Closed jacquesvaneeden closed 3 months ago
Thanks for asking. Indeed the current viewer can be adapted for such a purpose (by simply hiding it).
I just added offscreen rendering. Below is an example showing how to use it. Let me know if you encounter any issuing when using it.
#include <easy3d/renderer/camera.h>
#include <easy3d/viewer/offscreen.h>
#include <easy3d/util/resource.h>
#include <easy3d/util/initializer.h>
using namespace easy3d;
int main(int argc, char** argv) {
// initialize Easy3D.
initialize();
const std::string file_name = resource::directory() + "/data/bunny.ply";
OffScreen os;
if (!os.add_model(file_name)) {
LOG(ERROR) << "failed to load model. Please make sure the file exists and format is correct.";
return EXIT_FAILURE;
}
bool success = os.render("D:\\tmp\\image.png");
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}
Thank you very much
May I suggest you add the rest of the parameters for the snapshot function. It is useful to render to a transparent background
bool OffScreen::render(const std::string& file_name, float scaling, int samples, int back_ground, bool expand) const {
return snapshot(file_name, scaling, samples, back_ground, expand);
}
Done!
Is it possible to render to a file without having a visible viewer. The viewer.Snapshot works great but, in my case, I don't want to have a visible viewer just the final rendered image file