Esempio n. 1
0
void ParseCommandLine(int argc, const char *argv[], CMDLineArgs *args) {
	ez::ezOptionParser parser;
	parser.overview = "Converts OBJ files to Lantern Model Files";
	parser.syntax = "lmf_compiler [OPTIONS] <input obj file>";
	parser.example = "lmf_compiler -o dragon.lmf dragon.obj\n\n";

	// Help message
	parser.add(
		"", false, 1, NULL,
		"Display usage instructions",
		"-h",
		"--help"
	);

	parser.add(
		"", true, 1, NULL,
		"The output file. This can be relative or absolute.\n"
		"The file name should have the .lmf extension",
		"-o",
		"--output"
	);

	parser.parse(argc, argv);

	if (parser.isSet("-h")) {
		PrintHelpString(parser);
		exit(1);
	}

	// Check that the options are valid
	std::vector<std::string> badOptions;
	if (!parser.gotRequired(badOptions)) {
		for (std::size_t i = 0; i < badOptions.size(); ++i) {
			std::cerr << "ERROR: Missing required option " << badOptions[i] << ".\n\n";
		}
		PrintHelpString(parser);
		exit(1);
	}
	badOptions.clear();

	if (!parser.gotExpected(badOptions)) {
		for (std::size_t i = 0; i < badOptions.size(); ++i)
			std::cerr << "ERROR: Got an unexpected number of arguments for option " << badOptions[i] << ".\n\n";

		PrintHelpString(parser);
		exit(1);
	}

	// Check that we have the correct number of arguments
	if (parser.lastArgs.size() != 1) {
		std::cerr << "ERROR: Got an unexpected number of arguments.\n\n";
		PrintHelpString(parser);
		exit(1);
	}

	// Load the data
	args->inputFile = *parser.lastArgs[0];
	parser.get("-o")->getString(args->outputFile);
}
Esempio n. 2
0
	void PrintHelp() {
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glColor4f(0.f, 0.f, 0.5f, 0.5f);
		glRecti(50, 50, windowWidth - 50, windowHeight - 50);

		glColor3f(1.f, 1.f, 1.f);
		int fontOffset = windowHeight - 50 - 20;
		glRasterPos2i((windowWidth - glutBitmapLength(GLUT_BITMAP_9_BY_15, (unsigned char *)"Help & Devices")) / 2, fontOffset);
		PrintString(GLUT_BITMAP_9_BY_15, "Help & Devices");

        // Help
		fontOffset -= 30;
		PrintHelpString(60, fontOffset, "h", "toggle Help");
		fontOffset -= 17;
		PrintHelpString(60, fontOffset, "arrow Keys", "rotate camera left/right");
		fontOffset -= 17;
		PrintHelpString(60, fontOffset, "a and d", "move camera left and right");
		fontOffset -= 17;
		PrintHelpString(60, fontOffset, "w and s", "move camera forward and backward");
		fontOffset -= 17;
		PrintHelpString(60, fontOffset, "r and f", "move camera up and down");
		fontOffset -= 17;
		PrintHelpString(60, fontOffset, "PageUp and PageDown", "move camera target up and down");
		fontOffset -= 17;
		PrintHelpString(60, fontOffset, "p", "save image.ppm");
		fontOffset -= 17;
		PrintHelpString(60, fontOffset, "space", "restart animation");

		glDisable(GL_BLEND);
	}
Esempio n. 3
0
static void PrintHelpAndSettings() {
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glColor4f(0.f, 0.f, 0.f, 0.5f);
	glRecti(10, 40, session->film->GetWidth() - 10, session->film->GetHeight() - 40);
	glDisable(GL_BLEND);

	glColor3f(1.f, 1.f, 1.f);
	int fontOffset = session->film->GetHeight() - 40 - 20;
	glRasterPos2i((session->film->GetWidth() - glutBitmapLength(GLUT_BITMAP_9_BY_15, (unsigned char *)"Help & Settings & Devices")) / 2, fontOffset);
	PrintString(GLUT_BITMAP_9_BY_15, "Help & Settings & Devices");

	// Help
	fontOffset -= 25;
	PrintHelpString(15, fontOffset, "h", "toggle Help");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "arrow Keys or mouse X/Y + mouse button 0", "rotate camera");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "a, s, d, w or mouse X/Y + mouse button 1", "move camera");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "p", "save image.png (or to image.filename property value)");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "t", "toggle tonemapping");
	PrintHelpString(320, fontOffset, "n, m", "dec./inc. the screen refresh");
	fontOffset -= 15;
	PrintHelpString(320, fontOffset, "0", "OpenCL path tracing");
	fontOffset -= 15;
