END_TEST;
}
-//todor
int UtcDaliCameraActorSetAspectRatioP(void)
{
TestApplication application;
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
DALI_TEST_CHECK( frameBuffer );
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_DEPTH );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::DEPTH );
DALI_TEST_CHECK( frameBuffer );
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_STENCIL );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::STENCIL );
DALI_TEST_CHECK( frameBuffer );
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_DEPTH_STENCIL );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::DEPTH_STENCIL );
DALI_TEST_CHECK( frameBuffer );
END_TEST;
}
+int UtcDaliFrameBufferNew06(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::DEPTH | FrameBuffer::Attachment::STENCIL );
+
+ DALI_TEST_CHECK( frameBuffer );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliFrameBufferCopyConstructor(void)
{
TestApplication application;
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
FrameBuffer frameBufferCopy( frameBuffer );
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
FrameBuffer frameBuffer2;
DALI_TEST_CHECK( !frameBuffer2 );
TestApplication application;
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
BaseHandle handle(frameBuffer);
FrameBuffer frameBuffer2 = FrameBuffer::DownCast(handle);
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_DEPTH_STENCIL );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::DEPTH_STENCIL );
Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
frameBuffer.AttachColorTexture( texture );
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
texture.GenerateMipmaps();
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
Texture texture = Texture::New( TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height );
texture.GenerateMipmaps();
END_TEST;
}
+int UtcDaliFrameBufferAttachColorTexture04(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::DEPTH | FrameBuffer::Attachment::STENCIL );
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+ frameBuffer.AttachColorTexture( texture );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliFrameBufferGetColorTexture01(void)
{
TestApplication application;
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
frameBuffer.AttachColorTexture( texture );
unsigned int width(64);
unsigned int height(64);
- FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
frameBuffer.AttachColorTexture( texture, 0u, 1u );
RenderTask task = taskList.GetTask( 0u );
- FrameBuffer newFrameBuffer = FrameBuffer::New( 128u, 128u, FrameBuffer::COLOR );
+ FrameBuffer newFrameBuffer = FrameBuffer::New( 128u, 128u, FrameBuffer::Attachment::NONE );
task.SetFrameBuffer( newFrameBuffer );
DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
END_TEST;
RenderTask task = taskList.GetTask( 0u );
- FrameBuffer newFrameBuffer = FrameBuffer::New( 1u, 1u, FrameBuffer::COLOR );
+ FrameBuffer newFrameBuffer = FrameBuffer::New( 1u, 1u, FrameBuffer::Attachment::NONE );
task.SetFrameBuffer( newFrameBuffer );
DALI_TEST_CHECK( task.GetFrameBuffer() == newFrameBuffer );
END_TEST;
/*
- * 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.
namespace Internal
{
-FrameBufferPtr FrameBuffer::New( unsigned int width, unsigned int height, Format format )
+FrameBufferPtr FrameBuffer::New( unsigned int width, unsigned int height, unsigned int attachments )
{
- FrameBufferPtr frameBuffer( new FrameBuffer( width, height, format ) );
+ FrameBufferPtr frameBuffer( new FrameBuffer( width, height, attachments ) );
frameBuffer->Initialize();
return frameBuffer;
}
return mRenderObject;
}
-FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, Format format )
+FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments )
: mEventThreadServices( *Stage::GetCurrent() ),
mRenderObject( NULL ),
- mColor(NULL),
+ mColor( NULL ),
mWidth( width ),
mHeight( height ),
- mFormat( format )
+ mAttachments( attachments )
{
}
void FrameBuffer::Initialize()
{
- mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mFormat );
+ mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mAttachments );
AddFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject );
}
void FrameBuffer::AttachColorTexture( NewTexturePtr texture, unsigned int mipmapLevel, unsigned int layer )
{
- if( (unsigned int)(texture->GetWidth() / (1<<mipmapLevel)) != mWidth ||
- (unsigned int)(texture->GetHeight() / (1<<mipmapLevel)) != mHeight )
+ if( (unsigned int)( texture->GetWidth() / ( 1 << mipmapLevel ) ) == mWidth &&
+ (unsigned int)( texture->GetHeight() / ( 1 << mipmapLevel ) ) == mHeight )
{
- DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Size mismatch \n" );
+ mColor = texture;
+ AttachColorTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer );
}
else
{
- mColor = texture;
- AttachColorTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer );
+ DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Size mismatch \n" );
}
}
{
public:
- typedef Dali::FrameBuffer::Format Format;
-
/**
* @brief Create a new FrameBuffer
*
- * @param[in] width The width of the FrameBuffer
- * @param[in] height The height of the FrameBuffer
- * @param[in] format The format of the FrameBuffer
+ * @param[in] width The width of the FrameBuffer
+ * @param[in] height The height of the FrameBuffer
+ * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
* @return A smart-pointer to the newly allocated Texture.
*/
- static FrameBufferPtr New( unsigned int width, unsigned int height, Format format );
+ static FrameBufferPtr New( unsigned int width, unsigned int height, unsigned int attachments );
/**
* @brief Get the FrameBuffer render object
/**
* Constructor
- * @param[in] width The width of the FrameBuffer
- * @param[in] height The height of the FrameBuffer
- * @param[in] format The format of the FrameBuffer
+ * @param[in] width The width of the FrameBuffer
+ * @param[in] height The height of the FrameBuffer
+ * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
*/
- FrameBuffer( unsigned int width, unsigned int height, Format format );
+ FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments );
/**
* Second stage initialization of the Texture
private: // data
- Internal::EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
- Internal::Render::FrameBuffer* mRenderObject; ///<The Render::Texture associated to this texture
+ Internal::EventThreadServices& mEventThreadServices; ///< Used to send messages to the render thread via update thread
+ Internal::Render::FrameBuffer* mRenderObject; ///< The Render::Texture associated to this texture
NewTexturePtr mColor;
unsigned int mWidth;
unsigned int mHeight;
- Format mFormat;
+ unsigned int mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask
};
// CLASS HEADER
#include <dali/internal/render/renderers/render-frame-buffer.h>
-//INTERNAL INCLUDES
+// INTERNAL INCLUDES
#include <dali/internal/render/renderers/render-texture.h>
namespace Dali
namespace Render
{
-FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, Format format )
+FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments )
:mId( 0u ),
- mDepthBuffer( (format == Dali::FrameBuffer::COLOR_DEPTH || format == Dali::FrameBuffer::COLOR_DEPTH_STENCIL ) ? 1u : 0u ),
- mStencilBuffer( (format == Dali::FrameBuffer::COLOR_STENCIL || format == Dali::FrameBuffer::COLOR_DEPTH_STENCIL ) ? 1u : 0u ),
+ mDepthBuffer( attachments & Dali::FrameBuffer::Attachment::DEPTH ),
+ mStencilBuffer( attachments & Dali::FrameBuffer::Attachment::STENCIL ),
mWidth( width ),
mHeight( height )
{
if( mDepthBuffer )
{
- //Create a depth render target
- context.GenRenderbuffers(1, &mDepthBuffer );
- context.BindRenderbuffer(GL_RENDERBUFFER, mDepthBuffer);
- context.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight);
- context.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthBuffer);
+ // Create a depth render target.
+ context.GenRenderbuffers( 1, &mDepthBuffer );
+ context.BindRenderbuffer( GL_RENDERBUFFER, mDepthBuffer );
+ context.RenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight );
+ context.FramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthBuffer );
}
if( mStencilBuffer )
{
- //Create a stencil render target
- context.GenRenderbuffers(1, &mStencilBuffer );
- context.BindRenderbuffer(GL_RENDERBUFFER, mStencilBuffer);
- context.RenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, mWidth, mHeight);
- context.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mStencilBuffer );
+ // Create a stencil render target.
+ context.GenRenderbuffers( 1, &mStencilBuffer );
+ context.BindRenderbuffer( GL_RENDERBUFFER, mStencilBuffer );
+ context.RenderbufferStorage( GL_RENDERBUFFER, GL_STENCIL_INDEX8, mWidth, mHeight );
+ context.FramebufferRenderbuffer( GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mStencilBuffer );
}
context.BindFramebuffer( GL_FRAMEBUFFER, 0 );
{
context.BindFramebuffer( GL_FRAMEBUFFER, mId );
+ // Create a color attachment.
if( texture->GetType() == TextureType::TEXTURE_2D )
{
context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->GetId(), mipmapLevel );
{
public:
- typedef Dali::FrameBuffer::Format Format;
-
/**
* Constructor
* @param[in] width The width of the FrameBuffer
* @param[in] height The height of the FrameBuffer
- * @param[in] format The format of the FrameBuffer
+ * @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
*/
- FrameBuffer( unsigned int width, unsigned int height, Format format );
+ FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments );
/**
* Destructor
void Destroy( Context& context );
/**
- * @brief Attach a texture for color rendering
+ * @brief Attach a texture for color rendering. Valid only for Framebuffers with COLOR attachments.
* param[in] context The GL context
* @param[in] texture The texture that will be used as output when rendering
* @param[in] mipmapLevel The mipmap of the texture to be attached
} // namespace Dali
-#endif // DALI_INTERNAL_RENDER_FRAME_BUFFER_H
+#endif // DALI_INTERNAL_RENDER_FRAME_BUFFER_H
namespace Dali
{
-FrameBuffer FrameBuffer::New( unsigned int width, unsigned int height, Format format )
+FrameBuffer FrameBuffer::New( unsigned int width, unsigned int height, unsigned int attachments )
{
- Internal::FrameBufferPtr frameBuffer = Internal::FrameBuffer::New( width, height, format );
+ Internal::FrameBufferPtr frameBuffer = Internal::FrameBuffer::New( width, height, attachments );
return FrameBuffer( frameBuffer.Get() );
}
public:
/**
- * @brief Format of the FrameBuffer to be created.
- * @SINCE_1_1.43
+ * @brief The initial attachments to create the FrameBuffer with.
+ * @note The color attachment is created on calling AttachColorTexture(). If a color attachment is not required, omit this call.
+ * @note With "NONE", no attachments are created initially. However color attachments can still be added as described above.
+ *
+ * @SINCE_1_1.45
*/
- enum Format
+ struct Attachment
{
- COLOR, ///< Framebuffer will be created with color buffer @SINCE_1_1.43
- COLOR_DEPTH, ///< Framebuffer will be created with color and depth buffer @SINCE_1_1.43
- COLOR_STENCIL, ///< Framebuffer will be created with color and stencil buffer @SINCE_1_1.43
- COLOR_DEPTH_STENCIL ///< Framebuffer will be created with color, depth and stencil buffer. @note May be not supported in all devices @SINCE_1_1.43
+ enum Mask
+ {
+ NONE = 0, ///< No attachments are created initially @SINCE_1_1.45
+
+ DEPTH = 1 << 0, ///< Depth buffer bit-mask value @SINCE_1_1.45
+ STENCIL = 1 << 1, ///< Stencil buffer bit-mask value @SINCE_1_1.45
+
+ // Preset bit-mask combinations:
+ DEPTH_STENCIL = DEPTH | STENCIL ///< The Framebuffer will be created with depth and stencil buffer @SINCE_1_1.45
+ };
};
/**
* @SINCE_1_1.43
* @param[in] width The width of the FrameBuffer
* @param[in] height The height of the FrameBuffer
- * @param[in] format The format of the FrameBuffer
+ * @param[in] attachments The attachments comprising the format of the FrameBuffer (the type is int to allow multiple bitmasks to be ORd).
* @return A handle to a newly allocated FrameBuffer
*/
- static FrameBuffer New( unsigned int width, unsigned int height, Format format );
+ static FrameBuffer New( unsigned int width, unsigned int height, unsigned int attachments );
/**
* @brief Default constructor, creates an empty handle
FrameBuffer& operator=( const FrameBuffer& handle );
/**
- * @brief Attach the base LOD of a 2D texture to the framebuffer for color rendering
+ * @brief Attach the base LOD of a 2D texture to the framebuffer for color rendering.
+ * @note This causes a color attachment to be added.
*
* @SINCE_1_1.43
* @param[in] texture The texture that will be used as output when rendering
void AttachColorTexture( Texture& texture );
/**
- * @brief Attach a texture to the framebuffer for color rendering
+ * @brief Attach a texture to the framebuffer for color rendering.
+ * @note This causes a color attachment to be added.
*
* @SINCE_1_1.43
* @param[in] texture The texture that will be used as output when rendering