mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-29 21:42:26 -04:00
Simply matrix calcs. Fix for clang
This commit is contained in:
parent
d441e6d475
commit
c135affb6a
@ -310,7 +310,7 @@ void GLShaderSpectrogram::subTextureMutable(int xOffset, int yOffset, int width,
|
|||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, xOffset, yOffset, width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, xOffset, yOffset, width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLShaderSpectrogram::drawSurface(SpectrumSettings::SpectrogramStyle style, float textureOffset, bool invert)
|
void GLShaderSpectrogram::drawSurface(SpectrumSettings::SpectrogramStyle style, const QMatrix4x4& vertexTransform, float textureOffset, bool invert)
|
||||||
{
|
{
|
||||||
if ((m_useImmutableStorage && !m_texture) || (!m_useImmutableStorage && !m_textureId))
|
if ((m_useImmutableStorage && !m_texture) || (!m_useImmutableStorage && !m_textureId))
|
||||||
{
|
{
|
||||||
@ -325,17 +325,6 @@ void GLShaderSpectrogram::drawSurface(SpectrumSettings::SpectrogramStyle style,
|
|||||||
program = m_programSimple;
|
program = m_programSimple;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that translation to the origin and rotation
|
|
||||||
// needs to be performed in reverse order to what you
|
|
||||||
// might normally expect
|
|
||||||
// See: https://bugreports.qt.io/browse/QTBUG-20752
|
|
||||||
|
|
||||||
QMatrix4x4 vertexTransform;
|
|
||||||
vertexTransform.translate(0.0f, 0.0f, -1.65f);
|
|
||||||
applyScaleRotate(vertexTransform);
|
|
||||||
vertexTransform.translate(-0.5f, -0.5f, 0.0f);
|
|
||||||
applyPerspective(vertexTransform);
|
|
||||||
|
|
||||||
float rot = invert ? 1.0 : -1.0;
|
float rot = invert ? 1.0 : -1.0;
|
||||||
QMatrix4x4 textureTransform(
|
QMatrix4x4 textureTransform(
|
||||||
1.0, 0.0, 0.0, 0.0,
|
1.0, 0.0, 0.0, 0.0,
|
||||||
@ -652,14 +641,20 @@ void GLShaderSpectrogram::lightRotateZ(float degrees)
|
|||||||
m_lightRotZ += degrees;
|
m_lightRotZ += degrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLShaderSpectrogram::applyScaleRotate(QMatrix4x4 &matrix)
|
void GLShaderSpectrogram::applyTransform(QMatrix4x4 &matrix)
|
||||||
{
|
{
|
||||||
// As above, this is in reverse
|
// Note that translation to the origin and rotation
|
||||||
matrix.translate(m_translateX, m_translateY, m_translateZ);
|
// needs to be performed in reverse order to what you
|
||||||
matrix.rotate(m_rotX, 1.0f, 0.0f, 0.0f);
|
// might normally expect
|
||||||
|
// See: https://bugreports.qt.io/browse/QTBUG-20752
|
||||||
|
matrix.translate(0.0f, 0.0f, -1.65f); // Camera position
|
||||||
|
matrix.translate(m_translateX, m_translateY, m_translateZ); // User camera position adjustment
|
||||||
|
matrix.rotate(m_rotX, 1.0f, 0.0f, 0.0f); // User rotation
|
||||||
matrix.rotate(m_rotY, 0.0f, 1.0f, 0.0f);
|
matrix.rotate(m_rotY, 0.0f, 1.0f, 0.0f);
|
||||||
matrix.rotate(m_rotZ, 0.0f, 0.0f, 1.0f);
|
matrix.rotate(m_rotZ, 0.0f, 0.0f, 1.0f);
|
||||||
matrix.scale(m_scaleX, m_scaleY, m_scaleZ * m_userScaleZ);
|
matrix.scale(m_scaleX, m_scaleY, m_scaleZ * m_userScaleZ); // Scaling
|
||||||
|
matrix.translate(-0.5f, -0.5f, 0.0f); // Centre at origin for correct rotation
|
||||||
|
applyPerspective(matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLShaderSpectrogram::applyPerspective(QMatrix4x4 &matrix)
|
void GLShaderSpectrogram::applyPerspective(QMatrix4x4 &matrix)
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
void initColorMapTexture(const QString &colorMapName);
|
void initColorMapTexture(const QString &colorMapName);
|
||||||
void initTexture(const QImage& image);
|
void initTexture(const QImage& image);
|
||||||
void subTexture(int xOffset, int yOffset, int width, int height, const void *pixels);
|
void subTexture(int xOffset, int yOffset, int width, int height, const void *pixels);
|
||||||
void drawSurface(SpectrumSettings::SpectrogramStyle style, float textureOffset, bool invert);
|
void drawSurface(SpectrumSettings::SpectrogramStyle style, const QMatrix4x4& vertexTransform, float textureOffset, bool invert);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void translateX(float distance);
|
void translateX(float distance);
|
||||||
void translateY(float distance);
|
void translateY(float distance);
|
||||||
@ -61,7 +61,7 @@ public:
|
|||||||
void lightRotateX(float degrees);
|
void lightRotateX(float degrees);
|
||||||
void lightRotateY(float degrees);
|
void lightRotateY(float degrees);
|
||||||
void lightRotateZ(float degrees);
|
void lightRotateZ(float degrees);
|
||||||
void applyScaleRotate(QMatrix4x4 &matrix);
|
void applyTransform(QMatrix4x4 &matrix);
|
||||||
void applyPerspective(QMatrix4x4 &matrix);
|
void applyPerspective(QMatrix4x4 &matrix);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -872,13 +872,10 @@ void GLSpectrum::paintGL()
|
|||||||
glFunctions->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glFunctions->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
QMatrix4x4 spectrogramGridMatrix;
|
QMatrix4x4 spectrogramGridMatrix;
|
||||||
spectrogramGridMatrix.translate(0.0f, 0.0f, -1.65f);
|
|
||||||
m_glShaderSpectrogram.applyScaleRotate(spectrogramGridMatrix);
|
|
||||||
spectrogramGridMatrix.translate(-0.5f, -0.5f, 0.0f);
|
|
||||||
m_glShaderSpectrogram.applyPerspective(spectrogramGridMatrix);
|
|
||||||
|
|
||||||
if (m_display3DSpectrogram)
|
if (m_display3DSpectrogram)
|
||||||
{
|
{
|
||||||
|
m_glShaderSpectrogram.applyTransform(spectrogramGridMatrix);
|
||||||
// paint 3D spectrogram
|
// paint 3D spectrogram
|
||||||
if (m_3DSpectrogramTexturePos + m_3DSpectrogramBufferPos < m_3DSpectrogramTextureHeight)
|
if (m_3DSpectrogramTexturePos + m_3DSpectrogramBufferPos < m_3DSpectrogramTextureHeight)
|
||||||
{
|
{
|
||||||
@ -900,7 +897,7 @@ void GLSpectrum::paintGL()
|
|||||||
|
|
||||||
// Temporarily reduce viewport to waterfall area so anything outside is clipped
|
// Temporarily reduce viewport to waterfall area so anything outside is clipped
|
||||||
glFunctions->glViewport(0, m_3DSpectrogramBottom, width(), m_waterfallHeight);
|
glFunctions->glViewport(0, m_3DSpectrogramBottom, width(), m_waterfallHeight);
|
||||||
m_glShaderSpectrogram.drawSurface(m_3DSpectrogramStyle, prop_y, m_invertedWaterfall);
|
m_glShaderSpectrogram.drawSurface(m_3DSpectrogramStyle, spectrogramGridMatrix, prop_y, m_invertedWaterfall);
|
||||||
glFunctions->glViewport(0, 0, width(), height());
|
glFunctions->glViewport(0, 0, width(), height());
|
||||||
}
|
}
|
||||||
else if (m_displayWaterfall)
|
else if (m_displayWaterfall)
|
||||||
@ -1168,15 +1165,15 @@ void GLSpectrum::paintGL()
|
|||||||
{
|
{
|
||||||
glFunctions->glViewport(0, m_3DSpectrogramBottom, width(), m_waterfallHeight);
|
glFunctions->glViewport(0, m_3DSpectrogramBottom, width(), m_waterfallHeight);
|
||||||
{
|
{
|
||||||
float l = m_spectrogramTimePixmap.width() / (float) width();
|
GLfloat l = m_spectrogramTimePixmap.width() / (GLfloat) width();
|
||||||
float r = m_rightMargin / (float) width();
|
GLfloat r = m_rightMargin / (GLfloat) width();
|
||||||
float h = m_frequencyPixmap.height() / (float) m_waterfallHeight;
|
GLfloat h = m_frequencyPixmap.height() / (GLfloat) m_waterfallHeight;
|
||||||
|
|
||||||
GLfloat vtx1[] = {
|
GLfloat vtx1[] = {
|
||||||
-l, -h,
|
-l, -h,
|
||||||
1+r, -h,
|
1.0f+r, -h,
|
||||||
1+r, 0,
|
1.0f+r, 0.0f,
|
||||||
-l, 0
|
-l, 0.0f
|
||||||
};
|
};
|
||||||
GLfloat tex1[] = {
|
GLfloat tex1[] = {
|
||||||
0, 1,
|
0, 1,
|
||||||
@ -1189,14 +1186,14 @@ void GLSpectrum::paintGL()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
float w = m_spectrogramTimePixmap.width() / (float) width();
|
GLfloat w = m_spectrogramTimePixmap.width() / (GLfloat) width();
|
||||||
float h = (m_bottomMargin/2) / (float) m_waterfallHeight; // m_bottomMargin is fm.ascent
|
GLfloat h = (m_bottomMargin/2) / (GLfloat) m_waterfallHeight; // m_bottomMargin is fm.ascent
|
||||||
|
|
||||||
GLfloat vtx1[] = {
|
GLfloat vtx1[] = {
|
||||||
-w, 0.0-h,
|
-w, 0.0f-h,
|
||||||
0, 0.0-h,
|
0.0f, 0.0f-h,
|
||||||
0, 1.0+h,
|
0.0f, 1.0f+h,
|
||||||
-w, 1.0+h
|
-w, 1.0f+h
|
||||||
};
|
};
|
||||||
GLfloat tex1[] = {
|
GLfloat tex1[] = {
|
||||||
0, 1,
|
0, 1,
|
||||||
@ -1209,14 +1206,14 @@ void GLSpectrum::paintGL()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
float w = m_spectrogramPowerPixmap.width() / (float) width();
|
GLfloat w = m_spectrogramPowerPixmap.width() / (GLfloat) width();
|
||||||
float h = m_topMargin / (float) m_spectrogramPowerPixmap.height();
|
GLfloat h = m_topMargin / (GLfloat) m_spectrogramPowerPixmap.height();
|
||||||
|
|
||||||
GLfloat vtx1[] = {
|
GLfloat vtx1[] = {
|
||||||
-w, 1.0, 0.0,
|
-w, 1.0f, 0.0f,
|
||||||
0, 1.0, 0.0,
|
0.0f, 1.0f, 0.0f,
|
||||||
0, 1.0, 1.0+h,
|
0.0f, 1.0f, 1.0f+h,
|
||||||
-w, 1.0, 1.0+h,
|
-w, 1.0f, 1.0f+h,
|
||||||
};
|
};
|
||||||
GLfloat tex1[] = {
|
GLfloat tex1[] = {
|
||||||
0, 1,
|
0, 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user