Example #1
0
void ColorTexture::construct( unsigned int width, unsigned int height, IECore::ConstDataPtr r,
	IECore::ConstDataPtr g, IECore::ConstDataPtr b, IECore::ConstDataPtr a )
{
	if( r->typeId() != g->typeId() ||
		r->typeId() != b->typeId() ||
		( a && (r->typeId() != a->typeId()) ) )
	{
		throw Exception( "Channel types do not match." );
	}

	if( r->typeId()==UCharVectorData::staticTypeId() )
	{
		castConstruct<UCharVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==CharVectorData::staticTypeId() )
	{
		castConstruct<CharVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==UIntVectorData::staticTypeId() )
	{
		castConstruct<UIntVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==IntVectorData::staticTypeId() )
	{
		castConstruct<IntVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==HalfVectorData::staticTypeId() )
	{
		castConstruct<HalfVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==FloatVectorData::staticTypeId() )
	{
		castConstruct<FloatVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==DoubleVectorData::staticTypeId() )
	{
		castConstruct<DoubleVectorData>( width, height, r, g, b, a );
	}
	else {
		throw Exception( boost::str( boost::format( "Unsupported channel type \"%s\"." ) % r->typeName() ) );
	}
}
Example #2
0
void OSLRenderer::setOption( const std::string &name, IECore::ConstDataPtr value )
{
    if( boost::starts_with( name, "osl:" ) )
    {
        const void *data = 0;
        TypeDesc typeDesc = typeDescFromData( value.get(), data );
        if( data )
        {
            m_shadingSystem->attribute( name.c_str() + 4, typeDesc, data );
        }
        else
        {
            msg( Msg::Warning, "OSLRenderer::setOption", boost::format( "Option \"%s\" has unsupported type \"%s\"" ) % name % value->typeName() );
        }
    }
    else if( boost::starts_with( name, "user:"******"OSLRenderer::setOption", boost::format( "Unsupported option \"%s\"" ) % name );
    }
    else
    {
        // option is for another renderer and can be ignored.
    }
}
void IECoreRI::SXRendererImplementation::setOption( const std::string &name, IECore::ConstDataPtr value )
{
	if( name.compare( 0, 3, "ri:" )==0 || name.compare( 0, 3, "sx:" )==0 )
	{
		switch( value->typeId() )
		{
			case IntDataTypeId :
				SxSetOption( m_stateStack.top().context.get(), name.c_str() + 3, SxInt, (void *)&(static_cast<const IntData *>( value.get() )->readable() ) );
				break;
			case FloatDataTypeId :
				SxSetOption( m_stateStack.top().context.get(), name.c_str() + 3, SxFloat, (void *)&(static_cast<const FloatData *>( value.get() )->readable() ) );
				break;
			case StringDataTypeId :
				{
					const char *s = static_cast<const StringData *>( value.get() )->readable().c_str();
					SxSetOption( m_stateStack.top().context.get(), name.c_str() + 3, SxString, &s );
					break;	
				}
			default :
				msg( Msg::Warning, "IECoreRI::SXRendererImplementation::setOption", format( "Unsupport type \"%s\"." ) % value->typeName() );
		}
	}
	else if( name.compare( 0, 5, "user:"******"IECoreRI::SXRendererImplementation::setOption", format( "Unsupport type \"%s\"." ) % value->typeName() );
		}
	}
	else if( name.find_first_of( ":" )!=string::npos )
	{
		// ignore options prefixed for some other renderer
	}
	else
	{
		msg( Msg::Warning, "IECoreRI::SXRendererImplementation::setOption", format( "Unknown option \"%s\"." ) % name );
	}
}