#if defined(WIN32)
	PrintHelpString(15, fontOffset, "o", "windows always on top");
	fontOffset -= 15;
#endif

	// Settings
	char buf[512];
	glColor3f(0.5f, 1.0f, 0.f);
	fontOffset -= 15;
	glRasterPos2i(15, fontOffset);
	PrintString(GLUT_BITMAP_8_BY_13, "Settings:");
	fontOffset -= 15;
	glRasterPos2i(20, fontOffset);
	sprintf(buf, "[Rendering time %dsecs][Screen refresh %dms]",
			int(session->renderEngine->GetRenderingTime()),
			session->renderConfig->GetScreenRefreshInterval());
	PrintString(GLUT_BITMAP_8_BY_13, buf);
	fontOffset -= 15;
	glRasterPos2i(20, fontOffset);
	sprintf(buf, "[Tonemapping %s]",
			(session->film->GetToneMapParams()->GetType() == TONEMAP_LINEAR) ? "LINEAR" : "REINHARD02");
	PrintString(GLUT_BITMAP_8_BY_13, buf);
	fontOffset -= 15;
	glRasterPos2i(20, fontOffset);

	// Intersection devices
	switch (session->renderEngine->GetEngineType()) {
		case PATHOCL: {
			PathOCLRenderEngine *engine = (PathOCLRenderEngine *)session->renderEngine;
			const vector<OpenCLIntersectionDevice *> &idevices = engine->GetIntersectionDevices();

			double minPerf = idevices[0]->GetPerformance();
			double totalPerf = idevices[0]->GetPerformance();
			for (size_t i = 1; i < idevices.size(); ++i) {
				minPerf = min(minPerf, idevices[i]->GetPerformance());
				totalPerf += idevices[i]->GetPerformance();
			}

			glColor3f(1.0f, 0.5f, 0.f);
			int offset = 45;
			size_t deviceCount = idevices.size();

			char buff[512];
			for (size_t i = 0; i < deviceCount; ++i) {
				const OpenCLDeviceDescription *desc = ((OpenCLIntersectionDevice *)idevices[i])->GetDeviceDesc();
				sprintf(buff, "[%s][Rays/sec % 3dK][Prf Idx %.2f][Wrkld %.1f%%][Mem %dM/%dM]",
						idevices[i]->GetName().c_str(),
						int(idevices[i]->GetPerformance() / 1000.0),
						idevices[i]->GetPerformance() / minPerf,
						100.0 * idevices[i]->GetPerformance() / totalPerf,
						int(desc->GetUsedMemory() / (1024 * 1024)),
						int(desc->GetMaxMemory() / (1024 * 1024)));
				glRasterPos2i(20, offset);
				PrintString(GLUT_BITMAP_8_BY_13, buff);
				offset += 15;
			}

			glRasterPos2i(15, offset);
			PrintString(GLUT_BITMAP_9_BY_15, "Rendering devices:");
			break;
		}
		default:
			assert (false);
	}
}
static void PrintHelpAndSettings() {
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glColor4f(0.f, 0.f, 0.f, 0.5f);
	glRecti(10, 20, session->film->GetWidth() - 10, session->film->GetHeight() - 20);
	glDisable(GL_BLEND);

	glColor3f(1.f, 1.f, 1.f);
	int fontOffset = session->film->GetHeight() - 20 - 20;
	glRasterPos2i((session->film->GetWidth() - glutBitmapLength(GLUT_BITMAP_9_BY_15, (unsigned char *)"Help & Settings & Devices")) / 2, fontOffset);
	PrintString(GLUT_BITMAP_9_BY_15, "Help & Settings & Devices");

	// Help
	fontOffset -= 25;
	PrintHelpString(15, fontOffset, "h", "toggle Help");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "arrow Keys or mouse X/Y + mouse button 0", "rotate camera");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "a, s, d, w or mouse X/Y + mouse button 1", "move camera");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "p", "save image.png (or to image.filename property value)");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "t", "toggle tonemapping");
	PrintHelpString(320, fontOffset, "n, m", "dec./inc. the screen refresh");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "i", "switch sampler");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "1", "OpenCL path tracing");
	PrintHelpString(320, fontOffset, "2", "CPU light tracing");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "3", "CPU path tracing");
	PrintHelpString(320, fontOffset, "4", "CPU bidir. path tracing");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "5", "Hybrid bidir. path tracing");
	PrintHelpString(320, fontOffset, "6", "Hybrid combinatorial bidir. path tracing");
	fontOffset -= 15;
	PrintHelpString(15, fontOffset, "7", "CPU bidir. VM path tracing");
	fontOffset -= 15;
