/* * YaGL * * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. * * Contact : * Stanislav Vorobiov * Jinhyung Jo * YeongKyoon Lee * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * Contributors: * - S-Core Co., Ltd * */ #include "yagl_native_platform.h" #ifdef YAGL_PLATFORM_X11 #include "x11/yagl_x11_platform.h" #endif #ifdef YAGL_PLATFORM_GBM #include "gbm/yagl_gbm_platform.h" #endif #ifdef YAGL_PLATFORM_WAYLAND #include "wayland/yagl_wayland_platform.h" #endif #ifdef YAGL_PLATFORM_TIZEN #include "tizen/yagl_tizen_platform.h" #endif #include "yagl_log.h" #include #include static struct { struct yagl_native_platform *platform; const char *name; } g_platforms[] = { #ifdef YAGL_PLATFORM_TIZEN {&yagl_tizen_platform, "wayland"}, #endif #ifdef YAGL_PLATFORM_WAYLAND {&yagl_wayland_platform, "wayland"}, #endif #ifdef YAGL_PLATFORM_GBM {&yagl_gbm_platform, "gbm"}, #endif #ifdef YAGL_PLATFORM_X11 {&yagl_x11_platform, "x11"}, #endif }; struct yagl_native_platform *yagl_guess_platform(yagl_os_display os_dpy) { const char *platform_name = NULL; uint32_t i; YAGL_LOG_FUNC_SET(yagl_guess_platform); platform_name = getenv("EGL_PLATFORM"); if (!platform_name || !platform_name[0]) { platform_name = getenv("EGL_DISPLAY"); } if (platform_name && platform_name[0]) { for (i = 0; i < sizeof(g_platforms)/sizeof(g_platforms[0]); ++i) { if (strcmp(g_platforms[i].name, platform_name) == 0) { YAGL_LOG_INFO("EGL platform %s chosen by environment variable", g_platforms[i].name); return g_platforms[i].platform; } } } for (i = 0; i < sizeof(g_platforms)/sizeof(g_platforms[0]); ++i) { if (g_platforms[i].platform->probe(os_dpy)) { YAGL_LOG_INFO("EGL platform %s chosen by probing", g_platforms[i].name); return g_platforms[i].platform; } } YAGL_LOG_ERROR("No EGL platform chosen"); return NULL; }