1
0

EscapeTimeVisualWidget.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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(void);
  16. void draw(float x, float y, float w, float h,
  17. float tx = 0.0f, float ty = 0.0f,
  18. float tw = 1.0f, float th = 1.0f);
  19. };
  20. class EscapeTimeVisualWidget :
  21. public QOpenGLWidget
  22. {
  23. Q_OBJECT
  24. friend class ETVImage;
  25. protected:
  26. QOpenGLShaderProgram* program;
  27. QOpenGLShaderProgram* renderTextures;
  28. QOpenGLShaderProgram* juliaPreviewer;
  29. GLuint gradientTextureId;
  30. float gradientTextureMax;
  31. float maxIterations;
  32. Gradient gradient;
  33. bool gradientNeedsUpdate;
  34. float resolutionX;
  35. float resolutionY;
  36. GLuint tileFramebuffer;
  37. GLuint tileTexture;
  38. public:
  39. EscapeTimeVisualWidget(QWidget* parent = nullptr);
  40. void setGradient(Gradient newGradient);
  41. const Gradient& getGradient(void);
  42. virtual void initializeGL(void) override;
  43. virtual void resizeGL(int w, int h) override;
  44. virtual void paintGL(void) override;
  45. void drawJulia(float jx, float jy, QRectF area);
  46. void setMaxIterationCutoff(float maxIter);
  47. void setResolutionX(int w);
  48. void setResolutionY(int h);
  49. int getResolutionX(void) const;
  50. int getResolutionY(void) const;
  51. private:
  52. void updateGradient(void);
  53. };
  54. #endif // ESCAPETIMEVISUALWIDGET_H