Skip to content

Commit cda409f

Browse files
committed
Enable Qt::AA_EnableHighDpiScaling attribute
1 parent 9224eda commit cda409f

8 files changed

Lines changed: 116 additions & 61 deletions

File tree

occt-qopenglwidget/OcctQOpenGLWidgetViewer.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <AIS_Shape.hxx>
2121
#include <AIS_ViewCube.hxx>
2222
#include <Aspect_DisplayConnection.hxx>
23-
#include <Aspect_NeutralWindow.hxx>
2423
#include <BRepPrimAPI_MakeBox.hxx>
2524
#include <Message.hxx>
2625
#include <OpenGl_GraphicDriver.hxx>
@@ -150,7 +149,7 @@ void OcctQOpenGLWidgetViewer::initializeGL()
150149
const Graphic3d_Vec2i aViewSize(rect().right() - rect().left(), rect().bottom() - rect().top());
151150

152151
const bool isFirstInit = myView->Window().IsNull();
153-
if (!OcctGlTools::InitializeGlWindow(myView, aNativeWin, aViewSize))
152+
if (!OcctGlTools::InitializeGlWindow(myView, aNativeWin, aViewSize, devicePixelRatioF()))
154153
{
155154
QMessageBox::critical(0, "Failure", "OpenGl_Context is unable to wrap OpenGL context");
156155
QApplication::exit(1);
@@ -188,7 +187,8 @@ bool OcctQOpenGLWidgetViewer::event(QEvent* theEvent)
188187
for (const QTouchEvent::TouchPoint& aQTouch : aQTouchEvent->touchPoints())
189188
{
190189
const Standard_Size aTouchId = aQTouch.id();
191-
const Graphic3d_Vec2d aNewPos2d(aQTouch.pos().x(), aQTouch.pos().y());
190+
const Graphic3d_Vec2d aNewPos2d =
191+
myView->Window()->ConvertPointToBacking(Graphic3d_Vec2d(aQTouch.pos().x(), aQTouch.pos().y()));
192192
const Graphic3d_Vec2i aNewPos2i = Graphic3d_Vec2i(aNewPos2d + Graphic3d_Vec2d(0.5));
193193
if (aQTouch.state() == Qt::TouchPointPressed
194194
&& aNewPos2i.minComp() >= 0)
@@ -262,10 +262,11 @@ void OcctQOpenGLWidgetViewer::mousePressEvent(QMouseEvent* theEvent)
262262
return; // skip mouse events emulated by system from screen touches
263263

264264
theEvent->accept();
265-
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
265+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
266+
const Graphic3d_Vec2i aPnt2i(myView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
266267
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
267268
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
268-
if (AIS_ViewController::UpdateMouseButtons(aPnt, aButtons, aFlags, false))
269+
if (AIS_ViewController::UpdateMouseButtons(aPnt2i, aButtons, aFlags, false))
269270
updateView();
270271
}
271272

@@ -279,10 +280,11 @@ void OcctQOpenGLWidgetViewer::mouseReleaseEvent(QMouseEvent* theEvent)
279280
return;
280281

281282
theEvent->accept();
282-
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
283+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
284+
const Graphic3d_Vec2i aPnt2i(myView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
283285
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
284286
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
285-
if (AIS_ViewController::UpdateMouseButtons(aPnt, aButtons, aFlags, false))
287+
if (AIS_ViewController::UpdateMouseButtons(aPnt2i, aButtons, aFlags, false))
286288
updateView();
287289
}
288290

@@ -299,10 +301,11 @@ void OcctQOpenGLWidgetViewer::mouseMoveEvent(QMouseEvent* theEvent)
299301
return; // skip mouse events emulated by system from screen touches
300302

301303
theEvent->accept();
302-
const Graphic3d_Vec2i aNewPos(theEvent->pos().x(), theEvent->pos().y());
304+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
305+
const Graphic3d_Vec2i aPnt2i(myView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
303306
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
304307
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
305-
if (AIS_ViewController::UpdateMousePosition(aNewPos, aButtons, aFlags, false))
308+
if (AIS_ViewController::UpdateMousePosition(aPnt2i, aButtons, aFlags, false))
306309
updateView();
307310
}
308311

@@ -317,15 +320,16 @@ void OcctQOpenGLWidgetViewer::wheelEvent(QWheelEvent* theEvent)
317320

318321
theEvent->accept();
319322
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
320-
const Graphic3d_Vec2i aPos(Graphic3d_Vec2d(theEvent->position().x(), theEvent->position().y()));
323+
const Graphic3d_Vec2d aPnt2d(theEvent->position().x(), theEvent->position().y());
321324
#else
322-
const Graphic3d_Vec2i aPos(theEvent->pos().x(), theEvent->pos().y());
325+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
323326
#endif
327+
const Graphic3d_Vec2i aPnt2i(myView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
324328

325329
#if (OCC_VERSION_HEX >= 0x070700)
326330
if (!myView->Subviews().IsEmpty())
327331
{
328-
Handle(V3d_View) aPickedView = myView->PickSubview(aPos);
332+
Handle(V3d_View) aPickedView = myView->PickSubview(aPnt2i);
329333
if (!aPickedView.IsNull() && aPickedView != myFocusView)
330334
{
331335
// switch input focus to another subview
@@ -336,7 +340,7 @@ void OcctQOpenGLWidgetViewer::wheelEvent(QWheelEvent* theEvent)
336340
}
337341
#endif
338342

339-
if (AIS_ViewController::UpdateZoom(Aspect_ScrollDelta(aPos, double(theEvent->angleDelta().y()) / 8.0)))
343+
if (AIS_ViewController::UpdateZoom(Aspect_ScrollDelta(aPnt2i, double(theEvent->angleDelta().y()) / 8.0)))
340344
updateView();
341345
}
342346

@@ -358,6 +362,7 @@ void OcctQOpenGLWidgetViewer::paintGL()
358362
return;
359363

360364
Graphic3d_Vec2i aViewSizeOld; myView->Window()->Size(aViewSizeOld.x(), aViewSizeOld.y());
365+
const double aDevPixelRatioOld = myView->Window()->DevicePixelRatio();
361366

362367
const Aspect_Drawable aNativeWin = OcctGlTools::GetGlNativeWindow((Aspect_Drawable)winId());
363368
if (myView->Window()->NativeHandle() != aNativeWin)
@@ -369,15 +374,15 @@ void OcctQOpenGLWidgetViewer::paintGL()
369374
}
370375

371376
// wrap FBO created by QOpenGLFramebufferObject
372-
if (!OcctGlTools::InitializeGlFbo(myView))
377+
if (!OcctGlTools::InitializeGlFbo(myView, devicePixelRatioF()))
373378
{
374379
QMessageBox::critical(0, "Failure", "Default FBO wrapper creation failed");
375380
QApplication::exit(1);
376381
return;
377382
}
378383

379384
Graphic3d_Vec2i aViewSizeNew; myView->Window()->Size(aViewSizeNew.x(), aViewSizeNew.y());
380-
if (aViewSizeNew != aViewSizeOld)
385+
if (aViewSizeNew != aViewSizeOld || myView->Window()->DevicePixelRatio() != aDevPixelRatioOld)
381386
dumpGlInfo(true, false);
382387

383388
// reset global GL state from Qt before redrawing OCCT

occt-qt-tools/OcctGlTools.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "OcctGlTools.h"
88

9-
#include <Aspect_NeutralWindow.hxx>
109
#include <OpenGl_GraphicDriver.hxx>
1110
#include <OpenGl_GlCore20.hxx>
1211
#include <OpenGl_FrameBuffer.hxx>
@@ -74,7 +73,8 @@ Aspect_Drawable OcctGlTools::GetGlNativeWindow(Aspect_Drawable theNativeWin)
7473
// ================================================================
7574
bool OcctGlTools::InitializeGlWindow(const Handle(V3d_View)& theView,
7675
const Aspect_Drawable theNativeWin,
77-
const Graphic3d_Vec2i& theSize)
76+
const Graphic3d_Vec2i& theSize,
77+
const double thePixelRatio)
7878
{
7979
const Aspect_Drawable aNativeWin = GetGlNativeWindow(theNativeWin);
8080

@@ -86,19 +86,21 @@ bool OcctGlTools::InitializeGlWindow(const Handle(V3d_View)& theView,
8686
return false;
8787
}
8888

89-
Handle(Aspect_NeutralWindow) aWindow = Handle(Aspect_NeutralWindow)::DownCast(theView->Window());
89+
Handle(OcctNeutralWindow) aWindow = Handle(OcctNeutralWindow)::DownCast(theView->Window());
9090
if (!aWindow.IsNull())
9191
{
9292
aWindow->SetNativeHandle(aNativeWin);
9393
aWindow->SetSize(theSize.x(), theSize.y());
94+
aWindow->SetDevicePixelRatio(thePixelRatio);
9495
theView->SetWindow(aWindow, aGlCtx->RenderingContext());
9596
}
9697
else
9798
{
98-
aWindow = new Aspect_NeutralWindow();
99+
aWindow = new OcctNeutralWindow();
99100
aWindow->SetVirtual(true);
100101
aWindow->SetNativeHandle(aNativeWin);
101102
aWindow->SetSize(theSize.x(), theSize.y());
103+
aWindow->SetDevicePixelRatio(thePixelRatio);
102104
theView->SetWindow(aWindow, aGlCtx->RenderingContext());
103105
}
104106
return true;
@@ -107,7 +109,8 @@ bool OcctGlTools::InitializeGlWindow(const Handle(V3d_View)& theView,
107109
// ================================================================
108110
// Function : InitializeGlFbo
109111
// ================================================================
110-
bool OcctGlTools::InitializeGlFbo(const Handle(V3d_View)& theView)
112+
bool OcctGlTools::InitializeGlFbo(const Handle(V3d_View)& theView,
113+
const double thePixelRatio)
111114
{
112115
Handle(OpenGl_Context) aGlCtx = OcctGlTools::GetGlContext(theView);
113116
Handle(OpenGl_FrameBuffer) aDefaultFbo = aGlCtx->DefaultFrameBuffer();
@@ -124,12 +127,13 @@ bool OcctGlTools::InitializeGlFbo(const Handle(V3d_View)& theView)
124127
}
125128

126129
Graphic3d_Vec2i aViewSizeOld;
127-
const Graphic3d_Vec2i aViewSizeNew = aDefaultFbo->GetVPSize();
128-
Handle(Aspect_NeutralWindow) aWindow = Handle(Aspect_NeutralWindow)::DownCast(theView->Window());
130+
const Graphic3d_Vec2i aViewSizeNew = aDefaultFbo->GetVPSize();
131+
Handle(OcctNeutralWindow) aWindow = Handle(OcctNeutralWindow)::DownCast(theView->Window());
129132
aWindow->Size(aViewSizeOld.x(), aViewSizeOld.y());
130-
if (aViewSizeNew != aViewSizeOld)
133+
if (aViewSizeNew != aViewSizeOld || aWindow->DevicePixelRatio() != thePixelRatio)
131134
{
132135
aWindow->SetSize(aViewSizeNew.x(), aViewSizeNew.y());
136+
aWindow->SetDevicePixelRatio(thePixelRatio);
133137
theView->MustBeResized();
134138
theView->Invalidate();
135139
#if (OCC_VERSION_HEX >= 0x070700)

occt-qt-tools/OcctGlTools.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,30 @@
33
#ifndef _OcctGlTools_HeaderFile
44
#define _OcctGlTools_HeaderFile
55

6+
#include <Aspect_NeutralWindow.hxx>
67
#include <V3d_View.hxx>
78

89
class OpenGl_Context;
910

1011
//! Auxiliary wrapper to avoid OpenGL macros collisions between Qt and OCCT headers.
1112
class OcctGlTools
1213
{
14+
public:
15+
//! Class making DevicePixelRatio() configurable.
16+
class OcctNeutralWindow : public Aspect_NeutralWindow
17+
{
18+
public:
19+
//! Empty constructor.
20+
OcctNeutralWindow() {}
21+
22+
//! Return device pixel ratio (logical to backing store scale factor).
23+
virtual double DevicePixelRatio() const override { return myPixelRatio; }
24+
25+
//! Set device pixel ratio.
26+
void SetDevicePixelRatio(double theRatio) { myPixelRatio = theRatio; }
27+
private:
28+
double myPixelRatio = 1.0;
29+
};
1330
public:
1431
//! Return GL context.
1532
static Handle(OpenGl_Context) GetGlContext(const Handle(V3d_View)& theView);
@@ -20,10 +37,12 @@ class OcctGlTools
2037
//! Initialize native window for OCCT 3D Viewer.
2138
static bool InitializeGlWindow(const Handle(V3d_View)& theView,
2239
const Aspect_Drawable theNativeWin,
23-
const Graphic3d_Vec2i& theSize);
40+
const Graphic3d_Vec2i& theSize,
41+
const double thePixelRatio);
2442

2543
//! Wrap FBO created by QOpenGLFramebufferObject to OCCT 3D Viewer target.
26-
static bool InitializeGlFbo(const Handle(V3d_View)& theView);
44+
static bool InitializeGlFbo(const Handle(V3d_View)& theView,
45+
const double thePixelRatio);
2746

2847
//! Cleanup up global GL state after Qt before redrawing OCCT Viewer.
2948
static void ResetGlStateBeforeOcct(const Handle(V3d_View)& theView);

occt-qt-tools/OcctQtTools.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ void OcctQtTools::qtGlPlatformSetup()
6969
aQsgLoop.SetValue("basic");
7070
aQsgLoop.Build();
7171
}*/
72+
73+
// enable auto-scaling for high-density screens
74+
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
75+
#if (QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR >= 14)
76+
// this is default since Qt6 (for fractional scale factors)
77+
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
78+
#endif
7279
}
7380

7481
// ================================================================

occt-qtquick/OcctQQuickFramebufferViewer.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <AIS_Shape.hxx>
2222
#include <AIS_ViewCube.hxx>
2323
#include <Aspect_DisplayConnection.hxx>
24-
#include <Aspect_NeutralWindow.hxx>
2524
#include <BRepPrimAPI_MakeBox.hxx>
2625
#include <Message.hxx>
2726
#include <OpenGl_GraphicDriver.hxx>
@@ -166,7 +165,8 @@ bool OcctQQuickFramebufferViewer::event(QEvent* theEvent)
166165
for (const QTouchEvent::TouchPoint& aQTouch : aQTouchEvent->touchPoints())
167166
{
168167
const Standard_Size aTouchId = aQTouch.id();
169-
const Graphic3d_Vec2d aNewPos2d(aQTouch.pos().x(), aQTouch.pos().y());
168+
const Graphic3d_Vec2d aNewPos2d =
169+
myView->Window()->ConvertPointToBacking(Graphic3d_Vec2d(aQTouch.pos().x(), aQTouch.pos().y()));
170170
const Graphic3d_Vec2i aNewPos2i = Graphic3d_Vec2i(aNewPos2d + Graphic3d_Vec2d(0.5));
171171
if (aQTouch.state() == Qt::TouchPointPressed
172172
&& aNewPos2i.minComp() >= 0)
@@ -237,10 +237,11 @@ void OcctQQuickFramebufferViewer::mousePressEvent(QMouseEvent* theEvent)
237237
return; // skip mouse events emulated by system from screen touches
238238

239239
theEvent->accept();
240-
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
240+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
241+
const Graphic3d_Vec2i aPnt2i(myView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
241242
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
242243
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
243-
if (AIS_ViewController::UpdateMouseButtons(aPnt, aButtons, aFlags, false))
244+
if (AIS_ViewController::UpdateMouseButtons(aPnt2i, aButtons, aFlags, false))
244245
updateView();
245246
}
246247

@@ -254,10 +255,11 @@ void OcctQQuickFramebufferViewer::mouseReleaseEvent(QMouseEvent* theEvent)
254255
return;
255256

256257
theEvent->accept();
257-
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
258+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
259+
const Graphic3d_Vec2i aPnt2i(myView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
258260
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
259261
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
260-
if (AIS_ViewController::UpdateMouseButtons(aPnt, aButtons, aFlags, false))
262+
if (AIS_ViewController::UpdateMouseButtons(aPnt2i, aButtons, aFlags, false))
261263
updateView();
262264

263265
// take keyboard focus on mouse click
@@ -277,10 +279,11 @@ void OcctQQuickFramebufferViewer::mouseMoveEvent(QMouseEvent* theEvent)
277279
return; // skip mouse events emulated by system from screen touches
278280

279281
theEvent->accept();
280-
const Graphic3d_Vec2i aNewPos(theEvent->pos().x(), theEvent->pos().y());
282+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
283+
const Graphic3d_Vec2i aPnt2i(myView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
281284
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
282285
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
283-
if (AIS_ViewController::UpdateMousePosition(aNewPos, aButtons, aFlags, false))
286+
if (AIS_ViewController::UpdateMousePosition(aPnt2i, aButtons, aFlags, false))
284287
updateView();
285288
}
286289

@@ -295,11 +298,12 @@ void OcctQQuickFramebufferViewer::wheelEvent(QWheelEvent* theEvent)
295298

296299
theEvent->accept();
297300
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
298-
const Graphic3d_Vec2i aPos(Graphic3d_Vec2d(theEvent->position().x(), theEvent->position().y()));
301+
const Graphic3d_Vec2d aPnt2d(theEvent->position().x(), theEvent->position().y());
299302
#else
300-
const Graphic3d_Vec2i aPos(theEvent->pos().x(), theEvent->pos().y());
303+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
301304
#endif
302-
if (AIS_ViewController::UpdateZoom(Aspect_ScrollDelta(aPos, double(theEvent->angleDelta().y()) / 8.0)))
305+
const Graphic3d_Vec2i aPnt2i(myView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
306+
if (AIS_ViewController::UpdateZoom(Aspect_ScrollDelta(aPnt2i, double(theEvent->angleDelta().y()) / 8.0)))
303307
updateView();
304308
}
305309

@@ -337,10 +341,11 @@ void OcctQQuickFramebufferViewer::hoverMoveEvent(QHoverEvent* theEvent)
337341
return;
338342

339343
theEvent->accept();
340-
const Graphic3d_Vec2i aNewPos(theEvent->pos().x(), theEvent->pos().y());
344+
const Graphic3d_Vec2d aPnt2d(theEvent->pos().x(), theEvent->pos().y());
345+
const Graphic3d_Vec2i aPnt2i(myView->Window()->ConvertPointToBacking(aPnt2d) + Graphic3d_Vec2d(0.5));
341346
const Aspect_VKeyMouse aButtons = Aspect_VKeyMouse_NONE;
342347
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
343-
if (AIS_ViewController::UpdateMousePosition(aNewPos, aButtons, aFlags, false))
348+
if (AIS_ViewController::UpdateMousePosition(aPnt2i, aButtons, aFlags, false))
344349
updateView();
345350
}
346351

@@ -463,7 +468,7 @@ void OcctQQuickFramebufferViewer::initializeGL(QOpenGLFramebufferObject* theFbo)
463468
const Graphic3d_Vec2i aViewSize(theFbo->size().width(), theFbo->size().height());
464469

465470
const bool isFirstInit = myView->Window().IsNull();
466-
if (!OcctGlTools::InitializeGlWindow(myView, aNativeWin, aViewSize))
471+
if (!OcctGlTools::InitializeGlWindow(myView, aNativeWin, aViewSize, aQWindow->devicePixelRatio()))
467472
{
468473
Q_EMIT glCriticalError("OpenGl_Context is unable to wrap OpenGL context");
469474
return;
@@ -506,16 +511,17 @@ void OcctQQuickFramebufferViewer::render(QOpenGLFramebufferObject* theFbo)
506511
}
507512

508513
Graphic3d_Vec2i aViewSizeOld; myView->Window()->Size(aViewSizeOld.x(), aViewSizeOld.y());
514+
const double aDevPixelRatioOld = myView->Window()->DevicePixelRatio();
509515

510516
// wrap FBO created by QOpenGLFramebufferObject
511-
if (!OcctGlTools::InitializeGlFbo(myView))
517+
if (!OcctGlTools::InitializeGlFbo(myView, aQWindow->devicePixelRatio()))
512518
{
513519
Q_EMIT glCriticalError("Default FBO wrapper creation failed");
514520
return;
515521
}
516522

517523
Graphic3d_Vec2i aViewSizeNew; myView->Window()->Size(aViewSizeNew.x(), aViewSizeNew.y());
518-
if (aViewSizeNew != aViewSizeOld)
524+
if (aViewSizeNew != aViewSizeOld || myView->Window()->DevicePixelRatio() != aDevPixelRatioOld)
519525
dumpGlInfo(true, false);
520526

521527
// reset global GL state from Qt before redrawing OCCT

occt-qtquick/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ int main(int theNbArgs, char** theArgVec)
3636
QCoreApplication::setApplicationName("OCCT Qt/QtQuick Viewer sample");
3737
QCoreApplication::setOrganizationName("OpenCASCADE");
3838
QCoreApplication::setApplicationVersion(OCC_VERSION_STRING_EXT);
39-
//QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
4039

4140
qmlRegisterType<OcctQQuickFramebufferViewer>("OcctQQuickFramebufferViewer", 1, 0, "OcctQQuickFramebufferViewer");
4241

occt-qwidget/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ set (OpenCASCADE_LIBS TKRWMesh TKBinXCAF TKBin TKBinL TKOpenGl TKXCAF TKVCAF TKC
7878
add_executable (${PROJECT_NAME}
7979
../occt-qt-tools/OcctQtTools.h
8080
../occt-qt-tools/OcctQtTools.cpp
81+
../occt-qt-tools/OcctGlTools.h
8182
main.cpp
8283
OcctQWidgetViewer.h
8384
OcctQWidgetViewer.cpp

0 commit comments

Comments
 (0)