widnow setup
| _xWindow = Gdk.X11Window.get_xid(area.get_window()) | |
| xDisplay = Gdk.X11Display.get_xdisplay(area.get_window().get_display()) | |
| _eglDisplay = eglGetDisplay(xDisplay) | |
| xVisInfo = xDisplay.get_visual_info(0, xVisInfo, out matches) | |
| visualid = (int) xVisInfo.visualid | |
| // Copy X11 depth into EGL attributes | |
| egl_attrs : array of EGLint = { | |
| EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // OpenGL ES 2.0 | |
| EGL_NATIVE_VISUAL_ID, visualid, // Use X11 VisualID | |
| EGL_DEPTH_SIZE, 16, // Depth | |
| EGL_STENCIL_SIZE, 1, // Stencil | |
| EGL_NONE | |
| } | |
| ctx_attrs : array of EGLint = { | |
| EGL_CONTEXT_CLIENT_VERSION, 2, // OpenGL ES 2.0 | |
| EGL_NONE | |
| } | |
| if not eglInitialize(_eglDisplay, out major, out minor) | |
| print "Failed to initialize EGL." | |
| return false | |
| // Check EGL version | |
| if major != 1 or minor < 3 | |
| print "EGL version %i.%i not supported.", major, minor | |
| return false | |
| if (!eglChooseConfig(_eglDisplay, egl_attrs, {_eglConfig}, out matches) | |
| or matches == 0) | |
| print "EGL configuration failed." | |
| eglBindAPI(EGL_OPENGL_ES_API) | |
| _eglContext = eglCreateContext(_eglDisplay, _eglConfig, | |
| EGL_NO_CONTEXT, ctx_attrs) | |
| if _eglContext is EGL_NO_CONTEXT | |
| print("_eglContext is EGL_NO_CONTEXT") | |
| // and before drawing | |
| if _eglSurface is null | |
| // Get EGLSurface | |
| _eglSurface = eglCreateWindowSurface(_eglDisplay, _eglConfig, | |
| _xWindow, null) | |
| area.get_window().flush() | |
| if _eglSurface is EGL_NO_SURFACE | |
| print eglGetError().to_string() | |
| print "_eglSurface is EGL_NO_SURFACE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment