Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

juce_Initialisation.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_INITIALISATION_H_INCLUDED
  18. #define JUCE_INITIALISATION_H_INCLUDED
  19. //==============================================================================
  20. /** Initialises Juce's GUI classes.
  21. If you're embedding Juce into an application that uses its own event-loop rather
  22. than using the START_JUCE_APPLICATION macro, call this function before making any
  23. Juce calls, to make sure things are initialised correctly.
  24. Note that if you're creating a Juce DLL for Windows, you may also need to call the
  25. Process::setCurrentModuleInstanceHandle() method.
  26. @see shutdownJuce_GUI()
  27. */
  28. JUCE_API void JUCE_CALLTYPE initialiseJuce_GUI();
  29. /** Clears up any static data being used by Juce's GUI classes.
  30. If you're embedding Juce into an application that uses its own event-loop rather
  31. than using the START_JUCE_APPLICATION macro, call this function in your shutdown
  32. code to clean up any juce objects that might be lying around.
  33. @see initialiseJuce_GUI()
  34. */
  35. JUCE_API void JUCE_CALLTYPE shutdownJuce_GUI();
  36. //==============================================================================
  37. /** A utility object that helps you initialise and shutdown Juce correctly
  38. using an RAII pattern.
  39. When an instance of this class is created, it calls initialiseJuce_GUI(),
  40. and when it's deleted, it calls shutdownJuce_GUI(), which lets you easily
  41. make sure that these functions are matched correctly.
  42. This class is particularly handy to use at the beginning of a console app's
  43. main() function, because it'll take care of shutting down whenever you return
  44. from the main() call.
  45. */
  46. class JUCE_API ScopedJuceInitialiser_GUI
  47. {
  48. public:
  49. /** The constructor simply calls initialiseJuce_GUI(). */
  50. ScopedJuceInitialiser_GUI();
  51. /** The destructor simply calls shutdownJuce_GUI(). */
  52. ~ScopedJuceInitialiser_GUI();
  53. };
  54. //==============================================================================
  55. /**
  56. To start a JUCE app, use this macro: START_JUCE_APPLICATION (AppSubClass) where
  57. AppSubClass is the name of a class derived from JUCEApplication or JUCEApplicationBase.
  58. See the JUCEApplication and JUCEApplicationBase class documentation for more details.
  59. */
  60. #ifdef DOXYGEN
  61. #define START_JUCE_APPLICATION(AppClass)
  62. #elif JUCE_ANDROID
  63. #define START_JUCE_APPLICATION(AppClass) \
  64. juce::JUCEApplicationBase* juce_CreateApplication() { return new AppClass(); }
  65. #else
  66. #if JUCE_WINDOWS
  67. #if defined (WINAPI) || defined (_WINDOWS_) || defined(JUCE_MINGW)
  68. #define JUCE_MAIN_FUNCTION int __stdcall WinMain (HINSTANCE, HINSTANCE, const LPSTR, int)
  69. #elif defined (_UNICODE)
  70. #define JUCE_MAIN_FUNCTION int __stdcall WinMain (void*, void*, const wchar_t*, int)
  71. #else
  72. #define JUCE_MAIN_FUNCTION int __stdcall WinMain (void*, void*, const char*, int)
  73. #endif
  74. #define JUCE_MAIN_FUNCTION_ARGS
  75. #else
  76. #define JUCE_MAIN_FUNCTION int main (int argc, char* argv[])
  77. #define JUCE_MAIN_FUNCTION_ARGS argc, (const char**) argv
  78. #endif
  79. #define START_JUCE_APPLICATION(AppClass) \
  80. static juce::JUCEApplicationBase* juce_CreateApplication() { return new AppClass(); } \
  81. extern "C" JUCE_MAIN_FUNCTION \
  82. { \
  83. juce::JUCEApplicationBase::createInstance = &juce_CreateApplication; \
  84. return juce::JUCEApplicationBase::main (JUCE_MAIN_FUNCTION_ARGS); \
  85. }
  86. #endif
  87. #endif // JUCE_INITIALISATION_H_INCLUDED