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

Function attributeToColorState

src/IECoreGL/ToGLStateConverter.cpp:146–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146StateComponentPtr attributeToColorState( const IECore::Object *attribute )
147{
148 Imath::Color4f color( 1 );
149
150 if( auto vectorData = runTimeCast<const Color3fVectorData>( attribute ) )
151 {
152 const std::vector<Imath::Color3f> &v = vectorData->readable();
153 if( v.size() == 1 )
154 {
155 const Imath::Color3f &c = v[0];
156 color = Imath::Color4f( c[0], c[1], c[2], 1.0f );
157 }
158 else
159 {
160 IECore::msg( IECore::Msg::Warning, "ToGLStateConverter", "Expected array of length 1 for \"render:displayColor\"" );
161 }
162 }
163 else if( auto color4fData = runTimeCast<const Color4fData>( attribute ) )
164 {
165 color = color4fData->readable();
166 }
167 else if( auto color3fData = runTimeCast<const Color3fData>( attribute ) )
168 {
169 const Imath::Color3f &c = color3fData->readable();
170 color = Imath::Color4f( c[0], c[1], c[2], 1.0f );
171 }
172 else
173 {
174 IECore::msg( IECore::Msg::Warning, "ToGLStateConverter", "Expected Color3fData or Color4fData or Color3fVectorData for \"render:displayColor\"" );
175 }
176
177 return new Color( color );
178}
179
180typedef StateComponentPtr (*AttributeToState)( const IECore::Object *attribute );
181typedef std::map<IECore::InternedString, AttributeToState> AttributeToStateMap;

Callers

nothing calls this directly

Calls 2

readableMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected