SDL_metal.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. * Header file for functions to creating Metal layers and views on SDL
  22. * windows.
  23. */
  24. #ifndef SDL_metal_h_
  25. #define SDL_metal_h_
  26. #include "SDL_video.h"
  27. #include "begin_code.h"
  28. /* Set up for C function definitions, even when using C++ */
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /**
  33. * A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
  34. *
  35. * This can be cast directly to an NSView or UIView.
  36. */
  37. typedef void *SDL_MetalView;
  38. /**
  39. * \name Metal support functions
  40. */
  41. /* @{ */
  42. /**
  43. * Create a CAMetalLayer-backed NSView/UIView and attach it to the specified
  44. * window.
  45. *
  46. * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on
  47. * its own. It is up to user code to do that.
  48. *
  49. * The returned handle can be casted directly to a NSView or UIView. To access
  50. * the backing CAMetalLayer, call SDL_Metal_GetLayer().
  51. *
  52. * \since This function is available since SDL 2.0.12.
  53. *
  54. * \sa SDL_Metal_DestroyView
  55. * \sa SDL_Metal_GetLayer
  56. */
  57. extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window);
  58. /**
  59. * Destroy an existing SDL_MetalView object.
  60. *
  61. * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was
  62. * called after SDL_CreateWindow.
  63. *
  64. * \since This function is available since SDL 2.0.12.
  65. *
  66. * \sa SDL_Metal_CreateView
  67. */
  68. extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view);
  69. /**
  70. * Get a pointer to the backing CAMetalLayer for the given view.
  71. *
  72. * \since This function is available since SDL 2.0.14.
  73. *
  74. * \sa SDL_Metal_CreateView
  75. */
  76. extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view);
  77. /**
  78. * Get the size of a window's underlying drawable in pixels (for use with
  79. * setting viewport, scissor & etc).
  80. *
  81. * \param window SDL_Window from which the drawable size should be queried.
  82. * \param w Pointer to variable for storing the width in pixels, may be NULL.
  83. * \param h Pointer to variable for storing the height in pixels, may be NULL.
  84. *
  85. * \since This function is available since SDL 2.0.14.
  86. *
  87. * \sa SDL_GetWindowSize
  88. * \sa SDL_CreateWindow
  89. */
  90. extern DECLSPEC void SDLCALL SDL_Metal_GetDrawableSize(SDL_Window* window, int *w,
  91. int *h);
  92. /* @} *//* Metal support functions */
  93. /* Ends C function definitions when using C++ */
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #include "close_code.h"
  98. #endif /* SDL_metal_h_ */