19#ifdef WITH_CYCLES_STANDALONE_GUI
33#ifdef WITH_CYCLES_STANDALONE_GUI
59 static int maxlen = 0;
60 const int len =
str.size();
63 for (
int i =
len; i < maxlen; i++) {
80 if (!substatus.empty()) {
81 status +=
": " + substatus;
85 status =
string_printf(
"Progress %05.2f %s", progress * 100, status.c_str());
134#ifdef WITH_CYCLES_STANDALONE_GUI
136 options.
session->set_display_driver(make_unique<OpenGLDisplayDriver>(
149#ifdef WITH_CYCLES_STANDALONE_GUI
179#ifdef WITH_CYCLES_STANDALONE_GUI
180static void display_info(
Progress &progress)
182 static double latency = 0.0;
183 static double last = 0;
184 const double elapsed =
time_dt();
188 latency = (elapsed - last);
200 if (!substatus.empty()) {
201 status +=
": " + substatus;
218 interactive.c_str());
234static void motion(
const int x,
const int y,
int button)
246 else if (button == 2) {
263static void resize(
const int width,
const int height)
280static void keyboard(
unsigned char key)
288 else if (
key ==
'r') {
293 else if (
key == 27) {
298 else if (
key ==
'p') {
304 else if (
key ==
'i') {
316 else if (
key ==
's') {
319 else if (
key ==
'a') {
322 else if (
key ==
'd') {
364static void parse_int(OIIO::cspan<const char *> argv,
int *i)
370static void parse_string(OIIO::cspan<const char *> argv, std::string *s)
388 string devicename =
"CPU";
394 if (!device_names.empty()) {
395 device_names +=
", ";
402 string ssname =
"svm";
407 bool profile =
false;
409 bool version =
false;
412 ap.usage(
"cycles [options] file.xml");
413 ap.arg(
"filename").hidden().action([&](
auto argv) {
options.
filepath = argv[0]; });
414 ap.arg(
"--device %s:DEVICE").help(
"Devices to use: " + device_names).action([&](
auto argv) {
418 ap.arg(
"--shadingsys %s:SHADINGSYSTEM")
419 .help(
"Shading system to use: svm, osl")
420 .action([&](
auto argv) {
parse_string(argv, &ssname); });
423 .help(
"Render in background, without user interface");
424 ap.arg(
"--quiet", &
options.
quiet).help(
"In background mode, don't print progress messages");
425 ap.arg(
"--samples %d:SAMPLES").help(
"Number of samples to render").action([&](
auto argv) {
428 ap.arg(
"--output %s:OUTPUT").help(
"File path to write output image").action([&](
auto argv) {
431 ap.arg(
"--threads %d:THREADS").help(
"CPU Rendering Threads").action([&](
auto argv) {
434 ap.arg(
"--width %d:WIDTH").help(
"Image width in pixelx").action([&](
auto argv) {
437 ap.arg(
"--height %d:HEIGHT").help(
"Image height in pixel").action([&](
auto argv) {
440 ap.arg(
"--tile-size %d:TILE_SIZE").help(
"Tile size in pixels").action([&](
auto argv) {
443 ap.arg(
"--list-devices", &list).help(
"List information about all available devices");
444 ap.arg(
"--profile", &profile).help(
"Enable profile logging");
445#ifdef WITH_CYCLES_LOGGING
446 ap.arg(
"--debug", &debug).help(
"Enable debug logging");
447 ap.arg(
"--verbose %d:VERBOSE").help(
"Set verbosity of the logger").action([&](
auto argv) {
451 ap.arg(
"--help", &help).help(
"Print help message");
452 ap.arg(
"--version", &version).help(
"Print version number");
454 if (ap.parse_args(argc, argv) < 0) {
455 fprintf(stderr,
"%s\n", ap.geterror().c_str());
472 info.description.c_str(),
473 (
info.display_device) ?
" (display)" :
"");
489 if (ssname ==
"osl") {
492 else if (ssname ==
"svm") {
496#ifndef WITH_CYCLES_STANDALONE_GUI
508 bool device_available =
false;
509 if (!devices.empty()) {
511 device_available =
true;
516 fprintf(stderr,
"Unknown device: %s\n", devicename.c_str());
520 else if (!(ssname ==
"osl" || ssname ==
"svm")) {
521 fprintf(stderr,
"Unknown shading system: %s\n", ssname.c_str());
527 fprintf(stderr,
"OSL shading system only works with CPU device\n");
536 fprintf(stderr,
"No file path specified\n");
545int main(
const int argc,
const char **argv)
551#ifdef WITH_CYCLES_STANDALONE_GUI
557#ifdef WITH_CYCLES_STANDALONE_GUI
static DeviceType type_from_string(const char *name)
static vector< DeviceType > available_types()
static string string_from_type(DeviceType type)
static vector< DeviceInfo > available_devices(const uint device_type_mask=DEVICE_MASK_ALL)
void get_status(string &status_, string &substatus_) const
void get_time(double &total_time_, double &render_time_) const
double get_progress() const
ShadingSystem shadingsystem
static void session_init()
static void options_parse(const int argc, const char **argv)
static BufferParams & session_buffer_params()
static void session_print_status()
static void session_exit()
static void parse_string(OIIO::cspan< const char * > argv, std::string *s)
CCL_NAMESPACE_BEGIN struct Options options
static void session_print(const string &str)
static void parse_int(OIIO::cspan< const char * > argv, int *i)
void xml_read_file(Scene *scene, const char *filepath)
#define CCL_NAMESPACE_END
#define DEVICE_MASK(type)
#define assert(assertion)
void util_logging_verbosity_set(const int verbosity)
CCL_NAMESPACE_BEGIN void util_logging_init(const char *argv0)
void util_logging_start()
MatBase< T, NumCol, NumRow > translate(const MatBase< T, NumCol, NumRow > &mat, const VectorT &translation)
string path_filename(const string &path)
void path_init(const string &path, const string &user_path)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
bool string_endswith(const string_view s, const string_view end)
string string_to_lower(const string &s)
SessionParams session_params
unique_ptr< Session > session
T * create_node(Args &&...)=delete
CCL_NAMESPACE_BEGIN double time_dt()
#define CYCLES_VERSION_STRING
void window_opengl_context_disable()
bool window_opengl_context_enable()
void window_display_info(const char *info)
void window_main_loop(const char *title, const int width, const int height, WindowInitFunc initf, WindowExitFunc exitf, WindowResizeFunc resize, WindowDisplayFunc display, WindowKeyboardFunc keyboard, WindowMotionFunc motion)
void window_display_help()