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.

81 lines
2.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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_OPENGLAPPCOMPONENT_H_INCLUDED
  18. #define JUCE_OPENGLAPPCOMPONENT_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A base class for writing simple one-page graphical apps.
  22. A subclass can inherit from this and implement just a few methods such as
  23. paint() and mouse-handling. The base class provides some simple abstractions
  24. to take care of continuously repainting itself.
  25. */
  26. class OpenGLAppComponent : public Component,
  27. private OpenGLRenderer
  28. {
  29. public:
  30. OpenGLAppComponent();
  31. ~OpenGLAppComponent();
  32. /** Returns the number of times that the render method has been called since
  33. the component started running.
  34. */
  35. int getFrameCounter() const noexcept { return frameCounter; }
  36. void shutdownOpenGL();
  37. /** Implement this method to set up any GL objects that you need for rendering.
  38. The GL context will be active when this method is called.
  39. */
  40. virtual void initialise() = 0;
  41. /** Implement this method to free any GL objects that you created during rendering.
  42. The GL context will still be active when this method is called.
  43. */
  44. virtual void shutdown() = 0;
  45. /**
  46. */
  47. virtual void render() = 0;
  48. OpenGLContext openGLContext;
  49. private:
  50. //==============================================================================
  51. int frameCounter;
  52. void newOpenGLContextCreated() override;
  53. void renderOpenGL() override;
  54. void openGLContextClosing() override;
  55. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLAppComponent)
  56. };
  57. #endif // JUCE_OPENGLAPPCOMPONENT_H_INCLUDED