X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fgraphics%2Fgles-impl%2Fgles-graphics-buffer.cpp;h=ed72c221b14a797b5413aa8c932ce355ea72148d;hb=806a9fe4f62159bf09fb1c1b78bbec211af879de;hp=2e4d4dc1f0a5bbbbf0444547cae6758f6219c18b;hpb=ed6148202ef7f9086818070ffa8d98db83d52f95;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/graphics/gles-impl/gles-graphics-buffer.cpp b/dali/internal/graphics/gles-impl/gles-graphics-buffer.cpp index 2e4d4dc..ed72c22 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-buffer.cpp +++ b/dali/internal/graphics/gles-impl/gles-graphics-buffer.cpp @@ -83,10 +83,16 @@ void Buffer::InitializeCPUBuffer() void Buffer::InitializeGPUBuffer() { - auto gl = mController.GetGL(); + auto context = mController.GetCurrentContext(); + auto gl = mController.GetGL(); + if(!gl || !context) + { + return; + } + gl->GenBuffers(1, &mBufferId); - gl->BindBuffer(GL_ARRAY_BUFFER, mBufferId); - gl->BufferData(GL_ARRAY_BUFFER, mCreateInfo.size, nullptr, GL_STATIC_DRAW); + context->BindBuffer(GL_ARRAY_BUFFER, mBufferId); + gl->BufferData(GL_ARRAY_BUFFER, GLsizeiptr(mCreateInfo.size), nullptr, GL_STATIC_DRAW); } void Buffer::DestroyResource() @@ -109,7 +115,10 @@ void Buffer::DestroyResource() else { auto gl = mController.GetGL(); - gl->DeleteBuffers(1, &mBufferId); + if(gl) + { + gl->DeleteBuffers(1, &mBufferId); + } } } @@ -120,7 +129,12 @@ void Buffer::DiscardResource() void Buffer::Bind(Graphics::BufferUsage bindingTarget) const { - auto gl = mController.GetGL(); + auto context = mController.GetCurrentContext(); + auto gl = mController.GetGL(); + if(!gl || !context) + { + return; + } // CPU allocated buffer may be bound only as Uniform Buffer // on special binding point @@ -139,12 +153,12 @@ void Buffer::Bind(Graphics::BufferUsage bindingTarget) const { case Graphics::BufferUsage::VERTEX_BUFFER: { - gl->BindBuffer(GL_ARRAY_BUFFER, mBufferId); + context->BindBuffer(GL_ARRAY_BUFFER, mBufferId); break; } case Graphics::BufferUsage::INDEX_BUFFER: { - gl->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBufferId); + context->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBufferId); break; } default: @@ -155,4 +169,4 @@ void Buffer::Bind(Graphics::BufferUsage bindingTarget) const } } -} // namespace Dali::Graphics::GLES \ No newline at end of file +} // namespace Dali::Graphics::GLES