コード例 #1
0
ファイル: classbuffer.c プロジェクト: barak/ivtools-cvs
void ClassBuffer::SearchFile (const char* path, struct stat&) {
    InputFile* f = InputFile::open(path);
    if (f == nil) {
	return;
    }
    const char* buf;
    int len = f->read(buf);
    if (len <= 0) {
	return;
    }
    if (_verbose) {
	printf("searching file %s (%d)\n", path, len);
    }

    /*
     * stupid regular expression requires writable strings to guarantee
     * null-termination
     */
    char* tbuf = new char[len + 1];
    Memory::copy(buf, tbuf, len);
    tbuf[len] = '\0';

    TextBuffer textbuf(tbuf, len, len);

    SearchTextBuffer(&textbuf, path);

    delete tbuf;
    f->close();
    delete f;
}
コード例 #2
0
ファイル: wrapper.cpp プロジェクト: matus-chochlik/oglplu2
example_wrapper::
example_wrapper(
	example_args& args,
	example_params& params,
	example_state& state
): _params(params)
 , _state(state)
 , _example(make_example(args, _params, _state))
 , _screenshot_done(false)
 , _start(clock_type::now())
 , _now(_start)
{
	assert(_example);

	_state.sync_size();
	_example->resize(_state);

	_state.center_mouse();
	_example->pointer_motion(_state);

	if(_params.doing_framedump())
	{
		textbuf(1024);
		std::cin.getline(
			_textbuf.data(),
			std::streamsize(_textbuf.size())
		);

		if(std::strncmp(
			_params.framedump_prefix().c_str(),
			_textbuf.data(),
			_textbuf.size()
		) != 0)
		{
			throw std::runtime_error(
				"Expected frame-dump prefix on stdin"
			);
		}
	}

	if(_state.multiple_tiles() && _params.auto_tiles())
	{
		glEnable(GL_SCISSOR_TEST);
	}
}
コード例 #3
0
ファイル: wrapper.cpp プロジェクト: matus-chochlik/oglplu2
void example_wrapper::render(void)
{
	assert(_example);

	bool save_frame = _params.doing_framedump();
	save_frame |= _params.doing_screenshot() &&
		(_state.exec_time() >= _params.screenshot_time());

	if(_state.multiple_tiles())
	{
		assert(_state.first_tile());
		do {
			if(_params.auto_tiles())
			{
				glScissor(
					_state.tile_x(),
					_state.tile_y(),
					_state.tile_w(),
					_state.tile_h()
				);
			}

			_example->render(_state);
			glFlush();
			
		} while(!_state.next_tile());
	}
	else _example->render(_state);

	if(save_frame)
	{
		glReadPixels(
			0, 0,
			GLsizei(_state.width()),
			GLsizei(_state.height()),
			GL_RGBA,
			GL_UNSIGNED_BYTE,
			pixels().data()
		);

		std::stringstream filename;

		if(_params.doing_framedump())
		{
			filename <<
				_params.framedump_prefix() <<
				std::setfill('0') << std::setw(6) <<
				_state.frame_number() << ".rgba";
		}
		else if(_params.doing_screenshot())
		{
			filename << _params.screenshot_path();
		}

		std::ofstream file(filename.str());
		file.write(pixels().data(), std::streamsize(pixels().size()));
		file.flush();

		if(_params.doing_framedump())
		{
			std::cout << filename.str() << std::endl;
			textbuf(filename.str().size()+1);

			std::cin.getline(
				_textbuf.data(),
				std::streamsize(_textbuf.size())
			);

			if(std::strncmp(
				filename.str().c_str(),
				_textbuf.data(),
				_textbuf.size()
			) != 0)
			{
				throw std::runtime_error(
					"Expected frame-dump filepath on stdin."
				);
			}
		}
		else if(_params.doing_screenshot())
		{
			_screenshot_done = true;
		}
	}
}