Skip to content

Commit

Permalink
qgs3daxis: Fix label transparency issues by using a sort policy
Browse files Browse the repository at this point in the history
This ensures to have the labels (Text2DEntity) rendered after the
other objects and therefore avoid any transparency issue on the
labels.
  • Loading branch information
ptitjano authored and github-actions[bot] committed Apr 5, 2023
1 parent 0e419a3 commit 2d3cc1c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/3d/qgs3daxis.cpp
Expand Up @@ -38,6 +38,7 @@ typedef Qt3DCore::QBuffer Qt3DQBuffer;
#include <Qt3DRender/QLayer>
#include <Qt3DRender/QLayerFilter>
#include <Qt3DRender/QPointLight>
#include <Qt3DRender/QSortPolicy>
#include <QWidget>
#include <QScreen>
#include <QShortcut>
Expand Down Expand Up @@ -307,7 +308,14 @@ Qt3DRender::QViewport *Qgs3DAxis::constructAxisViewport( Qt3DCore::QEntity *pare
axisCameraSelector->setParent( axisLayerFilter );
axisCameraSelector->setCamera( mAxisCamera );

Qt3DRender::QClearBuffers *clearBuffers = new Qt3DRender::QClearBuffers( axisCameraSelector );
// This ensures to have the labels (Text2DEntity) rendered after the other objects and therefore
// avoid any transparency issue on the labels.
Qt3DRender::QSortPolicy *sortPolicy = new Qt3DRender::QSortPolicy( axisCameraSelector );
QVector<Qt3DRender::QSortPolicy::SortType> sortTypes = QVector<Qt3DRender::QSortPolicy::SortType>();
sortTypes << Qt3DRender::QSortPolicy::BackToFront;
sortPolicy->setSortTypes( sortTypes );

Qt3DRender::QClearBuffers *clearBuffers = new Qt3DRender::QClearBuffers( sortPolicy );
clearBuffers->setBuffers( Qt3DRender::QClearBuffers::DepthBuffer );

// cppcheck-suppress memleak
Expand Down Expand Up @@ -348,7 +356,14 @@ Qt3DRender::QViewport *Qgs3DAxis::constructLabelViewport( Qt3DCore::QEntity *par
twoDCameraSelector->setParent( twoDLayerFilter );
twoDCameraSelector->setCamera( mTwoDLabelCamera );

Qt3DRender::QClearBuffers *clearBuffers = new Qt3DRender::QClearBuffers( twoDCameraSelector );
// this ensures to have the labels (Text2DEntity) rendered after the other objects and therefore
// avoid any transparency issue on the labels.
Qt3DRender::QSortPolicy *sortPolicy = new Qt3DRender::QSortPolicy( twoDCameraSelector );
QVector<Qt3DRender::QSortPolicy::SortType> sortTypes = QVector<Qt3DRender::QSortPolicy::SortType>();
sortTypes << Qt3DRender::QSortPolicy::BackToFront;
sortPolicy->setSortTypes( sortTypes );

Qt3DRender::QClearBuffers *clearBuffers = new Qt3DRender::QClearBuffers( sortPolicy );
clearBuffers->setBuffers( Qt3DRender::QClearBuffers::DepthBuffer );

// cppcheck-suppress memleak
Expand Down

0 comments on commit 2d3cc1c

Please sign in to comment.