The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

89 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A base class that should be implemented by classes which want to render openGL
  23. on a background thread.
  24. @see OpenGLContext
  25. @tags{OpenGL}
  26. */
  27. class JUCE_API OpenGLRenderer
  28. {
  29. public:
  30. OpenGLRenderer() = default;
  31. virtual ~OpenGLRenderer() = default;
  32. /** Called when a new GL context has been created.
  33. You can use this as an opportunity to create your textures, shaders, etc.
  34. When the method is invoked, the new GL context will be active.
  35. Note that this callback will be made on a background thread, so make sure
  36. that your implementation is thread-safe.
  37. */
  38. virtual void newOpenGLContextCreated() = 0;
  39. /** Called when you should render the next openGL frame.
  40. Note that this callback will be made on a background thread.
  41. If the context is attached to a component in order to do component rendering,
  42. then the MessageManager will be locked when this callback is made.
  43. If no component rendering is being done, then the MessageManager will not be
  44. locked, and you'll need to make sure your code is thread-safe in any
  45. interactions it has with your GUI classes.
  46. For information about how to trigger a render callback, see
  47. OpenGLContext::triggerRepaint() and OpenGLContext::setContinuousRepainting().
  48. IMPORTANT: Never take a MessageManagerLock inside this function! On
  49. macOS, the OpenGL context will be locked for the duration of this call.
  50. The main thread may also attempt to interact with the OpenGL context at
  51. any time, which will also require locking the OpenGL context. As a
  52. result, taking a MessageManagerLock inside renderOpenGL() may cause a
  53. hierarchical deadlock.
  54. */
  55. virtual void renderOpenGL() = 0;
  56. /** Called when the current openGL context is about to close.
  57. You can use this opportunity to release any GL resources that you may have
  58. created.
  59. Note that this callback will be made on a background thread, so make sure
  60. that your implementation is thread-safe.
  61. (Also note that on Android, this callback won't happen, because there's currently
  62. no way to implement it..)
  63. */
  64. virtual void openGLContextClosing() = 0;
  65. };
  66. } // namespace juce