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.

137 lines
3.2KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2014 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 "ImageButton.hpp"
  19. #include "StandaloneWindow.hpp"
  20. #include "widgets/ExampleColorWidget.hpp"
  21. #include "widgets/ExampleImagesWidget.hpp"
  22. #include "widgets/ExampleRectanglesWidget.hpp"
  23. #include "widgets/ExampleShapesWidget.hpp"
  24. // ------------------------------------------------------
  25. // Images
  26. #include "images_res/CatPics.cpp"
  27. // ------------------------------------------------------
  28. // use namespace
  29. using DGL::App;
  30. using DGL::ImageButton;
  31. using DGL::Size;
  32. // ------------------------------------------------------
  33. // Our Demo Window
  34. class LeftSizeWidget : public Widget
  35. {
  36. public:
  37. LeftSizeWidget(Window& parent)
  38. : Widget(parent)
  39. {
  40. }
  41. protected:
  42. void onDisplay() override
  43. {
  44. glColor3f(0.302f/5, 0.337f/5, 0.361f/5);
  45. bg.draw();
  46. // reset color
  47. glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  48. }
  49. void onReshape(int, int) override
  50. {
  51. bg = getArea();
  52. }
  53. private:
  54. Rectangle<int> bg;
  55. };
  56. // ------------------------------------------------------
  57. // Our Demo Window
  58. class DemoWindow : public Window
  59. {
  60. public:
  61. DemoWindow(App& app)
  62. : Window(app),
  63. wColor(*this),
  64. wImages(*this),
  65. wRects(*this),
  66. wShapes(*this),
  67. wLeft(*this),
  68. b1(*this, Image()),
  69. b2(*this, Image())
  70. {
  71. wColor.hide();
  72. wImages.hide();
  73. wRects.hide();
  74. wShapes.hide();
  75. wColor.setX(100);
  76. wImages.setX(100);
  77. wRects.setX(100);
  78. wShapes.setX(100);
  79. setSize(600, 500);
  80. setTitle("DGL Demo");
  81. }
  82. void onReshape(int width, int height) override
  83. {
  84. Size<int> size(width-100, height);
  85. wColor.setSize(size);
  86. wImages.setSize(size);
  87. wRects.setSize(size);
  88. wShapes.setSize(size);
  89. wLeft.setSize(100, height);
  90. Window::onReshape(width, height);
  91. }
  92. private:
  93. ExampleColorWidget wColor;
  94. ExampleImagesWidget wImages;
  95. ExampleRectanglesWidget wRects;
  96. ExampleShapesWidget wShapes;
  97. LeftSizeWidget wLeft;
  98. ImageButton b1, b2;
  99. };
  100. // ------------------------------------------------------
  101. // main entry point
  102. int main()
  103. {
  104. App app;
  105. DemoWindow win(app);
  106. win.show();
  107. app.exec();
  108. return 0;
  109. }
  110. // ------------------------------------------------------