1848b8605Smrg/************************************************************************** 2848b8605Smrg * 3848b8605Smrg * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> 4848b8605Smrg * All Rights Reserved. 5848b8605Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the 8848b8605Smrg * "Software"), to deal in the Software without restriction, including 9848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish, 10848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to 11848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to 12848b8605Smrg * the following conditions: 13848b8605Smrg * 14848b8605Smrg * The above copyright notice and this permission notice (including the 15848b8605Smrg * next paragraph) shall be included in all copies or substantial portions 16848b8605Smrg * of the Software. 17848b8605Smrg * 18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19848b8605Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22848b8605Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23848b8605Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24848b8605Smrg * DEALINGS IN THE SOFTWARE. 25848b8605Smrg * 26848b8605Smrg **************************************************************************/ 27848b8605Smrg 28848b8605Smrg 29848b8605Smrg#ifndef EGLCURRENT_INCLUDED 30848b8605Smrg#define EGLCURRENT_INCLUDED 31848b8605Smrg 32b8e80941Smrg#include "c99_compat.h" 33848b8605Smrg 34848b8605Smrg#include "egltypedefs.h" 35848b8605Smrg 36848b8605Smrg 37b8e80941Smrg#ifdef __cplusplus 38b8e80941Smrgextern "C" { 39b8e80941Smrg#endif 40b8e80941Smrg 41848b8605Smrg#define _EGL_API_ALL_BITS \ 42848b8605Smrg (EGL_OPENGL_ES_BIT | \ 43848b8605Smrg EGL_OPENVG_BIT | \ 44848b8605Smrg EGL_OPENGL_ES2_BIT | \ 45848b8605Smrg EGL_OPENGL_ES3_BIT_KHR | \ 46848b8605Smrg EGL_OPENGL_BIT) 47848b8605Smrg 48848b8605Smrg 49848b8605Smrg/** 50848b8605Smrg * Per-thread info 51848b8605Smrg */ 52848b8605Smrgstruct _egl_thread_info 53848b8605Smrg{ 54848b8605Smrg EGLint LastError; 55b8e80941Smrg _EGLContext *CurrentContext; 56b8e80941Smrg EGLenum CurrentAPI; 57b8e80941Smrg EGLLabelKHR Label; 58b8e80941Smrg 59b8e80941Smrg /** 60b8e80941Smrg * The name of the EGL function that's being called at the moment. This is 61b8e80941Smrg * used to report the function name to the EGL_KHR_debug callback. 62b8e80941Smrg */ 63b8e80941Smrg const char *CurrentFuncName; 64b8e80941Smrg EGLLabelKHR CurrentObjectLabel; 65848b8605Smrg}; 66848b8605Smrg 67848b8605Smrg 68848b8605Smrg/** 69848b8605Smrg * Return true if a client API enum is recognized. 70848b8605Smrg */ 71b8e80941Smrgstatic inline EGLBoolean 72848b8605Smrg_eglIsApiValid(EGLenum api) 73848b8605Smrg{ 74b8e80941Smrg#ifdef ANDROID 75b8e80941Smrg /* OpenGL is not a valid/supported API on Android */ 76b8e80941Smrg return api == EGL_OPENGL_ES_API; 77b8e80941Smrg#else 78b8e80941Smrg return (api == EGL_OPENGL_ES_API || api == EGL_OPENGL_API); 79b8e80941Smrg#endif 80848b8605Smrg} 81848b8605Smrg 82848b8605Smrg 83b8e80941Smrgextern _EGLThreadInfo * 84848b8605Smrg_eglGetCurrentThread(void); 85848b8605Smrg 86848b8605Smrg 87848b8605Smrgextern void 88848b8605Smrg_eglDestroyCurrentThread(void); 89848b8605Smrg 90848b8605Smrg 91848b8605Smrgextern EGLBoolean 92848b8605Smrg_eglIsCurrentThreadDummy(void); 93848b8605Smrg 94848b8605Smrg 95b8e80941Smrgextern _EGLContext * 96848b8605Smrg_eglGetCurrentContext(void); 97848b8605Smrg 98848b8605Smrg 99b8e80941Smrgextern EGLBoolean 100848b8605Smrg_eglError(EGLint errCode, const char *msg); 101848b8605Smrg 102b8e80941Smrgextern void 103b8e80941Smrg_eglDebugReport(EGLenum error, const char *funcName, 104b8e80941Smrg EGLint type, const char *message, ...); 105b8e80941Smrg 106b8e80941Smrg#define _eglReportCritical(error, funcName, ...) \ 107b8e80941Smrg _eglDebugReport(error, funcName, EGL_DEBUG_MSG_CRITICAL_KHR, __VA_ARGS__) 108b8e80941Smrg 109b8e80941Smrg#define _eglReportError(error, funcName, ...) \ 110b8e80941Smrg _eglDebugReport(error, funcName, EGL_DEBUG_MSG_ERROR_KHR, __VA_ARGS__) 111b8e80941Smrg 112b8e80941Smrg#define _eglReportWarn(funcName, ...) \ 113b8e80941Smrg _eglDebugReport(EGL_SUCCESS, funcName, EGL_DEBUG_MSG_WARN_KHR, __VA_ARGS__) 114b8e80941Smrg 115b8e80941Smrg#define _eglReportInfo(funcName, ...) \ 116b8e80941Smrg _eglDebugReport(EGL_SUCCESS, funcName, EGL_DEBUG_MSG_INFO_KHR, __VA_ARGS__) 117b8e80941Smrg 118b8e80941Smrg#ifdef __cplusplus 119b8e80941Smrg} 120b8e80941Smrg#endif 121848b8605Smrg 122848b8605Smrg#endif /* EGLCURRENT_INCLUDED */ 123