diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2013-11-27 16:28:57 -0800 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2013-11-27 16:42:39 -0800 |
| commit | df0386562111870047c854f28ff59fdbcb8879cc (patch) | |
| tree | 398d263a76a1748202e2a7deff2992a234a468b6 /src/egl.cpp | |
| parent | dedef4369dea1131248b56b22573d0365f321179 (diff) | |
Refactor window creation into egl module
Diffstat (limited to 'src/egl.cpp')
| -rw-r--r-- | src/egl.cpp | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/egl.cpp b/src/egl.cpp index 978a334..e3ae179 100644 --- a/src/egl.cpp +++ b/src/egl.cpp @@ -7,6 +7,25 @@ #include "egl.h" bool +createWindow(egl_state_t *state, int width, int height) +{ + state->dpy = XOpenDisplay (NULL); + if (state->dpy == NULL) { + warnx ("Failed to open display: %s\n", XDisplayName (0)); + return false; + } + + state->window = XCreateSimpleWindow (state->dpy, DefaultRootWindow (state->dpy), + 0, 0, + width, height, + 0, + BlackPixel (state->dpy, DefaultRootWindow (state->dpy)), + BlackPixel (state->dpy, DefaultRootWindow (state->dpy))); + XMapWindow (state->dpy, state->window); + return true; +} + +bool createEGLContextWithWindow(egl_state_t *state) { EGLint attr[] = { @@ -27,6 +46,7 @@ createEGLContextWithWindow(egl_state_t *state) }; EGLConfig config; EGLint num; + EGLint major, minor; state->egl_display = eglGetDisplay ((EGLNativeDisplayType) state->dpy); if (state->egl_display == EGL_NO_DISPLAY) { @@ -34,6 +54,16 @@ createEGLContextWithWindow(egl_state_t *state) return false; } + if (!eglInitialize(state->egl_display, &major, &minor)) { + warnx ("Cannot initialize EGL\n"); + return false; + } + + if (!eglBindAPI(EGL_OPENGL_ES_API)) { + warnx ("Cannot bind EGL to GLES API\n"); + return false; + } + if (! eglChooseConfig (state->egl_display, attr, &config, 1, &num)) { warnx ("Cannot choose EGL configuration\n"); return false; @@ -52,20 +82,3 @@ createEGLContextWithWindow(egl_state_t *state) } return true; } - -bool -initializeEGL(egl_state_t *state) -{ - EGLint major, minor; - if (!eglInitialize(state->egl_display, &major, &minor)) { - warnx ("Cannot initialize EGL\n"); - return false; - } - - if (!eglBindAPI(EGL_OPENGL_ES_API)) { - warnx ("Cannot bind EGL to GLES API\n"); - return false; - } - - return true; -} |