Dali 3D User Interface Engine
gl-extensions.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 
18 // CLASS HEADER
19 #include "gl-extensions.h"
20 
21 // EXTERNAL INCLUDES
22 #include <EGL/egl.h>
23 #include <EGL/eglext.h>
24 
26 
27 namespace Dali
28 {
29 
30 namespace Internal
31 {
32 
33 namespace Adaptor
34 {
35 
36 namespace ECoreX
37 {
38 
40  : mInitialized( false )
41 {
42 }
43 
45 {
46 }
47 
48 #if DALI_GLES_VERSION < 30
49 
50 void GlExtensions::DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
51 {
52  // initialize extension on first use as on some hw platforms a context
53  // has to be bound for the extensions to return correct pointer
54  if( !mInitialized )
55  {
56  Initialize();
57  }
58 
59 #ifdef GL_EXT_discard_framebuffer
60  if( mGlDiscardFramebuffer )
61  {
62  mGlDiscardFramebuffer(target, numAttachments, attachments);
63  }
64  else
65  {
66  DALI_LOG_ERROR("Error: glDiscardFramebufferEXT extension is not available\n");
67  }
68 #endif
69 }
70 
71 void GlExtensions::GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
72 {
73  // initialize extension on first use as on some hw platforms a context
74  // has to be bound for the extensions to return correct pointer
75  if( !mInitialized )
76  {
77  Initialize();
78  }
79 
80 #ifdef GL_OES_get_program_binary
81  if (mGlGetProgramBinaryOES)
82  {
83  mGlGetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
84  }
85  else
86  {
87  DALI_LOG_ERROR("Error: glGetProgramBinaryOES extension is not available\n");
89  }
90 #endif
91 }
92 
93 void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
94 {
95  // initialize extension on first use as on some hw platforms a context
96  // has to be bound for the extensions to return correct pointer
97  if( !mInitialized )
98  {
99  Initialize();
100  }
101 
102 #ifdef GL_OES_get_program_binary
103  if (mGlProgramBinaryOES)
104  {
105  mGlProgramBinaryOES(program, binaryFormat, binary, length);
106  }
107  else
108  {
109  DALI_LOG_ERROR("Error: glProgramBinaryOES extension is not available\n");
111  }
112 #endif
113 }
114 
116 {
117  mInitialized = true;
118 
119 #ifdef GL_EXT_discard_framebuffer
120  mGlDiscardFramebuffer = (PFNGLDISCARDFRAMEBUFFEREXTPROC) eglGetProcAddress("glDiscardFramebufferEXT");
121 #endif
122 
123 #ifdef GL_OES_get_program_binary
124  mGlGetProgramBinaryOES = (PFNGLGETPROGRAMBINARYOESPROC) eglGetProcAddress("glGetProgramBinaryOES");
125  mGlProgramBinaryOES = (PFNGLPROGRAMBINARYOESPROC) eglGetProcAddress("glProgramBinaryOES");
126 #endif
127 }
128 
129 #endif // DALI_GLES_VERSION < 30
130 
131 } // namespace ECoreX
132 
133 } // namespace Adaptor
134 
135 } // namespace Internal
136 
137 } // namespace Dali
Dali Docs Home
Read more about Dali