#define DALI_RENDERER_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-// EXTERNAL INCLUDES
-#include <string> // std::string
-
// INTERNAL INCLUDES
+#include <dali/public-api/actors/blending.h> // Dali::BlendingMode, Dali::BlendingEquation, Dali::BlendingFactor
#include <dali/public-api/object/handle.h> // Dali::Handle
-#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
+#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_OBJECT_PROPERTY_START_INDEX
#include <dali/devel-api/rendering/geometry.h> // Dali::Geometry
-#include <dali/devel-api/rendering/material.h> // Dali::Material
+#include <dali/devel-api/rendering/texture-set.h> // Dali::TextureSet
namespace Dali
{
}
/**
- * @brief Renderer is a handle to an object that can be used to provide an image to a material.
+ * @brief Renderer is a handle to an object used to show content by combining a Geometry, a TextureSet and a shader
*/
class DALI_IMPORT_API Renderer : public Handle
{
public:
/**
+ * @brief Set face culling mode.
+ */
+ enum FaceCullingMode
+ {
+ NONE, ///< None of the faces should be culled
+ CULL_FRONT, ///< Cull front face, back face should never be shown
+ CULL_BACK, ///< Cull back face, back face should never be shown
+ CULL_BACK_AND_FRONT, ///< Cull back and front faces, if the geometry is composed of triangles none of the faces will be shown
+ };
+
+ /**
* @brief An enumeration of properties belonging to the Renderer class.
*/
struct Property
{
enum
{
- DEPTH_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "depth-index", type INTEGER
+ DEPTH_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "depthIndex", type INTEGER
+ FACE_CULLING_MODE, ///< name "faceCullingMode", type INTEGER
+ BLENDING_MODE, ///< name "blendingMode", type INTEGER
+ BLEND_EQUATION_RGB, ///< name "blendEquationRgb", type INTEGER
+ BLEND_EQUATION_ALPHA, ///< name "blendEquationAlpha", type INTEGER
+ BLENDING_SRC_FACTOR_RGB, ///< name "sourceBlendFactorRgb", type INTEGER
+ BLENDING_DEST_FACTOR_RGB, ///< name "destinationBlendFactorRgb", type INTEGER
+ BLENDING_SRC_FACTOR_ALPHA, ///< name "sourceBlendFactorAlpha", type INTEGER
+ BLENDING_DEST_FACTOR_ALPHA, ///< name "destinationBlendFactorAlpha", type INTEGER
+ BLENDING_COLOR, ///< name "blendingColor", type VECTOR4
+ BLEND_PRE_MULTIPLIED_ALPHA, ///< name "blendPreMultipledAlpha", type BOOLEAN
+ INDEX_RANGE_FIRST, ///< name "indexRangeFirst", type INTEGER
+ INDEX_RANGE_COUNT ///< name "indexRangeCount", type INTEGER
};
};
* @brief Creates a new Renderer object
*
* @param[in] geometry Geometry to be used by this renderer
- * @param[in] material Material to be used by this renderer
+ * @param[in] shader Shader to be used by this renderer
*/
- static Renderer New( Geometry& geometry, Material& material );
+ static Renderer New( Geometry& geometry, Shader& shader );
/**
* @brief Default constructor, creates an empty handle
Geometry GetGeometry() const;
/**
- * @brief Sets the material to be used by this renderer
+ * @brief Sets effective range of indices to draw from bound index buffer
+ * @param [in] firstElement first element to draw
+ * @param [in] elementsCount number of elements to draw
+ */
+ inline void SetIndexRange( int firstElement, int elementsCount )
+ {
+ SetProperty( Property::INDEX_RANGE_FIRST, firstElement );
+ SetProperty( Property::INDEX_RANGE_COUNT, elementsCount );
+ }
+
+ /**
+ * @brief Sets the texture set to be used by this renderer
+ *
+ * @param[in] textureSet The texture set to be used by this renderer
+ */
+ void SetTextures( TextureSet& textureSet );
+
+ /**
+ * @brief Gets the texture set used by this renderer
+ *
+ * @return The texture set used by the renderer
+ */
+ TextureSet GetTextures() const;
+
+ /**
+ * @brief Set the shader used by this renderer
+ * @param[in] shader The shader to be used by this renderer
+ */
+ void SetShader( Shader& shader );
+
+ /**
+ * @brief Get the shader used by this renderer
+ * @return THe shader used by the renderer
+ */
+ Shader GetShader() const;
+
+ /**
+ * @brief Specify the pixel arithmetic used when the actor is blended.
*
- * @param[in] material The material to be used by this renderer
+ * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed.
+ * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
+ * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
+ * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
+ *
+ * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed.
+ * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
+ * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
+ * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
*/
- void SetMaterial( Material& material );
+ void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
/**
- * @brief Gets the material used by this renderer
+ * @brief Specify the pixel arithmetic used when the actor is blended.
+ *
+ * @param[in] srcFactorRgb Specifies how the red, green, and blue source blending factors are computed.
+ * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
+ * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
+ * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE.
*
- * @return The material used by the renderer
+ * @param[in] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
+ * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR,
+ * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR,
+ * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA.
+ *
+ * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed.
+ * The options are the same as for srcFactorRgb.
+ *
+ * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed.
+ * The options are the same as for destFactorRgb.
*/
- Material GetMaterial() const;
+ void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
+ BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
/**
- * @brief Set the depth index of this renderer
+ * @brief Query the pixel arithmetic used when the actor is blended.
*
- * Renderer with higher depth indices are rendered in front of other renderers with smaller values
+ * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed.
+ * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed.
+ * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed.
+ * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed.
+ */
+ void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
+ BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
+
+ /**
+ * @brief Specify the equation used when the actor is blended.
*
- * @param[in] depthIndex The depth index of this renderer
+ * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
+ * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components.
*/
- void SetDepthIndex( int depthIndex );
+ void SetBlendEquation( BlendingEquation::Type equationRgba );
- //@todo No interface to remove geometry / material? I guess you have to throw away
- // this renderer if you don't want it to work any more...
+ /**
+ * @brief Specify the equation used when the actor is blended.
+ *
+ * @param[in] equationRgb The equation used for combining red, green, and blue components.
+ * @param[in] equationAlpha The equation used for combining the alpha component.
+ * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT.
+ */
+ void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
/**
- * @brief Get the depth index of this renderer
+ * @brief Query the equation used when the actor is blended.
*
- * @sa SetDepthIndex()
- * @return the depth index
+ * @param[out] equationRgb The equation used for combining red, green, and blue components.
+ * @param[out] equationAlpha The equation used for combining the alpha component.
*/
- int GetDepthIndex();
+ void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
public:
/**