2 * Copyright (c) 2017 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 #if DALI_GLES_VERSION < 30
42 #ifdef GL_EXT_discard_framebuffer
43 mGlDiscardFramebuffer( NULL ),
45 #ifdef GL_OES_get_program_binary
46 mGlGetProgramBinaryOES( NULL ),
47 mGlProgramBinaryOES( NULL ),
49 #endif // DALI_GLES_VERSION < 30
54 GlExtensions::~GlExtensions()
58 #if DALI_GLES_VERSION < 30
60 void GlExtensions::DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
62 // initialize extension on first use as on some hw platforms a context
63 // has to be bound for the extensions to return correct pointer
69 #ifdef GL_EXT_discard_framebuffer
70 if( mGlDiscardFramebuffer )
72 mGlDiscardFramebuffer(target, numAttachments, attachments);
76 DALI_LOG_ERROR("Error: glDiscardFramebufferEXT extension is not available\n");
81 void GlExtensions::GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
83 // initialize extension on first use as on some hw platforms a context
84 // has to be bound for the extensions to return correct pointer
90 #ifdef GL_OES_get_program_binary
91 if (mGlGetProgramBinaryOES)
93 mGlGetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
97 DALI_LOG_ERROR("Error: glGetProgramBinaryOES extension is not available\n");
103 void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
105 // initialize extension on first use as on some hw platforms a context
106 // has to be bound for the extensions to return correct pointer
112 #ifdef GL_OES_get_program_binary
113 if (mGlProgramBinaryOES)
115 mGlProgramBinaryOES(program, binaryFormat, binary, length);
119 DALI_LOG_ERROR("Error: glProgramBinaryOES extension is not available\n");
120 DALI_ASSERT_DEBUG(0);
125 void GlExtensions::Initialize()
129 #ifdef GL_EXT_discard_framebuffer
130 mGlDiscardFramebuffer = reinterpret_cast< PFNGLDISCARDFRAMEBUFFEREXTPROC >( eglGetProcAddress("glDiscardFramebufferEXT") );
133 #ifdef GL_OES_get_program_binary
134 mGlGetProgramBinaryOES = reinterpret_cast< PFNGLGETPROGRAMBINARYOESPROC >( eglGetProcAddress("glGetProgramBinaryOES") );
135 mGlProgramBinaryOES = reinterpret_cast< PFNGLPROGRAMBINARYOESPROC >( eglGetProcAddress("glProgramBinaryOES") );
139 #endif // DALI_GLES_VERSION < 30
141 } // namespace ECoreX
143 } // namespace Adaptor
145 } // namespace Internal