2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/graphics/gles/gl-extensions.h>
23 #include <EGL/eglext.h>
25 #include <dali/integration-api/debug.h>
39 GlExtensions::GlExtensions()
41 #ifdef GL_EXT_discard_framebuffer
42 mGlDiscardFramebuffer( NULL ),
44 #ifdef GL_OES_get_program_binary
45 mGlGetProgramBinaryOES( NULL ),
46 mGlProgramBinaryOES( NULL ),
52 GlExtensions::~GlExtensions()
56 void GlExtensions::DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
58 // initialize extension on first use as on some hw platforms a context
59 // has to be bound for the extensions to return correct pointer
65 #ifdef GL_EXT_discard_framebuffer
66 if( mGlDiscardFramebuffer )
68 mGlDiscardFramebuffer(target, numAttachments, attachments);
72 DALI_LOG_ERROR("Error: glDiscardFramebufferEXT extension is not available\n");
77 void GlExtensions::GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
79 // initialize extension on first use as on some hw platforms a context
80 // has to be bound for the extensions to return correct pointer
86 #ifdef GL_OES_get_program_binary
87 if (mGlGetProgramBinaryOES)
89 mGlGetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
93 DALI_LOG_ERROR("Error: glGetProgramBinaryOES extension is not available\n");
99 void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
101 // initialize extension on first use as on some hw platforms a context
102 // has to be bound for the extensions to return correct pointer
108 #ifdef GL_OES_get_program_binary
109 if (mGlProgramBinaryOES)
111 mGlProgramBinaryOES(program, binaryFormat, binary, length);
115 DALI_LOG_ERROR("Error: glProgramBinaryOES extension is not available\n");
116 DALI_ASSERT_DEBUG(0);
121 void GlExtensions::Initialize()
125 #ifdef GL_EXT_discard_framebuffer
126 mGlDiscardFramebuffer = reinterpret_cast< PFNGLDISCARDFRAMEBUFFEREXTPROC >( eglGetProcAddress("glDiscardFramebufferEXT") );
129 #ifdef GL_OES_get_program_binary
130 mGlGetProgramBinaryOES = reinterpret_cast< PFNGLGETPROGRAMBINARYOESPROC >( eglGetProcAddress("glGetProgramBinaryOES") );
131 mGlProgramBinaryOES = reinterpret_cast< PFNGLPROGRAMBINARYOESPROC >( eglGetProcAddress("glProgramBinaryOES") );
135 } // namespace ECoreX
137 } // namespace Adaptor
139 } // namespace Internal