The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | #ifndef __eglplatform_h_ |
| 2 | #define __eglplatform_h_ |
| 3 | |
| 4 | /* |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 5 | ** Copyright 2007-2020 The Khronos Group Inc. |
| 6 | ** SPDX-License-Identifier: Apache-2.0 |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | /* Platform-specific types and definitions for egl.h |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 10 | * |
| 11 | * Adopters may modify khrplatform.h and this file to suit their platform. |
| 12 | * You are encouraged to submit all modifications to the Khronos group so that |
| 13 | * they can be included in future versions of this file. Please submit changes |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 14 | * by filing an issue or pull request on the public Khronos EGL Registry, at |
| 15 | * https://www.github.com/KhronosGroup/EGL-Registry/ |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <KHR/khrplatform.h> |
| 19 | |
| 20 | /* Macros used in EGL function prototype declarations. |
| 21 | * |
| 22 | * EGL functions should be prototyped as: |
| 23 | * |
| 24 | * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); |
| 25 | * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); |
| 26 | * |
| 27 | * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h |
| 28 | */ |
| 29 | |
| 30 | #ifndef EGLAPI |
| 31 | #define EGLAPI KHRONOS_APICALL |
| 32 | #endif |
| 33 | |
Mathias Agopian | e81a3cb | 2010-06-09 18:46:35 -0700 | [diff] [blame] | 34 | #ifndef EGLAPIENTRY |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | #define EGLAPIENTRY KHRONOS_APIENTRY |
Mathias Agopian | e81a3cb | 2010-06-09 18:46:35 -0700 | [diff] [blame] | 36 | #endif |
| 37 | #define EGLAPIENTRYP EGLAPIENTRY* |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
| 39 | /* The types NativeDisplayType, NativeWindowType, and NativePixmapType |
| 40 | * are aliases of window-system-dependent types, such as X Display * or |
| 41 | * Windows Device Context. They must be defined in platform-specific |
| 42 | * code below. The EGL-prefixed versions of Native*Type are the same |
| 43 | * types, renamed in EGL 1.3 so all types in the API start with "EGL". |
Mathias Agopian | 12af3f6 | 2013-03-27 14:55:03 -0700 | [diff] [blame] | 44 | * |
| 45 | * Khronos STRONGLY RECOMMENDS that you use the default definitions |
| 46 | * provided below, since these changes affect both binary and source |
| 47 | * portability of applications using EGL running on different EGL |
| 48 | * implementations. |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | */ |
| 50 | |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 51 | #if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES) |
| 52 | |
| 53 | typedef void *EGLNativeDisplayType; |
| 54 | typedef void *EGLNativePixmapType; |
| 55 | typedef void *EGLNativeWindowType; |
| 56 | |
| 57 | #elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | #ifndef WIN32_LEAN_AND_MEAN |
| 59 | #define WIN32_LEAN_AND_MEAN 1 |
| 60 | #endif |
| 61 | #include <windows.h> |
| 62 | |
| 63 | typedef HDC EGLNativeDisplayType; |
| 64 | typedef HBITMAP EGLNativePixmapType; |
| 65 | typedef HWND EGLNativeWindowType; |
| 66 | |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 67 | #elif defined(__QNX__) |
| 68 | |
| 69 | typedef khronos_uintptr_t EGLNativeDisplayType; |
| 70 | typedef struct _screen_pixmap* EGLNativePixmapType; /* screen_pixmap_t */ |
| 71 | typedef struct _screen_window* EGLNativeWindowType; /* screen_window_t */ |
| 72 | |
| 73 | #elif defined(__EMSCRIPTEN__) |
| 74 | |
| 75 | typedef int EGLNativeDisplayType; |
| 76 | typedef int EGLNativePixmapType; |
| 77 | typedef int EGLNativeWindowType; |
| 78 | |
Courtney Goeltzenleuchter | edf87c1 | 2018-07-18 09:32:50 -0600 | [diff] [blame] | 79 | #elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | |
| 81 | typedef int EGLNativeDisplayType; |
Priyanka Advani (xWF) | d28f4fe | 2024-07-29 23:38:45 +0000 | [diff] [blame] | 82 | typedef void *EGLNativePixmapType; |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 83 | typedef void *EGLNativeWindowType; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | |
Courtney Goeltzenleuchter | edf87c1 | 2018-07-18 09:32:50 -0600 | [diff] [blame] | 85 | #elif defined(WL_EGL_PLATFORM) |
| 86 | |
| 87 | typedef struct wl_display *EGLNativeDisplayType; |
| 88 | typedef struct wl_egl_pixmap *EGLNativePixmapType; |
| 89 | typedef struct wl_egl_window *EGLNativeWindowType; |
| 90 | |
| 91 | #elif defined(__GBM__) |
| 92 | |
| 93 | typedef struct gbm_device *EGLNativeDisplayType; |
| 94 | typedef struct gbm_bo *EGLNativePixmapType; |
| 95 | typedef void *EGLNativeWindowType; |
| 96 | |
David 'Digit' Turner | dfd0759 | 2010-11-05 12:41:51 +0100 | [diff] [blame] | 97 | #elif defined(__ANDROID__) || defined(ANDROID) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | |
Mathias Agopian | b0e76f4 | 2012-03-23 14:15:44 -0700 | [diff] [blame] | 99 | struct ANativeWindow; |
Mathias Agopian | 7189c00 | 2009-05-05 18:11:11 -0700 | [diff] [blame] | 100 | struct egl_native_pixmap_t; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 101 | |
Priyanka Advani (xWF) | d28f4fe | 2024-07-29 23:38:45 +0000 | [diff] [blame] | 102 | typedef void* EGLNativeDisplayType; |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 103 | typedef struct egl_native_pixmap_t* EGLNativePixmapType; |
| 104 | typedef struct ANativeWindow* EGLNativeWindowType; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | |
Courtney Goeltzenleuchter | edf87c1 | 2018-07-18 09:32:50 -0600 | [diff] [blame] | 106 | #elif defined(USE_OZONE) |
| 107 | |
| 108 | typedef intptr_t EGLNativeDisplayType; |
Priyanka Advani (xWF) | d28f4fe | 2024-07-29 23:38:45 +0000 | [diff] [blame] | 109 | typedef intptr_t EGLNativePixmapType; |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 110 | typedef intptr_t EGLNativeWindowType; |
Courtney Goeltzenleuchter | edf87c1 | 2018-07-18 09:32:50 -0600 | [diff] [blame] | 111 | |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 112 | #elif defined(USE_X11) |
David 'Digit' Turner | dfd0759 | 2010-11-05 12:41:51 +0100 | [diff] [blame] | 113 | |
| 114 | /* X11 (tentative) */ |
| 115 | #include <X11/Xlib.h> |
| 116 | #include <X11/Xutil.h> |
| 117 | |
| 118 | typedef Display *EGLNativeDisplayType; |
| 119 | typedef Pixmap EGLNativePixmapType; |
| 120 | typedef Window EGLNativeWindowType; |
| 121 | |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 122 | #elif defined(__unix__) |
| 123 | |
| 124 | typedef void *EGLNativeDisplayType; |
| 125 | typedef khronos_uintptr_t EGLNativePixmapType; |
| 126 | typedef khronos_uintptr_t EGLNativeWindowType; |
| 127 | |
Courtney Goeltzenleuchter | edf87c1 | 2018-07-18 09:32:50 -0600 | [diff] [blame] | 128 | #elif defined(__APPLE__) |
| 129 | |
| 130 | typedef int EGLNativeDisplayType; |
Priyanka Advani (xWF) | d28f4fe | 2024-07-29 23:38:45 +0000 | [diff] [blame] | 131 | typedef void *EGLNativePixmapType; |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 132 | typedef void *EGLNativeWindowType; |
Courtney Goeltzenleuchter | edf87c1 | 2018-07-18 09:32:50 -0600 | [diff] [blame] | 133 | |
| 134 | #elif defined(__HAIKU__) |
| 135 | |
| 136 | #include <kernel/image.h> |
| 137 | |
| 138 | typedef void *EGLNativeDisplayType; |
| 139 | typedef khronos_uintptr_t EGLNativePixmapType; |
| 140 | typedef khronos_uintptr_t EGLNativeWindowType; |
| 141 | |
Tom Murphy | 790b461 | 2024-07-22 12:11:52 +0000 | [diff] [blame] | 142 | #elif defined(__Fuchsia__) |
| 143 | |
| 144 | typedef void *EGLNativeDisplayType; |
| 145 | typedef khronos_uintptr_t EGLNativePixmapType; |
| 146 | typedef khronos_uintptr_t EGLNativeWindowType; |
| 147 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 148 | #else |
| 149 | #error "Platform not recognized" |
| 150 | #endif |
| 151 | |
| 152 | /* EGL 1.2 types, renamed for consistency in EGL 1.3 */ |
| 153 | typedef EGLNativeDisplayType NativeDisplayType; |
| 154 | typedef EGLNativePixmapType NativePixmapType; |
| 155 | typedef EGLNativeWindowType NativeWindowType; |
| 156 | |
| 157 | |
| 158 | /* Define EGLint. This must be a signed integral type large enough to contain |
| 159 | * all legal attribute names and values passed into and out of EGL, whether |
| 160 | * their type is boolean, bitmask, enumerant (symbolic constant), integer, |
| 161 | * handle, or other. While in general a 32-bit integer will suffice, if |
| 162 | * handles are 64 bit types, then EGLint should be defined as a signed 64-bit |
| 163 | * integer type. |
| 164 | */ |
| 165 | typedef khronos_int32_t EGLint; |
| 166 | |
Ian Elliott | e7be42b | 2017-07-06 13:02:32 -0600 | [diff] [blame] | 167 | |
| 168 | /* C++ / C typecast macros for special EGL handle values */ |
Colin Cross | 0c7cc2e | 2016-11-03 17:36:46 -0700 | [diff] [blame] | 169 | #if defined(__cplusplus) |
| 170 | #define EGL_CAST(type, value) (static_cast<type>(value)) |
| 171 | #else |
| 172 | #define EGL_CAST(type, value) ((type) (value)) |
| 173 | #endif |
| 174 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | #endif /* __eglplatform_h */ |