Lines Matching refs:eglman

59 static EGLBoolean check_ext(EGLmanager *eglman)
62 egl_ext_str = eglQueryString(eglman->dpy, EGL_EXTENSIONS);
95 static EGLBoolean create_x_window(EGLmanager *eglman, const char *name)
115 scrnum = DefaultScreen(eglman->xdpy);
116 root = RootWindow(eglman->xdpy, scrnum);
118 if (!eglChooseConfig(eglman->dpy, config_attrib, &eglman->conf, 1, &num_conf) ||
126 if (!eglGetConfigAttrib(eglman->dpy, eglman->conf, EGL_NATIVE_VISUAL_ID, &vid) ||
135 visInfo = XGetVisualInfo(eglman->xdpy, VisualIDMask, &visTemplate, &num_visuals);
145 attr.colormap = XCreateColormap(eglman->xdpy, root, visInfo->visual, AllocNone);
149 eglman->xwin = XCreateWindow(eglman->xdpy, root, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT,
153 if (!eglman->xwin)
167 XSetNormalHints(eglman->xdpy, eglman->xwin, &sizehints);
168 XSetStandardProperties(eglman->xdpy, eglman->xwin, name, name,
177 static EGLBoolean egl_init(EGLmanager *eglman)
187 if (check_ext(eglman) != EGL_TRUE)
194 eglman->es_ctx = eglCreateContext(eglman->dpy, eglman->conf, NULL, NULL);
195 if (eglman->es_ctx == EGL_NO_CONTEXT ||
203 eglman->vg_ctx = eglCreateContext(eglman->dpy, eglman->conf, NULL, NULL);
204 if (eglman->vg_ctx == EGL_NO_CONTEXT ||
211 eglman->win_surface = eglCreateWindowSurface(eglman->dpy, eglman->conf, eglman->xwin, NULL);
212 if (eglman->win_surface == EGL_NO_SURFACE ||
219 eglman->pbuf_surface = eglCreatePbufferSurface(eglman->dpy, eglman->conf, pbuffer_attrib);
220 if (eglman->pbuf_surface == EGL_NO_SURFACE ||
230 static void egl_deinit(EGLmanager *eglman)
233 eglMakeCurrent(eglman->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
236 eglMakeCurrent(eglman->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
238 eglDestroySurface(eglman->dpy, eglman->win_surface);
239 eglDestroySurface(eglman->dpy, eglman->pbuf_surface);
241 eglDestroyContext(eglman->dpy, eglman->es_ctx);
242 eglDestroyContext(eglman->dpy, eglman->vg_ctx);
245 static EGLBoolean vg_es_init(EGLmanager *eglman)
249 eglMakeCurrent(eglman->dpy, eglman->pbuf_surface, eglman->pbuf_surface, eglman->vg_ctx);
252 eglman->vg_image = vgCreateImage(VG_sRGBA_8888, WINDOW_WIDTH, WINDOW_HEIGHT, VG_IMAGE_QUALITY_BETTER);
255 eglman->egl_image = (EGLImageKHR)eglCreateImageKHR(eglman->dpy, eglman->vg_ctx, EGL_VG_PARENT_IMAGE_KHR, (EGLClientBuffer)eglman->vg_image, NULL);
259 eglMakeCurrent(eglman->dpy, eglman->win_surface, eglman->win_surface, eglman->es_ctx);
262 glGenTextures(1, &eglman->texture);
263 glBindTexture(GL_TEXTURE_2D, eglman->texture);
268 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)eglman->egl_image);
273 static void vg_es_deinit(EGLmanager *eglman)
277 eglMakeCurrent(eglman->dpy, eglman->pbuf_surface, eglman->pbuf_surface, eglman->vg_ctx);
278 eglDestroyImageKHR(eglman->dpy, eglman->egl_image);
279 vgDestroyImage(eglman->vg_image);
283 eglMakeCurrent(eglman->dpy, eglman->win_surface, eglman->win_surface, eglman->es_ctx);
284 glDeleteTextures(1, &eglman->texture);
289 static void draw(EGLmanager *eglman)
311 eglMakeCurrent(eglman->dpy, eglman->pbuf_surface, eglman->pbuf_surface, eglman->vg_ctx);
314 vgClearImage(eglman->vg_image, 0, 0, WINDOW_WIDTH/2, WINDOW_HEIGHT/2);
317 vgClearImage(eglman->vg_image, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, WINDOW_WIDTH/2, WINDOW_HEIGHT/2);
321 eglMakeCurrent(eglman->dpy, eglman->win_surface, eglman->win_surface, eglman->es_ctx);
328 glBindTexture(GL_TEXTURE_2D, eglman->texture);
338 eglSwapBuffers(eglman->dpy, eglman->win_surface);
347 EGLmanager *eglman = calloc(1, sizeof(*eglman));
356 eglman->xdpy = (EGLNativeDisplayType)x_dpy;
359 eglman->dpy = eglGetDisplay(eglman->xdpy);
360 if (!eglman->dpy || eglGetError() != EGL_SUCCESS)
367 eglInitialize(eglman->dpy, &eglman->major_ver, &eglman->minor_ver);
374 s = eglQueryString(eglman->dpy, EGL_VERSION);
377 s = eglQueryString(eglman->dpy, EGL_VENDOR);
380 s = eglQueryString(eglman->dpy, EGL_EXTENSIONS);
383 s = eglQueryString(eglman->dpy, EGL_CLIENT_APIS);
387 if (create_x_window(eglman, "vgimage to texture") != EGL_TRUE)
392 XMapWindow(eglman->xdpy, eglman->xwin);
395 if (egl_init(eglman) != EGL_TRUE)
401 if (vg_es_init(eglman) != EGL_TRUE)
407 draw(eglman);
410 vg_es_deinit(eglman);
413 egl_deinit(eglman);
416 XDestroyWindow(eglman->xdpy, eglman->xwin);
418 eglTerminate(eglman->dpy);
420 XCloseDisplay(eglman->xdpy);
422 free(eglman);