SDL_metal.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2021 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. * \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. * Create a CAMetalLayer-backed NSView/UIView and attach it to the specified
  43. * window.
  44. *
  45. * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on
  46. * its own. It is up to user code to do that.
  47. *
  48. * The returned handle can be casted directly to a NSView or UIView. To access
  49. * the backing CAMetalLayer, call SDL_Metal_GetLayer().
  50. *
  51. * \sa SDL_Metal_DestroyView
  52. * \sa SDL_Metal_GetLayer
  53. */
  54. extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window);
  55. /**
  56. * Destroy an existing SDL_MetalView object.
  57. *
  58. * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was
  59. * called after SDL_CreateWindow.
  60. *
  61. * \sa SDL_Metal_CreateView
  62. */
  63. extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view);
  64. /**
  65. * Get a pointer to the backing CAMetalLayer for the given view.
  66. *
  67. * \sa SDL_MetalCreateView
  68. */
  69. extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view);
  70. /**
  71. * Get the size of a window's underlying drawable in pixels (for use with
  72. * setting viewport, scissor & etc).
  73. *
  74. * \param window SDL_Window from which the drawable size should be queried
  75. * \param w Pointer to variable for storing the width in pixels, may be NULL
  76. *
  77. * \sa SDL_GetWindowSize
  78. * \sa SDL_CreateWindow
  79. */
  80. extern DECLSPEC void SDLCALL SDL_Metal_GetDrawableSize(SDL_Window* window, int *w,
  81. int *h);
  82. /* @} *//* Metal support functions */
  83. /* Ends C function definitions when using C++ */
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #include "close_code.h"
  88. #endif /* SDL_metal_h_ */