2
* Copyright © 2013 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Robert Carr <robert.carr@canonical.com>
19
#include "example_egl_helper.h"
23
namespace me = mir::examples;
25
me::EGLHelper::EGLHelper(EGLNativeDisplayType native_display, EGLNativeWindowType native_window)
27
display = eglGetDisplay(native_display);
28
assert(display != EGL_NO_DISPLAY);
31
rc = eglInitialize(display, &major, &minor);
32
assert(rc == EGL_TRUE);
37
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
42
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
46
rc = eglChooseConfig(display, attribs, &egl_config, 1, &n);
47
assert(rc == EGL_TRUE);
50
surface = eglCreateWindowSurface(display, egl_config, native_window, nullptr);
51
assert(surface != EGL_NO_SURFACE);
53
EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
54
context = eglCreateContext(display, egl_config, EGL_NO_CONTEXT, context_attribs);
55
assert(surface != EGL_NO_CONTEXT);
58
me::EGLHelper::~EGLHelper()
60
eglDestroySurface(display, surface);
61
eglDestroyContext(display, context);
62
eglTerminate(display);
65
EGLDisplay me::EGLHelper::the_display() const
70
EGLContext me::EGLHelper::the_context() const
75
EGLSurface me::EGLHelper::the_surface() const