#include <dali/internal/render/shaders/program.h>
#include <dali/internal/render/data-providers/node-data-provider.h>
#include <dali/internal/render/data-providers/uniform-name-cache.h>
-#include <dali/internal/render/gl-resources/texture.h>
#include <dali/internal/render/gl-resources/texture-cache.h>
#include <dali/public-api/actors/blending.h>
+#include <dali/internal/render/gl-resources/gl-texture.h>
namespace Dali
{
Render::Geometry* geometry,
unsigned int blendingBitmask,
const Vector4* blendColor,
- Dali::Renderer::FaceCullingMode faceCullingMode,
- bool preMultipliedAlphaEnabled )
+ FaceCullingMode::Type faceCullingMode,
+ bool preMultipliedAlphaEnabled,
+ DepthWriteMode::Type depthWriteMode,
+ DepthTestMode::Type depthTestMode,
+ DepthFunction::Type depthFunction )
{
- return new Renderer( dataProvider, geometry, blendingBitmask, blendColor, faceCullingMode, preMultipliedAlphaEnabled );
+ return new Renderer( dataProvider, geometry, blendingBitmask, blendColor, faceCullingMode, preMultipliedAlphaEnabled, depthWriteMode, depthTestMode, depthFunction );
}
Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
Render::Geometry* geometry,
unsigned int blendingBitmask,
const Vector4* blendColor,
- Dali::Renderer::FaceCullingMode faceCullingMode,
- bool preMultipliedAlphaEnabled)
+ FaceCullingMode::Type faceCullingMode,
+ bool preMultipliedAlphaEnabled,
+ DepthWriteMode::Type depthWriteMode,
+ DepthTestMode::Type depthTestMode,
+ DepthFunction::Type depthFunction )
: mRenderDataProvider( dataProvider ),
mContext(NULL),
mTextureCache( NULL ),
mUniformIndexMap(),
mAttributesLocation(),
mBlendingOptions(),
- mFaceCullingMode( faceCullingMode ),
+ mFaceCullingMode( faceCullingMode ),
+ mDepthFunction( depthFunction ),
mIndexedDrawFirstElement( 0 ),
mIndexedDrawElementsCount( 0 ),
- mSamplerBitfield( ImageSampler::PackBitfield( FilterMode::DEFAULT, FilterMode::DEFAULT ) ),
+ mDepthWriteMode( depthWriteMode ),
+ mDepthTestMode( depthTestMode ),
mUpdateAttributesLocation( true ),
mPremultipledAlphaEnabled( preMultipliedAlphaEnabled )
{
mUpdateAttributesLocation = true;
}
-// Note - this is currently called from UpdateThread, PrepareRenderInstructions,
-// as an optimisation.
-// @todo MESH_REWORK Should use Update thread objects only in PrepareRenderInstructions.
-bool Renderer::RequiresDepthTest() const
-{
- return mGeometry->RequiresDepthTest();
-}
-
void Renderer::SetBlending( Context& context, bool blend )
{
context.SetBlend( blend );
}
}
-bool Renderer::BindTextures( SceneGraph::TextureCache& textureCache, Program& program )
+bool Renderer::BindTextures( Context& context, SceneGraph::TextureCache& textureCache, Program& program )
{
- int textureUnit = 0;
+ unsigned int textureUnit = 0;
bool result = true;
+ std::vector<Render::Sampler*>& samplers( mRenderDataProvider->GetSamplers() );
+
std::vector<Render::Texture>& textures( mRenderDataProvider->GetTextures() );
+ GLint uniformLocation(-1);
for( size_t i(0); result && i<textures.size(); ++i )
{
ResourceId textureId = textures[i].GetTextureId();
{
GLint uniformLocation;
+ //TODO : This is a bug, result variable is being shadowed. Fix it!
bool result = program.GetSamplerUniformLocation( i, uniformLocation );
if( result && Program::UNIFORM_UNKNOWN != uniformLocation )
{
program.SetUniform1i( uniformLocation, textureUnit );
- unsigned int samplerBitfield(0);
- Render::Texture& textureMapping = textures[i];
- const Render::Sampler* sampler( textureMapping.GetSampler() );
+ unsigned int samplerBitfield(ImageSampler::DEFAULT_BITFIELD);
+ const Render::Sampler* sampler( samplers[i] );
if( sampler )
{
- samplerBitfield = ImageSampler::PackBitfield(
- static_cast< FilterMode::Type >(sampler->GetMinifyFilterMode()),
- static_cast< FilterMode::Type >(sampler->GetMagnifyFilterMode()),
- static_cast< WrapMode::Type >(sampler->GetUWrapMode()),
- static_cast< WrapMode::Type >(sampler->GetVWrapMode())
- );
- }
- else
- {
- samplerBitfield = ImageSampler::DEFAULT_BITFIELD;
+ samplerBitfield = sampler->mBitfield;
}
texture->ApplySampler( (TextureUnit)textureUnit, samplerBitfield );
}
}
}
+
+ std::vector<Render::NewTexture*>& newTextures( mRenderDataProvider->GetNewTextures() );
+ for( size_t i(0); result && i<newTextures.size(); ++i )
+ {
+ if( newTextures[i] )
+ {
+ result = program.GetSamplerUniformLocation( i, uniformLocation ) &&
+ newTextures[i]->Bind(context, textureUnit, samplers[i] );
+
+ if( result )
+ {
+ program.SetUniform1i( uniformLocation, textureUnit );
+ ++textureUnit;
+ }
+ }
+ }
+
return result;
}
-void Renderer::SetFaceCullingMode( Dali::Renderer::FaceCullingMode mode )
+void Renderer::SetFaceCullingMode( FaceCullingMode::Type mode )
{
mFaceCullingMode = mode;
}
mPremultipledAlphaEnabled = enable;
}
-void Renderer::SetSampler( unsigned int samplerBitfield )
+void Renderer::SetDepthWriteMode( DepthWriteMode::Type depthWriteMode )
+{
+ mDepthWriteMode = depthWriteMode;
+}
+
+void Renderer::SetDepthTestMode( DepthTestMode::Type depthTestMode )
+{
+ mDepthTestMode = depthTestMode;
+}
+
+DepthWriteMode::Type Renderer::GetDepthWriteMode() const
+{
+ return mDepthWriteMode;
+}
+
+DepthTestMode::Type Renderer::GetDepthTestMode() const
+{
+ return mDepthTestMode;
+}
+
+void Renderer::SetDepthFunction( DepthFunction::Type depthFunction )
+{
+ mDepthFunction = depthFunction;
+}
+
+DepthFunction::Type Renderer::GetDepthFunction() const
{
- mSamplerBitfield = samplerBitfield;
+ return mDepthFunction;
}
void Renderer::Render( Context& context,
BufferIndex bufferIndex,
const SceneGraph::NodeDataProvider& node,
SceneGraph::Shader& defaultShader,
+ const Matrix& modelMatrix,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix,
const Matrix& projectionMatrix,
// Take the program into use so we can send uniforms to it
program->Use();
- if( DALI_LIKELY( BindTextures( textureCache, *program ) ) )
+ if( DALI_LIKELY( BindTextures( context, textureCache, *program ) ) )
{
// Only set up and draw if we have textures and they are all valid
// set projection and view matrix if program has not yet received them yet this frame
- SetMatrices( *program, node.GetModelMatrix( bufferIndex ), viewMatrix, projectionMatrix, modelViewMatrix );
+ SetMatrices( *program, modelMatrix, viewMatrix, projectionMatrix, modelViewMatrix );
// set color uniform
GLint loc = program->GetUniformLocation( Program::UNIFORM_COLOR );