DPF OpenGL examples
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.

102 lines
2.8KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. // ------------------------------------------------------
  17. // DGL Stuff
  18. #include "StandaloneWindow.hpp"
  19. #include "widgets/ExampleColorWidget.hpp"
  20. #include "widgets/ExampleImagesWidget.hpp"
  21. #include "widgets/ExampleRectanglesWidget.hpp"
  22. #include "widgets/ExampleShapesWidget.hpp"
  23. #include "widgets/ExampleTextWidget.hpp"
  24. #include "widgets/NanoPerfWidget.hpp"
  25. // ------------------------------------------------------
  26. // Images
  27. #include "demo_res/DemoArtwork.cpp"
  28. #include "images_res/CatPics.cpp"
  29. // ------------------------------------------------------
  30. // Single Widget Window
  31. static int gWindowCount = 0;
  32. template<class WIG>
  33. class SingleWidgetWindow : public Window
  34. {
  35. public:
  36. SingleWidgetWindow(Application& app)
  37. : Window(app),
  38. fWidget(*this),
  39. fIsMain(true)
  40. {
  41. setSize(fWidget.getSize());
  42. setTitle("demo-multi");
  43. show();
  44. }
  45. SingleWidgetWindow(Application& app, Window& parent)
  46. : Window(app, parent),
  47. fWidget(*this),
  48. fIsMain(false)
  49. {
  50. setResizable(false);
  51. setSize(fWidget.getSize());
  52. setTitle(String("transient #") + String(++gWindowCount));
  53. show();
  54. }
  55. protected:
  56. void onReshape(uint width, uint height) override
  57. {
  58. fWidget.setSize(width, height);
  59. Window::onReshape(width, height);
  60. }
  61. void onClose() override
  62. {
  63. Window::onClose();
  64. if (fIsMain)
  65. getApp().quit();
  66. }
  67. private:
  68. WIG fWidget;
  69. bool fIsMain;
  70. };
  71. // ------------------------------------------------------
  72. // main entry point
  73. int main()
  74. {
  75. Application app;
  76. SingleWidgetWindow<ExampleColorWidget> wColor(app);
  77. SingleWidgetWindow<ExampleImagesWidget> wImages(app, wColor);
  78. SingleWidgetWindow<ExampleRectanglesWidget> wRects(app, wColor);
  79. SingleWidgetWindow<ExampleShapesWidget> wShapes(app, wColor);
  80. SingleWidgetWindow<ExampleTextWidget> wText(app, wColor);
  81. app.exec();
  82. return 0;
  83. }
  84. // ------------------------------------------------------