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.

78 lines
2.6KB

  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_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. /** Implement this method to set up any GL objects that you need for rendering.
  37. The GL context will be active when this method is called.
  38. */
  39. virtual void initialise() = 0;
  40. /** Implement this method to free any GL objects that you created during rendering.
  41. The GL context will still be active when this method is called.
  42. */
  43. virtual void shutdown() = 0;
  44. /**
  45. */
  46. virtual void render() = 0;
  47. private:
  48. //==============================================================================
  49. OpenGLContext openGLContext;
  50. int frameCounter;
  51. void newOpenGLContextCreated() override;
  52. void renderOpenGL() override;
  53. void openGLContextClosing() override;
  54. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLAppComponent)
  55. };
  56. #endif // JUCE_OPENGLAPPCOMPONENT_H_INCLUDED