Commit d68d9abdb83792e81017f2c960a06cd8ce82a0cd

Authored by Tom Robinson
1 parent 280e1b5a

Combine StencilMode and WriteToColorBuffer to RenderMode

Change-Id: I423fa10241eaf3a617f47490aa5484ed54c68594
examples/renderer-stencil/renderer-stencil-example.cpp
@@ -275,13 +275,10 @@ private: @@ -275,13 +275,10 @@ private:
275 renderer.SetTextures( textureSet ); 275 renderer.SetTextures( textureSet );
276 276
277 // Setup the renderer properties: 277 // Setup the renderer properties:
278 - // We are writing to the color buffer & culling back faces.  
279 - renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true ); 278 + // We are writing to the color buffer & culling back faces (no stencil is used for the main cube).
  279 + renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
280 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK ); 280 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
281 281
282 - // No stencil is used for the main cube.  
283 - renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::OFF );  
284 -  
285 // We do need to write to the depth buffer as other objects need to appear underneath this cube. 282 // We do need to write to the depth buffer as other objects need to appear underneath this cube.
286 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::ON ); 283 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::ON );
287 // We do not need to test the depth buffer as we are culling the back faces. 284 // We do not need to test the depth buffer as we are culling the back faces.
@@ -316,13 +313,10 @@ private: @@ -316,13 +313,10 @@ private:
316 renderer.SetTextures( planeTextureSet ); 313 renderer.SetTextures( planeTextureSet );
317 314
318 // Setup the renderer properties: 315 // Setup the renderer properties:
319 - // We are writing to the color buffer & culling back faces (as we are NOT doing depth write).  
320 - renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true ); 316 + // We are writing to the color buffer & culling back faces as we are NOT doing depth write (no stencil is used for the floor).
  317 + renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
321 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK ); 318 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
322 319
323 - // No stencil is used for the floor.  
324 - renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::OFF );  
325 -  
326 // We do not write to the depth buffer as its not needed. 320 // We do not write to the depth buffer as its not needed.
327 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF ); 321 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
328 // We do need to test the depth buffer as we need the floor to be underneath the cube. 322 // We do need to test the depth buffer as we need the floor to be underneath the cube.
@@ -360,11 +354,9 @@ private: @@ -360,11 +354,9 @@ private:
360 Renderer renderer = CreateRenderer( planeGeometry, size, false, Vector4::ONE ); 354 Renderer renderer = CreateRenderer( planeGeometry, size, false, Vector4::ONE );
361 355
362 // Setup the renderer properties: 356 // Setup the renderer properties:
363 - // The stencil plane is only for stencilling, so disable writing to color buffer.  
364 - renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, false ); 357 + // The stencil plane is only for stencilling.
  358 + renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
365 359
366 - // Enable stencil. Draw to the stencil buffer (only).  
367 - renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );  
368 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS ); 360 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS );
369 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, 1 ); 361 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, 1 );
370 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, 0xFF ); 362 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, 0xFF );
@@ -410,8 +402,9 @@ private: @@ -410,8 +402,9 @@ private:
410 renderer.SetTextures( textureSet ); 402 renderer.SetTextures( textureSet );
411 403
412 // Setup the renderer properties: 404 // Setup the renderer properties:
413 - // Write to color buffer so reflection is visible  
414 - renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true ); 405 + // Write to color buffer so reflection is visible.
  406 + // Also enable the stencil buffer, as we will be testing against it to only draw to areas within the stencil.
  407 + renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL );
415 // We cull to skip drawing the back faces. 408 // We cull to skip drawing the back faces.
416 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK ); 409 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
417 410
@@ -422,7 +415,6 @@ private: @@ -422,7 +415,6 @@ private:
422 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE ); 415 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE );
423 416
424 // Enable stencil. Here we only draw to areas within the stencil. 417 // Enable stencil. Here we only draw to areas within the stencil.
425 - renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );  
426 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::EQUAL ); 418 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::EQUAL );
427 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, 1 ); 419 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, 1 );
428 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, 0xff ); 420 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, 0xff );