SDL_metal.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
  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. * # CategoryMetal
  20. *
  21. * Functions to creating Metal layers and views on SDL windows.
  22. *
  23. * This provides some platform-specific glue for Apple platforms. Most macOS
  24. * and iOS apps can use SDL without these functions, but this API they can be
  25. * useful for specific OS-level integration tasks.
  26. */
  27. #ifndef SDL_metal_h_
  28. #define SDL_metal_h_
  29. #include <SDL3/SDL_video.h>
  30. #include <SDL3/SDL_begin_code.h>
  31. /* Set up for C function definitions, even when using C++ */
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /**
  36. * A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
  37. *
  38. * \since This datatype is available since SDL 3.1.3.
  39. */
  40. typedef void *SDL_MetalView;
  41. /**
  42. * \name Metal support functions
  43. */
  44. /* @{ */
  45. /**
  46. * Create a CAMetalLayer-backed NSView/UIView and attach it to the specified
  47. * window.
  48. *
  49. * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on
  50. * its own. It is up to user code to do that.
  51. *
  52. * The returned handle can be casted directly to a NSView or UIView. To access
  53. * the backing CAMetalLayer, call SDL_Metal_GetLayer().
  54. *
  55. * \param window the window.
  56. * \returns handle NSView or UIView.
  57. *
  58. * \since This function is available since SDL 3.1.3.
  59. *
  60. * \sa SDL_Metal_DestroyView
  61. * \sa SDL_Metal_GetLayer
  62. */
  63. extern SDL_DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window *window);
  64. /**
  65. * Destroy an existing SDL_MetalView object.
  66. *
  67. * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was
  68. * called after SDL_CreateWindow.
  69. *
  70. * \param view the SDL_MetalView object.
  71. *
  72. * \since This function is available since SDL 3.1.3.
  73. *
  74. * \sa SDL_Metal_CreateView
  75. */
  76. extern SDL_DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view);
  77. /**
  78. * Get a pointer to the backing CAMetalLayer for the given view.
  79. *
  80. * \param view the SDL_MetalView object.
  81. * \returns a pointer.
  82. *
  83. * \since This function is available since SDL 3.1.3.
  84. */
  85. extern SDL_DECLSPEC void * SDLCALL SDL_Metal_GetLayer(SDL_MetalView view);
  86. /* @} *//* Metal support functions */
  87. /* Ends C function definitions when using C++ */
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #include <SDL3/SDL_close_code.h>
  92. #endif /* SDL_metal_h_ */