3 // Open Service Platform
4 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // All rights reserved.
7 // This software contains confidential and proprietary information
8 // of Samsung Electronics Co., Ltd.
9 // The user of this software agrees not to disclose, disseminate or copy such
10 // Confidential Information and shall use the software only in accordance with
11 // the terms of the license agreement the user entered into with Samsung.
16 using namespace Tizen::Graphics::Opengl;
18 EGLDisplay GLtools::eglDisplay(EGL_DEFAULT_DISPLAY);
19 EGLSurface GLtools::eglSurface(EGL_NO_SURFACE);
20 EGLConfig GLtools::eglConfig(null);
21 EGLContext GLtools::eglContext(EGL_NO_DISPLAY);
22 Tizen::Ui::Container* GLtools::pContainer(null);
25 int GLtools::screenWidth(0);
26 int GLtools::screenHeight(0);
30 GLtools::getCurrentGLContainer()
38 EGLint numConfigs = 1;
39 EGLint eglConfigList[] = {
45 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
46 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
49 EGLint eglContextList[] = {
50 EGL_CONTEXT_CLIENT_VERSION, 2,
54 eglBindAPI(EGL_OPENGL_ES_API);
61 eglDisplay = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY);
62 if (EGL_NO_DISPLAY == eglDisplay)
67 if (EGL_FALSE == eglInitialize(eglDisplay, null, null) || EGL_SUCCESS != eglGetError())
72 if (EGL_FALSE == eglChooseConfig(eglDisplay, eglConfigList, &eglConfig, 1, &numConfigs) || EGL_SUCCESS != eglGetError())
82 eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, (EGLNativeWindowType) pContainer, null);
84 if (EGL_NO_SURFACE == eglSurface || EGL_SUCCESS != eglGetError())
89 eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, eglContextList);
90 if (EGL_NO_CONTEXT == eglContext || EGL_SUCCESS != eglGetError())
95 if (EGL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) || EGL_SUCCESS != eglGetError())
104 GLtools::initGL(Tizen::Ui::Container *const container)
106 if(pContainer == container)
111 pContainer = container;
124 pContainer->GetBounds(x, y, screenWidth, screenHeight);
134 eglMakeCurrent(eglDisplay, null, null, null);
138 eglDestroyContext(eglDisplay, eglContext);
139 eglContext = EGL_NO_CONTEXT;
144 //eglDestroySurface(eglDisplay, eglSurface);
145 eglSurface = EGL_NO_SURFACE;
148 //eglTerminate(eglDisplay);
149 eglDisplay = EGL_NO_DISPLAY;
157 GLtools::startDrawing()
159 if (!pContainer->IsEnabled()) return false;
161 if (GL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) || EGL_SUCCESS != eglGetError()) return false;
163 glViewport(x, y, screenWidth, screenHeight);
165 glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
167 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
174 GLtools::finishDrawing(void)
176 //Causing image flickering. 2.1.0_RC12_M5
179 eglSwapBuffers(eglDisplay, eglSurface);
183 GLtools::getWidth(void)
185 return (screenWidth);
189 GLtools::getHeight(void)
191 return (screenHeight);