| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <EGL/egl.h> | 5 #include <EGL/egl.h> |
| 6 | 6 |
| 7 #include "main.h" | 7 #include "main.h" |
| 8 #include "xlib_window.h" | 8 #include "xlib_window.h" |
| 9 | 9 |
| 10 | 10 |
| 11 static EGLDisplay egl_display = NULL; | 11 static EGLDisplay egl_display = NULL; |
| 12 static EGLConfig egl_config = NULL; | 12 static EGLConfig egl_config = NULL; |
| 13 static EGLSurface egl_surface = NULL; | 13 static EGLSurface egl_surface = NULL; |
| 14 static EGLContext egl_context = NULL; | 14 static EGLContext egl_context = NULL; |
| 15 | 15 |
| 16 #define CHECK_EGL() do { \ | 16 #define CHECK_EGL() do { \ |
| 17 if (eglGetError() != EGL_SUCCESS) return false; \ | 17 if (eglGetError() != EGL_SUCCESS) return false; \ |
| 18 } while (0) | 18 } while (0) |
| 19 | 19 |
| 20 bool Init() { | 20 bool Init() { |
| 21 if (!XlibInit()) | 21 if (!XlibInit()) |
| 22 return false; | 22 return false; |
| 23 | 23 |
| 24 EGLNativeWindowType native_window = | 24 EGLNativeWindowType native_window = |
| 25 static_cast<EGLNativeWindowType>(xlib_window); | 25 static_cast<EGLNativeWindowType>(g_xlib_window); |
| 26 egl_surface = eglCreateWindowSurface(egl_display, egl_config, | 26 egl_surface = eglCreateWindowSurface(egl_display, egl_config, |
| 27 native_window, NULL); | 27 native_window, NULL); |
| 28 CHECK_EGL(); | 28 CHECK_EGL(); |
| 29 return true; | 29 return true; |
| 30 } | 30 } |
| 31 | 31 |
| 32 VisualID GetVisualID() { | 32 VisualID GetVisualID() { |
| 33 EGLint attribs[] = { | 33 EGLint attribs[] = { |
| 34 EGL_RED_SIZE, 1, | 34 EGL_RED_SIZE, 1, |
| 35 EGL_GREEN_SIZE, 1, | 35 EGL_GREEN_SIZE, 1, |
| 36 EGL_BLUE_SIZE, 1, | 36 EGL_BLUE_SIZE, 1, |
| 37 EGL_DEPTH_SIZE, 1, | 37 EGL_DEPTH_SIZE, 1, |
| 38 EGL_STENCIL_SIZE, 1, | 38 EGL_STENCIL_SIZE, 1, |
| 39 EGL_SURFACE_TYPE, EGL_WINDOW_BIT, | 39 EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
| 40 EGL_NONE | 40 EGL_NONE |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 EGLNativeDisplayType native_display = | 43 EGLNativeDisplayType native_display = |
| 44 static_cast<EGLNativeDisplayType>(xlib_display); | 44 static_cast<EGLNativeDisplayType>(g_xlib_display); |
| 45 | 45 |
| 46 EGLDisplay egl_display = eglGetDisplay(native_display); | 46 EGLDisplay egl_display = eglGetDisplay(native_display); |
| 47 CHECK_EGL(); | 47 CHECK_EGL(); |
| 48 | 48 |
| 49 eglInitialize(egl_display, NULL, NULL); | 49 eglInitialize(egl_display, NULL, NULL); |
| 50 CHECK_EGL(); | 50 CHECK_EGL(); |
| 51 | 51 |
| 52 EGLint num_configs = -1; | 52 EGLint num_configs = -1; |
| 53 eglGetConfigs(egl_display, NULL, 0, &num_configs); | 53 eglGetConfigs(egl_display, NULL, 0, &num_configs); |
| 54 CHECK_EGL(); | 54 CHECK_EGL(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 eglTerminate(egl_display); | 91 eglTerminate(egl_display); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void SwapBuffers() { | 94 void SwapBuffers() { |
| 95 eglSwapBuffers(egl_display, egl_surface); | 95 eglSwapBuffers(egl_display, egl_surface); |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool SwapInterval(int interval) { | 98 bool SwapInterval(int interval) { |
| 99 return eglSwapInterval(egl_display, interval) == EGL_TRUE; | 99 return eglSwapInterval(egl_display, interval) == EGL_TRUE; |
| 100 } | 100 } |
| OLD | NEW |