#if defined(WIN32)
	PrintHelpString(15, fontOffset, "o", "windows always on top");
	fontOffset -= 15;
#endif

	// Settings
	char buf[512];
	glColor3f(0.5f, 1.0f, 0.f);
	fontOffset -= 15;
	glRasterPos2i(15, fontOffset);
	PrintString(GLUT_BITMAP_8_BY_13, "Settings:");
	fontOffset -= 15;
	glRasterPos2i(20, fontOffset);
	sprintf(buf, "[Rendering time %dsecs][Screen refresh %dms]",
			int(session->renderEngine->GetRenderingTime()),
			session->renderConfig->GetScreenRefreshInterval());
	PrintString(GLUT_BITMAP_8_BY_13, buf);
	fontOffset -= 15;
	glRasterPos2i(20, fontOffset);
	sprintf(buf, "[Render engine %s][Sampler %s][Tone mapping %s]",
			RenderEngine::RenderEngineType2String(session->renderEngine->GetEngineType()).c_str(),
			session->renderConfig->cfg.GetString("sampler.type", "RANDOM").c_str(),
			(session->film->GetToneMapParams()->GetType() == TONEMAP_LINEAR) ? "LINEAR" : "REINHARD02");
	PrintString(GLUT_BITMAP_8_BY_13, buf);
	fontOffset -= 15;
	glRasterPos2i(20, fontOffset);

	// Intersection devices
	const vector<IntersectionDevice *> &idevices = session->renderEngine->GetIntersectionDevices();

	double minPerf = idevices[0]->GetTotalPerformance();
	double totalPerf = idevices[0]->GetTotalPerformance();
	for (size_t i = 1; i < idevices.size(); ++i) {
		minPerf = min(minPerf, idevices[i]->GetTotalPerformance());
		totalPerf += idevices[i]->GetTotalPerformance();
	}

	glColor3f(1.0f, 0.5f, 0.f);
	int offset = 45;
	size_t deviceCount = idevices.size();

	char buff[512];
	for (size_t i = 0; i < deviceCount; ++i) {
		sprintf(buff, "[%s][Rays/sec %dK (%dK + %dK)][Prf Idx %.2f][Wrkld %.1f%%][Mem %dM/%dM]",
			idevices[i]->GetName().c_str(),
			int(idevices[i]->GetTotalPerformance() / 1000.0),
				int(idevices[i]->GetSerialPerformance() / 1000.0),
				int(idevices[i]->GetDataParallelPerformance() / 1000.0),
			idevices[i]->GetTotalPerformance() / minPerf,
			100.0 * idevices[i]->GetTotalPerformance() / totalPerf,
			int(idevices[i]->GetUsedMemory() / (1024 * 1024)),
			int(idevices[i]->GetMaxMemory() / (1024 * 1024)));
		glRasterPos2i(20, offset);
		PrintString(GLUT_BITMAP_8_BY_13, buff);
		offset += 15;
	}

	glRasterPos2i(15, offset);
	PrintString(GLUT_BITMAP_9_BY_15, "Rendering devices:");
}