2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
20 * @brief This is the implementation file for OpenGL ES 2.X.
25 #define FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING
26 #if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING)
35 #include <unique_ptr.h>
37 #include <GLES2/gl2.h>
38 #include <GLES2/gl2ext.h>
40 #if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING)
41 #include <FBaseSysLog.h>
44 #define FGRAPHICS_INTERNAL_USE_FBO
45 #if defined(FGRAPHICS_INTERNAL_USE_FBO)
46 #include <FUiCtrlFrame.h>
49 #include "../util/FGrp_UtilTemplate.h"
50 using namespace Tizen::Base;
51 using namespace Tizen::Ui;
52 using namespace Tizen::Ui::Controls;
54 namespace Tizen { namespace Graphics
60 #if !defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING)
68 _GlActiveTexture_2(GLenum texture)
70 glActiveTexture(texture);
74 _GlAttachShader_2(GLuint program, GLuint shader)
76 glAttachShader(program, shader);
80 _GlBindAttribLocation_2(GLuint program, GLuint index, const char* pName)
82 glBindAttribLocation(program, index, pName);
86 _GlBindBuffer_2(GLenum target, GLuint buffer)
88 glBindBuffer(target, buffer);
92 _GlBindFramebuffer_2(GLenum target, GLuint framebuffer)
94 glBindFramebuffer(target, framebuffer);
98 _GlBindRenderbuffer_2(GLenum target, GLuint renderbuffer)
100 glBindRenderbuffer(target, renderbuffer);
104 _GlBindTexture_2(GLenum target, GLuint texture)
106 glBindTexture(target, texture);
110 _GlBlendColor_2(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
112 glBlendColor(red, green, blue, alpha);
116 _GlBlendEquation_2(GLenum mode)
118 glBlendEquation(mode);
122 _GlBlendEquationSeparate_2(GLenum modeRGB, GLenum modeAlpha)
124 glBlendEquationSeparate(modeRGB, modeAlpha);
128 _GlBlendFunc_2(GLenum sfactor, GLenum dfactor)
130 glBlendFunc(sfactor, dfactor);
134 _GlBlendFuncSeparate_2(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
136 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
140 _GlBufferData_2(GLenum target, GLsizeiptr size, const void* pData, GLenum usage)
142 glBufferData(target, size, pData, usage);
146 _GlBufferSubData_2(GLenum target, GLintptr offset, GLsizeiptr size, const void* pData)
148 glBufferSubData(target, offset, size, pData);
152 _GlCheckFramebufferStatus_2(GLenum target)
154 return glCheckFramebufferStatus(target);
158 _GlClear_2(GLbitfield mask)
164 _GlClearColor_2(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
166 glClearColor(red, green, blue, alpha);
170 _GlClearDepthf_2(GLclampf depth)
172 glClearDepthf(depth);
176 _GlClearStencil_2(GLint s)
182 _GlColorMask_2(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
184 glColorMask(red, green, blue, alpha);
188 _GlCompileShader_2(GLuint shader)
190 glCompileShader(shader);
194 _GlCompressedTexImage2D_2(GLenum target, GLint level, GLenum internalformat,
195 GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* pData)
197 glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pData);
201 _GlCompressedTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset,
202 GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* pData)
204 glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pData);
208 _GlCopyTexImage2D_2(GLenum target, GLint level,
209 GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
211 glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
215 _GlCopyTexSubImage2D_2(GLenum target, GLint level,
216 GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
218 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
222 _GlCreateProgram_2(void)
224 return glCreateProgram();
228 _GlCreateShader_2(GLenum type)
230 return glCreateShader(type);
234 _GlCullFace_2(GLenum mode)
240 _GlDeleteBuffers_2(GLsizei n, const GLuint* pBuffers)
242 glDeleteBuffers(n, pBuffers);
246 _GlDeleteFramebuffers_2(GLsizei n, const GLuint* pFramebuffers)
248 glDeleteFramebuffers(n, pFramebuffers);
252 _GlDeleteProgram_2(GLuint program)
254 glDeleteProgram(program);
258 _GlDeleteRenderbuffers_2(GLsizei n, const GLuint* pRenderbuffers)
260 glDeleteRenderbuffers(n, pRenderbuffers);
264 _GlDeleteShader_2(GLuint shader)
266 glDeleteShader(shader);
270 _GlDeleteTextures_2(GLsizei n, const GLuint* pTextures)
272 glDeleteTextures(n, pTextures);
276 _GlDepthFunc_2(GLenum func)
282 _GlDepthMask_2(GLboolean flag)
288 _GlDepthRangef_2(GLclampf zNear, GLclampf zFar)
290 glDepthRangef(zNear, zFar);
294 _GlDetachShader_2(GLuint program, GLuint shader)
296 glDetachShader(program, shader);
300 _GlDisable_2(GLenum cap)
306 _GlDisableVertexAttribArray_2(GLuint index)
308 glDisableVertexAttribArray(index);
312 _GlDrawArrays_2(GLenum mode, GLint first, GLsizei count)
314 glDrawArrays(mode, first, count);
318 _GlDrawElements_2(GLenum mode, GLsizei count, GLenum type, const void* pIndices)
320 glDrawElements(mode, count, type, pIndices);
324 _GlEnable_2(GLenum cap)
330 _GlEnableVertexAttribArray_2(GLuint index)
332 glEnableVertexAttribArray(index);
348 _GlFramebufferRenderbuffer_2(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
350 glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
354 _GlFramebufferTexture2D_2(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
356 glFramebufferTexture2D(target, attachment, textarget, texture, level);
360 _GlFrontFace_2(GLenum mode)
366 _GlGenBuffers_2(GLsizei n, GLuint* pBuffers)
368 glGenBuffers(n, pBuffers);
372 _GlGenerateMipmap_2(GLenum target)
374 glGenerateMipmap(target);
378 _GlGenFramebuffers_2(GLsizei n, GLuint* pFramebuffers)
380 glGenFramebuffers(n, pFramebuffers);
384 _GlGenRenderbuffers_2(GLsizei n, GLuint* pRenderbuffers)
386 glGenRenderbuffers(n, pRenderbuffers);
390 _GlGenTextures_2(GLsizei n, GLuint* pTextures)
392 glGenTextures(n, pTextures);
396 _GlGetActiveAttrib_2(GLuint program, GLuint index, GLsizei bufsize,
397 GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName)
399 glGetActiveAttrib(program, index, bufsize, pLength, pSize, pType, pName);
403 _GlGetActiveUniform_2(GLuint program, GLuint index, GLsizei bufsize,
404 GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName)
406 glGetActiveUniform(program, index, bufsize, pLength, pSize, pType, pName);
410 _GlGetAttachedShaders_2(GLuint program, GLsizei maxcount, GLsizei* pCount, GLuint* pShaders)
412 glGetAttachedShaders(program, maxcount, pCount, pShaders);
416 _GlGetAttribLocation_2(GLuint program, const char* pName)
418 return glGetAttribLocation(program, pName);
422 _GlGetBooleanv_2(GLenum pname, GLboolean* pParams)
424 glGetBooleanv(pname, pParams);
428 _GlGetBufferParameteriv_2(GLenum target, GLenum pname, GLint* pParams)
430 glGetBufferParameteriv(target, pname, pParams);
440 _GlGetFloatv_2(GLenum pname, GLfloat* pParams)
442 glGetFloatv(pname, pParams);
446 _GlGetFramebufferAttachmentParameteriv_2(GLenum target, GLenum attachment, GLenum pname, GLint* pParams)
448 glGetFramebufferAttachmentParameteriv(target, attachment, pname, pParams);
452 _GlGetIntegerv_2(GLenum pname, GLint* pParams)
454 glGetIntegerv(pname, pParams);
458 _GlGetProgramiv_2(GLuint program, GLenum pname, GLint* pParams)
460 glGetProgramiv(program, pname, pParams);
464 _GlGetProgramInfoLog_2(GLuint program, GLsizei bufsize, GLsizei* pLength, char* pInfolog)
466 glGetProgramInfoLog(program, bufsize, pLength, pInfolog);
470 _GlGetRenderbufferParameteriv_2(GLenum target, GLenum pname, GLint* pParams)
472 glGetRenderbufferParameteriv(target, pname, pParams);
476 _GlGetShaderiv_2(GLuint shader, GLenum pname, GLint* pParams)
478 glGetShaderiv(shader, pname, pParams);
482 _GlGetShaderInfoLog_2(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pInfolog)
484 glGetShaderInfoLog(shader, bufsize, pLength, pInfolog);
488 _GlGetShaderPrecisionFormat_2(GLenum shadertype, GLenum precisiontype, GLint* pRange, GLint* pPrecision)
490 glGetShaderPrecisionFormat(shadertype, precisiontype, pRange, pPrecision);
494 _GlGetShaderSource_2(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pSource)
496 glGetShaderSource(shader, bufsize, pLength, pSource);
500 _GlGetString_2(GLenum name)
502 return glGetString(name);
506 _GlGetTexParameterfv_2(GLenum target, GLenum pname, GLfloat* pParams)
508 glGetTexParameterfv(target, pname, pParams);
512 _GlGetTexParameteriv_2(GLenum target, GLenum pname, GLint* pParams)
514 glGetTexParameteriv(target, pname, pParams);
518 _GlGetUniformfv_2(GLuint program, GLint location, GLfloat* pParams)
520 glGetUniformfv(program, location, pParams);
524 _GlGetUniformiv_2(GLuint program, GLint location, GLint* pParams)
526 glGetUniformiv(program, location, pParams);
530 _GlGetUniformLocation_2(GLuint program, const char* pName)
532 return glGetUniformLocation(program, pName);
536 _GlGetVertexAttribfv_2(GLuint index, GLenum pname, GLfloat* pParams)
538 glGetVertexAttribfv(index, pname, pParams);
542 _GlGetVertexAttribiv_2(GLuint index, GLenum pname, GLint* pParams)
544 glGetVertexAttribiv(index, pname, pParams);
548 _GlGetVertexAttribPointerv_2(GLuint index, GLenum pname, void** ppPointer)
550 glGetVertexAttribPointerv(index, pname, ppPointer);
554 _GlHint_2(GLenum target, GLenum mode)
556 glHint(target, mode);
560 _GlIsBuffer_2(GLuint buffer)
562 return glIsBuffer(buffer);
566 _GlIsEnabled_2(GLenum cap)
568 return glIsEnabled(cap);
572 _GlIsFramebuffer_2(GLuint framebuffer)
574 return glIsFramebuffer(framebuffer);
578 _GlIsProgram_2(GLuint program)
580 return glIsProgram(program);
584 _GlIsRenderbuffer_2(GLuint renderbuffer)
586 return glIsRenderbuffer(renderbuffer);
590 _GlIsShader_2(GLuint shader)
592 return glIsShader(shader);
596 _GlIsTexture_2(GLuint texture)
598 return glIsTexture(texture);
602 _GlLineWidth_2(GLfloat width)
608 _GlLinkProgram_2(GLuint program)
610 glLinkProgram(program);
614 _GlPixelStorei_2(GLenum pname, GLint param)
616 glPixelStorei(pname, param);
620 _GlPolygonOffset_2(GLfloat factor, GLfloat units)
622 glPolygonOffset(factor, units);
626 _GlReadPixels_2(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pPixels)
628 glReadPixels(x, y, width, height, format, type, pPixels);
632 _GlReleaseShaderCompiler_2(void)
634 glReleaseShaderCompiler();
638 _GlRenderbufferStorage_2(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
640 glRenderbufferStorage(target, internalformat, width, height);
644 _GlSampleCoverage_2(GLclampf value, GLboolean invert)
646 glSampleCoverage(value, invert);
650 _GlScissor_2(GLint x, GLint y, GLsizei width, GLsizei height)
652 glScissor(x, y, width, height);
656 _GlShaderBinary_2(GLint n, GLuint* pShaders, GLenum binaryformat, const void* pBinary, GLint length)
658 glShaderBinary(n, pShaders, binaryformat, pBinary, length);
662 _GlShaderSource_2(GLuint shader, GLsizei count, const char** pString, const GLint* pLength)
664 glShaderSource(shader, count, pString, pLength);
668 _GlStencilFunc_2(GLenum func, GLint ref, GLuint mask)
670 glStencilFunc(func, ref, mask);
674 _GlStencilFuncSeparate_2(GLenum face, GLenum func, GLint ref, GLuint mask)
676 glStencilFuncSeparate(face, func, ref, mask);
680 _GlStencilMask_2(GLuint mask)
686 _GlStencilMaskSeparate_2(GLenum face, GLuint mask)
688 glStencilMaskSeparate(face, mask);
692 _GlStencilOp_2(GLenum fail, GLenum zfail, GLenum zpass)
694 glStencilOp(fail, zfail, zpass);
698 _GlStencilOpSeparate_2(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
700 glStencilOpSeparate(face, fail, zfail, zpass);
704 _GlTexImage2D_2(GLenum target, GLint level, GLenum internalformat,
705 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pPixels)
707 glTexImage2D(target, level, internalformat, width, height, border, format, type, pPixels);
711 _GlTexParameterf_2(GLenum target, GLenum pname, GLfloat param)
713 glTexParameterf(target, pname, param);
717 _GlTexParameterfv_2(GLenum target, GLenum pname, const GLfloat* pParams)
719 glTexParameterfv(target, pname, pParams);
723 _GlTexParameteri_2(GLenum target, GLenum pname, GLint param)
725 glTexParameteri(target, pname, param);
729 _GlTexParameteriv_2(GLenum target, GLenum pname, const GLint* pParams)
731 glTexParameteriv(target, pname, pParams);
735 _GlTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset,
736 GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pPixels)
738 glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pPixels);
742 _GlUniform1f_2(GLint location, GLfloat x)
744 glUniform1f(location, x);
748 _GlUniform1fv_2(GLint location, GLsizei count, const GLfloat* pV)
750 glUniform1fv(location, count, pV);
754 _GlUniform1i_2(GLint location, GLint x)
756 glUniform1i(location, x);
760 _GlUniform1iv_2(GLint location, GLsizei count, const GLint* pV)
762 glUniform1iv(location, count, pV);
766 _GlUniform2f_2(GLint location, GLfloat x, GLfloat y)
768 glUniform2f(location, x, y);
772 _GlUniform2fv_2(GLint location, GLsizei count, const GLfloat* pV)
774 glUniform2fv(location, count, pV);
778 _GlUniform2i_2(GLint location, GLint x, GLint y)
780 glUniform2i(location, x, y);
784 _GlUniform2iv_2(GLint location, GLsizei count, const GLint* pV)
786 glUniform2iv(location, count, pV);
790 _GlUniform3f_2(GLint location, GLfloat x, GLfloat y, GLfloat z)
792 glUniform3f(location, x, y, z);
796 _GlUniform3fv_2(GLint location, GLsizei count, const GLfloat* pV)
798 glUniform3fv(location, count, pV);
802 _GlUniform3i_2(GLint location, GLint x, GLint y, GLint z)
804 glUniform3i(location, x, y, z);
808 _GlUniform3iv_2(GLint location, GLsizei count, const GLint* pV)
810 glUniform3iv(location, count, pV);
814 _GlUniform4f_2(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
816 glUniform4f(location, x, y, z, w);
820 _GlUniform4fv_2(GLint location, GLsizei count, const GLfloat* pV)
822 glUniform4fv(location, count, pV);
826 _GlUniform4i_2(GLint location, GLint x, GLint y, GLint z, GLint w)
828 glUniform4i(location, x, y, z, w);
832 _GlUniform4iv_2(GLint location, GLsizei count, const GLint* pV)
834 glUniform4iv(location, count, pV);
838 _GlUniformMatrix2fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue)
840 glUniformMatrix2fv(location, count, transpose, pValue);
844 _GlUniformMatrix3fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue)
846 glUniformMatrix3fv(location, count, transpose, pValue);
850 _GlUniformMatrix4fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue)
852 glUniformMatrix4fv(location, count, transpose, pValue);
856 _GlUseProgram_2(GLuint program)
858 glUseProgram(program);
862 _GlValidateProgram_2(GLuint program)
864 glValidateProgram(program);
868 _GlVertexAttrib1f_2(GLuint indx, GLfloat x)
870 glVertexAttrib1f(indx, x);
874 _GlVertexAttrib1fv_2(GLuint indx, const GLfloat* pValues)
876 glVertexAttrib1fv(indx, pValues);
880 _GlVertexAttrib2f_2(GLuint indx, GLfloat x, GLfloat y)
882 glVertexAttrib2f(indx, x, y);
886 _GlVertexAttrib2fv_2(GLuint indx, const GLfloat* pValues)
888 glVertexAttrib2fv(indx, pValues);
892 _GlVertexAttrib3f_2(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
894 glVertexAttrib3f(indx, x, y, z);
898 _GlVertexAttrib3fv_2(GLuint indx, const GLfloat* pValues)
900 glVertexAttrib3fv(indx, pValues);
904 _GlVertexAttrib4f_2(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
906 glVertexAttrib4f(indx, x, y, z, w);
910 _GlVertexAttrib4fv_2(GLuint indx, const GLfloat* pValues)
912 glVertexAttrib4fv(indx, pValues);
916 _GlVertexAttribPointer_2(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pPtr)
918 glVertexAttribPointer(indx, size, type, normalized, stride, pPtr);
922 _GlViewport_2(GLint x, GLint y, GLsizei width, GLsizei height)
924 glViewport(x, y, width, height);
933 #define _GLES_CHECK_INTERFACE_VOID_2 if (!_GlesInterfaceInitialize_2()) \
937 #define _GLES_CHECK_INTERFACE_GLBOOLEAN_2 if (!_GlesInterfaceInitialize_2()) \
941 #define _GLES_CHECK_INTERFACE_GLENUM_2 if (!_GlesInterfaceInitialize_2()) \
945 #define _GLES_CHECK_INTERFACE_CONSTGLUBYTEP_2 if (!_GlesInterfaceInitialize_2()) \
947 return (const GLubyte*) 0; \
949 #define _GLES_CHECK_INTERFACE_GLUINT_2 if (!_GlesInterfaceInitialize_2()) \
953 #define _GLES_CHECK_INTERFACE_INT_2 if (!_GlesInterfaceInitialize_2()) \
961 struct _GlesInterface2
963 void (* glActiveTexture)(GLenum texture);
964 void (* glAttachShader)(GLuint program, GLuint shader);
965 void (* glBindAttribLocation)(GLuint program, GLuint index, const char* pName);
966 void (* glBindBuffer)(GLenum target, GLuint buffer);
967 void (* glBindFramebuffer)(GLenum target, GLuint framebuffer);
968 void (* glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
969 void (* glBindTexture)(GLenum target, GLuint texture);
970 void (* glBlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
971 void (* glBlendEquation)(GLenum mode);
972 void (* glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
973 void (* glBlendFunc)(GLenum sfactor, GLenum dfactor);
974 void (* glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
975 void (* glBufferData)(GLenum target, GLsizeiptr size, const void* pData, GLenum usage);
976 void (* glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void* pData);
977 GLenum (* glCheckFramebufferStatus)(GLenum target);
978 void (* glClear)(GLbitfield mask);
979 void (* glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
980 void (* glClearDepthf)(GLclampf depth);
981 void (* glClearStencil)(GLint s);
982 void (* glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
983 void (* glCompileShader)(GLuint shader);
984 void (* glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat,
985 GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* pData);
986 void (* glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset,
987 GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* pData);
988 void (* glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y,
989 GLsizei width, GLsizei height, GLint border);
990 void (* glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
991 GLsizei width, GLsizei height);
992 GLuint (* glCreateProgram)(void);
993 GLuint (* glCreateShader)(GLenum type);
994 void (* glCullFace)(GLenum mode);
995 void (* glDeleteBuffers)(GLsizei n, const GLuint* pBuffers);
996 void (* glDeleteFramebuffers)(GLsizei n, const GLuint* pFramebuffers);
997 void (* glDeleteProgram)(GLuint program);
998 void (* glDeleteRenderbuffers)(GLsizei n, const GLuint* pRenderbuffers);
999 void (* glDeleteShader)(GLuint shader);
1000 void (* glDeleteTextures)(GLsizei n, const GLuint* pTextures);
1001 void (* glDepthFunc)(GLenum func);
1002 void (* glDepthMask)(GLboolean flag);
1003 void (* glDepthRangef)(GLclampf zNear, GLclampf zFar);
1004 void (* glDetachShader)(GLuint program, GLuint shader);
1005 void (* glDisable)(GLenum cap);
1006 void (* glDisableVertexAttribArray)(GLuint index);
1007 void (* glDrawArrays)(GLenum mode, GLint first, GLsizei count);
1008 void (* glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void* pIndices);
1009 void (* glEnable)(GLenum cap);
1010 void (* glEnableVertexAttribArray)(GLuint index);
1011 void (* glFinish)(void);
1012 void (* glFlush)(void);
1013 void (* glFramebufferRenderbuffer)(GLenum target, GLenum attachment,
1014 GLenum renderbuffertarget, GLuint renderbuffer);
1015 void (* glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
1016 void (* glFrontFace)(GLenum mode);
1017 void (* glGenBuffers)(GLsizei n, GLuint* pBuffers);
1018 void (* glGenerateMipmap)(GLenum target);
1019 void (* glGenFramebuffers)(GLsizei n, GLuint* pFramebuffers);
1020 void (* glGenRenderbuffers)(GLsizei n, GLuint* pRenderbuffers);
1021 void (* glGenTextures)(GLsizei n, GLuint* pTextures);
1022 void (* glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize,
1023 GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName);
1024 void (* glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* pLength, GLint* pSize,
1025 GLenum* pType, char* pName);
1026 void (* glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* pCount, GLuint* pShaders);
1027 int (* glGetAttribLocation)(GLuint program, const char* pName);
1028 void (* glGetBooleanv)(GLenum pname, GLboolean* pParams);
1029 void (* glGetBufferParameteriv)(GLenum target, GLenum pname, GLint* pParams);
1030 GLenum (* glGetError)(void);
1031 void (* glGetFloatv)(GLenum pname, GLfloat* pParams);
1032 void (* glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* pParams);
1033 void (* glGetIntegerv)(GLenum pname, GLint* pParams);
1034 void (* glGetProgramiv)(GLuint program, GLenum pname, GLint* pParams);
1035 void (* glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* pLength, char* pInfolog);
1036 void (* glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* pParams);
1037 void (* glGetShaderiv)(GLuint shader, GLenum pname, GLint* pParams);
1038 void (* glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pInfolog);
1039 void (* glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* pRange, GLint* pPrecision);
1040 void (* glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pSource);
1041 const GLubyte* (*glGetString)(GLenum name);
1042 void (* glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* pParams);
1043 void (* glGetTexParameteriv)(GLenum target, GLenum pname, GLint* pParams);
1044 void (* glGetUniformfv)(GLuint program, GLint location, GLfloat* pParams);
1045 void (* glGetUniformiv)(GLuint program, GLint location, GLint* pParams);
1046 int (* glGetUniformLocation)(GLuint program, const char* pName);
1047 void (* glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* pParams);
1048 void (* glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* pParams);
1049 void (* glGetVertexAttribPointerv)(GLuint index, GLenum pname, void** ppPointer);
1050 void (* glHint)(GLenum target, GLenum mode);
1051 GLboolean (* glIsBuffer)(GLuint buffer);
1052 GLboolean (* glIsEnabled)(GLenum cap);
1053 GLboolean (* glIsFramebuffer)(GLuint framebuffer);
1054 GLboolean (* glIsProgram)(GLuint program);
1055 GLboolean (* glIsRenderbuffer)(GLuint renderbuffer);
1056 GLboolean (* glIsShader)(GLuint shader);
1057 GLboolean (* glIsTexture)(GLuint texture);
1058 void (* glLineWidth)(GLfloat width);
1059 void (* glLinkProgram)(GLuint program);
1060 void (* glPixelStorei)(GLenum pname, GLint param);
1061 void (* glPolygonOffset)(GLfloat factor, GLfloat units);
1062 void (* glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pPixels);
1063 void (* glReleaseShaderCompiler)(void);
1064 void (* glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
1065 void (* glSampleCoverage)(GLclampf value, GLboolean invert);
1066 void (* glScissor)(GLint x, GLint y, GLsizei width, GLsizei height);
1067 void (* glShaderBinary)(GLint n, GLuint* pShaders, GLenum binaryformat, const void* pBinary, GLint length);
1068 void (* glShaderSource)(GLuint shader, GLsizei count, const char** ppString, const GLint* pLength);
1069 void (* glStencilFunc)(GLenum func, GLint ref, GLuint mask);
1070 void (* glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask);
1071 void (* glStencilMask)(GLuint mask);
1072 void (* glStencilMaskSeparate)(GLenum face, GLuint mask);
1073 void (* glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass);
1074 void (* glStencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
1075 void (* glTexImage2D)(GLenum target, GLint level, GLenum internalformat,
1076 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pPixels);
1077 void (* glTexParameterf)(GLenum target, GLenum pname, GLfloat param);
1078 void (* glTexParameterfv)(GLenum target, GLenum pname, const GLfloat* pParams);
1079 void (* glTexParameteri)(GLenum target, GLenum pname, GLint param);
1080 void (* glTexParameteriv)(GLenum target, GLenum pname, const GLint* pParams);
1081 void (* glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset,
1082 GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pPixels);
1083 void (* glUniform1f)(GLint location, GLfloat x);
1084 void (* glUniform1fv)(GLint location, GLsizei count, const GLfloat* pV);
1085 void (* glUniform1i)(GLint location, GLint x);
1086 void (* glUniform1iv)(GLint location, GLsizei count, const GLint* pV);
1087 void (* glUniform2f)(GLint location, GLfloat x, GLfloat y);
1088 void (* glUniform2fv)(GLint location, GLsizei count, const GLfloat* pV);
1089 void (* glUniform2i)(GLint location, GLint x, GLint y);
1090 void (* glUniform2iv)(GLint location, GLsizei count, const GLint* pV);
1091 void (* glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z);
1092 void (* glUniform3fv)(GLint location, GLsizei count, const GLfloat* pV);
1093 void (* glUniform3i)(GLint location, GLint x, GLint y, GLint z);
1094 void (* glUniform3iv)(GLint location, GLsizei count, const GLint* pV);
1095 void (* glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1096 void (* glUniform4fv)(GLint location, GLsizei count, const GLfloat* pV);
1097 void (* glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w);
1098 void (* glUniform4iv)(GLint location, GLsizei count, const GLint* pV);
1099 void (* glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue);
1100 void (* glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue);
1101 void (* glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue);
1102 void (* glUseProgram)(GLuint program);
1103 void (* glValidateProgram)(GLuint program);
1104 void (* glVertexAttrib1f)(GLuint indx, GLfloat x);
1105 void (* glVertexAttrib1fv)(GLuint indx, const GLfloat* pValues);
1106 void (* glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y);
1107 void (* glVertexAttrib2fv)(GLuint indx, const GLfloat* pValues);
1108 void (* glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
1109 void (* glVertexAttrib3fv)(GLuint indx, const GLfloat* pValues);
1110 void (* glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1111 void (* glVertexAttrib4fv)(GLuint indx, const GLfloat* pValues);
1112 void (* glVertexAttribPointer)(GLuint indx, GLint size,
1113 GLenum type, GLboolean normalized, GLsizei stride, const void* pPtr);
1114 void (* glViewport)(GLint x, GLint y, GLsizei width, GLsizei height);
1117 void* _pGlesLib2 = NULL;
1118 _GlesInterface2 _glesImpl2 = {0, };
1120 const int _MAX_GLES_FUNCTION_2 = 142;
1121 const char _glesStrings2[_MAX_GLES_FUNCTION_2][64] =
1125 "glBindAttribLocation",
1127 "glBindFramebuffer",
1128 "glBindRenderbuffer",
1132 "glBlendEquationSeparate",
1134 "glBlendFuncSeparate",
1137 "glCheckFramebufferStatus",
1143 "glCompileShader", //20
1144 "glCompressedTexImage2D",
1145 "glCompressedTexSubImage2D",
1147 "glCopyTexSubImage2D",
1152 "glDeleteFramebuffers",
1153 "glDeleteProgram", //30
1154 "glDeleteRenderbuffers",
1162 "glDisableVertexAttribArray",
1163 "glDrawArrays", //40
1166 "glEnableVertexAttribArray",
1169 "glFramebufferRenderbuffer",
1170 "glFramebufferTexture2D",
1173 "glGenerateMipmap", //50
1174 "glGenFramebuffers",
1175 "glGenRenderbuffers",
1177 "glGetActiveAttrib",
1178 "glGetActiveUniform",
1179 "glGetAttachedShaders",
1180 "glGetAttribLocation",
1182 "glGetBufferParameteriv",
1185 "glGetFramebufferAttachmentParameteriv",
1188 "glGetProgramInfoLog",
1189 "glGetRenderbufferParameteriv",
1191 "glGetShaderInfoLog",
1192 "glGetShaderPrecisionFormat",
1193 "glGetShaderSource", //70
1195 "glGetTexParameterfv",
1196 "glGetTexParameteriv",
1199 "glGetUniformLocation",
1200 "glGetVertexAttribfv",
1201 "glGetVertexAttribiv",
1202 "glGetVertexAttribPointerv",
1213 "glPixelStorei", //90
1216 "glReleaseShaderCompiler",
1217 "glRenderbufferStorage",
1223 "glStencilFuncSeparate", //100
1225 "glStencilMaskSeparate",
1227 "glStencilOpSeparate",
1233 "glTexSubImage2D", //110
1243 "glUniform3fv", //120
1250 "glUniformMatrix2fv",
1251 "glUniformMatrix3fv",
1252 "glUniformMatrix4fv",
1253 "glUseProgram", //130
1254 "glValidateProgram",
1256 "glVertexAttrib1fv",
1258 "glVertexAttrib2fv",
1260 "glVertexAttrib3fv",
1262 "glVertexAttrib4fv",
1263 "glVertexAttribPointer", //140
1268 _GlesInterfaceInitialize_2(void)
1272 if (_pGlesLib2 == NULL)
1274 ptrdiff_t** ppPtr = (ptrdiff_t**) (&_glesImpl2);
1276 _pGlesLib2 = dlopen("libGLESv2.so", RTLD_LAZY | RTLD_GLOBAL);
1277 if (_pGlesLib2 == NULL)
1279 SysLog(NID_GRP, "gles2 dlopen failed! %s", dlerror());
1283 for (count = 0; count < _MAX_GLES_FUNCTION_2; count++)
1285 *ppPtr = (ptrdiff_t*) (dlsym(_pGlesLib2, _glesStrings2[count]));
1289 SysLog(NID_GRP, "dlsym failed! %s name : %s", dlerror(), _glesStrings2[count]);
1305 #if defined(FGRAPHICS_INTERNAL_USE_FBO)
1306 GLuint _GlesGetCurrentFbo(void);
1307 bool _GlesFboEnableStencil(GLuint& frameBufferObject, GLuint& renderBuffer);
1311 _GlesInterfaceTerminate_2(void)
1313 if (_pGlesLib2 != NULL)
1315 dlclose(_pGlesLib2);
1321 _GlActiveTexture_2(GLenum texture)
1323 _GLES_CHECK_INTERFACE_VOID_2
1324 _glesImpl2.glActiveTexture(texture);
1328 _GlAttachShader_2(GLuint program, GLuint shader)
1330 _GLES_CHECK_INTERFACE_VOID_2
1331 _glesImpl2.glAttachShader(program, shader);
1335 _GlBindAttribLocation_2(GLuint program, GLuint index, const char* pNname)
1337 _GLES_CHECK_INTERFACE_VOID_2
1338 _glesImpl2.glBindAttribLocation(program, index, pNname);
1342 _GlBindBuffer_2(GLenum target, GLuint buffer)
1344 _GLES_CHECK_INTERFACE_VOID_2
1345 _glesImpl2.glBindBuffer(target, buffer);
1349 _GlBindFramebuffer_2(GLenum target, GLuint framebuffer)
1351 _GLES_CHECK_INTERFACE_VOID_2
1353 #if defined(FGRAPHICS_INTERNAL_USE_FBO)
1354 if (framebuffer == 0)
1356 framebuffer = _GlesGetCurrentFbo();
1360 _glesImpl2.glBindFramebuffer(target, framebuffer);
1364 _GlBindRenderbuffer_2(GLenum target, GLuint renderbuffer)
1366 _GLES_CHECK_INTERFACE_VOID_2
1367 _glesImpl2.glBindRenderbuffer(target, renderbuffer);
1371 _GlBindTexture_2(GLenum target, GLuint texture)
1373 _GLES_CHECK_INTERFACE_VOID_2
1374 _glesImpl2.glBindTexture(target, texture);
1378 _GlBlendColor_2(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1380 _GLES_CHECK_INTERFACE_VOID_2
1381 _glesImpl2.glBlendColor(red, green, blue, alpha);
1385 _GlBlendEquation_2(GLenum mode)
1387 _GLES_CHECK_INTERFACE_VOID_2
1388 _glesImpl2.glBlendEquation(mode);
1392 _GlBlendEquationSeparate_2(GLenum modeRGB, GLenum modeAlpha)
1394 _GLES_CHECK_INTERFACE_VOID_2
1395 _glesImpl2.glBlendEquationSeparate(modeRGB, modeAlpha);
1399 _GlBlendFunc_2(GLenum sfactor, GLenum dfactor)
1401 _GLES_CHECK_INTERFACE_VOID_2
1402 _glesImpl2.glBlendFunc(sfactor, dfactor);
1406 _GlBlendFuncSeparate_2(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
1408 _GLES_CHECK_INTERFACE_VOID_2
1409 _glesImpl2.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
1413 _GlBufferData_2(GLenum target, GLsizeiptr size, const void* pData, GLenum usage)
1415 _GLES_CHECK_INTERFACE_VOID_2
1416 _glesImpl2.glBufferData(target, size, pData, usage);
1420 _GlBufferSubData_2(GLenum target, GLintptr offset, GLsizeiptr size, const void* pData)
1422 _GLES_CHECK_INTERFACE_VOID_2
1423 _glesImpl2.glBufferSubData(target, offset, size, pData);
1427 _GlCheckFramebufferStatus_2(GLenum target)
1429 _GLES_CHECK_INTERFACE_GLENUM_2
1430 return _glesImpl2.glCheckFramebufferStatus(target);
1434 _GlClear_2(GLbitfield mask)
1436 _GLES_CHECK_INTERFACE_VOID_2
1437 _glesImpl2.glClear(mask);
1441 _GlClearColor_2(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
1443 _GLES_CHECK_INTERFACE_VOID_2
1444 _glesImpl2.glClearColor(red, green, blue, alpha);
1448 _GlClearDepthf_2(GLclampf depth)
1450 _GLES_CHECK_INTERFACE_VOID_2
1451 _glesImpl2.glClearDepthf(depth);
1455 _GlClearStencil_2(GLint s)
1457 _GLES_CHECK_INTERFACE_VOID_2
1458 _glesImpl2.glClearStencil(s);
1462 _GlColorMask_2(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
1464 _GLES_CHECK_INTERFACE_VOID_2
1465 _glesImpl2.glColorMask(red, green, blue, alpha);
1469 _GlCompileShader_2(GLuint shader)
1471 _GLES_CHECK_INTERFACE_VOID_2
1472 _glesImpl2.glCompileShader(shader);
1476 _GlCompressedTexImage2D_2(GLenum target, GLint level, GLenum internalformat,
1477 GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* pData)
1479 _GLES_CHECK_INTERFACE_VOID_2
1480 _glesImpl2.glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pData);
1484 _GlCompressedTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset,
1485 GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* pData)
1487 _GLES_CHECK_INTERFACE_VOID_2
1488 _glesImpl2.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pData);
1492 _GlCopyTexImage2D_2(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y,
1493 GLsizei width, GLsizei height, GLint border)
1495 _GLES_CHECK_INTERFACE_VOID_2
1496 _glesImpl2.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
1500 _GlCopyTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x,
1501 GLint y, GLsizei width, GLsizei height)
1503 _GLES_CHECK_INTERFACE_VOID_2
1504 _glesImpl2.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
1508 _GlCreateProgram_2(void)
1510 _GLES_CHECK_INTERFACE_GLUINT_2
1511 return _glesImpl2.glCreateProgram();
1515 _GlCreateShader_2(GLenum type)
1517 _GLES_CHECK_INTERFACE_GLUINT_2
1518 return _glesImpl2.glCreateShader(type);
1522 _GlCullFace_2(GLenum mode)
1524 _GLES_CHECK_INTERFACE_VOID_2
1525 _glesImpl2.glCullFace(mode);
1529 _GlDeleteBuffers_2(GLsizei n, const GLuint* pBuffers)
1531 _GLES_CHECK_INTERFACE_VOID_2
1532 _glesImpl2.glDeleteBuffers(n, pBuffers);
1536 _GlDeleteFramebuffers_2(GLsizei n, const GLuint* pFramebuffers)
1538 _GLES_CHECK_INTERFACE_VOID_2
1539 _glesImpl2.glDeleteFramebuffers(n, pFramebuffers);
1543 _GlDeleteProgram_2(GLuint program)
1545 _GLES_CHECK_INTERFACE_VOID_2
1546 _glesImpl2.glDeleteProgram(program);
1550 _GlDeleteRenderbuffers_2(GLsizei n, const GLuint* pRenderbuffers)
1552 _GLES_CHECK_INTERFACE_VOID_2
1553 _glesImpl2.glDeleteRenderbuffers(n, pRenderbuffers);
1557 _GlDeleteShader_2(GLuint shader)
1559 _GLES_CHECK_INTERFACE_VOID_2
1560 _glesImpl2.glDeleteShader(shader);
1564 _GlDeleteTextures_2(GLsizei n, const GLuint* pTextures)
1566 _GLES_CHECK_INTERFACE_VOID_2
1567 _glesImpl2.glDeleteTextures(n, pTextures);
1571 _GlDepthFunc_2(GLenum func)
1573 _GLES_CHECK_INTERFACE_VOID_2
1574 _glesImpl2.glDepthFunc(func);
1578 _GlDepthMask_2(GLboolean flag)
1580 _GLES_CHECK_INTERFACE_VOID_2
1581 _glesImpl2.glDepthMask(flag);
1585 _GlDepthRangef_2(GLclampf zNear, GLclampf zFar)
1587 _GLES_CHECK_INTERFACE_VOID_2
1588 _glesImpl2.glDepthRangef(zNear, zFar);
1592 _GlDetachShader_2(GLuint program, GLuint shader)
1594 _GLES_CHECK_INTERFACE_VOID_2
1595 _glesImpl2.glDetachShader(program, shader);
1599 _GlDisable_2(GLenum cap)
1601 _GLES_CHECK_INTERFACE_VOID_2
1602 _glesImpl2.glDisable(cap);
1606 _GlDisableVertexAttribArray_2(GLuint index)
1608 _GLES_CHECK_INTERFACE_VOID_2
1609 _glesImpl2.glDisableVertexAttribArray(index);
1613 _GlDrawArrays_2(GLenum mode, GLint first, GLsizei count)
1615 _GLES_CHECK_INTERFACE_VOID_2
1616 _glesImpl2.glDrawArrays(mode, first, count);
1620 _GlDrawElements_2(GLenum mode, GLsizei count, GLenum type, const void* pIndices)
1622 _GLES_CHECK_INTERFACE_VOID_2
1623 _glesImpl2.glDrawElements(mode, count, type, pIndices);
1627 _GlEnable_2(GLenum cap)
1629 _GLES_CHECK_INTERFACE_VOID_2
1630 #if defined(FGRAPHICS_INTERNAL_USE_FBO)
1631 if (cap == GL_STENCIL_TEST)
1633 GLuint frameBufferObject = 0;
1634 GLuint stencilRenderBuffer = 0;
1636 bool ret = _GlesFboEnableStencil(frameBufferObject, stencilRenderBuffer);
1640 _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
1641 _glesImpl2.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencilRenderBuffer);
1645 _glesImpl2.glEnable(cap);
1649 _GlEnableVertexAttribArray_2(GLuint index)
1651 _GLES_CHECK_INTERFACE_VOID_2
1652 _glesImpl2.glEnableVertexAttribArray(index);
1658 _GLES_CHECK_INTERFACE_VOID_2
1659 _glesImpl2.glFinish();
1665 _GLES_CHECK_INTERFACE_VOID_2
1666 _glesImpl2.glFlush();
1670 _GlFramebufferRenderbuffer_2(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
1672 _GLES_CHECK_INTERFACE_VOID_2
1673 _glesImpl2.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
1677 _GlFramebufferTexture2D_2(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
1679 _GLES_CHECK_INTERFACE_VOID_2
1680 _glesImpl2.glFramebufferTexture2D(target, attachment, textarget, texture, level);
1684 _GlFrontFace_2(GLenum mode)
1686 _GLES_CHECK_INTERFACE_VOID_2
1687 _glesImpl2.glFrontFace(mode);
1691 _GlGenBuffers_2(GLsizei n, GLuint* pBuffers)
1693 _GLES_CHECK_INTERFACE_VOID_2
1694 _glesImpl2.glGenBuffers(n, pBuffers);
1698 _GlGenerateMipmap_2(GLenum target)
1700 _GLES_CHECK_INTERFACE_VOID_2
1701 _glesImpl2.glGenerateMipmap(target);
1705 _GlGenFramebuffers_2(GLsizei n, GLuint* pFramebuffers)
1707 _GLES_CHECK_INTERFACE_VOID_2
1708 _glesImpl2.glGenFramebuffers(n, pFramebuffers);
1712 _GlGenRenderbuffers_2(GLsizei n, GLuint* pRenderbuffers)
1714 _GLES_CHECK_INTERFACE_VOID_2
1715 _glesImpl2.glGenRenderbuffers(n, pRenderbuffers);
1719 _GlGenTextures_2(GLsizei n, GLuint* textures)
1721 _GLES_CHECK_INTERFACE_VOID_2
1722 _glesImpl2.glGenTextures(n, textures);
1726 _GlGetActiveAttrib_2(GLuint program, GLuint index, GLsizei bufsize,
1727 GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName)
1729 _GLES_CHECK_INTERFACE_VOID_2
1730 _glesImpl2.glGetActiveAttrib(program, index, bufsize, pLength, pSize, pType, pName);
1734 _GlGetActiveUniform_2(GLuint program, GLuint index, GLsizei bufsize,
1735 GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName)
1737 _GLES_CHECK_INTERFACE_VOID_2
1738 _glesImpl2.glGetActiveUniform(program, index, bufsize, pLength, pSize, pType, pName);
1742 _GlGetAttachedShaders_2(GLuint program, GLsizei maxcount, GLsizei* pCount, GLuint* pShaders)
1744 _GLES_CHECK_INTERFACE_VOID_2
1745 _glesImpl2.glGetAttachedShaders(program, maxcount, pCount, pShaders);
1749 _GlGetAttribLocation_2(GLuint program, const char* pName)
1751 _GLES_CHECK_INTERFACE_INT_2
1752 return _glesImpl2.glGetAttribLocation(program, pName);
1756 _GlGetBooleanv_2(GLenum pname, GLboolean* pParams)
1758 _GLES_CHECK_INTERFACE_VOID_2
1759 _glesImpl2.glGetBooleanv(pname, pParams);
1763 _GlGetBufferParameteriv_2(GLenum target, GLenum pname, GLint* pParams)
1765 _GLES_CHECK_INTERFACE_VOID_2
1766 _glesImpl2.glGetBufferParameteriv(target, pname, pParams);
1772 _GLES_CHECK_INTERFACE_GLENUM_2
1773 return _glesImpl2.glGetError();
1777 _GlGetFloatv_2(GLenum pname, GLfloat* pParams)
1779 _GLES_CHECK_INTERFACE_VOID_2
1780 _glesImpl2.glGetFloatv(pname, pParams);
1784 _GlGetFramebufferAttachmentParameteriv_2(GLenum target, GLenum attachment, GLenum pname, GLint* pParams)
1786 _GLES_CHECK_INTERFACE_VOID_2
1787 _glesImpl2.glGetFramebufferAttachmentParameteriv(target, attachment, pname, pParams);
1791 _GlGetIntegerv_2(GLenum pname, GLint* pParams)
1793 _GLES_CHECK_INTERFACE_VOID_2
1794 _glesImpl2.glGetIntegerv(pname, pParams);
1798 _GlGetProgramiv_2(GLuint program, GLenum pname, GLint* pParams)
1800 _GLES_CHECK_INTERFACE_VOID_2
1801 _glesImpl2.glGetProgramiv(program, pname, pParams);
1805 _GlGetProgramInfoLog_2(GLuint program, GLsizei bufsize, GLsizei* pLength, char* pInfolog)
1807 _GLES_CHECK_INTERFACE_VOID_2
1808 _glesImpl2.glGetProgramInfoLog(program, bufsize, pLength, pInfolog);
1812 _GlGetRenderbufferParameteriv_2(GLenum target, GLenum pname, GLint* pParams)
1814 _GLES_CHECK_INTERFACE_VOID_2
1815 _glesImpl2.glGetRenderbufferParameteriv(target, pname, pParams);
1819 _GlGetShaderiv_2(GLuint shader, GLenum pname, GLint* pParams)
1821 _GLES_CHECK_INTERFACE_VOID_2
1822 _glesImpl2.glGetShaderiv(shader, pname, pParams);
1826 _GlGetShaderInfoLog_2(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pInfolog)
1828 _GLES_CHECK_INTERFACE_VOID_2
1829 _glesImpl2.glGetShaderInfoLog(shader, bufsize, pLength, pInfolog);
1833 _GlGetShaderPrecisionFormat_2(GLenum shadertype, GLenum precisiontype, GLint* pRange, GLint* pPrecision)
1835 _GLES_CHECK_INTERFACE_VOID_2
1836 _glesImpl2.glGetShaderPrecisionFormat(shadertype, precisiontype, pRange, pPrecision);
1840 _GlGetShaderSource_2(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pSource)
1842 _GLES_CHECK_INTERFACE_VOID_2
1843 _glesImpl2.glGetShaderSource(shader, bufsize, pLength, pSource);
1847 _GlGetString_2(GLenum name)
1849 _GLES_CHECK_INTERFACE_CONSTGLUBYTEP_2
1850 return _glesImpl2.glGetString(name);
1854 _GlGetTexParameterfv_2(GLenum target, GLenum pname, GLfloat* pParams)
1856 _GLES_CHECK_INTERFACE_VOID_2
1857 _glesImpl2.glGetTexParameterfv(target, pname, pParams);
1861 _GlGetTexParameteriv_2(GLenum target, GLenum pname, GLint* pParams)
1863 _GLES_CHECK_INTERFACE_VOID_2
1864 _glesImpl2.glGetTexParameteriv(target, pname, pParams);
1868 _GlGetUniformfv_2(GLuint program, GLint location, GLfloat* pParams)
1870 _GLES_CHECK_INTERFACE_VOID_2
1871 _glesImpl2.glGetUniformfv(program, location, pParams);
1875 _GlGetUniformiv_2(GLuint program, GLint location, GLint* pParams)
1877 _GLES_CHECK_INTERFACE_VOID_2
1878 _glesImpl2.glGetUniformiv(program, location, pParams);
1882 _GlGetUniformLocation_2(GLuint program, const char* pName)
1884 _GLES_CHECK_INTERFACE_INT_2
1885 return _glesImpl2.glGetUniformLocation(program, pName);
1889 _GlGetVertexAttribfv_2(GLuint index, GLenum pname, GLfloat* pParams)
1891 _GLES_CHECK_INTERFACE_VOID_2
1892 _glesImpl2.glGetVertexAttribfv(index, pname, pParams);
1896 _GlGetVertexAttribiv_2(GLuint index, GLenum pname, GLint* pParams)
1898 _GLES_CHECK_INTERFACE_VOID_2
1899 _glesImpl2.glGetVertexAttribiv(index, pname, pParams);
1903 _GlGetVertexAttribPointerv_2(GLuint index, GLenum pname, void** ppPointer)
1905 _GLES_CHECK_INTERFACE_VOID_2
1906 _glesImpl2.glGetVertexAttribPointerv(index, pname, ppPointer);
1910 _GlHint_2(GLenum target, GLenum mode)
1912 _GLES_CHECK_INTERFACE_VOID_2
1913 _glesImpl2.glHint(target, mode);
1917 _GlIsBuffer_2(GLuint buffer)
1919 _GLES_CHECK_INTERFACE_GLBOOLEAN_2
1920 return _glesImpl2.glIsBuffer(buffer);
1924 _GlIsEnabled_2(GLenum cap)
1926 _GLES_CHECK_INTERFACE_GLBOOLEAN_2
1927 return _glesImpl2.glIsEnabled(cap);
1931 _GlIsFramebuffer_2(GLuint framebuffer)
1933 _GLES_CHECK_INTERFACE_GLBOOLEAN_2
1934 return _glesImpl2.glIsFramebuffer(framebuffer);
1938 _GlIsProgram_2(GLuint program)
1940 _GLES_CHECK_INTERFACE_GLBOOLEAN_2
1941 return _glesImpl2.glIsProgram(program);
1945 _GlIsRenderbuffer_2(GLuint renderbuffer)
1947 _GLES_CHECK_INTERFACE_GLBOOLEAN_2
1948 return _glesImpl2.glIsRenderbuffer(renderbuffer);
1952 _GlIsShader_2(GLuint shader)
1954 _GLES_CHECK_INTERFACE_GLBOOLEAN_2
1955 return _glesImpl2.glIsShader(shader);
1959 _GlIsTexture_2(GLuint texture)
1961 _GLES_CHECK_INTERFACE_GLBOOLEAN_2
1962 return _glesImpl2.glIsTexture(texture);
1966 _GlLineWidth_2(GLfloat width)
1968 _GLES_CHECK_INTERFACE_VOID_2
1969 _glesImpl2.glLineWidth(width);
1973 _GlLinkProgram_2(GLuint program)
1975 _GLES_CHECK_INTERFACE_VOID_2
1976 _glesImpl2.glLinkProgram(program);
1980 _GlPixelStorei_2(GLenum pname, GLint param)
1982 _GLES_CHECK_INTERFACE_VOID_2
1983 _glesImpl2.glPixelStorei(pname, param);
1987 _GlPolygonOffset_2(GLfloat factor, GLfloat units)
1989 _GLES_CHECK_INTERFACE_VOID_2
1990 _glesImpl2.glPolygonOffset(factor, units);
1994 _GlReadPixels_2(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pPixels)
1996 _GLES_CHECK_INTERFACE_VOID_2
1997 _glesImpl2.glReadPixels(x, y, width, height, format, type, pPixels);
2001 _GlReleaseShaderCompiler_2(void)
2003 _GLES_CHECK_INTERFACE_VOID_2
2004 _glesImpl2.glReleaseShaderCompiler();
2008 _GlRenderbufferStorage_2(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
2010 _GLES_CHECK_INTERFACE_VOID_2
2011 _glesImpl2.glRenderbufferStorage(target, internalformat, width, height);
2015 _GlSampleCoverage_2(GLclampf value, GLboolean invert)
2017 _GLES_CHECK_INTERFACE_VOID_2
2018 _glesImpl2.glSampleCoverage(value, invert);
2022 _GlScissor_2(GLint x, GLint y, GLsizei width, GLsizei height)
2024 _GLES_CHECK_INTERFACE_VOID_2
2025 _glesImpl2.glScissor(x, y, width, height);
2029 _GlShaderBinary_2(GLint n, GLuint* shaders, GLenum binaryformat, const void* pBinary, GLint length)
2031 _GLES_CHECK_INTERFACE_VOID_2
2032 _glesImpl2.glShaderBinary(n, shaders, binaryformat, pBinary, length);
2036 _GlShaderSource_2(GLuint shader, GLsizei count, const char** ppString, const GLint* pLength)
2038 _GLES_CHECK_INTERFACE_VOID_2
2039 _glesImpl2.glShaderSource(shader, count, ppString, pLength);
2043 _GlStencilFunc_2(GLenum func, GLint ref, GLuint mask)
2045 _GLES_CHECK_INTERFACE_VOID_2
2046 _glesImpl2.glStencilFunc(func, ref, mask);
2050 _GlStencilFuncSeparate_2(GLenum face, GLenum func, GLint ref, GLuint mask)
2052 _GLES_CHECK_INTERFACE_VOID_2
2053 _glesImpl2.glStencilFuncSeparate(face, func, ref, mask);
2057 _GlStencilMask_2(GLuint mask)
2059 _GLES_CHECK_INTERFACE_VOID_2
2060 _glesImpl2.glStencilMask(mask);
2064 _GlStencilMaskSeparate_2(GLenum face, GLuint mask)
2066 _GLES_CHECK_INTERFACE_VOID_2
2067 _glesImpl2.glStencilMaskSeparate(face, mask);
2071 _GlStencilOp_2(GLenum fail, GLenum zfail, GLenum zpass)
2073 _GLES_CHECK_INTERFACE_VOID_2
2074 _glesImpl2.glStencilOp(fail, zfail, zpass);
2078 _GlStencilOpSeparate_2(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
2080 _GLES_CHECK_INTERFACE_VOID_2
2081 _glesImpl2.glStencilOpSeparate(face, fail, zfail, zpass);
2085 _GlTexImage2D_2(GLenum target, GLint level, GLenum internalformat,
2086 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pPixels)
2088 _GLES_CHECK_INTERFACE_VOID_2
2089 _glesImpl2.glTexImage2D(target, level, internalformat, width, height, border, format, type, pPixels);
2093 _GlTexParameterf_2(GLenum target, GLenum pname, GLfloat param)
2095 _GLES_CHECK_INTERFACE_VOID_2
2096 _glesImpl2.glTexParameterf(target, pname, param);
2100 _GlTexParameterfv_2(GLenum target, GLenum pname, const GLfloat* pParams)
2102 _GLES_CHECK_INTERFACE_VOID_2
2103 _glesImpl2.glTexParameterfv(target, pname, pParams);
2107 _GlTexParameteri_2(GLenum target, GLenum pname, GLint param)
2109 _GLES_CHECK_INTERFACE_VOID_2
2110 _glesImpl2.glTexParameteri(target, pname, param);
2114 _GlTexParameteriv_2(GLenum target, GLenum pname, const GLint* pParams)
2116 _GLES_CHECK_INTERFACE_VOID_2
2117 _glesImpl2.glTexParameteriv(target, pname, pParams);
2121 _GlTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset,
2122 GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pPixels)
2124 _GLES_CHECK_INTERFACE_VOID_2
2125 _glesImpl2.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pPixels);
2129 _GlUniform1f_2(GLint location, GLfloat x)
2131 _GLES_CHECK_INTERFACE_VOID_2
2132 _glesImpl2.glUniform1f(location, x);
2136 _GlUniform1fv_2(GLint location, GLsizei count, const GLfloat* pV)
2138 _GLES_CHECK_INTERFACE_VOID_2
2139 _glesImpl2.glUniform1fv(location, count, pV);
2143 _GlUniform1i_2(GLint location, GLint x)
2145 _GLES_CHECK_INTERFACE_VOID_2
2146 _glesImpl2.glUniform1i(location, x);
2150 _GlUniform1iv_2(GLint location, GLsizei count, const GLint* pV)
2152 _GLES_CHECK_INTERFACE_VOID_2
2153 _glesImpl2.glUniform1iv(location, count, pV);
2157 _GlUniform2f_2(GLint location, GLfloat x, GLfloat y)
2159 _GLES_CHECK_INTERFACE_VOID_2
2160 _glesImpl2.glUniform2f(location, x, y);
2164 _GlUniform2fv_2(GLint location, GLsizei count, const GLfloat* pV)
2166 _GLES_CHECK_INTERFACE_VOID_2
2167 _glesImpl2.glUniform2fv(location, count, pV);
2171 _GlUniform2i_2(GLint location, GLint x, GLint y)
2173 _GLES_CHECK_INTERFACE_VOID_2
2174 _glesImpl2.glUniform2i(location, x, y);
2178 _GlUniform2iv_2(GLint location, GLsizei count, const GLint* pV)
2180 _GLES_CHECK_INTERFACE_VOID_2
2181 _glesImpl2.glUniform2iv(location, count, pV);
2185 _GlUniform3f_2(GLint location, GLfloat x, GLfloat y, GLfloat z)
2187 _GLES_CHECK_INTERFACE_VOID_2
2188 _glesImpl2.glUniform3f(location, x, y, z);
2192 _GlUniform3fv_2(GLint location, GLsizei count, const GLfloat* pV)
2194 _GLES_CHECK_INTERFACE_VOID_2
2195 _glesImpl2.glUniform3fv(location, count, pV);
2199 _GlUniform3i_2(GLint location, GLint x, GLint y, GLint z)
2201 _GLES_CHECK_INTERFACE_VOID_2
2202 _glesImpl2.glUniform3i(location, x, y, z);
2206 _GlUniform3iv_2(GLint location, GLsizei count, const GLint* pV)
2208 _GLES_CHECK_INTERFACE_VOID_2
2209 _glesImpl2.glUniform3iv(location, count, pV);
2213 _GlUniform4f_2(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
2215 _GLES_CHECK_INTERFACE_VOID_2
2216 _glesImpl2.glUniform4f(location, x, y, z, w);
2220 _GlUniform4fv_2(GLint location, GLsizei count, const GLfloat* pV)
2222 _GLES_CHECK_INTERFACE_VOID_2
2223 _glesImpl2.glUniform4fv(location, count, pV);
2227 _GlUniform4i_2(GLint location, GLint x, GLint y, GLint z, GLint w)
2229 _GLES_CHECK_INTERFACE_VOID_2
2230 _glesImpl2.glUniform4i(location, x, y, z, w);
2234 _GlUniform4iv_2(GLint location, GLsizei count, const GLint* v)
2236 _GLES_CHECK_INTERFACE_VOID_2
2237 _glesImpl2.glUniform4iv(location, count, v);
2241 _GlUniformMatrix2fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue)
2243 _GLES_CHECK_INTERFACE_VOID_2
2244 _glesImpl2.glUniformMatrix2fv(location, count, transpose, pValue);
2248 _GlUniformMatrix3fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue)
2250 _GLES_CHECK_INTERFACE_VOID_2
2251 _glesImpl2.glUniformMatrix3fv(location, count, transpose, pValue);
2255 _GlUniformMatrix4fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue)
2257 _GLES_CHECK_INTERFACE_VOID_2
2258 _glesImpl2.glUniformMatrix4fv(location, count, transpose, pValue);
2262 _GlUseProgram_2(GLuint program)
2264 _GLES_CHECK_INTERFACE_VOID_2
2265 _glesImpl2.glUseProgram(program);
2269 _GlValidateProgram_2(GLuint program)
2271 _GLES_CHECK_INTERFACE_VOID_2
2272 _glesImpl2.glValidateProgram(program);
2276 _GlVertexAttrib1f_2(GLuint indx, GLfloat x)
2278 _GLES_CHECK_INTERFACE_VOID_2
2279 _glesImpl2.glVertexAttrib1f(indx, x);
2283 _GlVertexAttrib1fv_2(GLuint indx, const GLfloat* pValues)
2285 _GLES_CHECK_INTERFACE_VOID_2
2286 _glesImpl2.glVertexAttrib1fv(indx, pValues);
2290 _GlVertexAttrib2f_2(GLuint indx, GLfloat x, GLfloat y)
2292 _GLES_CHECK_INTERFACE_VOID_2
2293 _glesImpl2.glVertexAttrib2f(indx, x, y);
2297 _GlVertexAttrib2fv_2(GLuint indx, const GLfloat* pValues)
2299 _GLES_CHECK_INTERFACE_VOID_2
2300 _glesImpl2.glVertexAttrib2fv(indx, pValues);
2304 _GlVertexAttrib3f_2(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
2306 _GLES_CHECK_INTERFACE_VOID_2
2307 _glesImpl2.glVertexAttrib3f(indx, x, y, z);
2311 _GlVertexAttrib3fv_2(GLuint indx, const GLfloat* pValues)
2313 _GLES_CHECK_INTERFACE_VOID_2
2314 _glesImpl2.glVertexAttrib3fv(indx, pValues);
2318 _GlVertexAttrib4f_2(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
2320 _GLES_CHECK_INTERFACE_VOID_2
2321 _glesImpl2.glVertexAttrib4f(indx, x, y, z, w);
2325 _GlVertexAttrib4fv_2(GLuint indx, const GLfloat* pValues)
2327 _GLES_CHECK_INTERFACE_VOID_2
2328 _glesImpl2.glVertexAttrib4fv(indx, pValues);
2332 _GlVertexAttribPointer_2(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pPtr)
2334 _GLES_CHECK_INTERFACE_VOID_2
2335 _glesImpl2.glVertexAttribPointer(indx, size, type, normalized, stride, pPtr);
2339 _GlViewport_2(GLint x, GLint y, GLsizei width, GLsizei height)
2341 _GLES_CHECK_INTERFACE_VOID_2
2342 _glesImpl2.glViewport(x, y, width, height);
2345 #if defined(FGRAPHICS_INTERNAL_USE_FBO)
2347 _CreateShader(GLuint& program)
2349 _GLES_CHECK_INTERFACE_GLBOOLEAN_2
2350 const char* VERTEX_TEXT =
2351 "attribute vec4 aPosition;\n"
2352 "attribute vec2 aTextureCoord;\n"
2353 "varying vec2 vTextureCoord;\n"
2357 " gl_Position = aPosition;\n"
2358 " vTextureCoord = aTextureCoord;\n"
2361 const char* FRAGMENT_TEXT =
2362 "precision highp float;\n"
2363 "uniform sampler2D uTexture;\n"
2364 "varying vec2 vTextureCoord;\n"
2366 "void main (void)\n"
2368 " gl_FragColor = texture2D(uTexture, vTextureCoord);\n"
2371 GLint linked = GL_FALSE;
2372 GLint bShaderCompiled = GL_FALSE;
2373 GLuint fragShader = _glesImpl2.glCreateShader(GL_FRAGMENT_SHADER);
2374 GLuint vertShader = _glesImpl2.glCreateShader(GL_VERTEX_SHADER);
2376 _glesImpl2.glShaderSource(fragShader, 1, (const char**)(&FRAGMENT_TEXT), NULL);
2377 _glesImpl2.glCompileShader(fragShader);
2378 _glesImpl2.glGetShaderiv(fragShader, GL_COMPILE_STATUS, &bShaderCompiled);
2380 _glesImpl2.glShaderSource(vertShader, 1, (const char**)&VERTEX_TEXT, NULL);
2381 _glesImpl2.glCompileShader(vertShader);
2382 _glesImpl2.glGetShaderiv(vertShader, GL_COMPILE_STATUS, &bShaderCompiled);
2384 program = _glesImpl2.glCreateProgram();
2386 _glesImpl2.glAttachShader(program, fragShader);
2387 _glesImpl2.glAttachShader(program, vertShader);
2388 _glesImpl2.glLinkProgram(program);
2389 _glesImpl2.glGetProgramiv(program, GL_LINK_STATUS, &linked);
2391 _glesImpl2.glDeleteShader(fragShader);
2392 _glesImpl2.glDeleteShader(vertShader);
2394 if (linked == GL_FALSE)
2397 _glesImpl2.glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLen);
2400 std::unique_ptr<char[]> autoPtrInfoLog(new (std::nothrow) char[infoLen]);
2401 _glesImpl2.glGetProgramInfoLog(program, infoLen, NULL, autoPtrInfoLog.get());
2402 SysLog(NID_GRP, "FBO Program Linking failed. log: %s", autoPtrInfoLog.get());
2411 _GlesFboTerminate_2(GLuint& frameBufferObject, GLuint& depthRenderBuffer
2412 , GLuint& stencilRenderBuffer, GLuint& textureId, GLuint& program)
2414 _GLES_CHECK_INTERFACE_VOID_2
2415 _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, 0);
2417 if (frameBufferObject != 0)
2419 _glesImpl2.glDeleteFramebuffers(1, &frameBufferObject);
2420 frameBufferObject = 0;
2423 if (depthRenderBuffer != 0)
2425 _glesImpl2.glDeleteRenderbuffers(1, &depthRenderBuffer);
2426 depthRenderBuffer = 0;
2429 if (stencilRenderBuffer != 0)
2431 _glesImpl2.glDeleteRenderbuffers(1, &depthRenderBuffer);
2432 depthRenderBuffer = 0;
2437 _glesImpl2.glDeleteTextures(1, &textureId);
2443 _glesImpl2.glDeleteProgram(program);
2449 _GlesFboInitialize_2(const int fboWidth, const int fboHeight, GLuint& frameBufferObject
2450 , GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer, GLuint colorSize
2451 , GLuint depthSize, GLuint stencilSize, GLuint& textureId, GLuint& program)
2453 _GLES_CHECK_INTERFACE_GLBOOLEAN_2
2454 if (!_CreateShader(program))
2460 _glesImpl2.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxSize);
2461 if (fboWidth > maxSize || fboHeight > maxSize)
2463 SysLog(NID_GRP, "FBO Incompatible size");
2467 _glesImpl2.glActiveTexture(GL_TEXTURE0);
2469 _glesImpl2.glGenFramebuffers(1, &frameBufferObject);
2470 _glesImpl2.glGenRenderbuffers(1, &depthRenderBuffer);
2471 _glesImpl2.glGenRenderbuffers(1, &stencilRenderBuffer);
2472 _glesImpl2.glGenTextures(1, &textureId);
2473 if (frameBufferObject == 0 || depthRenderBuffer == 0 || stencilRenderBuffer == 0 || textureId == 0)
2475 SysLog(NID_GRP, "FBO generating failed! fbo:%d depth:%d stencil:%d tex:%d"
2476 , frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId);
2477 _GlesFboTerminate_2(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId, program);
2480 _glesImpl2.glBindTexture(GL_TEXTURE_2D, textureId);
2483 _glesImpl2.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fboWidth, fboHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
2487 _glesImpl2.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fboWidth, fboHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
2489 _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2490 _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2491 _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2492 _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2494 const char* pString = (const char*)_glesImpl2.glGetString(GL_EXTENSIONS);
2495 String extensions(pString);
2499 GLenum internalFormat = GL_DEPTH_COMPONENT16;
2503 if (extensions.Contains(L"GL_OES_depth32"))
2505 internalFormat = GL_DEPTH_COMPONENT32_OES;
2508 else if (depthSize > 16)
2510 if (extensions.Contains(L"GL_OES_depth24"))
2512 internalFormat = GL_DEPTH_COMPONENT24_OES;
2516 _glesImpl2.glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer);
2517 _glesImpl2.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, fboWidth, fboHeight);
2520 if (stencilSize > 0)
2522 GLenum internalFormat = GL_STENCIL_INDEX8;
2524 if (stencilSize == 1)
2526 if (extensions.Contains(L"GL_OES_stencil1"))
2528 internalFormat = GL_STENCIL_INDEX1_OES;
2531 else if (stencilSize <= 4)
2533 if (extensions.Contains(L"GL_OES_stencil4"))
2535 internalFormat = GL_STENCIL_INDEX4_OES;
2539 _glesImpl2.glBindRenderbuffer(GL_RENDERBUFFER, stencilRenderBuffer);
2540 _glesImpl2.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, fboWidth, fboHeight);
2543 _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
2544 _glesImpl2.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0);
2547 _glesImpl2.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer);
2550 _glesImpl2.glBindTexture(GL_TEXTURE_2D, 0);
2552 GLenum ret = _glesImpl2.glCheckFramebufferStatus(GL_FRAMEBUFFER);
2553 if (ret != GL_FRAMEBUFFER_COMPLETE)
2555 _GlesFboTerminate_2(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId, program);
2556 SysLog(NID_GRP, "FBO glCheckFramebufferStatus failed! %#x", (unsigned int)ret);
2564 _GlesFboBinding_2(const GLuint frameBufferObject)
2566 _GLES_CHECK_INTERFACE_VOID_2
2567 _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
2571 _GlesFboSwapBuffers_2(const Frame* pFrame, const GLuint frameBufferObject
2572 , const GLuint textureId, const GLuint program)
2574 _GLES_CHECK_INTERFACE_VOID_2
2575 GLboolean isEnabledCullFace = GL_FALSE;
2576 GLboolean isEnabledStencil = GL_FALSE;
2577 GLboolean isEnabledDepth = GL_FALSE;
2578 GLboolean isEnabledScissor = GL_FALSE;
2579 GLboolean isEnabledBlend = GL_FALSE;
2581 isEnabledCullFace = _glesImpl2.glIsEnabled(GL_CULL_FACE);
2582 isEnabledStencil = _glesImpl2.glIsEnabled(GL_STENCIL_TEST);
2583 isEnabledDepth = _glesImpl2.glIsEnabled(GL_DEPTH_TEST);
2584 isEnabledScissor = _glesImpl2.glIsEnabled(GL_SCISSOR_TEST);
2585 isEnabledBlend = _glesImpl2.glIsEnabled(GL_BLEND);
2586 _glesImpl2.glDisable(GL_CULL_FACE);
2587 _glesImpl2.glDisable(GL_STENCIL_TEST);
2588 _glesImpl2.glDisable(GL_DEPTH_TEST);
2589 _glesImpl2.glDisable(GL_SCISSOR_TEST);
2590 _glesImpl2.glDisable(GL_BLEND);
2592 GLint previousTextureId = 0;
2593 GLint previousArrayBuffer = 0;
2594 GLint previousElementArrayBuffer = 0;
2595 GLint previousViewport[4] = {0,};
2596 GLint previousProgram = 0;
2597 _glesImpl2.glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureId);
2598 _glesImpl2.glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &previousArrayBuffer);
2599 _glesImpl2.glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &previousElementArrayBuffer);
2600 _glesImpl2.glGetIntegerv(GL_VIEWPORT, previousViewport);
2601 _glesImpl2.glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgram);
2603 _glesImpl2.glUseProgram(program);
2604 int indexTexture = 0;
2605 int indexAttribPosition = 0;
2606 int indexAttribTextureCoord = 0;
2607 indexTexture = _glesImpl2.glGetUniformLocation(program, "uTexture");
2608 indexAttribPosition = _glesImpl2.glGetAttribLocation(program, "aPosition");
2609 indexAttribTextureCoord = _glesImpl2.glGetAttribLocation(program, "aTextureCoord");
2611 _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, 0);
2612 _glesImpl2.glBindTexture( GL_TEXTURE_2D, textureId);
2618 pFrame->GetBounds(x, y, width, height);
2620 GLfloat ratioX1 = 0.0f;
2621 GLfloat ratioX2 = 1.0f;
2622 GLfloat ratioY1 = 0.0f;
2623 GLfloat ratioY2 = 1.0f;
2625 GLfloat texture[] = {
2632 OrientationStatus orientationStatus = pFrame->GetOrientationStatus();
2633 switch(orientationStatus)
2636 case ORIENTATION_STATUS_NONE:
2637 case ORIENTATION_STATUS_PORTRAIT:
2638 _glesImpl2.glViewport(0, 0, width, height);
2641 case ORIENTATION_STATUS_LANDSCAPE:
2642 texture[0] = ratioX2;
2643 texture[1] = ratioY1;
2644 texture[2] = ratioX2;
2645 texture[3] = ratioY2;
2646 texture[4] = ratioX1;
2647 texture[5] = ratioY1;
2648 texture[6] = ratioX1;
2649 texture[7] = ratioY2;
2650 _glesImpl2.glViewport(0, 0, height, width);
2653 case ORIENTATION_STATUS_PORTRAIT_REVERSE:
2654 texture[0] = ratioX2;
2655 texture[1] = ratioY2;
2656 texture[2] = ratioX1;
2657 texture[3] = ratioY2;
2658 texture[4] = ratioX2;
2659 texture[5] = ratioY1;
2660 texture[6] = ratioX1;
2661 texture[7] = ratioY1;
2662 _glesImpl2.glViewport(0, 0, width, height);
2665 case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
2666 texture[0] = ratioX1;
2667 texture[1] = ratioY2;
2668 texture[2] = ratioX1;
2669 texture[3] = ratioY1;
2670 texture[4] = ratioX2;
2671 texture[5] = ratioY2;
2672 texture[6] = ratioX2;
2673 texture[7] = ratioY1;
2674 _glesImpl2.glViewport(0, 0, height, width);
2678 _glesImpl2.glUniform1i(indexTexture, 0);
2680 _glesImpl2.glEnableVertexAttribArray(indexAttribPosition);
2681 _glesImpl2.glEnableVertexAttribArray(indexAttribTextureCoord);
2683 GLfloat vertex[] = {
2690 _glesImpl2.glBindBuffer(GL_ARRAY_BUFFER, 0);
2691 _glesImpl2.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
2693 _glesImpl2.glVertexAttribPointer(indexAttribPosition, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), vertex);
2694 _glesImpl2.glVertexAttribPointer(indexAttribTextureCoord, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), texture);
2696 _glesImpl2.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
2698 _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
2699 _glesImpl2.glUseProgram((GLuint)previousProgram);
2700 if (isEnabledCullFace)
2702 _glesImpl2.glEnable(GL_CULL_FACE);
2704 if (isEnabledStencil)
2706 _glesImpl2.glEnable(GL_STENCIL_TEST);
2710 _glesImpl2.glEnable(GL_DEPTH_TEST);
2712 if (isEnabledScissor)
2714 _glesImpl2.glEnable(GL_SCISSOR_TEST);
2718 _glesImpl2.glEnable(GL_BLEND);
2721 _glesImpl2.glBindTexture( GL_TEXTURE_2D, previousTextureId);
2722 _glesImpl2.glBindBuffer(GL_ARRAY_BUFFER, previousArrayBuffer);
2723 _glesImpl2.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, previousElementArrayBuffer);
2724 _glesImpl2.glViewport(previousViewport[0], previousViewport[1], previousViewport[2], previousViewport[3]);
2727 #endif //#if defined(FGRAPHICS_INTERNAL_USE_FBO)
2733 #endif //#if !defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING)
2737 }} // Tizen::Graphics