1 #include "evas_engine.h"
3 static Evas_GL_X11_Window *_evas_gl_x11_window = NULL;
5 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
6 static EGLContext context = EGL_NO_CONTEXT;
8 // FIXME: this will only work for 1 display connection (glx land can have > 1)
9 static GLXContext context = 0;
10 static GLXContext rgba_context = 0;
11 static GLXFBConfig fbconf = 0;
12 static GLXFBConfig rgba_fbconf = 0;
15 // fixme: something is up/wrong here - dont know what tho...
18 static XVisualInfo *_evas_gl_x11_vi = NULL;
19 static XVisualInfo *_evas_gl_x11_rgba_vi = NULL;
20 static Colormap _evas_gl_x11_cmap = 0;
21 static Colormap _evas_gl_x11_rgba_cmap = 0;
23 static int win_count = 0;
26 eng_window_new(Display *disp,
38 Evas_GL_X11_Window *gw;
39 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
42 int major_version, minor_version;
43 int num_config, n = 0;
46 const GLubyte *vendor, *renderer, *version;
49 if (!_evas_gl_x11_vi) return NULL;
51 gw = calloc(1, sizeof(Evas_GL_X11_Window));
66 vi_use = _evas_gl_x11_vi;
69 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
70 if (_evas_gl_x11_rgba_vi)
72 vi_use = _evas_gl_x11_rgba_vi;
76 if (_evas_gl_x11_rgba_vi)
78 vi_use = _evas_gl_x11_rgba_vi;
83 gw->visualinfo = vi_use;
86 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
87 context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
89 context_attrs[2] = EGL_NONE;
91 # if defined(GLES_VARIETY_S3C6410)
92 if (gw->visualinfo->depth == 16) // 16bpp
94 config_attrs[n++] = EGL_SURFACE_TYPE;
95 config_attrs[n++] = EGL_WINDOW_BIT;
96 config_attrs[n++] = EGL_RENDERABLE_TYPE;
97 config_attrs[n++] = EGL_OPENGL_ES2_BIT;
98 config_attrs[n++] = EGL_RED_SIZE;
99 config_attrs[n++] = 5;
100 config_attrs[n++] = EGL_GREEN_SIZE;
101 config_attrs[n++] = 6;
102 config_attrs[n++] = EGL_BLUE_SIZE;
103 config_attrs[n++] = 5;
104 config_attrs[n++] = EGL_DEPTH_SIZE;
105 config_attrs[n++] = 0;
106 config_attrs[n++] = EGL_STENCIL_SIZE;
107 config_attrs[n++] = 0;
108 config_attrs[n++] = EGL_NONE;
110 else // 24/32bit. no one does 8bpp anymore. and 15bpp... dead
112 config_attrs[n++] = EGL_SURFACE_TYPE;
113 config_attrs[n++] = EGL_WINDOW_BIT;
114 config_attrs[n++] = EGL_RENDERABLE_TYPE;
115 config_attrs[n++] = EGL_OPENGL_ES2_BIT;
116 config_attrs[n++] = EGL_RED_SIZE;
117 config_attrs[n++] = 8;
118 config_attrs[n++] = EGL_GREEN_SIZE;
119 config_attrs[n++] = 8;
120 config_attrs[n++] = EGL_BLUE_SIZE;
121 config_attrs[n++] = 8;
122 config_attrs[n++] = EGL_DEPTH_SIZE;
123 config_attrs[n++] = 0;
124 config_attrs[n++] = EGL_STENCIL_SIZE;
125 config_attrs[n++] = 0;
126 config_attrs[n++] = EGL_NONE;
128 # elif defined(GLES_VARIETY_SGX)
129 config_attrs[n++] = EGL_SURFACE_TYPE;
130 config_attrs[n++] = EGL_WINDOW_BIT;
131 config_attrs[n++] = EGL_RENDERABLE_TYPE;
132 config_attrs[n++] = EGL_OPENGL_ES2_BIT;
134 // FIXME: n900 - omap3 sgx libs break here
135 config_attrs[n++] = EGL_RED_SIZE;
136 config_attrs[n++] = 1;
137 config_attrs[n++] = EGL_GREEN_SIZE;
138 config_attrs[n++] = 1;
139 config_attrs[n++] = EGL_BLUE_SIZE;
140 config_attrs[n++] = 1;
141 // FIXME: end n900 breakage
145 config_attrs[n++] = EGL_ALPHA_SIZE;
146 config_attrs[n++] = 1;
150 config_attrs[n++] = EGL_ALPHA_SIZE;
151 config_attrs[n++] = 0;
153 config_attrs[n++] = EGL_DEPTH_SIZE;
154 config_attrs[n++] = 0;
155 config_attrs[n++] = EGL_STENCIL_SIZE;
156 config_attrs[n++] = 0;
157 config_attrs[n++] = EGL_NONE;
160 gw->egl_disp = eglGetDisplay((EGLNativeDisplayType)(gw->disp));
163 ERR("eglGetDisplay() fail. code=%#x", eglGetError());
167 if (!eglInitialize(gw->egl_disp, &major_version, &minor_version))
169 ERR("eglInitialize() fail. code=%#x", eglGetError());
173 eglBindAPI(EGL_OPENGL_ES_API);
174 if (eglGetError() != EGL_SUCCESS)
176 ERR("eglBindAPI() fail. code=%#x", eglGetError());
182 if (!eglChooseConfig(gw->egl_disp, config_attrs, &gw->egl_config,
183 1, &num_config) || (num_config != 1))
185 ERR("eglChooseConfig() fail. code=%#x", eglGetError());
189 gw->egl_surface[0] = eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
190 (EGLNativeWindowType)gw->win,
192 if (gw->egl_surface[0] == EGL_NO_SURFACE)
194 ERR("eglCreateWindowSurface() fail for %#x. code=%#x",
195 (unsigned int)gw->win, eglGetError());
199 if (context == EGL_NO_CONTEXT)
200 context = eglCreateContext(gw->egl_disp, gw->egl_config, NULL,
202 gw->egl_context[0] = context;
203 if (gw->egl_context[0] == EGL_NO_CONTEXT)
205 ERR("eglCreateContext() fail. code=%#x", eglGetError());
209 if (eglMakeCurrent(gw->egl_disp,
212 gw->egl_context[0]) == EGL_FALSE)
214 ERR("eglMakeCurrent() fail. code=%#x", eglGetError());
219 vendor = glGetString(GL_VENDOR);
220 renderer = glGetString(GL_RENDERER);
221 version = glGetString(GL_VERSION);
222 if (!vendor) vendor = (unsigned char *)"-UNKNOWN-";
223 if (!renderer) renderer = (unsigned char *)"-UNKNOWN-";
224 if (!version) version = (unsigned char *)"-UNKNOWN-";
225 if (getenv("EVAS_GL_INFO"))
227 fprintf(stderr, "vendor: %s\n", vendor);
228 fprintf(stderr, "renderer: %s\n", renderer);
229 fprintf(stderr, "version: %s\n", version);
232 if (strstr((const char *)vendor, "Mesa Project"))
234 if (strstr((const char *)renderer, "Software Rasterizer"))
237 //Temporary Code for Tizen Emulator. With this driver, mapbuf would not
238 //work correctly some kind of the reason.
239 else if (strstr((const char *)vendor, "Huone Inc."))
242 if (strstr((const char *)renderer, "softpipe"))
246 ERR("OpenGL Driver blacklisted:");
247 ERR("Vendor: %s", (const char *)vendor);
248 ERR("Renderer: %s", (const char *)renderer);
249 ERR("Version: %s", (const char *)version);
259 context = glXCreateNewContext(gw->disp, fbconf,
263 context = glXCreateNewContext(gw->disp, fbconf,
268 context = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_FALSE);
270 context = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_TRUE);
274 if ((gw->alpha) && (!rgba_context))
277 rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
278 GLX_RGBA_TYPE, context,
281 rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
282 GLX_RGBA_TYPE, context,
286 gw->glxwin = glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
288 gw->glxwin = glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
295 if (gw->alpha) gw->context = rgba_context;
296 else gw->context = context;
298 gw->context = context;
313 if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
316 printf("Error: glXMakeContextCurrent(%p, %p, %p, %p)\n", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->glxwin, (void *)gw->context);
323 if (!glXMakeCurrent(gw->disp, gw->win, gw->context))
325 printf("Error: glXMakeCurrent(%p, 0x%x, %p) failed\n", (void *)gw->disp, (unsigned int)gw->win, (void *)gw->context);
331 // FIXME: move this up to context creation
333 vendor = glGetString(GL_VENDOR);
334 renderer = glGetString(GL_RENDERER);
335 version = glGetString(GL_VERSION);
336 if (getenv("EVAS_GL_INFO"))
338 fprintf(stderr, "vendor: %s\n", vendor);
339 fprintf(stderr, "renderer: %s\n", renderer);
340 fprintf(stderr, "version: %s\n", version);
343 // vendor: NVIDIA Corporation
344 // renderer: NVIDIA Tegra
345 // version: OpenGL ES 2.0
347 // vendor: Imagination Technologies
348 // renderer: PowerVR SGX 540
349 // version: OpenGL ES 2.0
351 // vendor: NVIDIA Corporation
352 // renderer: GeForce GT 330M/PCI/SSE2
353 // version: 3.3.0 NVIDIA 256.53
355 // vendor: NVIDIA Corporation
356 // renderer: GeForce GT 220/PCI/SSE2
357 // version: 3.2.0 NVIDIA 195.36.24
359 // vendor: NVIDIA Corporation
360 // renderer: GeForce 8600 GTS/PCI/SSE2
361 // version: 3.3.0 NVIDIA 260.19.36
363 // vendor: ATI Technologies Inc.
364 // renderer: ATI Mobility Radeon HD 4650
365 // version: 3.2.9756 Compatibility Profile Context
367 // vendor: Tungsten Graphics, Inc
368 // renderer: Mesa DRI Mobile Intel® GM45 Express Chipset GEM 20100330 DEVELOPMENT x86/MMX/SSE2
369 // version: 2.1 Mesa 7.9-devel
371 // vendor: Advanced Micro Devices, Inc.
372 // renderer: Mesa DRI R600 (RS780 9610) 20090101 TCL DRI2
373 // version: 2.1 Mesa 7.9-devel
375 // vendor: NVIDIA Corporation
376 // renderer: GeForce 9600 GT/PCI/SSE2
377 // version: 3.3.0 NVIDIA 260.19.29
379 // vendor: ATI Technologies Inc.
380 // renderer: ATI Radeon HD 4800 Series
381 // version: 3.3.10237 Compatibility Profile Context
383 // vendor: Advanced Micro Devices, Inc.
384 // renderer: Mesa DRI R600 (RV770 9442) 20090101 TCL DRI2
385 // version: 2.0 Mesa 7.8.2
387 // vendor: Tungsten Graphics, Inc
388 // renderer: Mesa DRI Mobile Intel® GM45 Express Chipset GEM 20100330 DEVELOPMENT
389 // version: 2.1 Mesa 7.9-devel
390 // or (bad - software renderer)
391 // vendor: Mesa Project
392 // renderer: Software Rasterizer
393 // version: 2.1 Mesa 7.9-devel
394 // or (bad - software renderer)
395 // vendor: VMware, Inc.
396 // renderer: Gallium 0.4 on softpipe
397 // version: 2.1 Mesa 7.9-devel
399 if (strstr((const char *)vendor, "Mesa Project"))
401 if (strstr((const char *)renderer, "Software Rasterizer"))
404 if (strstr((const char *)renderer, "softpipe"))
408 ERR("OpenGL Driver blacklisted:");
409 ERR("Vendor: %s", (const char *)vendor);
410 ERR("Renderer: %s", (const char *)renderer);
411 ERR("Version: %s", (const char *)version);
415 if (strstr((const char *)vendor, "NVIDIA"))
417 if (!strstr((const char *)renderer, "NVIDIA Tegra"))
419 int v1 = 0, v2 = 0, v3 = 0;
421 if (sscanf((const char *)version,
426 if (sscanf((const char *)version,
431 // ALSO as of some nvidia driver version loose binding is
432 // probably not needed
433 if (v1 < 195) gw->detected.loose_binding = 1;
438 // noothing yet. add more cases and options over time
441 fbc = glXGetFBConfigs(gw->disp, screen, &num);
444 ERR("glXGetFBConfigs() returned no fb configs");
448 for (i = 0; i <= 32; i++)
450 for (j = 0; j < num; j++)
454 int alph, val, dbuf, stencil, tdepth;
457 vi = glXGetVisualFromFBConfig(gw->disp, fbc[j]);
462 if (vd != i) continue;
464 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_ALPHA_SIZE, &alph);
465 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BUFFER_SIZE, &val);
467 if ((val != i) && ((val - alph) != i)) continue;
474 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_RGBA_EXT, &val);
478 gw->depth_cfg[i].tex_format = GLX_TEXTURE_FORMAT_RGBA_EXT;
484 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_RGB_EXT, &val);
486 gw->depth_cfg[i].tex_format = GLX_TEXTURE_FORMAT_RGB_EXT;
490 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DOUBLEBUFFER, &val);
491 if (val > dbuf) continue;
495 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_STENCIL_SIZE, &val);
496 if (val > stencil) continue;
500 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DEPTH_SIZE, &val);
501 if (val > tdepth) continue;
504 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_MIPMAP_TEXTURE_EXT, &val);
505 if (val < 0) continue;
506 gw->depth_cfg[i].mipmap = val;
508 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_Y_INVERTED_EXT, &val);
509 gw->depth_cfg[i].yinvert = val;
511 glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &val);
512 gw->depth_cfg[i].tex_target = val;
514 gw->depth_cfg[i].fbc = fbc[j];
518 if (!gw->depth_cfg[DefaultDepth(gw->disp, screen)].fbc)
520 WRN("texture from pixmap not going to work");
525 gw->gl_context = evas_gl_common_context_new();
531 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
532 gw->gl_context->egldisp = gw->egl_disp;
535 evas_gl_common_context_resize(gw->gl_context, w, h, rot);
542 eng_window_free(Evas_GL_X11_Window *gw)
547 if (gw == _evas_gl_x11_window) _evas_gl_x11_window = NULL;
550 ref = gw->gl_context->references - 1;
551 evas_gl_common_context_free(gw->gl_context);
553 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
554 if (gw->egl_surface[0] != EGL_NO_SURFACE)
555 eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
556 eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
559 if (context) eglDestroyContext(gw->egl_disp, context);
560 eglTerminate(gw->egl_disp);
561 context = EGL_NO_CONTEXT;
563 eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
565 if (gw->glxwin) glXDestroyWindow(gw->disp, gw->glxwin);
568 if (context) glXDestroyContext(gw->disp, context);
569 if (rgba_context) glXDestroyContext(gw->disp, rgba_context);
580 eng_window_use(Evas_GL_X11_Window *gw)
582 Eina_Bool force_use = EINA_FALSE;
584 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
585 if (_evas_gl_x11_window)
587 if ((eglGetCurrentContext() !=
588 _evas_gl_x11_window->egl_context[0]) ||
589 (eglGetCurrentSurface(EGL_READ) !=
590 _evas_gl_x11_window->egl_surface[0]) ||
591 (eglGetCurrentSurface(EGL_DRAW) !=
592 _evas_gl_x11_window->egl_surface[0]))
593 force_use = EINA_TRUE;
596 if (_evas_gl_x11_window)
598 if (glXGetCurrentContext() != _evas_gl_x11_window->context)
599 force_use = EINA_TRUE;
602 if ((_evas_gl_x11_window != gw) || (force_use))
604 if (_evas_gl_x11_window)
606 evas_gl_common_context_use(_evas_gl_x11_window->gl_context);
607 evas_gl_common_context_flush(_evas_gl_x11_window->gl_context);
609 _evas_gl_x11_window = gw;
613 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
614 if (gw->egl_surface[0] != EGL_NO_SURFACE)
616 if (eglMakeCurrent(gw->egl_disp,
619 gw->egl_context[0]) == EGL_FALSE)
621 ERR("eglMakeCurrent() failed!");
628 if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
631 ERR("glXMakeContextCurrent(%p, %p, %p, %p)", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->glxwin, (void *)gw->context);
636 if (!glXMakeCurrent(gw->disp, gw->win, gw->context))
638 ERR("glXMakeCurrent(%p, 0x%x, %p) failed", gw->disp, (unsigned int)gw->win, (void *)gw->context);
644 if (gw) evas_gl_common_context_use(gw->gl_context);
648 eng_window_unsurf(Evas_GL_X11_Window *gw)
650 if (!gw->surf) return;
651 if (!getenv("EVAS_GL_WIN_RESURF")) return;
652 if (getenv("EVAS_GL_INFO"))
653 printf("unsurf %p\n", gw);
654 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
655 if (_evas_gl_x11_window)
656 evas_gl_common_context_flush(_evas_gl_x11_window->gl_context);
657 if (_evas_gl_x11_window == gw)
659 eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
660 if (gw->egl_surface[0] != EGL_NO_SURFACE)
661 eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
662 gw->egl_surface[0] = EGL_NO_SURFACE;
663 _evas_gl_x11_window = NULL;
668 glXDestroyWindow(gw->disp, gw->glxwin);
678 eng_window_resurf(Evas_GL_X11_Window *gw)
680 if (gw->surf) return;
681 if (getenv("EVAS_GL_INFO"))
682 printf("resurf %p\n", gw);
683 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
684 gw->egl_surface[0] = eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
685 (EGLNativeWindowType)gw->win,
687 if (gw->egl_surface[0] == EGL_NO_SURFACE)
689 ERR("eglCreateWindowSurface() fail for %#x. code=%#x",
690 (unsigned int)gw->win, eglGetError());
693 if (eglMakeCurrent(gw->egl_disp,
696 gw->egl_context[0]) == EGL_FALSE)
698 ERR("eglMakeCurrent() failed!");
703 gw->glxwin = glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
705 gw->glxwin = glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
706 if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
709 ERR("glXMakeContextCurrent(%p, %p, %p, %p)", (void *)gw->disp, (void *)gw->glxwin, (void *)gw->glxwin, (void *)gw->context);
712 if (!glXMakeCurrent(gw->disp, gw->win, gw->context))
714 ERR("glXMakeCurrent(%p, 0x%x, %p) failed", (void *)gw->disp, (unsigned int)gw->win, (void *)gw->context);
722 eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
724 if (!einfo) return NULL;
725 if (!einfo->info.display) return NULL;
726 if (!_evas_gl_x11_vi)
731 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
732 for (alpha = 0; alpha < 2; alpha++)
734 int depth = DefaultDepth(einfo->info.display,
738 XVisualInfo *xvi, vi_in;
740 XRenderPictFormat *fmt;
742 vi_in.screen = einfo->info.screen;
744 vi_in.class = TrueColor;
745 xvi = XGetVisualInfo(einfo->info.display,
746 VisualScreenMask | VisualDepthMask |
751 for (i = 0; i < nvi; i++)
753 fmt = XRenderFindVisualFormat(einfo->info.display,
755 if ((fmt->type == PictTypeDirect) &&
756 (fmt->direct.alphaMask))
758 _evas_gl_x11_rgba_vi =
759 calloc(1, sizeof(XVisualInfo));
760 if (_evas_gl_x11_rgba_vi)
761 memcpy(_evas_gl_x11_rgba_vi,
762 &(xvi[i]), sizeof(XVisualInfo));
771 _evas_gl_x11_vi = calloc(1, sizeof(XVisualInfo));
772 XMatchVisualInfo(einfo->info.display,
773 einfo->info.screen, depth, TrueColor,
779 for (alpha = 0; alpha < 2; alpha++)
781 int config_attrs[40];
782 GLXFBConfig *configs = NULL, config = 0;
786 config_attrs[i++] = GLX_DRAWABLE_TYPE;
787 config_attrs[i++] = GLX_WINDOW_BIT;
788 config_attrs[i++] = GLX_DOUBLEBUFFER;
789 config_attrs[i++] = 1;
790 config_attrs[i++] = GLX_RED_SIZE;
791 config_attrs[i++] = 1;
792 config_attrs[i++] = GLX_GREEN_SIZE;
793 config_attrs[i++] =1;
794 config_attrs[i++] = GLX_BLUE_SIZE;
795 config_attrs[i++] = 1;
798 config_attrs[i++] = GLX_RENDER_TYPE;
799 config_attrs[i++] = GLX_RGBA_BIT;
800 config_attrs[i++] = GLX_ALPHA_SIZE;
801 config_attrs[i++] = 1;
805 config_attrs[i++] = GLX_ALPHA_SIZE;
806 config_attrs[i++] = 0;
808 config_attrs[i++] = GLX_DEPTH_SIZE;
809 config_attrs[i++] = 0;
810 config_attrs[i++] = GLX_STENCIL_SIZE;
811 config_attrs[i++] = 0;
812 config_attrs[i++] = GLX_AUX_BUFFERS;
813 config_attrs[i++] = 0;
814 config_attrs[i++] = GLX_STEREO;
815 config_attrs[i++] = 0;
816 config_attrs[i++] = GLX_TRANSPARENT_TYPE;
817 config_attrs[i++] = GLX_NONE;//GLX_NONE;//GLX_TRANSPARENT_INDEX//GLX_TRANSPARENT_RGB;
818 config_attrs[i++] = 0;
820 configs = glXChooseFBConfig(einfo->info.display,
823 if ((!configs) || (num < 1))
825 ERR("glXChooseFBConfig returned no configs");
828 for (i = 0; i < num; i++)
830 XVisualInfo *visinfo;
831 XRenderPictFormat *format = NULL;
833 visinfo = glXGetVisualFromFBConfig(einfo->info.display,
835 if (!visinfo) continue;
839 _evas_gl_x11_vi = malloc(sizeof(XVisualInfo));
840 memcpy(_evas_gl_x11_vi, visinfo, sizeof(XVisualInfo));
847 format = XRenderFindVisualFormat
848 (einfo->info.display, visinfo->visual);
854 if (format->direct.alphaMask > 0)
857 _evas_gl_x11_rgba_vi = malloc(sizeof(XVisualInfo));
858 memcpy(_evas_gl_x11_rgba_vi, visinfo, sizeof(XVisualInfo));
859 rgba_fbconf = config;
869 if (!_evas_gl_x11_vi) return NULL;
870 if (einfo->info.destination_alpha)
873 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
874 if (_evas_gl_x11_rgba_vi) return _evas_gl_x11_rgba_vi->visual;
877 if (_evas_gl_x11_rgba_vi) return _evas_gl_x11_rgba_vi->visual;
881 return _evas_gl_x11_vi->visual;
885 eng_best_colormap_get(Evas_Engine_Info_GL_X11 *einfo)
887 if (!einfo) return 0;
888 if (!einfo->info.display) return 0;
889 if (!_evas_gl_x11_vi) eng_best_visual_get(einfo);
890 if (!_evas_gl_x11_vi) return 0;
891 if (einfo->info.destination_alpha)
893 if (!_evas_gl_x11_rgba_cmap)
894 _evas_gl_x11_rgba_cmap =
895 XCreateColormap(einfo->info.display,
896 RootWindow(einfo->info.display,
898 _evas_gl_x11_rgba_vi->visual,
900 return _evas_gl_x11_rgba_cmap;
902 if (!_evas_gl_x11_cmap)
904 XCreateColormap(einfo->info.display,
905 RootWindow(einfo->info.display,
907 _evas_gl_x11_vi->visual,
909 return _evas_gl_x11_cmap;
913 eng_best_depth_get(Evas_Engine_Info_GL_X11 *einfo)
915 if (!einfo) return 0;
916 if (!einfo->info.display) return 0;
917 if (!_evas_gl_x11_vi) eng_best_visual_get(einfo);
918 if (!_evas_gl_x11_vi) return 0;
919 if (einfo->info.destination_alpha)
921 if (_evas_gl_x11_rgba_vi) return _evas_gl_x11_rgba_vi->depth;
923 return _evas_gl_x11_vi->depth;