Support surfaceless context for OpenGL ES 2
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / gl-implementation.h
1 #ifndef DALI_INTERNAL_GL_IMPLEMENTATION_H
2 #define DALI_INTERNAL_GL_IMPLEMENTATION_H
3
4 /*
5  * Copyright (c) 2019 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 #include <memory>
23 #include <cstdlib>
24 #include <GLES2/gl2.h>
25 #include <dali/integration-api/gl-abstraction.h>
26
27 // INTERNAL INCLUDES
28 #include <dali/internal/graphics/gles/gles-abstraction.h>
29 #include <dali/internal/graphics/gles/gles2-implementation.h>
30 #include <dali/internal/graphics/gles/gles3-implementation.h>
31
32 namespace Dali
33 {
34
35 namespace Internal
36 {
37
38 namespace Adaptor
39 {
40
41 /**
42  * GlImplementation is a concrete implementation for GlAbstraction.
43  * The class provides an OpenGL-ES 2.0 or 3.0 implementation.
44  * The class is provided when creating the Integration::Core object.
45  */
46 class GlImplementation : public Dali::Integration::GlAbstraction
47 {
48
49 public:
50   GlImplementation()
51     : mGlesVersion( 30 ),
52       mIsSurfacelessContextSupported( false )
53   {
54     mImpl.reset( new Gles3Implementation() );
55   }
56
57   virtual ~GlImplementation() {}
58
59   void PreRender()
60   {
61     /* Do nothing in main implementation */
62   }
63
64   void PostRender()
65   {
66     /* Do nothing in main implementation */
67   }
68
69   void SetGlesVersion( const int32_t glesVersion )
70   {
71     if( mGlesVersion != glesVersion )
72     {
73       mGlesVersion = glesVersion;
74       if( mGlesVersion >= 30 )
75       {
76         mImpl.reset( new Gles3Implementation() );
77       }
78       else
79       {
80         mImpl.reset( new Gles2Implementation() );
81       }
82     }
83   }
84
85   void SetIsSurfacelessContextSupported( const bool isSupported )
86   {
87     mIsSurfacelessContextSupported = isSupported;
88   }
89
90   bool IsSurfacelessContextSupported() const
91   {
92     return mIsSurfacelessContextSupported;
93   }
94
95   bool TextureRequiresConverting( const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage ) const
96   {
97     bool convert = ( ( imageGlFormat == GL_RGB ) && ( textureGlFormat == GL_RGBA ) );
98     if( mGlesVersion >= 30 )
99     {
100       // Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded.
101       convert = ( convert && !isSubImage );
102     }
103     return convert;
104   }
105
106   /* OpenGL ES 2.0 */
107
108   void ActiveTexture( GLenum texture )
109   {
110     glActiveTexture( texture );
111   }
112
113   void AttachShader( GLuint program, GLuint shader )
114   {
115     glAttachShader( program, shader );
116   }
117
118   void BindAttribLocation( GLuint program, GLuint index, const char* name )
119   {
120     glBindAttribLocation( program, index, name );
121   }
122
123   void BindBuffer( GLenum target, GLuint buffer )
124   {
125     glBindBuffer( target, buffer );
126   }
127
128   void BindFramebuffer( GLenum target, GLuint framebuffer )
129   {
130     glBindFramebuffer( target, framebuffer );
131   }
132
133   void BindRenderbuffer( GLenum target, GLuint renderbuffer )
134   {
135     glBindRenderbuffer( target, renderbuffer );
136   }
137
138   void BindTexture( GLenum target, GLuint texture )
139   {
140     glBindTexture( target, texture );
141   }
142
143   void BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
144   {
145     glBlendColor( red, green, blue, alpha );
146   }
147
148   void BlendEquation( GLenum mode )
149   {
150     glBlendEquation( mode );
151   }
152
153   void BlendEquationSeparate( GLenum modeRGB, GLenum modeAlpha )
154   {
155     glBlendEquationSeparate( modeRGB, modeAlpha );
156   }
157
158   void BlendFunc( GLenum sfactor, GLenum dfactor )
159   {
160     glBlendFunc( sfactor, dfactor );
161   }
162
163   void BlendFuncSeparate( GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha )
164   {
165     glBlendFuncSeparate( srcRGB, dstRGB, srcAlpha, dstAlpha );
166   }
167
168   void BufferData( GLenum target, GLsizeiptr size, const void* data, GLenum usage )
169   {
170     glBufferData( target, size, data, usage );
171   }
172
173   void BufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const void* data )
174   {
175     glBufferSubData( target, offset, size, data );
176   }
177
178   GLenum CheckFramebufferStatus( GLenum target )
179   {
180     return glCheckFramebufferStatus( target );
181   }
182
183   void Clear( GLbitfield mask )
184   {
185     glClear( mask );
186   }
187
188   void ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
189   {
190     glClearColor( red, green, blue, alpha );
191   }
192
193   void ClearDepthf( GLclampf depth )
194   {
195     glClearDepthf( depth );
196   }
197
198   void ClearStencil( GLint s )
199   {
200     glClearStencil( s );
201   }
202
203   void ColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha )
204   {
205     glColorMask( red, green, blue, alpha );
206   }
207
208   void CompileShader( GLuint shader )
209   {
210     glCompileShader( shader );
211   }
212
213   void CompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data )
214   {
215     glCompressedTexImage2D( target, level, internalformat, width, height, border, imageSize, data );
216   }
217
218   void CompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data )
219   {
220     glCompressedTexSubImage2D( target, level, xoffset, yoffset, width, height, format, imageSize, data );
221   }
222
223   void CopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
224   {
225     glCopyTexImage2D( target, level, internalformat, x, y, width, height, border );
226   }
227
228   void CopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height )
229   {
230     glCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );
231   }
232
233   GLuint CreateProgram( void )
234   {
235     return glCreateProgram();
236   }
237
238   GLuint CreateShader( GLenum type )
239   {
240     return glCreateShader( type );
241   }
242
243   void CullFace( GLenum mode )
244   {
245     glCullFace( mode );
246   }
247
248   void DeleteBuffers( GLsizei n, const GLuint* buffers )
249   {
250     glDeleteBuffers( n, buffers );
251   }
252
253   void DeleteFramebuffers( GLsizei n, const GLuint* framebuffers )
254   {
255     glDeleteFramebuffers( n, framebuffers );
256   }
257
258   void DeleteProgram( GLuint program )
259   {
260     glDeleteProgram( program );
261   }
262
263   void DeleteRenderbuffers( GLsizei n, const GLuint* renderbuffers )
264   {
265     glDeleteRenderbuffers( n, renderbuffers );
266   }
267
268   void DeleteShader( GLuint shader )
269   {
270     glDeleteShader( shader );
271   }
272
273   void DeleteTextures( GLsizei n, const GLuint* textures )
274   {
275     glDeleteTextures( n, textures );
276   }
277
278   void DepthFunc( GLenum func )
279   {
280     glDepthFunc( func );
281   }
282
283   void DepthMask( GLboolean flag )
284   {
285     glDepthMask( flag );
286   }
287
288   void DepthRangef( GLclampf zNear, GLclampf zFar )
289   {
290     glDepthRangef( zNear, zFar );
291   }
292
293   void DetachShader( GLuint program, GLuint shader )
294   {
295     glDetachShader( program, shader );
296   }
297
298   void Disable( GLenum cap )
299   {
300     glDisable( cap );
301   }
302
303   void DisableVertexAttribArray( GLuint index )
304   {
305     glDisableVertexAttribArray( index );
306   }
307
308   void DrawArrays( GLenum mode, GLint first, GLsizei count )
309   {
310     glDrawArrays( mode, first, count );
311   }
312
313   void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices )
314   {
315     glDrawElements( mode, count, type, indices );
316   }
317
318   void Enable( GLenum cap )
319   {
320     glEnable( cap );
321   }
322
323   void EnableVertexAttribArray( GLuint index )
324   {
325     glEnableVertexAttribArray( index );
326   }
327
328   void Finish( void )
329   {
330     glFinish();
331   }
332
333   void Flush( void )
334   {
335     glFlush();
336   }
337
338   void FramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer )
339   {
340     glFramebufferRenderbuffer( target, attachment, renderbuffertarget, renderbuffer );
341   }
342
343   void FramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level )
344   {
345     glFramebufferTexture2D( target, attachment, textarget, texture, level );
346   }
347
348   void FrontFace( GLenum mode )
349   {
350     glFrontFace( mode );
351   }
352
353   void GenBuffers( GLsizei n, GLuint* buffers )
354   {
355     glGenBuffers( n, buffers );
356   }
357
358   void GenerateMipmap( GLenum target )
359   {
360     glGenerateMipmap( target );
361   }
362
363   void GenFramebuffers( GLsizei n, GLuint* framebuffers )
364   {
365     glGenFramebuffers( n, framebuffers );
366   }
367
368   void GenRenderbuffers( GLsizei n, GLuint* renderbuffers )
369   {
370     glGenRenderbuffers( n, renderbuffers );
371   }
372
373   void GenTextures( GLsizei n, GLuint* textures )
374   {
375     glGenTextures( n, textures );
376   }
377
378   void GetActiveAttrib( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name )
379   {
380     glGetActiveAttrib( program, index, bufsize, length, size, type, name );
381   }
382
383   void GetActiveUniform( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name )
384   {
385     glGetActiveUniform( program, index, bufsize, length, size, type, name );
386   }
387
388   void GetAttachedShaders( GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders )
389   {
390     glGetAttachedShaders( program, maxcount, count, shaders );
391   }
392
393   int  GetAttribLocation( GLuint program, const char* name )
394   {
395     return glGetAttribLocation( program, name );
396   }
397
398   void GetBooleanv( GLenum pname, GLboolean* params )
399   {
400     glGetBooleanv( pname, params );
401   }
402
403   void GetBufferParameteriv( GLenum target, GLenum pname, GLint* params )
404   {
405     glGetBufferParameteriv( target, pname, params );
406   }
407
408   GLenum GetError( void )
409   {
410     return glGetError();
411   }
412
413   void GetFloatv( GLenum pname, GLfloat* params )
414   {
415     glGetFloatv( pname, params );
416   }
417
418   void GetFramebufferAttachmentParameteriv( GLenum target, GLenum attachment, GLenum pname, GLint* params )
419   {
420     glGetFramebufferAttachmentParameteriv( target, attachment, pname, params );
421   }
422
423   void GetIntegerv( GLenum pname, GLint* params )
424   {
425     glGetIntegerv( pname, params );
426   }
427
428   void GetProgramiv( GLuint program, GLenum pname, GLint* params )
429   {
430     glGetProgramiv( program, pname, params );
431   }
432
433   void GetProgramInfoLog( GLuint program, GLsizei bufsize, GLsizei* length, char* infolog )
434   {
435     glGetProgramInfoLog( program, bufsize, length, infolog );
436   }
437
438   void GetRenderbufferParameteriv( GLenum target, GLenum pname, GLint* params )
439   {
440     glGetRenderbufferParameteriv( target, pname, params );
441   }
442
443   void GetShaderiv( GLuint shader, GLenum pname, GLint* params )
444   {
445     glGetShaderiv( shader, pname, params );
446   }
447
448   void GetShaderInfoLog( GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog )
449   {
450     glGetShaderInfoLog( shader, bufsize, length, infolog );
451   }
452
453   void GetShaderPrecisionFormat( GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision )
454   {
455     glGetShaderPrecisionFormat( shadertype, precisiontype, range, precision );
456   }
457
458   void GetShaderSource( GLuint shader, GLsizei bufsize, GLsizei* length, char* source )
459   {
460     glGetShaderSource( shader, bufsize, length, source );
461   }
462
463   const GLubyte* GetString( GLenum name )
464   {
465     return glGetString( name );
466   }
467
468   void GetTexParameterfv( GLenum target, GLenum pname, GLfloat* params )
469   {
470     glGetTexParameterfv( target, pname, params );
471   }
472
473   void GetTexParameteriv( GLenum target, GLenum pname, GLint* params )
474   {
475     glGetTexParameteriv( target, pname, params );
476   }
477
478   void GetUniformfv( GLuint program, GLint location, GLfloat* params )
479   {
480     glGetUniformfv( program, location, params );
481   }
482
483   void GetUniformiv( GLuint program, GLint location, GLint* params )
484   {
485     glGetUniformiv( program, location, params );
486   }
487
488   int  GetUniformLocation( GLuint program, const char* name )
489   {
490     return glGetUniformLocation( program, name );
491   }
492
493   void GetVertexAttribfv( GLuint index, GLenum pname, GLfloat* params )
494   {
495     glGetVertexAttribfv( index, pname, params );
496   }
497
498   void GetVertexAttribiv( GLuint index, GLenum pname, GLint* params )
499   {
500     glGetVertexAttribiv( index, pname, params );
501   }
502
503   void GetVertexAttribPointerv( GLuint index, GLenum pname, void** pointer )
504   {
505     glGetVertexAttribPointerv( index, pname, pointer );
506   }
507
508   void Hint( GLenum target, GLenum mode )
509   {
510     glHint( target, mode );
511   }
512
513   GLboolean IsBuffer( GLuint buffer )
514   {
515     return glIsBuffer( buffer );
516   }
517
518   GLboolean IsEnabled( GLenum cap )
519   {
520     return glIsEnabled( cap );
521   }
522
523   GLboolean IsFramebuffer( GLuint framebuffer )
524   {
525     return glIsFramebuffer( framebuffer );
526   }
527
528   GLboolean IsProgram( GLuint program )
529   {
530     return glIsProgram( program );
531   }
532
533   GLboolean IsRenderbuffer( GLuint renderbuffer )
534   {
535     return glIsRenderbuffer( renderbuffer );
536   }
537
538   GLboolean IsShader( GLuint shader )
539   {
540     return glIsShader( shader );
541   }
542
543   GLboolean IsTexture( GLuint texture )
544   {
545     return glIsTexture( texture );
546   }
547
548   void LineWidth( GLfloat width )
549   {
550     glLineWidth( width );
551   }
552
553   void LinkProgram( GLuint program )
554   {
555     glLinkProgram( program );
556   }
557
558   void PixelStorei( GLenum pname, GLint param )
559   {
560     glPixelStorei( pname, param );
561   }
562
563   void PolygonOffset( GLfloat factor, GLfloat units )
564   {
565     glPolygonOffset( factor, units );
566   }
567
568   void ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels )
569   {
570     glReadPixels( x, y, width, height, format, type, pixels );
571   }
572
573   void ReleaseShaderCompiler( void )
574   {
575     glReleaseShaderCompiler();
576   }
577
578   void RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height )
579   {
580     glRenderbufferStorage( target, internalformat, width, height );
581   }
582
583   void SampleCoverage( GLclampf value, GLboolean invert )
584   {
585     glSampleCoverage( value, invert );
586   }
587
588   void Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
589   {
590     glScissor( x, y, width, height );
591   }
592
593   void ShaderBinary( GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length )
594   {
595     glShaderBinary( n, shaders, binaryformat, binary, length );
596   }
597
598   void ShaderSource( GLuint shader, GLsizei count, const char** string, const GLint* length )
599   {
600     glShaderSource( shader, count, string, length );
601   }
602
603   void StencilFunc( GLenum func, GLint ref, GLuint mask )
604   {
605     glStencilFunc( func, ref, mask );
606   }
607
608   void StencilFuncSeparate( GLenum face, GLenum func, GLint ref, GLuint mask )
609   {
610     glStencilFuncSeparate( face, func, ref, mask );
611   }
612
613   void StencilMask( GLuint mask )
614   {
615     glStencilMask( mask );
616   }
617
618   void StencilMaskSeparate( GLenum face, GLuint mask )
619   {
620     glStencilMaskSeparate( face, mask );
621   }
622
623   void StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
624   {
625     glStencilOp( fail, zfail, zpass );
626   }
627
628   void StencilOpSeparate( GLenum face, GLenum fail, GLenum zfail, GLenum zpass )
629   {
630     glStencilOpSeparate( face, fail, zfail, zpass );
631   }
632
633   void TexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels )
634   {
635     glTexImage2D( target, level, internalformat, width, height, border, format, type, pixels );
636   }
637
638   void TexParameterf( GLenum target, GLenum pname, GLfloat param )
639   {
640     glTexParameterf( target, pname, param );
641   }
642
643   void TexParameterfv( GLenum target, GLenum pname, const GLfloat* params )
644   {
645     glTexParameterfv( target, pname, params );
646   }
647
648   void TexParameteri( GLenum target, GLenum pname, GLint param )
649   {
650     glTexParameteri( target, pname, param );
651   }
652
653   void TexParameteriv( GLenum target, GLenum pname, const GLint* params )
654   {
655     glTexParameteriv( target, pname, params );
656   }
657
658   void TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels )
659   {
660     glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
661   }
662
663   void Uniform1f( GLint location, GLfloat x )
664   {
665     glUniform1f( location, x );
666   }
667
668   void Uniform1fv( GLint location, GLsizei count, const GLfloat* v )
669   {
670     glUniform1fv( location, count, v );
671   }
672
673   void Uniform1i( GLint location, GLint x )
674   {
675     glUniform1i( location, x );
676   }
677
678   void Uniform1iv( GLint location, GLsizei count, const GLint* v )
679   {
680     glUniform1iv( location, count, v );
681   }
682
683   void Uniform2f( GLint location, GLfloat x, GLfloat y )
684   {
685     glUniform2f( location, x, y );
686   }
687
688   void Uniform2fv( GLint location, GLsizei count, const GLfloat* v )
689   {
690     glUniform2fv( location, count, v );
691   }
692
693   void Uniform2i( GLint location, GLint x, GLint y )
694   {
695     glUniform2i( location, x, y );
696   }
697
698   void Uniform2iv( GLint location, GLsizei count, const GLint* v )
699   {
700     glUniform2iv( location, count, v );
701   }
702
703   void Uniform3f( GLint location, GLfloat x, GLfloat y, GLfloat z )
704   {
705     glUniform3f( location, x, y, z );
706   }
707
708   void Uniform3fv( GLint location, GLsizei count, const GLfloat* v )
709   {
710     glUniform3fv( location, count, v );
711   }
712
713   void Uniform3i( GLint location, GLint x, GLint y, GLint z )
714   {
715     glUniform3i( location, x, y, z );
716   }
717
718   void Uniform3iv( GLint location, GLsizei count, const GLint* v )
719   {
720     glUniform3iv( location, count, v );
721   }
722
723   void Uniform4f( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
724   {
725     glUniform4f( location, x, y, z, w );
726   }
727
728   void Uniform4fv( GLint location, GLsizei count, const GLfloat* v )
729   {
730     glUniform4fv( location, count, v );
731   }
732
733   void Uniform4i( GLint location, GLint x, GLint y, GLint z, GLint w )
734   {
735     glUniform4i( location, x, y, z, w );
736   }
737
738   void Uniform4iv( GLint location, GLsizei count, const GLint* v )
739   {
740     glUniform4iv( location, count, v );
741   }
742
743   void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
744   {
745     glUniformMatrix2fv( location, count, transpose, value );
746   }
747
748   void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
749   {
750     glUniformMatrix3fv( location, count, transpose, value );
751   }
752
753   void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
754   {
755     glUniformMatrix4fv( location, count, transpose, value );
756   }
757
758   void UseProgram( GLuint program )
759   {
760     glUseProgram( program );
761   }
762
763   void ValidateProgram( GLuint program )
764   {
765     glValidateProgram( program );
766   }
767
768   void VertexAttrib1f( GLuint indx, GLfloat x )
769   {
770     glVertexAttrib1f( indx, x );
771   }
772
773   void VertexAttrib1fv( GLuint indx, const GLfloat* values )
774   {
775     glVertexAttrib1fv( indx, values );
776   }
777
778   void VertexAttrib2f( GLuint indx, GLfloat x, GLfloat y )
779   {
780     glVertexAttrib2f( indx, x, y );
781   }
782
783   void VertexAttrib2fv( GLuint indx, const GLfloat* values )
784   {
785     glVertexAttrib2fv( indx, values );
786   }
787
788   void VertexAttrib3f( GLuint indx, GLfloat x, GLfloat y, GLfloat z )
789   {
790     glVertexAttrib3f( indx, x, y, z );
791   }
792
793   void VertexAttrib3fv( GLuint indx, const GLfloat* values )
794   {
795     glVertexAttrib3fv( indx, values );
796   }
797
798   void VertexAttrib4f( GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
799   {
800     glVertexAttrib4f( indx, x, y, z, w );
801   }
802
803   void VertexAttrib4fv( GLuint indx, const GLfloat* values )
804   {
805     glVertexAttrib4fv( indx, values );
806   }
807
808   void VertexAttribPointer( GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr )
809   {
810     glVertexAttribPointer( indx, size, type, normalized, stride, ptr );
811   }
812
813   void Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
814   {
815     glViewport( x, y, width, height );
816   }
817
818   /* OpenGL ES 3.0 */
819
820   void ReadBuffer( GLenum mode )
821   {
822     mImpl->ReadBuffer( mode );
823   }
824
825   void DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices )
826   {
827     mImpl->DrawRangeElements( mode, start, end, count, type, indices );
828   }
829
830   void TexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels )
831   {
832     mImpl->TexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels );
833   }
834
835   void TexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels )
836   {
837     mImpl->TexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels );
838   }
839
840   void CopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height )
841   {
842     mImpl->CopyTexSubImage3D( target, level, xoffset, yoffset, zoffset, x, y, width, height );
843   }
844
845   void CompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data )
846   {
847     mImpl->CompressedTexImage3D( target, level, internalformat, width, height, depth, border, imageSize, data );
848   }
849
850   void CompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data )
851   {
852     mImpl->CompressedTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data );
853   }
854
855   void GenQueries( GLsizei n, GLuint* ids )
856   {
857     mImpl->GenQueries( n, ids );
858   }
859
860   void DeleteQueries( GLsizei n, const GLuint* ids )
861   {
862     mImpl->DeleteQueries( n, ids );
863   }
864
865   GLboolean IsQuery( GLuint id )
866   {
867     return mImpl->IsQuery( id );
868   }
869
870   void BeginQuery( GLenum target, GLuint id )
871   {
872     mImpl->BeginQuery( target, id );
873   }
874
875   void EndQuery( GLenum target )
876   {
877     mImpl->EndQuery( target );
878   }
879
880   void GetQueryiv( GLenum target, GLenum pname, GLint* params )
881   {
882     mImpl->GetQueryiv( target, pname, params );
883   }
884
885   void GetQueryObjectuiv( GLuint id, GLenum pname, GLuint* params )
886   {
887     mImpl->GetQueryObjectuiv( id, pname, params );
888   }
889
890   GLboolean UnmapBuffer( GLenum target )
891   {
892     return mImpl->UnmapBuffer( target );
893   }
894
895   void GetBufferPointerv( GLenum target, GLenum pname, GLvoid** params )
896   {
897     mImpl->GetBufferPointerv( target, pname, params );
898   }
899
900   void DrawBuffers( GLsizei n, const GLenum* bufs )
901   {
902     mImpl->DrawBuffers( n, bufs );
903   }
904
905   void UniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
906   {
907     mImpl->UniformMatrix2x3fv( location, count, transpose, value );
908   }
909
910   void UniformMatrix3x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
911   {
912     mImpl->UniformMatrix3x2fv( location, count, transpose, value );
913   }
914
915   void UniformMatrix2x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
916   {
917     mImpl->UniformMatrix2x4fv( location, count, transpose, value );
918   }
919
920   void UniformMatrix4x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
921   {
922     mImpl->UniformMatrix4x2fv( location, count, transpose, value );
923   }
924
925   void UniformMatrix3x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
926   {
927     mImpl->UniformMatrix3x4fv( location, count, transpose, value );
928   }
929
930   void UniformMatrix4x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
931   {
932     mImpl->UniformMatrix4x3fv( location, count, transpose, value );
933   }
934
935   void BlitFramebuffer( GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter )
936   {
937     mImpl->BlitFramebuffer( srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter );
938   }
939
940   void RenderbufferStorageMultisample( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height )
941   {
942     mImpl->RenderbufferStorageMultisample( target, samples, internalformat, width, height );
943   }
944
945   void FramebufferTextureLayer( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer )
946   {
947     mImpl->FramebufferTextureLayer( target, attachment, texture, level, layer );
948   }
949
950   GLvoid* MapBufferRange( GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access )
951   {
952     return mImpl->MapBufferRange( target, offset, length, access );
953   }
954
955   void FlushMappedBufferRange( GLenum target, GLintptr offset, GLsizeiptr length )
956   {
957     mImpl->FlushMappedBufferRange( target, offset, length );
958   }
959
960   void BindVertexArray( GLuint array )
961   {
962     mImpl->BindVertexArray( array );
963   }
964
965   void DeleteVertexArrays( GLsizei n, const GLuint* arrays )
966   {
967     mImpl->DeleteVertexArrays( n, arrays );
968   }
969
970   void GenVertexArrays( GLsizei n, GLuint* arrays )
971   {
972     mImpl->GenVertexArrays( n, arrays );
973   }
974
975   GLboolean IsVertexArray( GLuint array )
976   {
977     return mImpl->IsVertexArray( array );
978   }
979
980   void GetIntegeri_v( GLenum target, GLuint index, GLint* data )
981   {
982     mImpl->GetIntegeri_v( target, index, data );
983   }
984
985   void BeginTransformFeedback( GLenum primitiveMode )
986   {
987     mImpl->BeginTransformFeedback( primitiveMode );
988   }
989
990   void EndTransformFeedback( void )
991   {
992     mImpl->EndTransformFeedback();
993   }
994
995   void BindBufferRange( GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size )
996   {
997     mImpl->BindBufferRange( target, index, buffer, offset, size );
998   }
999
1000   void BindBufferBase( GLenum target, GLuint index, GLuint buffer )
1001   {
1002     mImpl->BindBufferBase( target, index, buffer );
1003   }
1004
1005   void TransformFeedbackVaryings( GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode )
1006   {
1007     mImpl->TransformFeedbackVaryings( program, count, varyings, bufferMode );
1008   }
1009
1010   void GetTransformFeedbackVarying( GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name )
1011   {
1012     mImpl->GetTransformFeedbackVarying( program, index, bufSize, length, size, type, name );
1013   }
1014
1015   void VertexAttribIPointer( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer )
1016   {
1017     mImpl->VertexAttribIPointer( index, size, type, stride, pointer );
1018   }
1019
1020   void GetVertexAttribIiv( GLuint index, GLenum pname, GLint* params )
1021   {
1022     mImpl->GetVertexAttribIiv( index, pname, params );
1023   }
1024
1025   void GetVertexAttribIuiv( GLuint index, GLenum pname, GLuint* params )
1026   {
1027     mImpl->GetVertexAttribIuiv( index, pname, params );
1028   }
1029
1030   void VertexAttribI4i( GLuint index, GLint x, GLint y, GLint z, GLint w )
1031   {
1032     mImpl->VertexAttribI4i( index, x, y, z, w );
1033   }
1034
1035   void VertexAttribI4ui( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w )
1036   {
1037     mImpl->VertexAttribI4ui( index, x, y, z, w );
1038   }
1039
1040   void VertexAttribI4iv( GLuint index, const GLint* v )
1041   {
1042     mImpl->VertexAttribI4iv( index, v );
1043   }
1044
1045   void VertexAttribI4uiv( GLuint index, const GLuint* v )
1046   {
1047     mImpl->VertexAttribI4uiv( index, v );
1048   }
1049
1050   void GetUniformuiv( GLuint program, GLint location, GLuint* params )
1051   {
1052     mImpl->GetUniformuiv( program, location, params );
1053   }
1054
1055   GLint GetFragDataLocation( GLuint program, const GLchar *name )
1056   {
1057     return mImpl->GetFragDataLocation( program, name );
1058   }
1059
1060   void Uniform1ui( GLint location, GLuint v0 )
1061   {
1062     mImpl->Uniform1ui( location, v0 );
1063   }
1064
1065   void Uniform2ui( GLint location, GLuint v0, GLuint v1 )
1066   {
1067     mImpl->Uniform2ui( location, v0, v1 );
1068   }
1069
1070   void Uniform3ui( GLint location, GLuint v0, GLuint v1, GLuint v2 )
1071   {
1072     mImpl->Uniform3ui( location, v0, v1, v2 );
1073   }
1074
1075   void Uniform4ui( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 )
1076   {
1077     mImpl->Uniform4ui( location, v0, v1, v2, v3 );
1078   }
1079
1080   void Uniform1uiv( GLint location, GLsizei count, const GLuint* value )
1081   {
1082     mImpl->Uniform1uiv( location, count, value );
1083   }
1084
1085   void Uniform2uiv( GLint location, GLsizei count, const GLuint* value )
1086   {
1087     mImpl->Uniform2uiv( location, count, value );
1088   }
1089
1090   void Uniform3uiv( GLint location, GLsizei count, const GLuint* value )
1091   {
1092     mImpl->Uniform3uiv( location, count, value );
1093   }
1094
1095   void Uniform4uiv( GLint location, GLsizei count, const GLuint* value )
1096   {
1097     mImpl->Uniform4uiv( location, count, value );
1098   }
1099
1100   void ClearBufferiv( GLenum buffer, GLint drawbuffer, const GLint* value )
1101   {
1102     mImpl->ClearBufferiv( buffer, drawbuffer, value );
1103   }
1104
1105   void ClearBufferuiv( GLenum buffer, GLint drawbuffer, const GLuint* value )
1106   {
1107     mImpl->ClearBufferuiv( buffer, drawbuffer, value );
1108   }
1109
1110   void ClearBufferfv( GLenum buffer, GLint drawbuffer, const GLfloat* value )
1111   {
1112     mImpl->ClearBufferfv( buffer, drawbuffer, value );
1113   }
1114
1115   void ClearBufferfi( GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil )
1116   {
1117     mImpl->ClearBufferfi( buffer, drawbuffer, depth, stencil );
1118   }
1119
1120   const GLubyte* GetStringi( GLenum name, GLuint index )
1121   {
1122     return mImpl->GetStringi( name, index );
1123   }
1124
1125   void CopyBufferSubData( GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size )
1126   {
1127     mImpl->CopyBufferSubData( readTarget, writeTarget, readOffset, writeOffset, size );
1128   }
1129
1130   void GetUniformIndices( GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices )
1131   {
1132     mImpl->GetUniformIndices( program, uniformCount, uniformNames, uniformIndices );
1133   }
1134
1135   void GetActiveUniformsiv( GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params )
1136   {
1137     mImpl->GetActiveUniformsiv( program, uniformCount, uniformIndices, pname, params );
1138   }
1139
1140   GLuint GetUniformBlockIndex( GLuint program, const GLchar* uniformBlockName )
1141   {
1142     return mImpl->GetUniformBlockIndex( program, uniformBlockName );
1143   }
1144
1145   void GetActiveUniformBlockiv( GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params )
1146   {
1147     mImpl->GetActiveUniformBlockiv( program, uniformBlockIndex, pname, params );
1148   }
1149
1150   void GetActiveUniformBlockName( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName )
1151   {
1152     mImpl->GetActiveUniformBlockName( program, uniformBlockIndex, bufSize, length, uniformBlockName );
1153   }
1154
1155   void UniformBlockBinding( GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding )
1156   {
1157     mImpl->UniformBlockBinding( program, uniformBlockIndex, uniformBlockBinding );
1158   }
1159
1160   void DrawArraysInstanced( GLenum mode, GLint first, GLsizei count, GLsizei instanceCount )
1161   {
1162     mImpl->DrawArraysInstanced( mode, first, count, instanceCount );
1163   }
1164
1165   void DrawElementsInstanced( GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount )
1166   {
1167     mImpl->DrawElementsInstanced( mode, count, type, indices, instanceCount );
1168   }
1169
1170   GLsync FenceSync( GLenum condition, GLbitfield flags )
1171   {
1172     return mImpl->FenceSync( condition, flags );
1173   }
1174
1175   GLboolean IsSync( GLsync sync )
1176   {
1177     return mImpl->IsSync( sync );
1178   }
1179
1180   void DeleteSync( GLsync sync )
1181   {
1182     mImpl->DeleteSync( sync );
1183   }
1184
1185   GLenum ClientWaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout )
1186   {
1187     return mImpl->ClientWaitSync( sync, flags, timeout );
1188   }
1189
1190   void WaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout )
1191   {
1192     mImpl->WaitSync( sync, flags, timeout );
1193   }
1194
1195   void GetInteger64v( GLenum pname, GLint64* params )
1196   {
1197     mImpl->GetInteger64v( pname, params );
1198   }
1199
1200   void GetSynciv( GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values )
1201   {
1202     mImpl->GetSynciv( sync, pname, bufSize, length, values );
1203   }
1204
1205   void GetInteger64i_v( GLenum target, GLuint index, GLint64* data )
1206   {
1207     mImpl->GetInteger64i_v( target, index, data );
1208   }
1209
1210   void GetBufferParameteri64v( GLenum target, GLenum pname, GLint64* params )
1211   {
1212     mImpl->GetBufferParameteri64v( target, pname, params );
1213   }
1214
1215   void GenSamplers( GLsizei count, GLuint* samplers )
1216   {
1217     mImpl->GenSamplers( count, samplers );
1218   }
1219
1220   void DeleteSamplers( GLsizei count, const GLuint* samplers )
1221   {
1222     mImpl->DeleteSamplers( count, samplers );
1223   }
1224
1225   GLboolean IsSampler( GLuint sampler )
1226   {
1227     return mImpl->IsSampler( sampler );
1228   }
1229
1230   void BindSampler( GLuint unit, GLuint sampler )
1231   {
1232     mImpl->BindSampler( unit, sampler );
1233   }
1234
1235   void SamplerParameteri( GLuint sampler, GLenum pname, GLint param )
1236   {
1237     mImpl->SamplerParameteri( sampler, pname, param );
1238   }
1239
1240   void SamplerParameteriv( GLuint sampler, GLenum pname, const GLint* param )
1241   {
1242     mImpl->SamplerParameteriv( sampler, pname, param );
1243   }
1244
1245   void SamplerParameterf( GLuint sampler, GLenum pname, GLfloat param )
1246   {
1247     mImpl->SamplerParameterf( sampler, pname, param );
1248   }
1249
1250   void SamplerParameterfv( GLuint sampler, GLenum pname, const GLfloat* param )
1251   {
1252     mImpl->SamplerParameterfv( sampler, pname, param );
1253   }
1254
1255   void GetSamplerParameteriv( GLuint sampler, GLenum pname, GLint* params )
1256   {
1257     mImpl->GetSamplerParameteriv( sampler, pname, params );
1258   }
1259
1260   void GetSamplerParameterfv( GLuint sampler, GLenum pname, GLfloat* params )
1261   {
1262     mImpl->GetSamplerParameterfv( sampler, pname, params );
1263   }
1264
1265   void VertexAttribDivisor( GLuint index, GLuint divisor )
1266   {
1267     mImpl->VertexAttribDivisor( index, divisor );
1268   }
1269
1270   void BindTransformFeedback( GLenum target, GLuint id )
1271   {
1272     mImpl->BindTransformFeedback( target, id );
1273   }
1274
1275   void DeleteTransformFeedbacks( GLsizei n, const GLuint* ids )
1276   {
1277     mImpl->DeleteTransformFeedbacks( n, ids );
1278   }
1279
1280   void GenTransformFeedbacks( GLsizei n, GLuint* ids )
1281   {
1282     mImpl->GenTransformFeedbacks( n, ids );
1283   }
1284
1285   GLboolean IsTransformFeedback( GLuint id )
1286   {
1287     return mImpl->IsTransformFeedback( id );
1288   }
1289
1290   void PauseTransformFeedback( void )
1291   {
1292     mImpl->PauseTransformFeedback();
1293   }
1294
1295   void ResumeTransformFeedback( void )
1296   {
1297     mImpl->ResumeTransformFeedback();
1298   }
1299
1300   void GetProgramBinary( GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary )
1301   {
1302     mImpl->GetProgramBinary( program, bufSize, length, binaryFormat, binary );
1303   }
1304
1305   void ProgramBinary( GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length )
1306   {
1307     mImpl->ProgramBinary( program, binaryFormat, binary, length );
1308   }
1309
1310   void ProgramParameteri( GLuint program, GLenum pname, GLint value )
1311   {
1312     mImpl->ProgramParameteri( program, pname, value );
1313   }
1314
1315   void InvalidateFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments )
1316   {
1317     mImpl->InvalidateFramebuffer( target, numAttachments, attachments );
1318   }
1319
1320   void InvalidateSubFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height )
1321   {
1322     mImpl->InvalidateSubFramebuffer( target, numAttachments, attachments, x, y, width, height );
1323   }
1324
1325   void TexStorage2D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height )
1326   {
1327     mImpl->TexStorage2D( target, levels, internalformat, width, height );
1328   }
1329
1330   void TexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth )
1331   {
1332     mImpl->TexStorage3D( target, levels, internalformat, width, height, depth );
1333   }
1334
1335   void GetInternalformativ( GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params )
1336   {
1337     mImpl->GetInternalformativ( target, internalformat, pname, bufSize, params );
1338   }
1339
1340 private:
1341   int32_t mGlesVersion;
1342   bool mIsSurfacelessContextSupported;
1343   std::unique_ptr<GlesAbstraction> mImpl;
1344 };
1345
1346 } // namespace Adaptor
1347
1348 } // namespace Internal
1349
1350 } // namespace Dali
1351
1352 #endif // DALI_INTERNAL_GL_IMPLEMENTATION_H