2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/devel-api/shader-effects/shader-effect.h>
22 #include <dali/internal/event/effects/shader-effect-impl.h>
23 #include <dali/internal/event/animation/constraint-impl.h>
24 #include <dali/public-api/animation/constraint.h>
25 #include <dali/public-api/math/vector2.h>
29 const float ShaderEffect::DEFAULT_GRID_DENSITY = 40;
31 ShaderEffect::ShaderEffect()
35 ShaderEffect::ShaderEffect(Internal::ShaderEffect* internal)
40 ShaderEffect::~ShaderEffect()
44 ShaderEffect::ShaderEffect(const ShaderEffect& handle)
49 ShaderEffect& ShaderEffect::operator=(const ShaderEffect& rhs)
51 BaseHandle::operator=(rhs);
55 ShaderEffect ShaderEffect::New( const std::string& vertexShader, const std::string& fragmentShader, GeometryHints hints)
57 Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New( hints );
59 internal->SetPrograms( vertexShader, fragmentShader );
61 return ShaderEffect( internal.Get() );
64 ShaderEffect ShaderEffect::NewWithPrefix( const std::string& vertexShaderPrefix,
65 const std::string& vertexShader,
66 const std::string& fragmentShaderPrefix,
67 const std::string& fragmentShader,
70 Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New( hints );
72 internal->SetPrograms( vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
74 return ShaderEffect( internal.Get() );
77 ShaderEffect ShaderEffect::DownCast( BaseHandle handle )
79 return ShaderEffect( dynamic_cast<Dali::Internal::ShaderEffect*>(handle.GetObjectPtr()) );
82 void ShaderEffect::SetEffectImage( Image image )
84 GetImplementation(*this).SetEffectImage( image );
87 void ShaderEffect::SetUniform( const std::string& name, float value, UniformCoordinateType uniformCoordinateType )
89 GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
92 void ShaderEffect::SetUniform( const std::string& name, Vector2 value, UniformCoordinateType uniformCoordinateType )
94 GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
97 void ShaderEffect::SetUniform( const std::string& name, Vector3 value, UniformCoordinateType uniformCoordinateType )
99 GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
102 void ShaderEffect::SetUniform( const std::string& name, Vector4 value, UniformCoordinateType uniformCoordinateType )
104 GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
107 void ShaderEffect::SetUniform( const std::string& name, const Matrix& value, UniformCoordinateType uniformCoordinateType )
109 GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
112 void ShaderEffect::SetUniform( const std::string& name, const Matrix3& value, UniformCoordinateType uniformCoordinateType )
114 GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );