dispatch_egl.c revision e52adb7b
1e52adb7bSmrg/* 2e52adb7bSmrg * Copyright © 2013 Intel Corporation 3e52adb7bSmrg * 4e52adb7bSmrg * Permission is hereby granted, free of charge, to any person obtaining a 5e52adb7bSmrg * copy of this software and associated documentation files (the "Software"), 6e52adb7bSmrg * to deal in the Software without restriction, including without limitation 7e52adb7bSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8e52adb7bSmrg * and/or sell copies of the Software, and to permit persons to whom the 9e52adb7bSmrg * Software is furnished to do so, subject to the following conditions: 10e52adb7bSmrg * 11e52adb7bSmrg * The above copyright notice and this permission notice (including the next 12e52adb7bSmrg * paragraph) shall be included in all copies or substantial portions of the 13e52adb7bSmrg * Software. 14e52adb7bSmrg * 15e52adb7bSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16e52adb7bSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17e52adb7bSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18e52adb7bSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19e52adb7bSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20e52adb7bSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21e52adb7bSmrg * IN THE SOFTWARE. 22e52adb7bSmrg */ 23e52adb7bSmrg 24e52adb7bSmrg#include <assert.h> 25e52adb7bSmrg#include <string.h> 26e52adb7bSmrg#include <stdio.h> 27e52adb7bSmrg 28e52adb7bSmrg#include "dispatch_common.h" 29e52adb7bSmrg 30e52adb7bSmrgint 31e52adb7bSmrgepoxy_conservative_egl_version(void) 32e52adb7bSmrg{ 33e52adb7bSmrg EGLDisplay dpy = eglGetCurrentDisplay(); 34e52adb7bSmrg 35e52adb7bSmrg if (!dpy) 36e52adb7bSmrg return 14; 37e52adb7bSmrg 38e52adb7bSmrg return epoxy_egl_version(dpy); 39e52adb7bSmrg} 40e52adb7bSmrg 41e52adb7bSmrgPUBLIC int 42e52adb7bSmrgepoxy_egl_version(EGLDisplay dpy) 43e52adb7bSmrg{ 44e52adb7bSmrg int major, minor; 45e52adb7bSmrg const char *version_string; 46e52adb7bSmrg int ret; 47e52adb7bSmrg 48e52adb7bSmrg version_string = eglQueryString(dpy, EGL_VERSION); 49e52adb7bSmrg ret = sscanf(version_string, "%d.%d", &major, &minor); 50e52adb7bSmrg assert(ret == 2); 51e52adb7bSmrg return major * 10 + minor; 52e52adb7bSmrg} 53e52adb7bSmrg 54e52adb7bSmrgbool 55e52adb7bSmrgepoxy_conservative_has_egl_extension(const char *ext) 56e52adb7bSmrg{ 57e52adb7bSmrg EGLDisplay dpy = eglGetCurrentDisplay(); 58e52adb7bSmrg 59e52adb7bSmrg if (!dpy) 60e52adb7bSmrg return true; 61e52adb7bSmrg 62e52adb7bSmrg return epoxy_has_egl_extension(dpy, ext); 63e52adb7bSmrg} 64e52adb7bSmrg 65e52adb7bSmrgPUBLIC bool 66e52adb7bSmrgepoxy_has_egl_extension(EGLDisplay dpy, const char *ext) 67e52adb7bSmrg{ 68e52adb7bSmrg return epoxy_extension_in_string(eglQueryString(dpy, EGL_EXTENSIONS), ext); 69e52adb7bSmrg} 70