MCPcopy Create free account
hub / github.com/ImageEngine/cortex / doConversion

Method doConversion

src/IECoreGL/ToGLTextureConverter.cpp:72–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72IECore::RunTimeTypedPtr ToGLTextureConverter::doConversion( IECore::ConstObjectPtr src, IECore::ConstCompoundObjectPtr operands ) const
73{
74
75 TexturePtr t = nullptr;
76 IECoreImage::ImagePrimitive::ConstPtr image;
77
78 image = IECore::runTimeCast<const IECoreImage::ImagePrimitive>( src );
79
80 if ( ! image )
81 {
82
83 IECore::CompoundData::ConstPtr data = IECore::runTimeCast<const IECore::CompoundData>( src );
84 if ( !data ) {
85 throw IECore::Exception( "Invalid object supplied. ToGLTextureConverter takes an ImagePrimitive or its CompoundData representation." );
86 }
87
88 image = imageFromCompoundData( data );
89
90 }
91
92 bool r = image->channelValid( "R" );
93 bool g = image->channelValid( "G" );
94 bool b = image->channelValid( "B" );
95 bool y = image->channelValid( "Y" );
96
97 if ( !y && r && g && b )
98 {
99 t = new ColorTexture( image.get() );
100 }
101 else if ( y && !r && !g && !b )
102 {
103 t = new LuminanceTexture( image.get() );
104 }
105 else
106 {
107 if( m_createMissingRGBChannels )
108 {
109 image = createMissingChannels( image.get() );
110 t = new ColorTexture( image.get() );
111 }
112 else
113 {
114 throw IECore::Exception( "Invalid image format, ToGLTextureConverter supports RGB[A] and Y[A]." );
115 }
116 }
117
118 if ( ! t )
119 {
120 throw IECore::Exception( "Failed to create IECoreGL Texture." );
121 }
122
123
124 return t;
125}
126
127IECoreImage::ImagePrimitivePtr ToGLTextureConverter::createMissingChannels( const IECoreImage::ImagePrimitive *image ) const
128{

Callers

nothing calls this directly

Calls 2

channelValidMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected