fix: Correct OpenGL viewport scaling on high-DPI displays
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -114,8 +114,10 @@ void ViewportWidget::initializeGL()
|
|||||||
|
|
||||||
void ViewportWidget::paintGL()
|
void ViewportWidget::paintGL()
|
||||||
{
|
{
|
||||||
|
const qreal retinaScale = devicePixelRatio();
|
||||||
|
|
||||||
// Main scene rendering
|
// Main scene rendering
|
||||||
glViewport(0, 0, width(), height());
|
glViewport(0, 0, width() * retinaScale, height() * retinaScale);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
if (!m_shaderProgram || !m_shaderProgram->isLinked()) {
|
if (!m_shaderProgram || !m_shaderProgram->isLinked()) {
|
||||||
@@ -189,9 +191,9 @@ void ViewportWidget::paintGL()
|
|||||||
QMatrix4x4 viewCubeModel;
|
QMatrix4x4 viewCubeModel;
|
||||||
viewCubeModel.rotate(m_camera->xRotation() / 16.0f, 1, 0, 0);
|
viewCubeModel.rotate(m_camera->xRotation() / 16.0f, 1, 0, 0);
|
||||||
viewCubeModel.rotate(m_camera->yRotation() / 16.0f, 0, 1, 0);
|
viewCubeModel.rotate(m_camera->yRotation() / 16.0f, 0, 1, 0);
|
||||||
m_viewCube->paintGL(m_shaderProgram, m_colorLoc, viewCubeModel, width(), height());
|
m_viewCube->paintGL(m_shaderProgram, m_colorLoc, viewCubeModel, width() * retinaScale, height() * retinaScale);
|
||||||
|
|
||||||
glViewport(0, 0, width(), height());
|
glViewport(0, 0, width() * retinaScale, height() * retinaScale);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user