mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-05 22:57:47 -04:00
Support high DPI devices
This commit is contained in:
parent
3335dd7cc0
commit
34ce5ae398
@ -23,6 +23,7 @@
|
|||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
|
#include <QWindow>
|
||||||
#include "maincore.h"
|
#include "maincore.h"
|
||||||
#include "dsp/spectrumvis.h"
|
#include "dsp/spectrumvis.h"
|
||||||
#include "gui/glspectrum.h"
|
#include "gui/glspectrum.h"
|
||||||
@ -784,10 +785,11 @@ void GLSpectrum::initializeGL()
|
|||||||
qDebug() << "GLSpectrum::initializeGL: current context is invalid";
|
qDebug() << "GLSpectrum::initializeGL: current context is invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (MainCore::instance()->getSettings().getConsoleMinLogLevel() <= QtDebugMsg)
|
// Enable OpenGL debugging
|
||||||
|| (MainCore::instance()->getSettings().getFileMinLogLevel() <= QtDebugMsg))
|
// Disable for release, as some OpenGL drivers are quite verbose and output
|
||||||
|
// info on every frame
|
||||||
|
if (false)
|
||||||
{
|
{
|
||||||
// Enable OpenGL debugging
|
|
||||||
QSurfaceFormat format = glCurrentContext->format();
|
QSurfaceFormat format = glCurrentContext->format();
|
||||||
format.setOption(QSurfaceFormat::DebugContext);
|
format.setOption(QSurfaceFormat::DebugContext);
|
||||||
glCurrentContext->setFormat(format);
|
glCurrentContext->setFormat(format);
|
||||||
@ -877,6 +879,7 @@ 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;
|
||||||
|
int devicePixelRatio;
|
||||||
|
|
||||||
if (m_display3DSpectrogram)
|
if (m_display3DSpectrogram)
|
||||||
{
|
{
|
||||||
@ -901,9 +904,14 @@ void GLSpectrum::paintGL()
|
|||||||
float prop_y = m_3DSpectrogramTexturePos / (m_3DSpectrogramTextureHeight - 1.0);
|
float prop_y = m_3DSpectrogramTexturePos / (m_3DSpectrogramTextureHeight - 1.0);
|
||||||
|
|
||||||
// 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);
|
if (window()->windowHandle()) {
|
||||||
|
devicePixelRatio = window()->windowHandle()->devicePixelRatio();
|
||||||
|
} else {
|
||||||
|
devicePixelRatio = 1;
|
||||||
|
}
|
||||||
|
glFunctions->glViewport(0, m_3DSpectrogramBottom*devicePixelRatio, width()*devicePixelRatio, m_waterfallHeight*devicePixelRatio);
|
||||||
m_glShaderSpectrogram.drawSurface(m_3DSpectrogramStyle, spectrogramGridMatrix, 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()*devicePixelRatio, height()*devicePixelRatio);
|
||||||
}
|
}
|
||||||
else if (m_displayWaterfall)
|
else if (m_displayWaterfall)
|
||||||
{
|
{
|
||||||
@ -1168,7 +1176,7 @@ void GLSpectrum::paintGL()
|
|||||||
// paint 3D spectrogram scales
|
// paint 3D spectrogram scales
|
||||||
if (m_display3DSpectrogram && m_displayGrid)
|
if (m_display3DSpectrogram && m_displayGrid)
|
||||||
{
|
{
|
||||||
glFunctions->glViewport(0, m_3DSpectrogramBottom, width(), m_waterfallHeight);
|
glFunctions->glViewport(0, m_3DSpectrogramBottom*devicePixelRatio, width()*devicePixelRatio, m_waterfallHeight*devicePixelRatio);
|
||||||
{
|
{
|
||||||
GLfloat l = m_spectrogramTimePixmap.width() / (GLfloat) width();
|
GLfloat l = m_spectrogramTimePixmap.width() / (GLfloat) width();
|
||||||
GLfloat r = m_rightMargin / (GLfloat) width();
|
GLfloat r = m_rightMargin / (GLfloat) width();
|
||||||
@ -1230,7 +1238,7 @@ void GLSpectrum::paintGL()
|
|||||||
m_glShaderSpectrogramPowerScale.drawSurface(spectrogramGridMatrix, tex1, vtx1, 4, 3);
|
m_glShaderSpectrogramPowerScale.drawSurface(spectrogramGridMatrix, tex1, vtx1, 4, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
glFunctions->glViewport(0, 0, width(), height());
|
glFunctions->glViewport(0, 0, width()*devicePixelRatio, height()*devicePixelRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
// paint max hold lines on top of histogram
|
// paint max hold lines on top of histogram
|
||||||
@ -1379,7 +1387,7 @@ void GLSpectrum::paintGL()
|
|||||||
const ScaleEngine::TickList* tickList;
|
const ScaleEngine::TickList* tickList;
|
||||||
const ScaleEngine::Tick* tick;
|
const ScaleEngine::Tick* tick;
|
||||||
|
|
||||||
glFunctions->glViewport(0, m_3DSpectrogramBottom, width(), m_waterfallHeight);
|
glFunctions->glViewport(0, m_3DSpectrogramBottom*devicePixelRatio, width()*devicePixelRatio, m_waterfallHeight*devicePixelRatio);
|
||||||
|
|
||||||
tickList = &m_powerScale.getTickList();
|
tickList = &m_powerScale.getTickList();
|
||||||
{
|
{
|
||||||
@ -1491,7 +1499,7 @@ void GLSpectrum::paintGL()
|
|||||||
m_glShaderSimple.drawSegments(spectrogramGridMatrix, color, q3, 2*effectiveTicks, 3);
|
m_glShaderSimple.drawSegments(spectrogramGridMatrix, color, q3, 2*effectiveTicks, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
glFunctions->glViewport(0, 0, width(), height());
|
glFunctions->glViewport(0, 0, width()*devicePixelRatio, height()*devicePixelRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
// paint histogram grid
|
// paint histogram grid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user