args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetNumberOfTextures() ) );
}
-/**
- * Set the culling mode for this material
- *
- * @method setFaceCullingMode
- * @for Material
- * @param {integer} cullingMode The culling mode for this material
- * @example
- * // face culling mode is one of the following
- * dali.MATERIAL_NONE // None of the faces should be culled
- * dali.MATERIAL_CULL_BACK // Cull back face, back face should never be shown
- * dali.MATERIAL_CULL_FRONT // Cull front face, back face should never be shown
- * dali.MATERIAL_CULL_BACK_AND_FRONT // Cull back and front faces, if the geometry is composed of triangles none of the faces will be shown
- *
- * material.setFaceCullingMode( dali.MATERIAL_NONE );
- */
-void MaterialApi::SetFaceCullingMode( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int mode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0);
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid cullingMode parameter" );
- }
- else
- {
- material.SetFaceCullingMode( static_cast<Material::FaceCullingMode>(mode) );
- }
-}
-
-/**
- * Set the blending mode.
- *
- * If blending is disabled (BLENDING_OFF) fade in and fade out animations do not work.
- *
- * @for Material
- * @method setBlendMode
- * @param { integer } mode The blending mode.
- * @example
- * // blend mode is one of the following
- * dali.BLENDING_OFF // Blending is disabled.
- * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel.
- * dali.BLENDING_ON // Blending is enabled.
- *
- * material.setBlendMode( dali.BLENDING_AUTO );
- */
-void MaterialApi::SetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int mode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid blendMode parameter" );
- }
- else
- {
- material.SetBlendMode( static_cast<Dali::BlendingMode::Type>( mode ) );
- }
-}
-
-/**
- * Retrieves the blending mode.
- *
- * @for Material
- * @method getBlendMode
- * @return { integer } blendMode
- * @example returns one of the following:
- *
- * dali.BLENDING_OFF // Blending is disabled.
- * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel.
- * dali.BLENDING_ON // Blending is enabled.
- */
-void MaterialApi::GetBlendMode( const v8::FunctionCallbackInfo<v8::Value>& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetBlendMode() ) );
-}
-
-/**
- * Specify the pixel arithmetic used when the actor is blended.
- *
- * @for Material
- * @method setBlendFunc
- * @param {integer} srcFactorRgb Source Blending RGB
- * @param {integer} destFactorRgb Destination Blending RGB
- * @param {integer} srcFactorAlpha Source Blending Alpha
- * @param {integer} destFactorAlpha Destinatino Blending Alpha
- * @example
- * //blending constants
- * dali.BLEND_FACTOR_ZERO
- * dali.BLEND_FACTOR_ONE
- * dali.BLEND_FACTOR_SRC_COLOR
- * dali.BLEND_FACTOR_ONE_MINUS_SRC_COLOR
- * dali.BLEND_FACTOR_SRC_ALPHA
- * dali.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
- * dali.BLEND_FACTOR_DST_ALPHA
- * dali.BLEND_FACTOR_ONE_MINUS_DST_ALPHA
- * dali.BLEND_FACTOR_DST_COLOR
- * dali.BLEND_FACTOR_ONE_MINUS_DST_COLOR
- * dali.BLEND_FACTOR_SRC_ALPHA_SATURATE
- * dali.BLEND_FACTOR_CONSTANT_COLOR
- * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
- * dali.BLEND_FACTOR_CONSTANT_ALPHA
- * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA
- *
- * material.setBlendFunc( dali.BLEND_FACTOR_CONSTANT_COLOR, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
- * dali.BLEND_FACTOR_CONSTANT_ALPHA, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA );
- */
-void MaterialApi::SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- int params[4];
- bool foundAllParams(false);
- V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 4, args, 0 );
- if( foundAllParams )
- {
- material.SetBlendFunc( static_cast< Dali::BlendingFactor::Type>(params[0]),
- static_cast< Dali::BlendingFactor::Type>(params[1]),
- static_cast< Dali::BlendingFactor::Type>(params[2]),
- static_cast< Dali::BlendingFactor::Type>(params[3]) );
- }
- else
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid blendFunc parameter");
- }
-}
-
-/**
- * Query the pixel arithmetic used when the actor is blended.
- *
- * @for Material
- * @method getBlendFunc
- * @return {Object} Blend properties
- * @example Blend properties object has 4 fields
- *
- * blendProperties.sourceRgb // source rgb enum
- * blendProperties.destinationRgb // destination rgb enum
- * blendProperties.sourceAlpha source // alpha enum
- * blendProperties.destinationAlpha // destination alpha enum
- */
-void MaterialApi::GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- // Pass by reference doesn't work in Javascript
- // For now just return a vector 4...
-
- BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha;
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
-
- v8::Local<v8::Object> blendProperties = v8::Object::New( isolate );
-
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceRgb" ), v8::Integer::New( isolate, srcFactorRgb) );
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationRgb" ), v8::Integer::New( isolate, destFactorRgb ) );
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceAlpha" ), v8::Integer::New( isolate, srcFactorAlpha ) );
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationAlpha" ), v8::Integer::New( isolate, destFactorAlpha ) );
-
- args.GetReturnValue().Set( blendProperties );
-}
-
-/**
- * Specify the equation used when the actor is blended.
- *
- * @for Material
- * @method setBlendEquation
- * @param { integer } equationRgb The equation used for combining red, green, and blue components.
- * @param { integer } equationAlpha The equation used for combining the alpha component.
- * @example
- * // blend equation is one of the following
- * dali.BLEND_EQUATION_ADD
- * dali.BLEND_EQUATION_SUBTRACT
- * dali.BLEND_EQUATION_REVERSE_SUBTRACT
- *
- * material.setBlendEquation( dali.BLEND_EQUATION_ADD, dali.BLEND_EQUATION_REVERSE_SUBTRACT );
- */
-void MaterialApi::SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- int params[2];
- bool foundAllParams(false);
- V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 2, args, 0 );
- if( foundAllParams )
- {
- material.SetBlendEquation( static_cast< BlendingEquation::Type>(params[0]), static_cast< BlendingEquation::Type>(params[1]) );
- }
- else
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid BlendEquation parameter");
- }
-}
-
-/**
- * Query the equation used when the actor is blended.
- *
- * @for Material
- * @method getBlendEquation
- * @return {Object} Blend equations
- * @example Blend equations object has 2 fields
- *
- * blendEquations.equationRgb // equation used for combining rgb components
- * blendEquations.equationAlpha // equation used for combining alpha components
- */
-void MaterialApi::GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- // Pass by reference doesn't work in Javascript
- // For now just return a vector 2...
-
- BlendingEquation::Type equationRgb, equationAlpha;
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- material.GetBlendEquation( equationRgb, equationAlpha );
-
- v8::Local<v8::Object> blendEquations = v8::Object::New( isolate );
-
- blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationRgb" ), v8::Integer::New( isolate, equationRgb) );
- blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationAlpha" ), v8::Integer::New( isolate, equationAlpha ) );
-
- args.GetReturnValue().Set( blendEquations );
-}
-
} // namespace V8Plugin
} // namespace Dali