1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-04 16:01:14 -05:00
sdrangel/sdrgui/gui/glshaderspectrogram.h

134 lines
5.0 KiB
C
Raw Normal View History

2022-06-18 07:35:44 -04:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB. //
// Copyright (C) 2022 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_GUI_GLSHADERSPECTROGRAM_H_
#define INCLUDE_GUI_GLSHADERSPECTROGRAM_H_
#include <QString>
#include <QOpenGLTexture>
#include <QOpenGLFunctions>
#include "export.h"
#include "dsp/spectrumsettings.h"
class QOpenGLShaderProgram;
class QMatrix4x4;
class QImage;
class SDRGUI_API GLShaderSpectrogram : protected QOpenGLFunctions
{
public:
GLShaderSpectrogram();
~GLShaderSpectrogram();
2022-06-18 19:11:46 -04:00
void initializeGL(int majorVersion, int minorVersion);
2022-06-18 07:35:44 -04:00
void initColorMapTexture(const QString &colorMapName);
void initTexture(const QImage& image);
void subTexture(int xOffset, int yOffset, int width, int height, const void *pixels);
2022-06-18 08:07:10 -04:00
void drawSurface(SpectrumSettings::SpectrogramStyle style, const QMatrix4x4& vertexTransform, float textureOffset, bool invert);
2022-06-18 07:35:44 -04:00
void cleanup();
void translateX(float distance);
void translateY(float distance);
void translateZ(float distance);
void rotateX(float degrees);
void rotateY(float degrees);
void rotateZ(float degrees);
void setScaleX(float factor);
void setScaleY(float factor);
void setScaleZ(float factor);
void userScaleZ(float factor);
void reset();
void setAspectRatio(float aspectRatio);
void verticalAngle(float degrees);
void lightTranslateX(float distance);
void lightTranslateY(float distance);
void lightTranslateZ(float distance);
void lightRotateX(float degrees);
void lightRotateY(float degrees);
void lightRotateZ(float degrees);
2022-06-18 08:07:10 -04:00
void applyTransform(QMatrix4x4 &matrix);
2022-06-18 07:35:44 -04:00
void applyPerspective(QMatrix4x4 &matrix);
private:
void initColorMapTextureMutable(const QString &colorMapName);
void initColorMapTextureImmutable(const QString &colorMapName);
void initTextureImmutable(const QImage& image);
void subTextureImmutable(int xOffset, int yOffset, int width, int height, const void *pixels);
void initTextureMutable(const QImage& image);
void subTextureMutable(int xOffset, int yOffset, int width, int height, const void *pixels);
bool useImmutableStorage();
void initGrid(int elements);
void setPerspective();
QOpenGLShaderProgram *m_programShaded;
QOpenGLShaderProgram *m_programSimple;
QOpenGLTexture *m_texture;
unsigned int m_textureId;
QOpenGLTexture *m_colorMapTexture;
unsigned int m_colorMapTextureId;
float m_limit;
2022-06-18 07:35:44 -04:00
QOpenGLShaderProgram *m_programForLocs; // Which program the locations are for
2022-06-19 06:22:46 -04:00
int m_coord2dLoc;
2022-06-18 07:35:44 -04:00
int m_textureTransformLoc;
int m_vertexTransformLoc;
int m_dataTextureLoc;
2022-06-18 07:35:44 -04:00
int m_limitLoc;
int m_brightnessLoc;
int m_colorMapLoc;
int m_lightDirLoc;
int m_lightPosLoc;
bool m_useImmutableStorage;
static const QString m_vertexShader2;
2022-06-18 07:35:44 -04:00
static const QString m_vertexShader;
static const QString m_geometryShader;
static const QString m_fragmentShaderShaded;
static const QString m_fragmentShaderSimple2;
2022-06-18 07:35:44 -04:00
static const QString m_fragmentShaderSimple;
2022-06-19 06:22:46 -04:00
QOpenGLVertexArrayObject *m_vao;
QOpenGLBuffer *m_vertexBuf;
QOpenGLBuffer *m_index0Buf;
QOpenGLBuffer *m_index1Buf;
2022-06-18 07:35:44 -04:00
float m_translateX;
float m_translateY;
float m_translateZ;
float m_rotX;
float m_rotY;
float m_rotZ;
float m_scaleX;
float m_scaleY;
float m_scaleZ;
float m_userScaleZ;
float m_verticalAngle;
float m_aspectRatio;
float m_lightTranslateX;
float m_lightTranslateY;
float m_lightTranslateZ;
float m_lightRotX;
float m_lightRotY;
float m_lightRotZ;
QMatrix4x4 m_perspective;
int m_gridElements;
};
#endif /* INCLUDE_GUI_GLSHADERSPECTROGRAM_H_ */