1
0

EscapeTimeVisualWidget.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef ESCAPETIMEVISUALWIDGET_H
  2. #define ESCAPETIMEVISUALWIDGET_H
  3. #include <QOpenGLWidget>
  4. #include "Bitmap.h"
  5. #include "Gradient.h"
  6. class QOpenGLShaderProgram;
  7. class EscapeTimeVisualWidget;
  8. class ETVImage
  9. {
  10. GLuint textureId;
  11. EscapeTimeVisualWidget& owner;
  12. public:
  13. ETVImage(EscapeTimeVisualWidget& owner,
  14. const Bitmap<float>& img);
  15. ETVImage(EscapeTimeVisualWidget& owner,
  16. QOpenGLContext* context,
  17. const Bitmap<float>& img);
  18. ~ETVImage(void);
  19. void draw(float x, float y, float w, float h,
  20. float tx = 0.0f, float ty = 0.0f,
  21. float tw = 1.0f, float th = 1.0f);
  22. };
  23. class EscapeTimeVisualWidget :
  24. public QOpenGLWidget
  25. {
  26. Q_OBJECT
  27. friend class ETVImage;
  28. protected:
  29. QOpenGLShaderProgram* program;
  30. QOpenGLShaderProgram* renderTextures;
  31. QOpenGLShaderProgram* juliaPreviewer;
  32. GLuint gradientTextureId;
  33. float gradientTextureMax;
  34. float maxIterations;
  35. Gradient gradient;
  36. bool gradientNeedsUpdate;
  37. float resolutionX;
  38. float resolutionY;
  39. GLuint tileFramebuffer;
  40. GLuint tileTexture;
  41. public:
  42. EscapeTimeVisualWidget(QWidget* parent = nullptr);
  43. void setGradient(Gradient newGradient);
  44. const Gradient& getGradient(void);
  45. virtual void initializeGL(void) override;
  46. virtual void resizeGL(int w, int h) override;
  47. virtual void paintGL(void) override;
  48. void drawJulia(float jx, float jy, QRectF area, bool drawSmooth);
  49. void setMaxIterationCutoff(float maxIter);
  50. void setResolutionX(int w);
  51. void setResolutionY(int h);
  52. int getResolutionX(void) const;
  53. int getResolutionY(void) const;
  54. private:
  55. void updateGradient(void);
  56. };
  57. #endif // ESCAPETIMEVISUALWIDGET_H