blob: f045d009c03d53bbe6f125f276f36e14aa3f4536 [file] [log] [blame]
Brian Paul704a5c72008-05-27 13:43:01 -06001#ifndef __eglplatform_h_
2#define __eglplatform_h_
3
Chia-I Wu95f8f752009-08-15 22:57:47 +08004/*
Eric Engestroma98b3a02017-01-24 18:07:05 +00005** Copyright (c) 2007-2016 The Khronos Group Inc.
Chia-I Wu95f8f752009-08-15 22:57:47 +08006**
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 Paul704a5c72008-05-27 13:43:01 -060026
Chia-I Wu95f8f752009-08-15 22:57:47 +080027/* Platform-specific types and definitions for egl.h
Marek Olšák20249d32015-05-15 19:59:59 +020028 * $Revision: 30994 $ on $Date: 2015-04-30 13:36:48 -0700 (Thu, 30 Apr 2015) $
Chia-I Wu95f8f752009-08-15 22:57:47 +080029 *
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 Paul704a5c72008-05-27 13:43:01 -060036
Chia-I Wu95f8f752009-08-15 22:57:47 +080037#include <KHR/khrplatform.h>
Chia-I Wu897cb892010-01-05 21:39:15 +080038
Brian Paul704a5c72008-05-27 13:43:01 -060039/* Macros used in EGL function prototype declarations.
40 *
Chia-I Wu95f8f752009-08-15 22:57:47 +080041 * EGL functions should be prototyped as:
42 *
Brian Paul704a5c72008-05-27 13:43:01 -060043 * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
44 * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
45 *
Chia-I Wu95f8f752009-08-15 22:57:47 +080046 * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
Brian Paul704a5c72008-05-27 13:43:01 -060047 */
48
Chia-I Wu95f8f752009-08-15 22:57:47 +080049#ifndef EGLAPI
50#define EGLAPI KHRONOS_APICALL
51#endif
52
Brian Paul704a5c72008-05-27 13:43:01 -060053#ifndef EGLAPIENTRY
Chia-I Wu95f8f752009-08-15 22:57:47 +080054#define EGLAPIENTRY KHRONOS_APIENTRY
Brian Paul704a5c72008-05-27 13:43:01 -060055#endif
Chia-I Wu95f8f752009-08-15 22:57:47 +080056#define EGLAPIENTRYP EGLAPIENTRY*
Brian Paul704a5c72008-05-27 13:43:01 -060057
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 Wub7acfe72011-12-15 15:20:01 +080063 *
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 Paul704a5c72008-05-27 13:43:01 -060068 */
69
Chia-I Wu95f8f752009-08-15 22:57:47 +080070#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 Whiteadaf0382008-06-06 15:13:59 -060073#endif
Chia-I Wu95f8f752009-08-15 22:57:47 +080074#include <windows.h>
Jonathan White240962f2008-08-05 19:20:43 -060075
Chia-I Wu95f8f752009-08-15 22:57:47 +080076typedef HDC EGLNativeDisplayType;
77typedef HBITMAP EGLNativePixmapType;
78typedef HWND EGLNativeWindowType;
Jonathan Whiteb5158412008-08-05 08:12:38 -060079
Julien Isorce7d642442015-07-02 23:10:38 +010080#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
Jonathan Whitefe1a2d12008-06-05 15:07:03 -060081
Chia-I Wu95f8f752009-08-15 22:57:47 +080082typedef int EGLNativeDisplayType;
83typedef void *EGLNativeWindowType;
84typedef void *EGLNativePixmapType;
Brian Paul18bdb6e2009-09-08 09:20:39 -060085
Kristian Høgsberg04c5cc52011-02-09 10:18:07 -050086#elif defined(WL_EGL_PLATFORM)
87
Kristian Høgsbergc0f8c992011-04-14 10:42:41 -040088typedef struct wl_display *EGLNativeDisplayType;
Kristian Høgsberg04c5cc52011-02-09 10:18:07 -050089typedef struct wl_egl_pixmap *EGLNativePixmapType;
90typedef struct wl_egl_window *EGLNativeWindowType;
91
Benjamin Franzkeeddcecb2011-05-26 15:09:39 +020092#elif defined(__GBM__)
93
94typedef struct gbm_device *EGLNativeDisplayType;
95typedef struct gbm_bo *EGLNativePixmapType;
96typedef void *EGLNativeWindowType;
97
Marek Olšák20249d32015-05-15 19:59:59 +020098#elif defined(__ANDROID__) || defined(ANDROID)
Chia-I Wub0945c12010-10-11 16:09:52 +080099
Marek Olšák20249d32015-05-15 19:59:59 +0200100#include <android/native_window.h>
101
Chia-I Wub0945c12010-10-11 16:09:52 +0800102struct egl_native_pixmap_t;
103
Marek Olšák20249d32015-05-15 19:59:59 +0200104typedef struct ANativeWindow* EGLNativeWindowType;
105typedef struct egl_native_pixmap_t* EGLNativePixmapType;
106typedef void* EGLNativeDisplayType;
Chia-I Wub0945c12010-10-11 16:09:52 +0800107
Julien Isorce7d642442015-07-02 23:10:38 +0100108#elif defined(__unix__) || defined(__APPLE__)
Jonathan Whitefe1a2d12008-06-05 15:07:03 -0600109
Alexander von Gluck IV400b8332014-12-22 10:10:13 -0500110#if defined(MESA_EGL_NO_X11_HEADERS)
Chia-I Wu985c2fc2010-06-19 00:21:39 +0800111
112typedef void *EGLNativeDisplayType;
Ross Burton2c618632013-06-27 12:35:08 +0100113typedef khronos_uintptr_t EGLNativePixmapType;
114typedef khronos_uintptr_t EGLNativeWindowType;
Chia-I Wu985c2fc2010-06-19 00:21:39 +0800115
116#else
117
Chia-I Wu95f8f752009-08-15 22:57:47 +0800118/* X11 (tentative) */
Brian Paul57da5672008-05-27 13:43:34 -0600119#include <X11/Xlib.h>
Chia-I Wu95f8f752009-08-15 22:57:47 +0800120#include <X11/Xutil.h>
Brian Paul57da5672008-05-27 13:43:34 -0600121
Chia-I Wu95f8f752009-08-15 22:57:47 +0800122typedef Display *EGLNativeDisplayType;
123typedef Pixmap EGLNativePixmapType;
124typedef Window EGLNativeWindowType;
125
Chia-I Wu985c2fc2010-06-19 00:21:39 +0800126#endif /* MESA_EGL_NO_X11_HEADERS */
127
Alexander von Gluck IV400b8332014-12-22 10:10:13 -0500128#elif __HAIKU__
129#include <kernel/image.h>
130typedef void *EGLNativeDisplayType;
131typedef khronos_uintptr_t EGLNativePixmapType;
132typedef khronos_uintptr_t EGLNativeWindowType;
133
Chia-I Wu95f8f752009-08-15 22:57:47 +0800134#else
135#error "Platform not recognized"
Jonathan Whitefe1a2d12008-06-05 15:07:03 -0600136#endif
137
Brian Paul704a5c72008-05-27 13:43:01 -0600138/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
Chia-I Wu95f8f752009-08-15 22:57:47 +0800139typedef EGLNativeDisplayType NativeDisplayType;
140typedef EGLNativePixmapType NativePixmapType;
141typedef 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 */
151typedef khronos_int32_t EGLint;
Brian Paul704a5c72008-05-27 13:43:01 -0600152
Eric Engestroma98b3a02017-01-24 18:07:05 +0000153
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 Paul704a5c72008-05-27 13:43:01 -0600161#endif /* __eglplatform_h */