X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Frenderers%2Frender-frame-buffer.cpp;h=44c00b022819a757f94fe87c06415236e8768f03;hb=79881246746f65474b24ea4fe14151ccef8df3f4;hp=2799893ae89544a9792d22e8a886488e8ca4ee17;hpb=74e251a7ba48158ff7b5540925d5e17b04e0e567;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/renderers/render-frame-buffer.cpp b/dali/internal/render/renderers/render-frame-buffer.cpp index 2799893..44c00b0 100644 --- a/dali/internal/render/renderers/render-frame-buffer.cpp +++ b/dali/internal/render/renderers/render-frame-buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,18 +26,35 @@ namespace Internal { namespace Render { +namespace +{ +const GLenum COLOR_ATTACHMENTS[] = +{ + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3, + GL_COLOR_ATTACHMENT4, + GL_COLOR_ATTACHMENT5, + GL_COLOR_ATTACHMENT6, + GL_COLOR_ATTACHMENT7, +}; +} -FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments ) -:mId( 0u ), - mDepthBuffer( attachments & Dali::FrameBuffer::Attachment::DEPTH ), - mStencilBuffer( attachments & Dali::FrameBuffer::Attachment::STENCIL ), - mWidth( width ), - mHeight( height ) +FrameBuffer::FrameBuffer( uint32_t width, uint32_t height, Mask attachments ) +: mId( 0u ), + mTextureId{ 0u }, + mDepthBuffer( attachments & Dali::FrameBuffer::Attachment::DEPTH ), + mStencilBuffer( attachments & Dali::FrameBuffer::Attachment::STENCIL ), + mWidth( width ), + mHeight( height ), + mColorAttachmentCount( 0u ) { } FrameBuffer::~FrameBuffer() -{} +{ +} void FrameBuffer::Destroy( Context& context ) { @@ -78,20 +95,28 @@ void FrameBuffer::Initialize(Context& context) context.BindFramebuffer( GL_FRAMEBUFFER, 0 ); } -void FrameBuffer::AttachColorTexture( Context& context, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer ) +void FrameBuffer::AttachColorTexture( Context& context, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer ) { context.BindFramebuffer( GL_FRAMEBUFFER, mId ); + const GLuint textureId = texture->GetId(); + mTextureId[mColorAttachmentCount] = textureId; + // Create a color attachment. + const GLenum iAttachment = COLOR_ATTACHMENTS[mColorAttachmentCount]; if( texture->GetType() == TextureType::TEXTURE_2D ) { - context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->GetId(), mipmapLevel ); + context.FramebufferTexture2D( GL_FRAMEBUFFER, iAttachment, texture->GetTarget(), textureId, mipmapLevel ); } else { - context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, texture->GetId(), mipmapLevel ); + context.FramebufferTexture2D( GL_FRAMEBUFFER, iAttachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, textureId, mipmapLevel ); } + ++mColorAttachmentCount; + context.DrawBuffers(mColorAttachmentCount, COLOR_ATTACHMENTS); + DALI_ASSERT_DEBUG(context.CheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + context.BindFramebuffer( GL_FRAMEBUFFER, 0 ); } @@ -100,12 +125,12 @@ void FrameBuffer::Bind( Context& context ) context.BindFramebuffer( GL_FRAMEBUFFER, mId ); } -unsigned int FrameBuffer::GetWidth() const +uint32_t FrameBuffer::GetWidth() const { return mWidth; } -unsigned int FrameBuffer::GetHeight() const +uint32_t FrameBuffer::GetHeight() const { return mHeight; }