SDL_metal.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 Sam Lantinga <[email protected]>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_metal.h
  20. *
  21. * Header file for functions to creating Metal layers and views on SDL windows.
  22. */
  23. #ifndef SDL_metal_h_
  24. #define SDL_metal_h_
  25. #include "SDL_video.h"
  26. #include "begin_code.h"
  27. /* Set up for C function definitions, even when using C++ */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /**
  32. * \brief A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
  33. *
  34. * \note This can be cast directly to an NSView or UIView.
  35. */
  36. typedef void *SDL_MetalView;
  37. /**
  38. * \name Metal support functions
  39. */
  40. /* @{ */
  41. /**
  42. * \brief Create a CAMetalLayer-backed NSView/UIView and attach it to the
  43. * specified window.
  44. *
  45. * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on its
  46. * own. It is up to user code to do that.
  47. *
  48. * The returned handle can be casted directly to a NSView or UIView, and the
  49. * CAMetalLayer can be accessed from the view's 'layer' property.
  50. *
  51. * \code
  52. * SDL_MetalView metalview = SDL_Metal_CreateView(window);
  53. * UIView *uiview = (__bridge UIView *)metalview;
  54. * CAMetalLayer *metallayer = (CAMetalLayer *)uiview.layer;
  55. * // [...]
  56. * SDL_Metal_DestroyView(metalview);
  57. * \endcode
  58. *
  59. * \sa SDL_Metal_DestroyView
  60. */
  61. extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window);
  62. /**
  63. * \brief Destroy an existing SDL_MetalView object.
  64. *
  65. * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was
  66. * called after SDL_CreateWindow.
  67. *
  68. * \sa SDL_Metal_CreateView
  69. */
  70. extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view);
  71. /* @} *//* Metal support functions */
  72. /* Ends C function definitions when using C++ */
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #include "close_code.h"
  77. #endif /* SDL_metal_h_ */