Commit 91d540b9bd4a31a4a6d9b876386369ccf81fcb76
1 parent
2d2a5847
Remove ImageActor from Demo
Change-Id: I597a13e0c249bdbd20b33e57ecc55e16fdfa8c77
Showing
1 changed file
with
24 additions
and
9 deletions
examples/new-window/new-window-example.cpp
| @@ -99,6 +99,9 @@ void main()\n | @@ -99,6 +99,9 @@ void main()\n | ||
| 99 | ); | 99 | ); |
| 100 | 100 | ||
| 101 | const char* FRAGMENT_BLEND_SHADER = MAKE_SHADER( | 101 | const char* FRAGMENT_BLEND_SHADER = MAKE_SHADER( |
| 102 | +varying mediump vec2 vTexCoord;\n | ||
| 103 | +uniform sampler2D sTexture;\n | ||
| 104 | +uniform sampler2D sEffect;\n | ||
| 102 | uniform mediump float alpha;\n | 105 | uniform mediump float alpha;\n |
| 103 | \n | 106 | \n |
| 104 | void main()\n | 107 | void main()\n |
| @@ -265,13 +268,12 @@ void NewWindowController::AddMeshActor( Actor& parentActor ) | @@ -265,13 +268,12 @@ void NewWindowController::AddMeshActor( Actor& parentActor ) | ||
| 265 | 268 | ||
| 266 | Actor colorMeshActor = Actor::New(); | 269 | Actor colorMeshActor = Actor::New(); |
| 267 | colorMeshActor.AddRenderer( colorMeshRenderer ); | 270 | colorMeshActor.AddRenderer( colorMeshRenderer ); |
| 268 | - colorMeshActor.SetSize( 175.f,175.f ); | 271 | + colorMeshActor.SetSize( 175.f,175.f, 175.f ); |
| 269 | colorMeshActor.SetParentOrigin( ParentOrigin::CENTER ); | 272 | colorMeshActor.SetParentOrigin( ParentOrigin::CENTER ); |
| 270 | colorMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER); | 273 | colorMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER); |
| 271 | colorMeshActor.SetPosition(Vector3(0.0f, 50.0f, 0.0f)); | 274 | colorMeshActor.SetPosition(Vector3(0.0f, 50.0f, 0.0f)); |
| 272 | colorMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS ); | 275 | colorMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS ); |
| 273 | colorMeshActor.SetName("ColorMeshActor"); | 276 | colorMeshActor.SetName("ColorMeshActor"); |
| 274 | - parentActor.Add( colorMeshActor ); | ||
| 275 | 277 | ||
| 276 | // Create a textured mesh | 278 | // Create a textured mesh |
| 277 | Image effectImage = ResourceImage::New(EFFECT_IMAGE); | 279 | Image effectImage = ResourceImage::New(EFFECT_IMAGE); |
| @@ -282,13 +284,21 @@ void NewWindowController::AddMeshActor( Actor& parentActor ) | @@ -282,13 +284,21 @@ void NewWindowController::AddMeshActor( Actor& parentActor ) | ||
| 282 | 284 | ||
| 283 | Actor textureMeshActor = Actor::New(); | 285 | Actor textureMeshActor = Actor::New(); |
| 284 | textureMeshActor.AddRenderer( textureMeshRenderer ); | 286 | textureMeshActor.AddRenderer( textureMeshRenderer ); |
| 285 | - textureMeshActor.SetSize( 175.f,175.f ); | 287 | + textureMeshActor.SetSize( 175.f,175.f, 175.f ); |
| 286 | textureMeshActor.SetParentOrigin( ParentOrigin::CENTER ); | 288 | textureMeshActor.SetParentOrigin( ParentOrigin::CENTER ); |
| 287 | textureMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER); | 289 | textureMeshActor.SetAnchorPoint(AnchorPoint::TOP_CENTER); |
| 288 | textureMeshActor.SetPosition(Vector3(0.0f, 200.0f, 0.0f)); | 290 | textureMeshActor.SetPosition(Vector3(0.0f, 200.0f, 0.0f)); |
| 289 | textureMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS ); | 291 | textureMeshActor.SetOrientation( Degree(75.f), Vector3::XAXIS ); |
| 290 | textureMeshActor.SetName("TextureMeshActor"); | 292 | textureMeshActor.SetName("TextureMeshActor"); |
| 291 | - parentActor.Add( textureMeshActor ); | 293 | + |
| 294 | + Layer layer3d = Layer::New(); | ||
| 295 | + layer3d.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 296 | + layer3d.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 297 | + layer3d.SetBehavior(Layer::LAYER_3D); | ||
| 298 | + | ||
| 299 | + layer3d.Add( colorMeshActor ); | ||
| 300 | + layer3d.Add( textureMeshActor ); | ||
| 301 | + parentActor.Add(layer3d); | ||
| 292 | } | 302 | } |
| 293 | 303 | ||
| 294 | void NewWindowController::AddBlendingImageActor( Actor& parentActor ) | 304 | void NewWindowController::AddBlendingImageActor( Actor& parentActor ) |
| @@ -305,18 +315,23 @@ void NewWindowController::AddBlendingImageActor( Actor& parentActor ) | @@ -305,18 +315,23 @@ void NewWindowController::AddBlendingImageActor( Actor& parentActor ) | ||
| 305 | tmpActor.SetScale(0.25f); | 315 | tmpActor.SetScale(0.25f); |
| 306 | 316 | ||
| 307 | // create blending shader effect | 317 | // create blending shader effect |
| 308 | - ShaderEffect blendShader = ShaderEffect::New( "", FRAGMENT_BLEND_SHADER ); | ||
| 309 | - blendShader.SetEffectImage( fb2 ); | ||
| 310 | - blendShader.SetUniform("alpha", 0.5f); | 318 | + Property::Map customShader; |
| 319 | + customShader[ "fragmentShader" ] = FRAGMENT_BLEND_SHADER; | ||
| 320 | + Property::Map map; | ||
| 321 | + map[ "shader" ] = customShader; | ||
| 311 | 322 | ||
| 312 | Image baseImage = ResourceImage::New(BASE_IMAGE); | 323 | Image baseImage = ResourceImage::New(BASE_IMAGE); |
| 313 | - ImageActor blendActor = ImageActor::New( baseImage ); | 324 | + ImageView blendActor = ImageView::New( baseImage ); |
| 325 | + blendActor.SetProperty( ImageView::Property::IMAGE, map ); | ||
| 326 | + blendActor.RegisterProperty( "alpha", 0.5f ); | ||
| 327 | + | ||
| 314 | blendActor.SetParentOrigin(ParentOrigin::CENTER_RIGHT); | 328 | blendActor.SetParentOrigin(ParentOrigin::CENTER_RIGHT); |
| 315 | blendActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); | 329 | blendActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); |
| 316 | blendActor.SetPosition(Vector3(0.0f, 100.0f, 0.0f)); | 330 | blendActor.SetPosition(Vector3(0.0f, 100.0f, 0.0f)); |
| 317 | blendActor.SetSize(140, 140); | 331 | blendActor.SetSize(140, 140); |
| 318 | - blendActor.SetShaderEffect( blendShader ); | ||
| 319 | parentActor.Add(blendActor); | 332 | parentActor.Add(blendActor); |
| 333 | + | ||
| 334 | + blendActor.GetRendererAt(0u).GetMaterial().AddTexture(fb2, "sEffect"); | ||
| 320 | } | 335 | } |
| 321 | 336 | ||
| 322 | void NewWindowController::AddTextLabel( Actor& parentActor ) | 337 | void NewWindowController::AddTextLabel( Actor& parentActor ) |