Beispiel #1
0
vd::status
ImageOutput::WriteTile(
	vd::i32 x, vd::i32 y, vd::i32 z,
	const PixelBuffer32f& pixels, size_t offset,
	size_t xstride, size_t ystride, size_t zstride)
{
	OiioImageOutput* output = reinterpret_cast<OiioImageOutput*>(m_Handle);
	vdAssert(output != NULL);

	if(m_Format.Tiles.Width <= 0 || m_Format.Tiles.Height <= 0)
	{
		vdLogWarning("Failed to write tile to image -- invalid tile size used in image format!");
		return Status::Code::ReadError;
	}
/*	
	if(!output->write_tile (x, y, z, OiioTypeDesc::FLOAT, ((char*)pixels.Data) + offset, 
							xstride ? xstride : OiioAutoStride,
							ystride ? ystride : OiioAutoStride,
							zstride ? zstride : OiioAutoStride))
*/
	if(!output->write_tile (x, y, z, OiioTypeDesc::FLOAT, ((char*)pixels.Data)))
	{
		vdLogWarning("Failed to save tile [%d,%d,%d] to image '%s'!", x, y, z, m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Saved tile [%d,%d,%d] %d x %d (%d channels - 32bit float) from '%s'!", 
		x,y,z, m_Format.Tiles.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}
Beispiel #2
0
vd::status
ImageInput::ReadTile(
	vd::i32 x, vd::i32 y, vd::i32 z,
	PixelBuffer32f& pixels)
{
	OiioImageInput* input = reinterpret_cast<OiioImageInput*>(m_Handle);
	vdAssert(input != NULL);

	if(m_Format.Tiles.Width <= 0 || m_Format.Tiles.Height <= 0)
	{
		vdLogWarning("Failed to read tile from image -- invalid tile size used in image format!");
		return Status::Code::ReadError;
	}
	
	pixels.Setup(m_Format.Channels, m_Format.Tiles.Width * m_Format.Tiles.Height);
	
	if(!input->read_tile (x, y, z, OiioTypeDesc::FLOAT, pixels.Data))
	{
		vdLogWarning("Failed to load image from file '%s'!", m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Loaded tile [%d,%d,%d] %d x %d (%d channels - 8-bit unsigned) from '%s'!", 
		x,y,z, m_Format.Tiles.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}
Beispiel #3
0
vd::status
Application::Shutdown()
{
    m_Status = Status::Code::Exiting;
    SetActive(NULL);

    vdLogInfo("Shutting Down...");
    Runtime::System::Release(m_Runtime);
    Runtime::System::Shutdown();
    Core::System::Shutdown();
    return m_Status;
}
Beispiel #4
0
vd::status 
Shader::SetUniform(
	Symbol name, const vd::m4f32& value)
{
	if(m_Uniforms.IsUsed(name))
	{
		m_Uniforms.Set4mf(name, (vd::m4f32)value);
		return Status::Code::Success;
	}
#if defined(VD_DEBUG_SHADERS)			
	vdLogInfo("Uniform '%s' not used!", Symbol::ToString(name));
#endif
	return Status::Code::InvalidSlot;
}
Beispiel #5
0
vd::status 
Shader::SetUniform(
	Symbol name, vd::f32 x, vd::f32 y, vd::f32 z, vd::f32 w)
{
	if(m_Uniforms.IsUsed(name))
	{
		m_Uniforms.Set4f(name, vd::v4f32(x,y,z,w));
		return Status::Code::Success;
	}
#if defined(VD_DEBUG_SHADERS)			
	vdLogInfo("Uniform '%s' not used!", Symbol::ToString(name));
#endif
	return Status::Code::InvalidSlot;
}
Beispiel #6
0
vd::status 
ImageOutput::Open(
	const std::string& location, 
	const ImageFormat& format)
{	
	if(m_Handle != NULL)
	{
		Close();
	}
	
	OiioImageOutput* output = OiioImageOutput::create (location.c_str());
	if (output == NULL)
	{
		vdLogWarning("Failed to open image for file '%s'!", location.c_str());
		return Status::Code::OpenError;
	}
	
	OiioImageSpec spec;
	if(format.Width > 0)			spec.width = format.Width;
	if(format.Height > 0)			spec.height = format.Height;
	if(format.Depth > 0)			spec.depth = format.Depth;
	if(format.Tiles.Width > 0)		spec.tile_width = format.Tiles.Width;
	if(format.Tiles.Height > 0)		spec.tile_height = format.Tiles.Height;
	if(format.Tiles.Depth > 0)		spec.tile_depth = format.Tiles.Depth;
	if(format.Channels.Count > 0)	spec.nchannels = format.Channels.Count;
	
	if(!output->open(location.c_str(), spec))
	{
		vdLogWarning("Failed to open image for file '%s'!", location.c_str());
		return Status::Code::OpenError;
	}
	
	vdLogInfo("Opened image %d x %d (%d channels) for '%s'!", 
		format.Width, format.Height, format.Channels.Count, location.c_str());

	m_Format = format;
	m_Format.Width = spec.width;
	m_Format.Height = spec.height;
	m_Format.Channels.Count = spec.nchannels;
	m_Format.Tiles.Width = spec.tile_width;
	m_Format.Tiles.Height = spec.tile_height;
	m_Format.Tiles.Depth = spec.tile_depth;

	m_Location = location;
	m_IsOpen = true;
	m_Handle = reinterpret_cast<void*>(output);

	return Status::Code::Success;
}
Beispiel #7
0
vd::status
ImageOutput::Write(
	ImageBuffer32f& pixels)
{
	OiioImageOutput* output = reinterpret_cast<OiioImageOutput*>(m_Handle);
	vdAssert(output != NULL);

	if(!output->write_image(OiioTypeDesc::FLOAT, pixels.Data))
	{
		vdLogWarning("Failed to load image from file '%s'!", m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Loaded image %d x %d (%d channels - 32 bit float) F32 from '%s'!", 
		m_Format.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}
Beispiel #8
0
vd::status
ImageOutput::Write(
	ImageBuffer8u& pixels)
{
	OiioImageOutput* output = reinterpret_cast<OiioImageOutput*>(m_Handle);
	vdAssert(output != NULL);
	
	if(!output->write_image(OiioTypeDesc::UINT8, pixels.Data))
	{
		vdLogWarning("Failed to write image to '%s'!", m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Wrote image %d x %d (%d channels - 8-bit unsigned) from '%s'!", 
		m_Format.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}
Beispiel #9
0
vd::status
ImageInput::Read(
	ImageBuffer8u& pixels)
{
	OiioImageInput* input = reinterpret_cast<OiioImageInput*>(m_Handle);
	vdAssert(input != NULL);
	
	pixels.Setup(m_Format);
	
	if(!input->read_image(OiioTypeDesc::UINT8, pixels.Data))
	{
		vdLogWarning("Failed to load image from file '%s'!", m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Loaded image %d x %d (%d channels - 8-bit unsigned) from '%s'!", 
		m_Format.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}