| 1 |
/************************************************************************** |
| 2 |
* |
| 3 |
* Copyright 2009-2010 Chia-I Wu <[email protected]> |
| 4 |
* All Rights Reserved. |
| 5 |
* |
| 6 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 7 |
* copy of this software and associated documentation files (the |
| 8 |
* "Software"), to deal in the Software without restriction, including |
| 9 |
* without limitation the rights to use, copy, modify, merge, publish, |
| 10 |
* distribute, sub license, and/or sell copies of the Software, and to |
| 11 |
* permit persons to whom the Software is furnished to do so, subject to |
| 12 |
* the following conditions: |
| 13 |
* |
| 14 |
* The above copyright notice and this permission notice (including the |
| 15 |
* next paragraph) shall be included in all copies or substantial portions |
| 16 |
* of the Software. |
| 17 |
* |
| 18 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 21 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 23 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 24 |
* DEALINGS IN THE SOFTWARE. |
| 25 |
* |
| 26 |
**************************************************************************/ |
| 27 |
|
| 28 |
#ifndef EGLCURRENT_INCLUDED |
| 29 |
#define EGLCURRENT_INCLUDED |
| 30 |
|
| 31 |
#include <stdbool.h> |
| 32 |
|
| 33 |
#include "util/detect_os.h" |
| 34 |
|
| 35 |
#include "egltypedefs.h" |
| 36 |
|
| 37 |
#ifdef __cplusplus |
| 38 |
extern "C" { |
| 39 |
#endif |
| 40 |
|
| 41 |
#define _EGL_API_ALL_BITS \ |
| 42 |
(EGL_OPENGL_ES_BIT | EGL_OPENVG_BIT | EGL_OPENGL_ES2_BIT | \ |
| 43 |
EGL_OPENGL_ES3_BIT_KHR | EGL_OPENGL_BIT) |
| 44 |
|
| 45 |
/** |
| 46 |
* Per-thread info |
| 47 |
*/ |
| 48 |
struct _egl_thread_info { |
| 49 |
bool inited; |
| 50 |
EGLint LastError; |
| 51 |
_EGLContext *CurrentContext; |
| 52 |
EGLenum CurrentAPI; |
| 53 |
EGLLabelKHR Label; |
| 54 |
|
| 55 |
/** |
| 56 |
* The name of the EGL function that's being called at the moment. This is |
| 57 |
* used to report the function name to the EGL_KHR_debug callback. |
| 58 |
*/ |
| 59 |
const char *CurrentFuncName; |
| 60 |
EGLLabelKHR CurrentObjectLabel; |
| 61 |
}; |
| 62 |
|
| 63 |
/** |
| 64 |
* Return true if a client API enum is recognized. |
| 65 |
*/ |
| 66 |
static inline EGLBoolean |
| 67 |
_eglIsApiValid(EGLenum api) |
| 68 |
{ |
| 69 |
#if HAVE_OPENGL && !DETECT_OS_ANDROID |
| 70 |
/* OpenGL is not a valid/supported API on Android */ |
| 71 |
if (api == EGL_OPENGL_API) |
| 72 |
return true; |
| 73 |
#endif |
| 74 |
#if HAVE_OPENGL_ES_1 || HAVE_OPENGL_ES_2 |
| 75 |
if (api == EGL_OPENGL_ES_API) |
| 76 |
return true; |
| 77 |
#endif |
| 78 |
return false; |
| 79 |
} |
| 80 |
|
| 81 |
extern _EGLThreadInfo * |
| 82 |
_eglGetCurrentThread(void); |
| 83 |
|
| 84 |
extern void |
| 85 |
_eglDestroyCurrentThread(void); |
| 86 |
|
| 87 |
extern _EGLContext * |
| 88 |
_eglGetCurrentContext(void); |
| 89 |
|
| 90 |
extern EGLBoolean |
| 91 |
_eglError(EGLint errCode, const char *msg); |
| 92 |
|
| 93 |
extern void |
| 94 |
_eglDebugReport(EGLenum error, const char *funcName, EGLint type, |
| 95 |
const char *message, ...); |
| 96 |
|
| 97 |
#ifdef __cplusplus |
| 98 |
} |
| 99 |
#endif |
| 100 |
|
| 101 |
#endif /* EGLCURRENT_INCLUDED */ |