mirror of https://github.com/CGAL/cgal
Add devicePixelRatio() to Camera
This commit is contained in:
parent
23333bed4e
commit
9ade574b1a
|
|
@ -199,6 +199,7 @@ public:
|
|||
CGAL::QGLViewer's window dimensions when the Camera is attached to a CGAL::QGLViewer. See
|
||||
also QOpenGLWidget::height() */
|
||||
int screenHeight() const { return screenHeight_; }
|
||||
qreal devicePixelRatio() const { return devicePixelRatio_; }
|
||||
void getViewport(GLint viewport[4]) const;
|
||||
qreal pixelGLRatio(const Vec &position) const;
|
||||
|
||||
|
|
@ -279,7 +280,7 @@ public Q_SLOTS:
|
|||
setScreenWidthAndHeight(int(100.0 * aspect), 100);
|
||||
}
|
||||
|
||||
void setScreenWidthAndHeight(int width, int height);
|
||||
void setScreenWidthAndHeight(int width, int height, qreal devicePixelRatio = 1.0);
|
||||
/*! Sets the zNearCoefficient() value. */
|
||||
void setZNearCoefficient(qreal coef) {
|
||||
zNearCoef_ = coef;
|
||||
|
|
@ -444,6 +445,7 @@ private:
|
|||
|
||||
// C a m e r a p a r a m e t e r s
|
||||
int screenWidth_, screenHeight_; // size of the window, in pixels
|
||||
qreal devicePixelRatio_;
|
||||
qreal fieldOfView_; // in radians
|
||||
Vec sceneCenter_;
|
||||
qreal sceneRadius_; // OpenGL units
|
||||
|
|
|
|||
|
|
@ -160,10 +160,11 @@ frustrum coherence.
|
|||
If your Camera is used without a CGAL::QGLViewer (offscreen rendering, shadow maps),
|
||||
use setAspectRatio() instead to define the projection matrix. */
|
||||
CGAL_INLINE_FUNCTION
|
||||
void Camera::setScreenWidthAndHeight(int width, int height) {
|
||||
void Camera::setScreenWidthAndHeight(int width, int height, qreal devicePixelRatio) {
|
||||
// Prevent negative and zero dimensions that would cause divisions by zero.
|
||||
screenWidth_ = width > 0 ? width : 1;
|
||||
screenHeight_ = height > 0 ? height : 1;
|
||||
devicePixelRatio_ = devicePixelRatio;
|
||||
projectionMatrixIsUpToDate_ = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -807,7 +807,7 @@ void CGAL::QGLViewer::setCamera(qglviewer::Camera *const camera) {
|
|||
|
||||
camera->setSceneRadius(sceneRadius());
|
||||
camera->setSceneCenter(sceneCenter());
|
||||
camera->setScreenWidthAndHeight(width(), height());
|
||||
camera->setScreenWidthAndHeight(width(), height(), devicePixelRatio());
|
||||
|
||||
// Disconnect current camera from this viewer.
|
||||
disconnect(this->camera()->frame(), SIGNAL(manipulated()), this,
|
||||
|
|
@ -2369,7 +2369,7 @@ CGAL_INLINE_FUNCTION
|
|||
void CGAL::QGLViewer::resizeGL(int width, int height) {
|
||||
QOpenGLWidget::resizeGL(width, height);
|
||||
glViewport(0, 0, GLint(width), GLint(height));
|
||||
camera()->setScreenWidthAndHeight(this->width(), this->height());
|
||||
camera()->setScreenWidthAndHeight(this->width(), this->height(), this->devicePixelRatio());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Reference in New Issue