Enable GLES 3.0 by default.
[platform/core/uifw/dali-adaptor.git] / adaptors / common / gl / gl-extensions.h
1 #ifndef __DALI_INTERNAL_GL_EXTENSION_H__
2 #define __DALI_INTERNAL_GL_EXTENSION_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22
23 #if DALI_GLES_VERSION >= 30
24 #include <GLES3/gl3.h>
25 #else
26 #include <GLES2/gl2.h>
27 #include <GLES2/gl2ext.h>
28 #endif
29
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40 namespace ECoreX
41 {
42
43 /**
44  * GlExtensions class provides GL extensions support
45  */
46 class GlExtensions
47 {
48 public:
49
50   /**
51    * Constructor
52    */
53   GlExtensions();
54
55   /**
56    * Destructor
57    */
58   ~GlExtensions();
59
60
61 public:
62
63 #if DALI_GLES_VERSION < 30
64
65   /**
66    * If the GL extension is available this function discards specified data in attachments
67    * from being copied from the target to improve performance.
68    *
69    * Usage: GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT };
70    *        DiscardFrameBufferEXT(GL_FRAMEBUFFER, 2, attachments);
71    *
72    * @param target is usually GL_FRAMEBUFFER
73    * @param numAttachments is the count of attachments
74    * @param attachments is a pointer to the attachments
75    */
76   void DiscardFrameBuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);
77
78   /**
79    * GLES extension
80    * Returns the program object's executable bytecode.
81    * @param[in] program       The program object's name/id
82    * @param[in] bufSize       The maximum number of bytes that may be written into binary
83    * @param[out] length       The actual number of bytes written into binary
84    * @param[out] binaryFormat The format of the program binary
85    * @param[out] binary       The actual program bytecode
86    */
87   void GetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
88
89   /**
90    * GLES extension
91    * Loads a program object with a program binary previously returned from GetProgramBinaryOES
92    * @param[in] program       The program object's name/id
93    * @param[in] binaryFormat  The format of the program binary
94    * @param[in] binary        The program bytecode
95    * @param[in] length        The number of bytes in binary
96    */
97   void ProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
98
99 #endif // DALI_GLES_VERSION < 30
100
101 private:
102
103   /**
104    * Lazy Initialize extensions on first use
105    */
106   void Initialize();
107
108 #if DALI_GLES_VERSION < 30
109
110 #ifdef GL_EXT_discard_framebuffer
111   PFNGLDISCARDFRAMEBUFFEREXTPROC mGlDiscardFramebuffer;
112 #endif
113
114 #ifdef GL_OES_get_program_binary
115   PFNGLGETPROGRAMBINARYOESPROC mGlGetProgramBinaryOES;
116   PFNGLPROGRAMBINARYOESPROC mGlProgramBinaryOES;
117 #endif
118
119 #endif // DALI_GLES_VERSION < 30
120
121   bool mInitialized;
122
123 };
124
125 } // namespace ECoreX
126
127 } // namespace Adaptor
128
129 } // namespace Internal
130
131 } // namespace Dali
132
133 #endif /* __DALI_INTERNAL_GL_EXTENSION_H__ */