aboutsummaryrefslogtreecommitdiff
path: root/libs/preview_dds_native/src/ddswidget.h
blob: 968e253eb9bf11b0186152d03e74912751a99795 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef DDSWIDGET_H
#define DDSWIDGET_H

#include "ddsfile.h"

#include <QOpenGLBuffer>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QOpenGLWidget>

class DDSWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
  Q_OBJECT

public:
  explicit DDSWidget(const DDSFile& dds, QWidget* parent = nullptr);
  ~DDSWidget() override;

protected:
  void initializeGL() override;
  void resizeGL(int w, int h) override;
  void paintGL() override;

private:
  void uploadTexture();
  void setupShaders();

  const DDSFile& m_dds;
  QOpenGLTexture* m_texture      = nullptr;
  QOpenGLShaderProgram* m_shader = nullptr;
  QOpenGLBuffer m_vbo;
  float m_aspectRatio = 1.0f;
};

#endif  // DDSWIDGET_H