using namespace Tizen::Ui::Controls;
-//#define FGRAPHICS_INTERNAL_USE_FBO
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-
-bool _GlesFboInitialize_1(int& fboWidth, int& fboHeight, GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer
- , GLuint colorSize, GLuint depthSize, GLuint stencilSize, GLuint& textureId);
-bool _GlesFboBinding_1(const GLuint frameBufferObject);
-void _GlesFboSwapBuffers_1(const Frame* pFrame, int fboWidth, int fboHeight, const GLuint frameBufferObject, const GLuint textureId);
-void _GlesFboTerminate_1(GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer, GLuint& textureId);
-
-bool _GlesFboInitialize_2(const int fboWidth, const int fboHeight, GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer
- , GLuint colorSize, GLuint depthSize, GLuint stencilSize, GLuint& textureId, GLuint &program);
-bool _GlesFboBinding_2(const GLuint frameBufferObject);
-void _GlesFboSwapBuffers_2(const Frame* pFrame, const GLuint frameBufferObject, const GLuint textureId, const GLuint program);
-void _GlesFboTerminate_2(GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer
- , GLuint& textureId, GLuint& program);
-#endif
-
#ifdef __cplusplus
}
#endif
void _OnBoundsChanged(void* pData);
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-void _OnBoundsChangedFbo(void* pData);
-EGLContext _fboContext = EGL_NO_CONTEXT;
-#endif
-
const int INVALID_SGL_INDEX = 0;
const int MAX_SGL_INDEX = 100;
, width(0)
, height(0)
#endif
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- , frameBufferObject(0)
- , depthRenderBuffer(0)
- , stencilRenderBuffer(0)
- , colorSize(0)
- , depthSize(0)
- , stencilSize(0)
- , isStencilEnabled(false)
- , textureId(0)
- , program(0)
- , pFrame(null)
- , isFboAvailable(true)
- , fboWidth(0)
- , fboHeight(0)
-#endif
, isBackbuffer(true)
, wasShown(false)
, swapDone(false)
glVersion = 0;
pWindow = null;
#if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER)
- Ecore_X_Image* pEcoreImage = null;
- int width = 0;
- int height = 0;
+ pEcoreImage = null;
+ width = 0;
+ height = 0;
#endif
isBackbuffer = true;
wasShown = false;
int width;
int height;
#endif
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- GLuint frameBufferObject;
- GLuint depthRenderBuffer;
- GLuint stencilRenderBuffer;
- EGLint colorSize;
- EGLint depthSize;
- EGLint stencilSize;
- bool isStencilEnabled;
- GLuint textureId;
- GLuint program;
- Frame* pFrame;
- bool isFboAvailable;
- int fboWidth;
- int fboHeight;
-#endif
bool isBackbuffer;
bool wasShown;
bool swapDone;
return;
}
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-void
-_OnBoundsChangedFbo(void* pData)
-{
- _SglInfo* pSglInfo = dynamic_cast<_SglInfo*> ((_SglInfo*)pData);
- SysTryReturnVoidResult(NID_GRP, pSglInfo != null
- && pSglInfo->pVisualElement != null
- , E_INVALID_STATE, "Invalid state.");
-
- FloatRectangle rect = pSglInfo->pVisualElement->GetBounds();
- pSglInfo->fboWidth = CoordinateSystem::ConvertToPhysicalX(rect.width);
- pSglInfo->fboHeight = CoordinateSystem::ConvertToPhysicalY(rect.height);
-
- if (pSglInfo->glVersion == 1)
- {
- eglMakeCurrent(pSglInfo->display
- , pSglInfo->surface
- , pSglInfo->surface
- , pSglInfo->context);
-
- _GlesFboTerminate_1(pSglInfo->frameBufferObject
- , pSglInfo->depthRenderBuffer
- , pSglInfo->stencilRenderBuffer
- , pSglInfo->textureId
- );
-
- _GlesFboInitialize_1(pSglInfo->fboWidth
- , pSglInfo->fboHeight
- , pSglInfo->frameBufferObject
- , pSglInfo->depthRenderBuffer
- , pSglInfo->stencilRenderBuffer
- , pSglInfo->colorSize
- , pSglInfo->depthSize
- , pSglInfo->stencilSize
- , pSglInfo->textureId
- );
- }
- else if (pSglInfo->glVersion == 2)
- {
- eglMakeCurrent(pSglInfo->display
- , pSglInfo->surface
- , pSglInfo->surface
- , pSglInfo->context);
-
- _GlesFboTerminate_2(pSglInfo->frameBufferObject
- , pSglInfo->depthRenderBuffer
- , pSglInfo->stencilRenderBuffer
- , pSglInfo->textureId
- , pSglInfo->program
- );
-
- _GlesFboInitialize_2(pSglInfo->fboWidth
- , pSglInfo->fboHeight
- , pSglInfo->frameBufferObject
- , pSglInfo->depthRenderBuffer
- , pSglInfo->stencilRenderBuffer
- , pSglInfo->colorSize
- , pSglInfo->depthSize
- , pSglInfo->stencilSize
- , pSglInfo->textureId
- , pSglInfo->program
- );
- }
- else
- {
- SysLog(NID_GRP, "ambiguous gl Version %d", pSglInfo->glVersion);
- }
-}
-#endif //#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-
void
_OnDestroyed(void* pData)
{
_SglInfoTableManipulator::GetInstance()->DestroySglInfoTable();
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- if (_fboContext != EGL_NO_CONTEXT)
- {
- eglDestroyContext(dpy, _fboContext);
- _fboContext = EGL_NO_CONTEXT;
- }
-#endif
-
if (!_IsEvasGlEnabled())
{
eglTerminate(dpy);
_SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- pSglInfo->pFrame = pFrame;
- eglGetConfigAttrib(dpy, config, EGL_BUFFER_SIZE, &pSglInfo->colorSize);
- eglGetConfigAttrib(dpy, config, EGL_DEPTH_SIZE, &pSglInfo->depthSize);
- eglGetConfigAttrib(dpy, config, EGL_STENCIL_SIZE, &pSglInfo->stencilSize);
-
- pSglInfo->display = dpy;
- pSglInfo->pVisualElement = pVisualElement;
- pVisualElementImpl->SetBoundsChangedCallback(_OnBoundsChangedFbo, pSglInfo);
-#endif
pSglInfo->surface = windowSurface;
pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
}
#endif
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- if (pSglInfo->isFboAvailable && pSglInfo->pFrame != null)
- {
- if (pSglInfo->glVersion == 1)
- {
- _GlesFboTerminate_1(pSglInfo->frameBufferObject
- , pSglInfo->depthRenderBuffer
- , pSglInfo->stencilRenderBuffer
- , pSglInfo->textureId);
- }
- else if (pSglInfo->glVersion == 2)
- {
- _GlesFboTerminate_2(pSglInfo->frameBufferObject
- , pSglInfo->depthRenderBuffer
- , pSglInfo->stencilRenderBuffer
- , pSglInfo->textureId
- , pSglInfo->program);
- }
- else
- {
- SysLog(NID_GRP, "ambiguous gl Version %d", pSglInfo->glVersion);
- }
- }
-#endif
ret = eglDestroySurface(dpy, pSglInfo->surface);
pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
EGLContext
_SglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareContext, const EGLint* pAttribList)
{
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- EGLContext ret = EGL_NO_CONTEXT;
- if (shareContext == EGL_NO_CONTEXT)
- {
- if (_fboContext == EGL_NO_CONTEXT)
- {
- _fboContext = eglCreateContext(dpy, config, EGL_NO_CONTEXT, pAttribList);
- if (_fboContext == EGL_NO_CONTEXT)
- {
- return EGL_NO_CONTEXT;
- }
- }
-
- ret = eglCreateContext(dpy, config, _fboContext, pAttribList);
- }
- else
- {
- ret = eglCreateContext(dpy, config, shareContext, pAttribList);
- }
- return ret;
-#else
return eglCreateContext(dpy, config, shareContext, pAttribList);
-#endif
}
EGLBoolean
eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &pSglInfoDraw->glVersion);
}
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- if (ret != EGL_TRUE || pSglInfoDraw->surface == EGL_NO_SURFACE
- || sglInfoReadSurface == EGL_NO_SURFACE
- || ctx == EGL_NO_CONTEXT)
- {
- pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
- return ret;
- }
-
-#if defined(_OSP_EMUL_) //fixme
- pSglInfoDraw->isFboAvailable = false;
-#endif
-
- if (pSglInfoDraw->pFrame != null)
- {
- if (pSglInfoDraw->isFboAvailable)
- {
- if (pSglInfoDraw->frameBufferObject == 0)
- {
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
- pSglInfoDraw->pFrame->GetBounds(x, y, width, height);
-
- pSglInfoDraw->fboWidth = CoordinateSystem::ConvertToPhysicalX(width);
- pSglInfoDraw->fboHeight = CoordinateSystem::ConvertToPhysicalY(height);
-
- if (pSglInfoDraw->glVersion == 1)
- {
- pSglInfoDraw->isFboAvailable = _GlesFboInitialize_1(pSglInfoDraw->fboWidth
- , pSglInfoDraw->fboHeight
- , pSglInfoDraw->frameBufferObject, pSglInfoDraw->depthRenderBuffer
- , pSglInfoDraw->stencilRenderBuffer, pSglInfoDraw->colorSize
- , pSglInfoDraw->depthSize, pSglInfoDraw->stencilSize
- , pSglInfoDraw->textureId);
- }
- else if (pSglInfoDraw->glVersion == 2)
- {
- pSglInfoDraw->isFboAvailable = _GlesFboInitialize_2(pSglInfoDraw->fboWidth
- , pSglInfoDraw->fboHeight
- , pSglInfoDraw->frameBufferObject, pSglInfoDraw->depthRenderBuffer
- , pSglInfoDraw->stencilRenderBuffer, pSglInfoDraw->colorSize
- , pSglInfoDraw->depthSize, pSglInfoDraw->stencilSize
- , pSglInfoDraw->textureId, pSglInfoDraw->program);
- }
- else
- {
- SysLog(NID_GRP, "ambiguous gl Version %d", pSglInfoDraw->glVersion);
- pSglInfoDraw->isFboAvailable = false;
- }
- }
- else
- {
- if (pSglInfoDraw->glVersion == 1)
- {
- _GlesFboBinding_1(pSglInfoDraw->frameBufferObject);
- }
- else if (pSglInfoDraw->glVersion == 2)
- {
- _GlesFboBinding_2(pSglInfoDraw->frameBufferObject);
- }
- else
- {
- SysLog(NID_GRP, "ambiguous gl Version %d", pSglInfoDraw->glVersion);
- }
- }
- }
- }
- else
- {
- if (pSglInfoDraw->frameBufferObject != 0 && pSglInfoDraw->isFboAvailable)
- {
- if (pSglInfoDraw->glVersion == 1)
- {
- _GlesFboBinding_1(0);
- }
- else if (pSglInfoDraw->glVersion == 2)
- {
- _GlesFboBinding_2(0);
- }
- else
- {
- SysLog(NID_GRP, "ambiguous gl Version %d", pSglInfoDraw->glVersion);
- }
- }
- }
-#endif
pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
return ret;
}
else
{
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- if (pSglInfo->pFrame != null)
- {
- if (pSglInfo->isFboAvailable)
- {
- if (pSglInfo->glVersion == 1)
- {
- _GlesFboSwapBuffers_1(pSglInfo->pFrame
- , pSglInfo->fboWidth
- , pSglInfo->fboHeight
- , pSglInfo->frameBufferObject
- , pSglInfo->textureId);
- }
- else if (pSglInfo->glVersion == 2)
- {
- _GlesFboSwapBuffers_2(pSglInfo->pFrame
- , pSglInfo->frameBufferObject
- , pSglInfo->textureId
- , pSglInfo->program);
- }
- else
- {
- SysLog(NID_GRP, "ambiguous gl Version %d", pSglInfo->glVersion);
- pSglInfo->isFboAvailable = false;
- }
- }
- }
-#endif
EGLBoolean ret = eglSwapBuffers(dpy, pSglInfo->surface);
pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
return EGL_TRUE;
}
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-_OSP_LOCAL_ GLuint
-_GlesGetCurrentFbo(void)
-{
- _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
-
- _SglIndex sglIndex = (_SglIndex)_SglGetCurrentSurface(EGL_DRAW);
- _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
-
- if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
- {
- pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
- SysLog(NID_GRP, "Fbo binding failed!!");
- return 0;
- }
-
- GLuint ret = pSglInfo->frameBufferObject;
- pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
-
- return ret;
-}
-
-_OSP_LOCAL_ bool
-_GlesFboEnableStencil(GLuint& frameBufferObject, GLuint& renderBuffer)
-{
- _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance();
-
- _SglIndex sglIndex = (_SglIndex)_SglGetCurrentSurface(EGL_DRAW);
- _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex);
-
- if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null)
- {
- pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
- return false;
- }
-
- if (!pSglInfo->isStencilEnabled)
- {
- pSglInfo->isStencilEnabled = true;
- frameBufferObject = pSglInfo->frameBufferObject;
- renderBuffer = pSglInfo->stencilRenderBuffer;
-
- pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
- return true;
- }
-
- pSglInfoTableManipulatorInstance->UnlockSglInfoTable();
- return false;
-}
-
-#endif
-
#ifdef __cplusplus
}
#endif
#include <FBaseSysLog.h>
#endif
-//#define FGRAPHICS_INTERNAL_USE_FBO
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-#include <FUiCtrlFrame.h>
-#endif
-
using namespace Tizen::Base;
using namespace Tizen::Ui;
using namespace Tizen::Ui::Controls;
{
#endif
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-GLuint _GlesGetCurrentFbo(void);
-bool _GlesFboEnableStencil(GLuint& frameBufferObject, GLuint& renderBuffer);
-#endif
-
_OSP_LOCAL_ void
_GlesInterfaceTerminate_1(void)
{
_GlEnable_1(GLenum cap)
{
_GLES_CHECK_INTERFACE_VOID_1
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- if (cap == GL_STENCIL_TEST)
- {
- GLuint frameBufferObject = 0;
- GLuint stencilRenderBuffer = 0;
-
- bool ret = _GlesFboEnableStencil(frameBufferObject, stencilRenderBuffer);
-
- if (ret)
- {
- _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBufferObject);
- _glesImpl1.glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, stencilRenderBuffer);
- }
- }
-#endif
_glesImpl1.glEnable(cap);
}
_GlBindFramebufferOES_1(GLenum target, GLuint framebuffer)
{
_GLES_CHECK_INTERFACE_VOID_1
-
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- if (framebuffer == 0)
- {
- framebuffer = _GlesGetCurrentFbo();
- }
-#endif
-
_glesImpl1.glBindFramebufferOES(target, framebuffer);
}
}
//End of FBO Functions
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-_OSP_LOCAL_ int
-_GlesFboGetPowerOf2(int value)
-{
- int result = 1;
-
- while(result < value)
- {
- result <<= 1;
- }
-
- return result;
-}
-
-_OSP_LOCAL_ void
-_GlesFboTerminate_1(GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer, GLuint& textureId)
-{
- _GLES_CHECK_INTERFACE_VOID_1
- _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
-
- if (frameBufferObject != 0)
- {
- _glesImpl1.glDeleteFramebuffersOES(1, &frameBufferObject);
- frameBufferObject = 0;
- }
-
- if (depthRenderBuffer != 0)
- {
- _glesImpl1.glDeleteRenderbuffersOES(1, &depthRenderBuffer);
- depthRenderBuffer = 0;
- }
-
- if (stencilRenderBuffer != 0)
- {
- _glesImpl1.glDeleteRenderbuffersOES(1, &stencilRenderBuffer);
- stencilRenderBuffer = 0;
- }
-
- if (textureId != 0)
- {
- _glesImpl1.glDeleteTextures(1, &textureId);
- textureId = 0;
- }
-}
-
-_OSP_LOCAL_ bool
-_GlesFboInitialize_1(int& fboWidth, int& fboHeight, GLuint& frameBufferObject, GLuint& depthRenderBuffer
- , GLuint& stencilRenderBuffer, GLuint colorSize, GLuint depthSize, GLuint stencilSize, GLuint& textureId)
-{
- _GLES_CHECK_INTERFACE_GLBOOLEAN_1
- const char* pString = (const char*)_glesImpl1.glGetString(GL_EXTENSIONS);
- String extensions(pString);
- if (!extensions.Contains(L"GL_OES_framebuffer_object"))
- {
- SysLog(NID_GRP, "FBO not supported : %ls", extensions.GetPointer());
- return false;
- }
-
- if (!extensions.Contains(L"GL_OES_texture_npot"))
- {
- fboWidth = _GlesFboGetPowerOf2(fboWidth);
- fboHeight = _GlesFboGetPowerOf2(fboHeight);
- }
-
- GLint maxSize = 0;
- _glesImpl1.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_OES, &maxSize);
- if (fboWidth > maxSize || fboHeight > maxSize)
- {
- SysLog(NID_GRP, "FBO Incompatible size");
- return false;
- }
-
- _glesImpl1.glEnable(GL_TEXTURE_2D);
-
- _glesImpl1.glGenFramebuffersOES(1, &frameBufferObject);
- _glesImpl1.glGenRenderbuffersOES(1, &depthRenderBuffer);
- _glesImpl1.glGenRenderbuffersOES(1, &stencilRenderBuffer);
- _glesImpl1.glGenTextures(1, &textureId);
- if (frameBufferObject == 0 || depthRenderBuffer == 0 || stencilRenderBuffer == 0 || textureId == 0)
- {
- SysLog(NID_GRP, "FBO generating failed! fbo:%d depth:%d stencil:%d tex:%d"
- , frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId);
- _GlesFboTerminate_1(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId);
- }
-
- _glesImpl1.glBindTexture(GL_TEXTURE_2D, textureId);
- if (colorSize > 16)
- {
- _glesImpl1.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fboWidth, fboHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- }
- else
- {
- _glesImpl1.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fboWidth, fboHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
- }
- _glesImpl1.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- _glesImpl1.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- _glesImpl1.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- _glesImpl1.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- if (depthSize > 0)
- {
- GLenum internalFormat = GL_DEPTH_COMPONENT16_OES;
-
- if (depthSize > 24)
- {
- if (extensions.Contains(L"GL_OES_depth32"))
- {
- internalFormat = GL_DEPTH_COMPONENT32_OES;
- }
- }
- else if (depthSize > 16)
- {
- if (extensions.Contains(L"GL_OES_depth24"))
- {
- internalFormat = GL_DEPTH_COMPONENT24_OES;
- }
- }
-
- _glesImpl1.glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderBuffer);
- _glesImpl1.glRenderbufferStorageOES(GL_RENDERBUFFER_OES, internalFormat, fboWidth, fboHeight);
- }
-
- if (stencilSize > 0)
- {
- GLenum internalFormat = 0;
-
- if (extensions.Contains(L"GL_OES_stencil8"))
- {
- internalFormat = GL_STENCIL_INDEX8_OES;
- }
-
- if (stencilSize == 1)
- {
- if (extensions.Contains(L"GL_OES_stencil1"))
- {
- internalFormat = GL_STENCIL_INDEX1_OES;
- }
- }
- else if (stencilSize <= 4)
- {
- if (extensions.Contains(L"GL_OES_stencil4"))
- {
- internalFormat = GL_STENCIL_INDEX4_OES;
- }
- }
-
- if (internalFormat != 0)
- {
- _glesImpl1.glBindRenderbufferOES(GL_RENDERBUFFER_OES, stencilRenderBuffer);
- _glesImpl1.glRenderbufferStorageOES(GL_RENDERBUFFER_OES, internalFormat, fboWidth, fboHeight);
- }
- }
-
- _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBufferObject);
- _glesImpl1.glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, textureId, 0);
- if (depthSize != 0)
- {
- _glesImpl1.glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES
- , GL_RENDERBUFFER_OES, depthRenderBuffer);
- }
-
- _glesImpl1.glBindTexture(GL_TEXTURE_2D, 0);
-
- GLenum ret = _glesImpl1.glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
- if (ret != GL_FRAMEBUFFER_COMPLETE_OES)
- {
- _GlesFboTerminate_1(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId);
- SysLog(NID_GRP, "FBO glCheckFramebufferStatus failed! %#x", (unsigned int)ret);
- return false;
- }
-
- return true;
-}
-
-_OSP_LOCAL_ void
-_GlesFboBinding_1(const GLuint frameBufferObject)
-{
- _GLES_CHECK_INTERFACE_VOID_1
- _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBufferObject);
-}
-
-_OSP_LOCAL_ void
-_GlesFboSwapBuffers_1(const Frame* pFrame, int fboWidth, int fboHeight, const GLuint frameBufferObject, const GLuint textureId)
-{
- _GLES_CHECK_INTERFACE_VOID_1
- GLboolean isEnabledCullFace = GL_FALSE;
- GLboolean isEnabledStencil = GL_FALSE;
- GLboolean isEnabledDepth = GL_FALSE;
- GLboolean isEnabledScissor = GL_FALSE;
- GLboolean isEnabledBlend = GL_FALSE;
- GLboolean isEnabledTexture = GL_FALSE;
- GLboolean isEnabledVertexArray = GL_FALSE;
- GLboolean isEnabledNormalArray = GL_FALSE;
- GLboolean isEnabledColorArray = GL_FALSE;
- GLboolean isEnabledTextureCoordArray = GL_FALSE;
-
- isEnabledCullFace = _glesImpl1.glIsEnabled(GL_CULL_FACE);
- isEnabledStencil = _glesImpl1.glIsEnabled(GL_STENCIL_TEST);
- isEnabledDepth = _glesImpl1.glIsEnabled(GL_DEPTH_TEST);
- isEnabledScissor = _glesImpl1.glIsEnabled(GL_SCISSOR_TEST);
- isEnabledBlend = _glesImpl1.glIsEnabled(GL_BLEND);
- isEnabledNormalArray = _glesImpl1.glIsEnabled(GL_NORMAL_ARRAY);
- isEnabledColorArray = _glesImpl1.glIsEnabled(GL_COLOR_ARRAY);
- _glesImpl1.glDisable(GL_CULL_FACE);
- _glesImpl1.glDisable(GL_STENCIL_TEST);
- _glesImpl1.glDisable(GL_DEPTH_TEST);
- _glesImpl1.glDisable(GL_SCISSOR_TEST);
- _glesImpl1.glDisable(GL_BLEND);
- _glesImpl1.glDisableClientState(GL_NORMAL_ARRAY);
- _glesImpl1.glDisableClientState(GL_COLOR_ARRAY);
-
- isEnabledTexture = _glesImpl1.glIsEnabled(GL_TEXTURE_2D);
- isEnabledVertexArray = _glesImpl1.glIsEnabled(GL_VERTEX_ARRAY);
- isEnabledTextureCoordArray = _glesImpl1.glIsEnabled(GL_TEXTURE_COORD_ARRAY);
- _glesImpl1.glEnable(GL_TEXTURE_2D);
- _glesImpl1.glEnableClientState(GL_VERTEX_ARRAY);
- _glesImpl1.glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-
- GLint previousTextureId = 0;
- GLint previousMatrixMode = 0;
- GLint previousArrayBuffer = 0;
- GLint previousElementArrayBuffer = 0;
- GLint previousViewport[4] = {0,};
- _glesImpl1.glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureId);
- _glesImpl1.glGetIntegerv(GL_MATRIX_MODE, &previousMatrixMode);
- _glesImpl1.glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &previousArrayBuffer);
- _glesImpl1.glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &previousElementArrayBuffer);
- _glesImpl1.glGetIntegerv(GL_VIEWPORT, previousViewport);
-
- GLfloat currentColor[4] = {0.0f, };
- GLfloat currentNormal[3] = {0.0f, };
- _glesImpl1.glGetFloatv(GL_CURRENT_COLOR, currentColor);
- _glesImpl1.glGetFloatv(GL_CURRENT_NORMAL, currentNormal);
- _glesImpl1.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- _glesImpl1.glNormal3f(0.0f, 0.0f, 1.0f);
-
- _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
- _glesImpl1.glBindTexture( GL_TEXTURE_2D, textureId);
-
- _glesImpl1.glMatrixMode(GL_PROJECTION);
- _glesImpl1.glPushMatrix();
- _glesImpl1.glLoadIdentity();
- _glesImpl1.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f);
-
- _glesImpl1.glMatrixMode(GL_TEXTURE);
- _glesImpl1.glPushMatrix();
- _glesImpl1.glLoadIdentity();
-
- _glesImpl1.glMatrixMode(GL_MODELVIEW);
- _glesImpl1.glPushMatrix();
- _glesImpl1.glLoadIdentity();
-
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
- pFrame->GetBounds(x, y, width, height);
-
- GLfloat ratioX1 = 0.0f;
- GLfloat ratioX2 = (GLfloat)width / fboWidth;
- GLfloat ratioY1 = 0.0f;
- GLfloat ratioY2 = (GLfloat)height / fboHeight;
-
- GLfloat texture[] = {
- ratioX1, ratioY1,
- ratioX2, ratioY1,
- ratioX1, ratioY2,
- ratioX2, ratioY2,
- };
-
- OrientationStatus orientationStatus = pFrame->GetOrientationStatus();
- switch (orientationStatus)
- {
- default:
- case ORIENTATION_STATUS_NONE:
- case ORIENTATION_STATUS_PORTRAIT:
- _glesImpl1.glViewport(0, 0, width, height);
- break;
-
- case ORIENTATION_STATUS_LANDSCAPE:
- texture[0] = ratioX2;
- texture[1] = ratioY1;
- texture[2] = ratioX2;
- texture[3] = ratioY2;
- texture[4] = ratioX1;
- texture[5] = ratioY1;
- texture[6] = ratioX1;
- texture[7] = ratioY2;
- _glesImpl1.glViewport(0, 0, height, width);
- break;
-
- case ORIENTATION_STATUS_PORTRAIT_REVERSE:
- texture[0] = ratioX2;
- texture[1] = ratioY2;
- texture[2] = ratioX1;
- texture[3] = ratioY2;
- texture[4] = ratioX2;
- texture[5] = ratioY1;
- texture[6] = ratioX1;
- texture[7] = ratioY1;
- _glesImpl1.glViewport(0, 0, width, height);
- break;
-
- case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
- texture[0] = ratioX1;
- texture[1] = ratioY2;
- texture[2] = ratioX1;
- texture[3] = ratioY1;
- texture[4] = ratioX2;
- texture[5] = ratioY2;
- texture[6] = ratioX2;
- texture[7] = ratioY1;
- _glesImpl1.glViewport(0, 0, height, width);
- break;
- }
-
- GLfloat vertex[] = {
- -1.0f, -1.0f,
- 1.0f, -1.0f,
- -1.0f, 1.0f,
- 1.0f, 1.0f,
- };
-
- _glesImpl1.glBindBuffer(GL_ARRAY_BUFFER, 0);
- _glesImpl1.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-
- _glesImpl1.glVertexPointer(2, GL_FLOAT, 0, vertex);
- _glesImpl1.glTexCoordPointer(2, GL_FLOAT, 0, texture);
-
- _glesImpl1.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- _glesImpl1.glPopMatrix();
- _glesImpl1.glMatrixMode(GL_TEXTURE);
- _glesImpl1.glPopMatrix();
- _glesImpl1.glMatrixMode(GL_PROJECTION);
- _glesImpl1.glPopMatrix();
-
- _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBufferObject);
- if (isEnabledCullFace)
- {
- _glesImpl1.glEnable(GL_CULL_FACE);
- }
- if (isEnabledStencil)
- {
- _glesImpl1.glEnable(GL_STENCIL_TEST);
- }
- if (isEnabledDepth)
- {
- _glesImpl1.glEnable(GL_DEPTH_TEST);
- }
- if (isEnabledScissor)
- {
- _glesImpl1.glEnable(GL_SCISSOR_TEST);
- }
- if (isEnabledBlend)
- {
- _glesImpl1.glEnable(GL_BLEND);
- }
- if (isEnabledNormalArray)
- {
- _glesImpl1.glIsEnabled(GL_NORMAL_ARRAY);
- }
- if (isEnabledColorArray)
- {
- _glesImpl1.glIsEnabled(GL_COLOR_ARRAY);
- }
-
- if (!isEnabledTexture)
- {
- _glesImpl1.glDisable(GL_TEXTURE_2D);
- }
- if (!isEnabledVertexArray)
- {
- _glesImpl1.glDisableClientState(GL_VERTEX_ARRAY);
- }
- if (!isEnabledTextureCoordArray)
- {
- _glesImpl1.glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- }
-
- _glesImpl1.glBindTexture( GL_TEXTURE_2D, previousTextureId);
- _glesImpl1.glMatrixMode(previousMatrixMode);
- _glesImpl1.glBindBuffer(GL_ARRAY_BUFFER, previousArrayBuffer);
- _glesImpl1.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, previousElementArrayBuffer);
- _glesImpl1.glViewport(previousViewport[0], previousViewport[1], previousViewport[2], previousViewport[3]);
- _glesImpl1.glColor4f(currentColor[0], currentColor[1], currentColor[2], currentColor[3]);
- _glesImpl1.glNormal3f(currentNormal[0], currentNormal[1], currentNormal[2]);
-}
-
-#endif //#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-
#ifdef __cplusplus
}
#endif
#include <FBaseSysLog.h>
#endif
-//#define FGRAPHICS_INTERNAL_USE_FBO
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-#include <FUiCtrlFrame.h>
-#endif
-
#include "../util/FGrp_UtilTemplate.h"
using namespace Tizen::Base;
using namespace Tizen::Ui;
{
#endif
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-GLuint _GlesGetCurrentFbo(void);
-bool _GlesFboEnableStencil(GLuint& frameBufferObject, GLuint& renderBuffer);
-#endif
-
_OSP_LOCAL_ void
_GlesInterfaceTerminate_2(void)
{
_GlBindFramebuffer_2(GLenum target, GLuint framebuffer)
{
_GLES_CHECK_INTERFACE_VOID_2
-
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- if (framebuffer == 0)
- {
- framebuffer = _GlesGetCurrentFbo();
- }
-#endif
-
_glesImpl2.glBindFramebuffer(target, framebuffer);
}
_GlEnable_2(GLenum cap)
{
_GLES_CHECK_INTERFACE_VOID_2
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
- if (cap == GL_STENCIL_TEST)
- {
- GLuint frameBufferObject = 0;
- GLuint stencilRenderBuffer = 0;
-
- bool ret = _GlesFboEnableStencil(frameBufferObject, stencilRenderBuffer);
-
- if (ret)
- {
- _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
- _glesImpl2.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencilRenderBuffer);
- }
- }
-#endif
_glesImpl2.glEnable(cap);
}
_glesImpl2.glViewport(x, y, width, height);
}
-#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-_OSP_LOCAL_ bool
-_CreateShader(GLuint& program)
-{
- _GLES_CHECK_INTERFACE_GLBOOLEAN_2
- const char* VERTEX_TEXT =
- "attribute vec4 aPosition;\n"
- "attribute vec2 aTextureCoord;\n"
- "varying vec2 vTextureCoord;\n"
- "\n"
- "void main()\n"
- "{\n"
- " gl_Position = aPosition;\n"
- " vTextureCoord = aTextureCoord;\n"
- "}";
-
- const char* FRAGMENT_TEXT =
- "precision highp float;\n"
- "uniform sampler2D uTexture;\n"
- "varying vec2 vTextureCoord;\n"
- "\n"
- "void main (void)\n"
- "{\n"
- " gl_FragColor = texture2D(uTexture, vTextureCoord);\n"
- "}";
-
- GLint linked = GL_FALSE;
- GLint bShaderCompiled = GL_FALSE;
- GLuint fragShader = _glesImpl2.glCreateShader(GL_FRAGMENT_SHADER);
- GLuint vertShader = _glesImpl2.glCreateShader(GL_VERTEX_SHADER);
-
- _glesImpl2.glShaderSource(fragShader, 1, (const char**)(&FRAGMENT_TEXT), NULL);
- _glesImpl2.glCompileShader(fragShader);
- _glesImpl2.glGetShaderiv(fragShader, GL_COMPILE_STATUS, &bShaderCompiled);
-
- _glesImpl2.glShaderSource(vertShader, 1, (const char**)&VERTEX_TEXT, NULL);
- _glesImpl2.glCompileShader(vertShader);
- _glesImpl2.glGetShaderiv(vertShader, GL_COMPILE_STATUS, &bShaderCompiled);
-
- program = _glesImpl2.glCreateProgram();
-
- _glesImpl2.glAttachShader(program, fragShader);
- _glesImpl2.glAttachShader(program, vertShader);
- _glesImpl2.glLinkProgram(program);
- _glesImpl2.glGetProgramiv(program, GL_LINK_STATUS, &linked);
-
- _glesImpl2.glDeleteShader(fragShader);
- _glesImpl2.glDeleteShader(vertShader);
-
- if (linked == GL_FALSE)
- {
- GLint infoLen = 0;
- _glesImpl2.glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLen);
- if (infoLen > 1)
- {
- std::unique_ptr<char[]> autoPtrInfoLog(new (std::nothrow) char[infoLen]);
- _glesImpl2.glGetProgramInfoLog(program, infoLen, NULL, autoPtrInfoLog.get());
- SysLog(NID_GRP, "FBO Program Linking failed. log: %s", autoPtrInfoLog.get());
- }
- return false;
- }
-
- return true;
-}
-
-_OSP_LOCAL_ void
-_GlesFboTerminate_2(GLuint& frameBufferObject, GLuint& depthRenderBuffer
- , GLuint& stencilRenderBuffer, GLuint& textureId, GLuint& program)
-{
- _GLES_CHECK_INTERFACE_VOID_2
- _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
- if (frameBufferObject != 0)
- {
- _glesImpl2.glDeleteFramebuffers(1, &frameBufferObject);
- frameBufferObject = 0;
- }
-
- if (depthRenderBuffer != 0)
- {
- _glesImpl2.glDeleteRenderbuffers(1, &depthRenderBuffer);
- depthRenderBuffer = 0;
- }
-
- if (stencilRenderBuffer != 0)
- {
- _glesImpl2.glDeleteRenderbuffers(1, &depthRenderBuffer);
- depthRenderBuffer = 0;
- }
-
- if (textureId != 0)
- {
- _glesImpl2.glDeleteTextures(1, &textureId);
- textureId = 0;
- }
-
- if (program != 0)
- {
- _glesImpl2.glDeleteProgram(program);
- program = 0;
- }
-}
-
-_OSP_LOCAL_ bool
-_GlesFboInitialize_2(const int fboWidth, const int fboHeight, GLuint& frameBufferObject
- , GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer, GLuint colorSize
- , GLuint depthSize, GLuint stencilSize, GLuint& textureId, GLuint& program)
-{
- _GLES_CHECK_INTERFACE_GLBOOLEAN_2
- if (!_CreateShader(program))
- {
- return false;
- }
-
- GLint maxSize = 0;
- _glesImpl2.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxSize);
- if (fboWidth > maxSize || fboHeight > maxSize)
- {
- SysLog(NID_GRP, "FBO Incompatible size");
- return false;
- }
-
- _glesImpl2.glActiveTexture(GL_TEXTURE0);
-
- _glesImpl2.glGenFramebuffers(1, &frameBufferObject);
- _glesImpl2.glGenRenderbuffers(1, &depthRenderBuffer);
- _glesImpl2.glGenRenderbuffers(1, &stencilRenderBuffer);
- _glesImpl2.glGenTextures(1, &textureId);
- if (frameBufferObject == 0 || depthRenderBuffer == 0 || stencilRenderBuffer == 0 || textureId == 0)
- {
- SysLog(NID_GRP, "FBO generating failed! fbo:%d depth:%d stencil:%d tex:%d"
- , frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId);
- _GlesFboTerminate_2(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId, program);
- }
-
- _glesImpl2.glBindTexture(GL_TEXTURE_2D, textureId);
- if (colorSize > 16)
- {
- _glesImpl2.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fboWidth, fboHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- }
- else
- {
- _glesImpl2.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fboWidth, fboHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
- }
- _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- const char* pString = (const char*)_glesImpl2.glGetString(GL_EXTENSIONS);
- String extensions(pString);
-
- if (depthSize > 0)
- {
- GLenum internalFormat = GL_DEPTH_COMPONENT16;
-
- if (depthSize > 24)
- {
- if (extensions.Contains(L"GL_OES_depth32"))
- {
- internalFormat = GL_DEPTH_COMPONENT32_OES;
- }
- }
- else if (depthSize > 16)
- {
- if (extensions.Contains(L"GL_OES_depth24"))
- {
- internalFormat = GL_DEPTH_COMPONENT24_OES;
- }
- }
-
- _glesImpl2.glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer);
- _glesImpl2.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, fboWidth, fboHeight);
- }
-
- if (stencilSize > 0)
- {
- GLenum internalFormat = GL_STENCIL_INDEX8;
-
- if (stencilSize == 1)
- {
- if (extensions.Contains(L"GL_OES_stencil1"))
- {
- internalFormat = GL_STENCIL_INDEX1_OES;
- }
- }
- else if (stencilSize <= 4)
- {
- if (extensions.Contains(L"GL_OES_stencil4"))
- {
- internalFormat = GL_STENCIL_INDEX4_OES;
- }
- }
-
- _glesImpl2.glBindRenderbuffer(GL_RENDERBUFFER, stencilRenderBuffer);
- _glesImpl2.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, fboWidth, fboHeight);
- }
-
- _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
- _glesImpl2.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0);
- if (depthSize != 0)
- {
- _glesImpl2.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer);
- }
-
- _glesImpl2.glBindTexture(GL_TEXTURE_2D, 0);
-
- GLenum ret = _glesImpl2.glCheckFramebufferStatus(GL_FRAMEBUFFER);
- if (ret != GL_FRAMEBUFFER_COMPLETE)
- {
- _GlesFboTerminate_2(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId, program);
- SysLog(NID_GRP, "FBO glCheckFramebufferStatus failed! %#x", (unsigned int)ret);
- return false;
- }
-
- return true;
-}
-
-_OSP_LOCAL_ void
-_GlesFboBinding_2(const GLuint frameBufferObject)
-{
- _GLES_CHECK_INTERFACE_VOID_2
- _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
-}
-
-_OSP_LOCAL_ void
-_GlesFboSwapBuffers_2(const Frame* pFrame, const GLuint frameBufferObject
- , const GLuint textureId, const GLuint program)
-{
- _GLES_CHECK_INTERFACE_VOID_2
- GLboolean isEnabledCullFace = GL_FALSE;
- GLboolean isEnabledStencil = GL_FALSE;
- GLboolean isEnabledDepth = GL_FALSE;
- GLboolean isEnabledScissor = GL_FALSE;
- GLboolean isEnabledBlend = GL_FALSE;
-
- isEnabledCullFace = _glesImpl2.glIsEnabled(GL_CULL_FACE);
- isEnabledStencil = _glesImpl2.glIsEnabled(GL_STENCIL_TEST);
- isEnabledDepth = _glesImpl2.glIsEnabled(GL_DEPTH_TEST);
- isEnabledScissor = _glesImpl2.glIsEnabled(GL_SCISSOR_TEST);
- isEnabledBlend = _glesImpl2.glIsEnabled(GL_BLEND);
- _glesImpl2.glDisable(GL_CULL_FACE);
- _glesImpl2.glDisable(GL_STENCIL_TEST);
- _glesImpl2.glDisable(GL_DEPTH_TEST);
- _glesImpl2.glDisable(GL_SCISSOR_TEST);
- _glesImpl2.glDisable(GL_BLEND);
-
- GLint previousTextureId = 0;
- GLint previousArrayBuffer = 0;
- GLint previousElementArrayBuffer = 0;
- GLint previousViewport[4] = {0,};
- GLint previousProgram = 0;
- _glesImpl2.glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureId);
- _glesImpl2.glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &previousArrayBuffer);
- _glesImpl2.glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &previousElementArrayBuffer);
- _glesImpl2.glGetIntegerv(GL_VIEWPORT, previousViewport);
- _glesImpl2.glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgram);
-
- _glesImpl2.glUseProgram(program);
- int indexTexture = 0;
- int indexAttribPosition = 0;
- int indexAttribTextureCoord = 0;
- indexTexture = _glesImpl2.glGetUniformLocation(program, "uTexture");
- indexAttribPosition = _glesImpl2.glGetAttribLocation(program, "aPosition");
- indexAttribTextureCoord = _glesImpl2.glGetAttribLocation(program, "aTextureCoord");
-
- _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, 0);
- _glesImpl2.glBindTexture( GL_TEXTURE_2D, textureId);
-
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
- pFrame->GetBounds(x, y, width, height);
-
- GLfloat ratioX1 = 0.0f;
- GLfloat ratioX2 = 1.0f;
- GLfloat ratioY1 = 0.0f;
- GLfloat ratioY2 = 1.0f;
-
- GLfloat texture[] = {
- ratioX1, ratioY1,
- ratioX2, ratioY1,
- ratioX1, ratioY2,
- ratioX2, ratioY2,
- };
-
- OrientationStatus orientationStatus = pFrame->GetOrientationStatus();
- switch (orientationStatus)
- {
- default:
- case ORIENTATION_STATUS_NONE:
- case ORIENTATION_STATUS_PORTRAIT:
- _glesImpl2.glViewport(0, 0, width, height);
- break;
-
- case ORIENTATION_STATUS_LANDSCAPE:
- texture[0] = ratioX2;
- texture[1] = ratioY1;
- texture[2] = ratioX2;
- texture[3] = ratioY2;
- texture[4] = ratioX1;
- texture[5] = ratioY1;
- texture[6] = ratioX1;
- texture[7] = ratioY2;
- _glesImpl2.glViewport(0, 0, height, width);
- break;
-
- case ORIENTATION_STATUS_PORTRAIT_REVERSE:
- texture[0] = ratioX2;
- texture[1] = ratioY2;
- texture[2] = ratioX1;
- texture[3] = ratioY2;
- texture[4] = ratioX2;
- texture[5] = ratioY1;
- texture[6] = ratioX1;
- texture[7] = ratioY1;
- _glesImpl2.glViewport(0, 0, width, height);
- break;
-
- case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
- texture[0] = ratioX1;
- texture[1] = ratioY2;
- texture[2] = ratioX1;
- texture[3] = ratioY1;
- texture[4] = ratioX2;
- texture[5] = ratioY2;
- texture[6] = ratioX2;
- texture[7] = ratioY1;
- _glesImpl2.glViewport(0, 0, height, width);
- break;
- }
-
- _glesImpl2.glUniform1i(indexTexture, 0);
-
- _glesImpl2.glEnableVertexAttribArray(indexAttribPosition);
- _glesImpl2.glEnableVertexAttribArray(indexAttribTextureCoord);
-
- GLfloat vertex[] = {
- -1.0f, -1.0f,
- 1.0f, -1.0f,
- -1.0f, 1.0f,
- 1.0f, 1.0f,
- };
-
- _glesImpl2.glBindBuffer(GL_ARRAY_BUFFER, 0);
- _glesImpl2.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-
- _glesImpl2.glVertexAttribPointer(indexAttribPosition, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), vertex);
- _glesImpl2.glVertexAttribPointer(indexAttribTextureCoord, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), texture);
-
- _glesImpl2.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
- _glesImpl2.glUseProgram((GLuint)previousProgram);
- if (isEnabledCullFace)
- {
- _glesImpl2.glEnable(GL_CULL_FACE);
- }
- if (isEnabledStencil)
- {
- _glesImpl2.glEnable(GL_STENCIL_TEST);
- }
- if (isEnabledDepth)
- {
- _glesImpl2.glEnable(GL_DEPTH_TEST);
- }
- if (isEnabledScissor)
- {
- _glesImpl2.glEnable(GL_SCISSOR_TEST);
- }
- if (isEnabledBlend)
- {
- _glesImpl2.glEnable(GL_BLEND);
- }
-
- _glesImpl2.glBindTexture( GL_TEXTURE_2D, previousTextureId);
- _glesImpl2.glBindBuffer(GL_ARRAY_BUFFER, previousArrayBuffer);
- _glesImpl2.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, previousElementArrayBuffer);
- _glesImpl2.glViewport(previousViewport[0], previousViewport[1], previousViewport[2], previousViewport[3]);
-}
-
-#endif //#if defined(FGRAPHICS_INTERNAL_USE_FBO)
-
#ifdef __cplusplus
}
#endif