eglplatform.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #ifndef __eglplatform_h_
  2. #define __eglplatform_h_
  3. /*
  4. ** Copyright 2007-2020 The Khronos Group Inc.
  5. ** SPDX-License-Identifier: Apache-2.0
  6. */
  7. /* Platform-specific types and definitions for egl.h
  8. *
  9. * Adopters may modify khrplatform.h and this file to suit their platform.
  10. * You are encouraged to submit all modifications to the Khronos group so that
  11. * they can be included in future versions of this file. Please submit changes
  12. * by filing an issue or pull request on the public Khronos EGL Registry, at
  13. * https://www.github.com/KhronosGroup/EGL-Registry/
  14. */
  15. #include <KHR/khrplatform.h>
  16. /* Macros used in EGL function prototype declarations.
  17. *
  18. * EGL functions should be prototyped as:
  19. *
  20. * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
  21. * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
  22. *
  23. * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
  24. */
  25. #ifndef EGLAPI
  26. #define EGLAPI KHRONOS_APICALL
  27. #endif
  28. #ifndef EGLAPIENTRY
  29. #define EGLAPIENTRY KHRONOS_APIENTRY
  30. #endif
  31. #define EGLAPIENTRYP EGLAPIENTRY*
  32. /* The types NativeDisplayType, NativeWindowType, and NativePixmapType
  33. * are aliases of window-system-dependent types, such as X Display * or
  34. * Windows Device Context. They must be defined in platform-specific
  35. * code below. The EGL-prefixed versions of Native*Type are the same
  36. * types, renamed in EGL 1.3 so all types in the API start with "EGL".
  37. *
  38. * Khronos STRONGLY RECOMMENDS that you use the default definitions
  39. * provided below, since these changes affect both binary and source
  40. * portability of applications using EGL running on different EGL
  41. * implementations.
  42. */
  43. /*
  44. * NVIDIA change: We've been using WIN_INTERFACE_CUSTOM for this for years, and
  45. * Khronos recently adopted the equivalent EGL_NO_PLATFORM_SPECIFIC_TYPES. For
  46. * compatibility with existing NVIDIA makefile logic, accept either.
  47. */
  48. #if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES) || defined(WIN_INTERFACE_CUSTOM)
  49. typedef void *EGLNativeDisplayType;
  50. typedef void *EGLNativePixmapType;
  51. typedef void *EGLNativeWindowType;
  52. #elif defined(KDWIN)
  53. typedef void *EGLNativeDisplayType;
  54. typedef void *EGLNativePixmapType;
  55. typedef struct KDWindow *EGLNativeWindowType;
  56. #elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
  57. #ifndef WIN32_LEAN_AND_MEAN
  58. #define WIN32_LEAN_AND_MEAN 1
  59. #endif
  60. #include <windows.h>
  61. typedef HDC EGLNativeDisplayType;
  62. typedef HBITMAP EGLNativePixmapType;
  63. typedef HWND EGLNativeWindowType;
  64. #elif defined(__EMSCRIPTEN__)
  65. typedef int EGLNativeDisplayType;
  66. typedef int EGLNativePixmapType;
  67. typedef int EGLNativeWindowType;
  68. #elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
  69. typedef int EGLNativeDisplayType;
  70. typedef void *EGLNativePixmapType;
  71. typedef void *EGLNativeWindowType;
  72. #elif defined(WL_EGL_PLATFORM)
  73. typedef struct wl_display *EGLNativeDisplayType;
  74. typedef struct wl_egl_pixmap *EGLNativePixmapType;
  75. typedef struct wl_egl_window *EGLNativeWindowType;
  76. #elif defined(__GBM__)
  77. typedef struct gbm_device *EGLNativeDisplayType;
  78. typedef struct gbm_bo *EGLNativePixmapType;
  79. typedef void *EGLNativeWindowType;
  80. #elif defined(__ANDROID__) || defined(ANDROID)
  81. struct ANativeWindow;
  82. struct egl_native_pixmap_t;
  83. typedef void* EGLNativeDisplayType;
  84. typedef struct egl_native_pixmap_t* EGLNativePixmapType;
  85. typedef struct ANativeWindow* EGLNativeWindowType;
  86. #elif defined(USE_OZONE)
  87. typedef intptr_t EGLNativeDisplayType;
  88. typedef intptr_t EGLNativePixmapType;
  89. typedef intptr_t EGLNativeWindowType;
  90. #elif defined(__unix__) && defined(EGL_NO_X11)
  91. typedef void *EGLNativeDisplayType;
  92. typedef khronos_uintptr_t EGLNativePixmapType;
  93. typedef khronos_uintptr_t EGLNativeWindowType;
  94. #elif defined(WAYLAND)
  95. #include <wayland-client.h>
  96. typedef struct wl_display *EGLNativeDisplayType;
  97. typedef void *EGLNativePixmapType;
  98. typedef struct wl_egl_window *EGLNativeWindowType;
  99. #elif defined(__unix__) || defined(USE_X11)
  100. /* X11 (tentative) */
  101. #include <X11/Xlib.h>
  102. #include <X11/Xutil.h>
  103. typedef Display *EGLNativeDisplayType;
  104. typedef Pixmap EGLNativePixmapType;
  105. typedef Window EGLNativeWindowType;
  106. #elif defined(__APPLE__)
  107. typedef int EGLNativeDisplayType;
  108. typedef void *EGLNativePixmapType;
  109. typedef void *EGLNativeWindowType;
  110. #elif defined(__HAIKU__)
  111. #include <kernel/image.h>
  112. typedef void *EGLNativeDisplayType;
  113. typedef khronos_uintptr_t EGLNativePixmapType;
  114. typedef khronos_uintptr_t EGLNativeWindowType;
  115. #elif defined(__Fuchsia__)
  116. typedef void *EGLNativeDisplayType;
  117. typedef khronos_uintptr_t EGLNativePixmapType;
  118. typedef khronos_uintptr_t EGLNativeWindowType;
  119. #else
  120. #error "Platform not recognized"
  121. #endif
  122. /* EGL 1.2 types, renamed for consistency in EGL 1.3 */
  123. typedef EGLNativeDisplayType NativeDisplayType;
  124. typedef EGLNativePixmapType NativePixmapType;
  125. typedef EGLNativeWindowType NativeWindowType;
  126. /* Define EGLint. This must be a signed integral type large enough to contain
  127. * all legal attribute names and values passed into and out of EGL, whether
  128. * their type is boolean, bitmask, enumerant (symbolic constant), integer,
  129. * handle, or other. While in general a 32-bit integer will suffice, if
  130. * handles are 64 bit types, then EGLint should be defined as a signed 64-bit
  131. * integer type.
  132. */
  133. typedef khronos_int32_t EGLint;
  134. /* C++ / C typecast macros for special EGL handle values */
  135. #if defined(__cplusplus)
  136. #define EGL_CAST(type, value) (static_cast<type>(value))
  137. #else
  138. #define EGL_CAST(type, value) ((type) (value))
  139. #endif
  140. #endif /* __eglplatform_h */