Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 1 | #ifndef __eglplatform_h_ |
| 2 | #define __eglplatform_h_ |
| 3 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 4 | /* |
Eric Engestrom | a98b3a0 | 2017-01-24 18:07:05 +0000 | [diff] [blame] | 5 | ** Copyright (c) 2007-2016 The Khronos Group Inc. |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 6 | ** |
| 7 | ** Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | ** copy of this software and/or associated documentation files (the |
| 9 | ** "Materials"), to deal in the Materials without restriction, including |
| 10 | ** without limitation the rights to use, copy, modify, merge, publish, |
| 11 | ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 12 | ** permit persons to whom the Materials are furnished to do so, subject to |
| 13 | ** the following conditions: |
| 14 | ** |
| 15 | ** The above copyright notice and this permission notice shall be included |
| 16 | ** in all copies or substantial portions of the Materials. |
| 17 | ** |
| 18 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 21 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 22 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 23 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 24 | ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 25 | */ |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 26 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 27 | /* Platform-specific types and definitions for egl.h |
Marek Olšák | 20249d3 | 2015-05-15 19:59:59 +0200 | [diff] [blame] | 28 | * $Revision: 30994 $ on $Date: 2015-04-30 13:36:48 -0700 (Thu, 30 Apr 2015) $ |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 29 | * |
| 30 | * Adopters may modify khrplatform.h and this file to suit their platform. |
| 31 | * You are encouraged to submit all modifications to the Khronos group so that |
| 32 | * they can be included in future versions of this file. Please submit changes |
| 33 | * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) |
| 34 | * by filing a bug against product "EGL" component "Registry". |
| 35 | */ |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 36 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 37 | #include <KHR/khrplatform.h> |
Chia-I Wu | 897cb89 | 2010-01-05 21:39:15 +0800 | [diff] [blame] | 38 | |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 39 | /* Macros used in EGL function prototype declarations. |
| 40 | * |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 41 | * EGL functions should be prototyped as: |
| 42 | * |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 43 | * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); |
| 44 | * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); |
| 45 | * |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 46 | * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 47 | */ |
| 48 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 49 | #ifndef EGLAPI |
| 50 | #define EGLAPI KHRONOS_APICALL |
| 51 | #endif |
| 52 | |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 53 | #ifndef EGLAPIENTRY |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 54 | #define EGLAPIENTRY KHRONOS_APIENTRY |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 55 | #endif |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 56 | #define EGLAPIENTRYP EGLAPIENTRY* |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 57 | |
| 58 | /* The types NativeDisplayType, NativeWindowType, and NativePixmapType |
| 59 | * are aliases of window-system-dependent types, such as X Display * or |
| 60 | * Windows Device Context. They must be defined in platform-specific |
| 61 | * code below. The EGL-prefixed versions of Native*Type are the same |
| 62 | * types, renamed in EGL 1.3 so all types in the API start with "EGL". |
Chia-I Wu | b7acfe7 | 2011-12-15 15:20:01 +0800 | [diff] [blame] | 63 | * |
| 64 | * Khronos STRONGLY RECOMMENDS that you use the default definitions |
| 65 | * provided below, since these changes affect both binary and source |
| 66 | * portability of applications using EGL running on different EGL |
| 67 | * implementations. |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 68 | */ |
| 69 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 70 | #if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ |
| 71 | #ifndef WIN32_LEAN_AND_MEAN |
| 72 | #define WIN32_LEAN_AND_MEAN 1 |
Jonathan White | adaf038 | 2008-06-06 15:13:59 -0600 | [diff] [blame] | 73 | #endif |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 74 | #include <windows.h> |
Jonathan White | 240962f | 2008-08-05 19:20:43 -0600 | [diff] [blame] | 75 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 76 | typedef HDC EGLNativeDisplayType; |
| 77 | typedef HBITMAP EGLNativePixmapType; |
| 78 | typedef HWND EGLNativeWindowType; |
Jonathan White | b515841 | 2008-08-05 08:12:38 -0600 | [diff] [blame] | 79 | |
Julien Isorce | 7d64244 | 2015-07-02 23:10:38 +0100 | [diff] [blame] | 80 | #elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ |
Jonathan White | fe1a2d1 | 2008-06-05 15:07:03 -0600 | [diff] [blame] | 81 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 82 | typedef int EGLNativeDisplayType; |
| 83 | typedef void *EGLNativeWindowType; |
| 84 | typedef void *EGLNativePixmapType; |
Brian Paul | 18bdb6e | 2009-09-08 09:20:39 -0600 | [diff] [blame] | 85 | |
Kristian Høgsberg | 04c5cc5 | 2011-02-09 10:18:07 -0500 | [diff] [blame] | 86 | #elif defined(WL_EGL_PLATFORM) |
| 87 | |
Kristian Høgsberg | c0f8c99 | 2011-04-14 10:42:41 -0400 | [diff] [blame] | 88 | typedef struct wl_display *EGLNativeDisplayType; |
Kristian Høgsberg | 04c5cc5 | 2011-02-09 10:18:07 -0500 | [diff] [blame] | 89 | typedef struct wl_egl_pixmap *EGLNativePixmapType; |
| 90 | typedef struct wl_egl_window *EGLNativeWindowType; |
| 91 | |
Benjamin Franzke | eddcecb | 2011-05-26 15:09:39 +0200 | [diff] [blame] | 92 | #elif defined(__GBM__) |
| 93 | |
| 94 | typedef struct gbm_device *EGLNativeDisplayType; |
| 95 | typedef struct gbm_bo *EGLNativePixmapType; |
| 96 | typedef void *EGLNativeWindowType; |
| 97 | |
Marek Olšák | 20249d3 | 2015-05-15 19:59:59 +0200 | [diff] [blame] | 98 | #elif defined(__ANDROID__) || defined(ANDROID) |
Chia-I Wu | b0945c1 | 2010-10-11 16:09:52 +0800 | [diff] [blame] | 99 | |
Marek Olšák | 20249d3 | 2015-05-15 19:59:59 +0200 | [diff] [blame] | 100 | #include <android/native_window.h> |
| 101 | |
Chia-I Wu | b0945c1 | 2010-10-11 16:09:52 +0800 | [diff] [blame] | 102 | struct egl_native_pixmap_t; |
| 103 | |
Marek Olšák | 20249d3 | 2015-05-15 19:59:59 +0200 | [diff] [blame] | 104 | typedef struct ANativeWindow* EGLNativeWindowType; |
| 105 | typedef struct egl_native_pixmap_t* EGLNativePixmapType; |
| 106 | typedef void* EGLNativeDisplayType; |
Chia-I Wu | b0945c1 | 2010-10-11 16:09:52 +0800 | [diff] [blame] | 107 | |
Julien Isorce | 7d64244 | 2015-07-02 23:10:38 +0100 | [diff] [blame] | 108 | #elif defined(__unix__) || defined(__APPLE__) |
Jonathan White | fe1a2d1 | 2008-06-05 15:07:03 -0600 | [diff] [blame] | 109 | |
Alexander von Gluck IV | 400b833 | 2014-12-22 10:10:13 -0500 | [diff] [blame] | 110 | #if defined(MESA_EGL_NO_X11_HEADERS) |
Chia-I Wu | 985c2fc | 2010-06-19 00:21:39 +0800 | [diff] [blame] | 111 | |
| 112 | typedef void *EGLNativeDisplayType; |
Ross Burton | 2c61863 | 2013-06-27 12:35:08 +0100 | [diff] [blame] | 113 | typedef khronos_uintptr_t EGLNativePixmapType; |
| 114 | typedef khronos_uintptr_t EGLNativeWindowType; |
Chia-I Wu | 985c2fc | 2010-06-19 00:21:39 +0800 | [diff] [blame] | 115 | |
| 116 | #else |
| 117 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 118 | /* X11 (tentative) */ |
Brian Paul | 57da567 | 2008-05-27 13:43:34 -0600 | [diff] [blame] | 119 | #include <X11/Xlib.h> |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 120 | #include <X11/Xutil.h> |
Brian Paul | 57da567 | 2008-05-27 13:43:34 -0600 | [diff] [blame] | 121 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 122 | typedef Display *EGLNativeDisplayType; |
| 123 | typedef Pixmap EGLNativePixmapType; |
| 124 | typedef Window EGLNativeWindowType; |
| 125 | |
Chia-I Wu | 985c2fc | 2010-06-19 00:21:39 +0800 | [diff] [blame] | 126 | #endif /* MESA_EGL_NO_X11_HEADERS */ |
| 127 | |
Alexander von Gluck IV | 400b833 | 2014-12-22 10:10:13 -0500 | [diff] [blame] | 128 | #elif __HAIKU__ |
| 129 | #include <kernel/image.h> |
| 130 | typedef void *EGLNativeDisplayType; |
| 131 | typedef khronos_uintptr_t EGLNativePixmapType; |
| 132 | typedef khronos_uintptr_t EGLNativeWindowType; |
| 133 | |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 134 | #else |
| 135 | #error "Platform not recognized" |
Jonathan White | fe1a2d1 | 2008-06-05 15:07:03 -0600 | [diff] [blame] | 136 | #endif |
| 137 | |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 138 | /* EGL 1.2 types, renamed for consistency in EGL 1.3 */ |
Chia-I Wu | 95f8f75 | 2009-08-15 22:57:47 +0800 | [diff] [blame] | 139 | typedef EGLNativeDisplayType NativeDisplayType; |
| 140 | typedef EGLNativePixmapType NativePixmapType; |
| 141 | typedef EGLNativeWindowType NativeWindowType; |
| 142 | |
| 143 | |
| 144 | /* Define EGLint. This must be a signed integral type large enough to contain |
| 145 | * all legal attribute names and values passed into and out of EGL, whether |
| 146 | * their type is boolean, bitmask, enumerant (symbolic constant), integer, |
| 147 | * handle, or other. While in general a 32-bit integer will suffice, if |
| 148 | * handles are 64 bit types, then EGLint should be defined as a signed 64-bit |
| 149 | * integer type. |
| 150 | */ |
| 151 | typedef khronos_int32_t EGLint; |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 152 | |
Eric Engestrom | a98b3a0 | 2017-01-24 18:07:05 +0000 | [diff] [blame] | 153 | |
| 154 | /* C++ / C typecast macros for special EGL handle values */ |
| 155 | #if defined(__cplusplus) |
| 156 | #define EGL_CAST(type, value) (static_cast<type>(value)) |
| 157 | #else |
| 158 | #define EGL_CAST(type, value) ((type) (value)) |
| 159 | #endif |
| 160 | |
Brian Paul | 704a5c7 | 2008-05-27 13:43:01 -0600 | [diff] [blame] | 161 | #endif /* __eglplatform_h */ |