Dimension fixes for Retina displays.

This commit is contained in:
Andrzej Kapolka 2014-09-05 16:44:45 -07:00
parent eecc94f816
commit 7f6b3d3649
15 changed files with 125 additions and 103 deletions

View file

@ -596,7 +596,7 @@ void Application::paintGL() {
if (OculusManager::isConnected()) {
_textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize());
} else {
_textureCache.setFrameBufferSize(_glWidget->size());
_textureCache.setFrameBufferSize(_glWidget->getDeviceSize());
}
glEnable(GL_LINE_SMOOTH);
@ -986,7 +986,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
if (isShifted) {
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
if (TV3DManager::isConnected()) {
TV3DManager::configureCamera(_myCamera, _glWidget->width(),_glWidget->height());
TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
}
} else {
_myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
@ -998,7 +998,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
if (isShifted) {
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
if (TV3DManager::isConnected()) {
TV3DManager::configureCamera(_myCamera, _glWidget->width(),_glWidget->height());
TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
}
} else {
@ -1424,7 +1424,7 @@ void Application::checkBandwidthMeterClick() {
if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY)))
<= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH
&& _bandwidthMeter.isWithinArea(_mouseX, _mouseY, _glWidget->width(), _glWidget->height())) {
&& _bandwidthMeter.isWithinArea(_mouseX, _mouseY, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight())) {
// The bandwidth meter is visible, the click didn't get dragged too far and
// we actually hit the bandwidth meter
@ -1438,7 +1438,7 @@ void Application::setFullscreen(bool fullscreen) {
}
void Application::setEnable3DTVMode(bool enable3DTVMode) {
resizeGL(_glWidget->width(),_glWidget->height());
resizeGL(_glWidget->getDeviceWidth(),_glWidget->getDeviceHeight());
}
void Application::setEnableVRMode(bool enableVRMode) {
@ -1451,7 +1451,7 @@ void Application::setEnableVRMode(bool enableVRMode) {
}
}
resizeGL(_glWidget->width(), _glWidget->height());
resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
}
void Application::setRenderVoxels(bool voxelRender) {
@ -1742,8 +1742,8 @@ void Application::init() {
_voxelShader.init();
_pointShader.init();
_mouseX = _glWidget->width() / 2;
_mouseY = _glWidget->height() / 2;
_mouseX = _glWidget->getDeviceWidth() / 2;
_mouseY = _glWidget->getDeviceHeight() / 2;
QCursor::setPos(_mouseX, _mouseY);
// TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager
@ -1898,8 +1898,8 @@ void Application::updateMouseRay() {
// if the mouse pointer isn't visible, act like it's at the center of the screen
float x = 0.5f, y = 0.5f;
if (!_mouseHidden) {
x = _mouseX / (float)_glWidget->width();
y = _mouseY / (float)_glWidget->height();
x = _mouseX / (float)_glWidget->getDeviceWidth();
y = _mouseY / (float)_glWidget->getDeviceHeight();
}
_viewFrustum.computePickRay(x, y, _mouseRayOrigin, _mouseRayDirection);
@ -2686,7 +2686,7 @@ void Application::updateShadowMap() {
fbo->release();
glViewport(0, 0, _glWidget->width(), _glWidget->height());
glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
}
const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
@ -2716,7 +2716,7 @@ QImage Application::renderAvatarBillboard() {
glDisable(GL_BLEND);
const int BILLBOARD_SIZE = 64;
renderRearViewMirror(QRect(0, _glWidget->height() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true);
renderRearViewMirror(QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true);
QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
@ -2976,8 +2976,8 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom
}
glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
float horizontalScale = _glWidget->width() / 2.0f;
float verticalScale = _glWidget->height() / 2.0f;
float horizontalScale = _glWidget->getDeviceWidth() / 2.0f;
float verticalScale = _glWidget->getDeviceHeight() / 2.0f;
// -1,-1 is 0,windowHeight
// 1,1 is windowWidth,0
@ -2996,7 +2996,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
// -1,-1 1,-1
glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale,
((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->height());
((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight());
return screenPoint;
}
@ -3032,8 +3032,8 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
_mirrorCamera.update(1.0f/_fps);
// set the bounds of rear mirror view
glViewport(region.x(), _glWidget->height() - region.y() - region.height(), region.width(), region.height());
glScissor(region.x(), _glWidget->height() - region.y() - region.height(), region.width(), region.height());
glViewport(region.x(), _glWidget->getDeviceHeight() - region.y() - region.height(), region.width(), region.height());
glScissor(region.x(), _glWidget->getDeviceHeight() - region.y() - region.height(), region.width(), region.height());
bool updateViewFrustum = false;
updateProjectionMatrix(_mirrorCamera, updateViewFrustum);
glEnable(GL_SCISSOR_TEST);
@ -3100,7 +3100,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
}
// reset Viewport and projection matrix
glViewport(0, 0, _glWidget->width(), _glWidget->height());
glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
glDisable(GL_SCISSOR_TEST);
updateProjectionMatrix(_myCamera, updateViewFrustum);
}
@ -3282,8 +3282,8 @@ void Application::deleteVoxelAt(const VoxelDetail& voxel) {
void Application::resetSensors() {
_mouseX = _glWidget->width() / 2;
_mouseY = _glWidget->height() / 2;
_mouseX = _glWidget->getDeviceWidth() / 2;
_mouseY = _glWidget->getDeviceHeight() / 2;
_faceplus.reset();
_faceshift.reset();

View file

@ -186,7 +186,7 @@ public:
glm::vec3 getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel);
QGLWidget* getGLWidget() { return _glWidget; }
GLCanvas* getGLWidget() { return _glWidget; }
bool isThrottleRendering() const { return _glWidget->isThrottleRendering(); }
MyAvatar* getAvatar() { return _myAvatar; }
Audio* getAudio() { return &_audio; }
@ -288,7 +288,7 @@ public:
PointShader& getPointShader() { return _pointShader; }
FileLogger* getLogger() { return _logger; }
glm::vec2 getViewportDimensions() const{ return glm::vec2(_glWidget->width(),_glWidget->height()); }
glm::vec2 getViewportDimensions() const { return glm::vec2(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); }
NodeToJurisdictionMap& getVoxelServerJurisdictions() { return _voxelServerJurisdictions; }
NodeToJurisdictionMap& getParticleServerJurisdictions() { return _particleServerJurisdictions; }
NodeToJurisdictionMap& getEntityServerJurisdictions() { return _entityServerJurisdictions; }

View file

@ -262,8 +262,8 @@ CameraScriptableObject::CameraScriptableObject(Camera* camera, ViewFrustum* view
}
PickRay CameraScriptableObject::computePickRay(float x, float y) {
float screenWidth = Application::getInstance()->getGLWidget()->width();
float screenHeight = Application::getInstance()->getGLWidget()->height();
float screenWidth = Application::getInstance()->getGLWidget()->getDeviceWidth();
float screenHeight = Application::getInstance()->getGLWidget()->getDeviceHeight();
PickRay result;
if (OculusManager::isConnected()) {
result.origin = _camera->getPosition();

View file

@ -9,13 +9,14 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "Application.h"
#include "GLCanvas.h"
#include "devices/OculusManager.h"
#include <QMainWindow>
#include <QMimeData>
#include <QUrl>
#include <QMainWindow>
#include <QWindow>
#include "Application.h"
#include "GLCanvas.h"
#include "devices/OculusManager.h"
const int MSECS_PER_FRAME_WHEN_THROTTLED = 66;
@ -34,6 +35,14 @@ bool GLCanvas::isThrottleRendering() const {
return _throttleRendering || Application::getInstance()->getWindow()->isMinimized();
}
int GLCanvas::getDeviceWidth() const {
return width() * (windowHandle() ? windowHandle()->devicePixelRatio() : 1.0f);
}
int GLCanvas::getDeviceHeight() const {
return height() * (windowHandle() ? windowHandle()->devicePixelRatio() : 1.0f);
}
void GLCanvas::initializeGL() {
Application::getInstance()->initializeGL();
setAttribute(Qt::WA_AcceptTouchEvents);

View file

@ -21,6 +21,11 @@ class GLCanvas : public QGLWidget {
public:
GLCanvas();
bool isThrottleRendering() const;
int getDeviceWidth() const;
int getDeviceHeight() const;
QSize getDeviceSize() const { return QSize(getDeviceWidth(), getDeviceHeight()); }
protected:
QTimer _frameTimer;

View file

@ -383,7 +383,8 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
}
// restore our normal viewport
glViewport(0, 0, Application::getInstance()->getGLWidget()->width(), Application::getInstance()->getGLWidget()->height());
glViewport(0, 0, Application::getInstance()->getGLWidget()->getDeviceWidth(),
Application::getInstance()->getGLWidget()->getDeviceHeight());
glMatrixMode(GL_PROJECTION);
glPopMatrix();
@ -400,7 +401,8 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p
void OculusManager::renderDistortionMesh(ovrPosef eyeRenderPose[ovrEye_Count]) {
glLoadIdentity();
gluOrtho2D(0, Application::getInstance()->getGLWidget()->width(), 0, Application::getInstance()->getGLWidget()->height());
gluOrtho2D(0, Application::getInstance()->getGLWidget()->getDeviceWidth(), 0,
Application::getInstance()->getGLWidget()->getDeviceHeight());
glDisable(GL_DEPTH_TEST);
@ -525,4 +527,4 @@ QSize OculusManager::getRenderTargetSize() {
#else
return QSize(100, 100);
#endif
}
}

View file

@ -209,8 +209,8 @@ void PrioVR::renderCalibrationCountdown() {
}
static TextRenderer textRenderer(MONO_FONT_FAMILY, 18, QFont::Bold, false, TextRenderer::OUTLINE_EFFECT, 2);
QByteArray text = "Assume T-Pose in " + QByteArray::number(secondsRemaining) + "...";
textRenderer.draw((Application::getInstance()->getGLWidget()->width() - textRenderer.computeWidth(text.constData())) / 2,
Application::getInstance()->getGLWidget()->height() / 2,
text);
textRenderer.draw((Application::getInstance()->getGLWidget()->getDeviceWidth() -
textRenderer.computeWidth(text.constData())) / 2, Application::getInstance()->getGLWidget()->getDeviceHeight() / 2,
text);
#endif
}

View file

@ -369,7 +369,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers)
void SixenseManager::emulateMouse(PalmData* palm, int index) {
Application* application = Application::getInstance();
MyAvatar* avatar = application->getAvatar();
QGLWidget* widget = application->getGLWidget();
GLCanvas* widget = application->getGLWidget();
QPoint pos;
Qt::MouseButton bumperButton;
@ -396,10 +396,10 @@ void SixenseManager::emulateMouse(PalmData* palm, int index) {
float yAngle = 0.5f - ((atan2(direction.z, direction.y) + M_PI_2));
// Get the pixel range over which the xAngle and yAngle are scaled
float cursorRange = widget->width() * getCursorPixelRangeMult();
float cursorRange = widget->getDeviceWidth() * getCursorPixelRangeMult();
pos.setX(widget->width() / 2.0f + cursorRange * xAngle);
pos.setY(widget->height() / 2.0f + cursorRange * yAngle);
pos.setX(widget->getDeviceWidth() / 2.0f + cursorRange * xAngle);
pos.setY(widget->getDeviceHeight() / 2.0f + cursorRange * yAngle);
}

View file

@ -33,8 +33,8 @@ bool TV3DManager::isConnected() {
void TV3DManager::connect() {
Application* app = Application::getInstance();
int width = app->getGLWidget()->width();
int height = app->getGLWidget()->height();
int width = app->getGLWidget()->getDeviceWidth();
int height = app->getGLWidget()->getDeviceHeight();
Camera& camera = *app->getCamera();
configureCamera(camera, width, height);
@ -90,8 +90,8 @@ void TV3DManager::display(Camera& whichCamera) {
// left eye portal
int portalX = 0;
int portalY = 0;
int portalW = Application::getInstance()->getGLWidget()->width() / 2;
int portalH = Application::getInstance()->getGLWidget()->height();
int portalW = Application::getInstance()->getGLWidget()->getDeviceWidth() / 2;
int portalH = Application::getInstance()->getGLWidget()->getDeviceHeight();
const bool glowEnabled = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect);
@ -137,7 +137,7 @@ void TV3DManager::display(Camera& whichCamera) {
glDisable(GL_SCISSOR_TEST);
// render right side view
portalX = Application::getInstance()->getGLWidget()->width() / 2;
portalX = Application::getInstance()->getGLWidget()->getDeviceWidth() / 2;
glEnable(GL_SCISSOR_TEST);
// render left side view
glViewport(portalX, portalY, portalW, portalH);
@ -165,7 +165,8 @@ void TV3DManager::display(Camera& whichCamera) {
glDisable(GL_SCISSOR_TEST);
// reset the viewport to how we started
glViewport(0, 0, Application::getInstance()->getGLWidget()->width(), Application::getInstance()->getGLWidget()->height());
glViewport(0, 0, Application::getInstance()->getGLWidget()->getDeviceWidth(),
Application::getInstance()->getGLWidget()->getDeviceHeight());
if (glowEnabled) {
Application::getInstance()->getGlowEffect()->render();

View file

@ -116,7 +116,7 @@ void AmbientOcclusionEffect::render() {
glGetIntegerv(GL_VIEWPORT, viewport);
const int VIEWPORT_X_INDEX = 0;
const int VIEWPORT_WIDTH_INDEX = 2;
QSize widgetSize = Application::getInstance()->getGLWidget()->size();
QSize widgetSize = Application::getInstance()->getGLWidget()->getDeviceSize();
float sMin = viewport[VIEWPORT_X_INDEX] / (float)widgetSize.width();
float sWidth = viewport[VIEWPORT_WIDTH_INDEX] / (float)widgetSize.width();

View file

@ -256,8 +256,8 @@ void ControllerScriptingInterface::releaseJoystick(int joystickIndex) {
}
glm::vec2 ControllerScriptingInterface::getViewportDimensions() const {
QGLWidget* widget = Application::getInstance()->getGLWidget();
return glm::vec2(widget->width(), widget->height());
GLCanvas* widget = Application::getInstance()->getGLWidget();
return glm::vec2(widget->getDeviceWidth(), widget->getDeviceHeight());
}
AbstractInputController* ControllerScriptingInterface::createInputController(const QString& deviceName, const QString& tracker) {

View file

@ -70,7 +70,7 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
Application* application = Application::getInstance();
Overlays& overlays = application->getOverlays();
QGLWidget* glWidget = application->getGLWidget();
GLCanvas* glWidget = application->getGLWidget();
MyAvatar* myAvatar = application->getAvatar();
//Handle fading and deactivation/activation of UI
@ -99,14 +99,14 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, glWidget->width(), glWidget->height(), 0);
gluOrtho2D(0, glWidget->getDeviceWidth(), glWidget->getDeviceHeight(), 0);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
renderAudioMeter();
if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) {
myAvatar->renderHeadMouse(glWidget->width(), glWidget->height());
myAvatar->renderHeadMouse(glWidget->getDeviceWidth(), glWidget->getDeviceHeight());
}
renderStatsAndLogs();
@ -141,7 +141,7 @@ void ApplicationOverlay::displayOverlayTexture() {
}
Application* application = Application::getInstance();
QGLWidget* glWidget = application->getGLWidget();
GLCanvas* glWidget = application->getGLWidget();
glEnable(GL_TEXTURE_2D);
@ -152,16 +152,16 @@ void ApplicationOverlay::displayOverlayTexture() {
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, glWidget->width(), glWidget->height(), 0);
gluOrtho2D(0, glWidget->getDeviceWidth(), glWidget->getDeviceHeight(), 0);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glColor4f(1.0f, 1.0f, 1.0f, _alpha);
glTexCoord2f(0, 0); glVertex2i(0, glWidget->height());
glTexCoord2f(1, 0); glVertex2i(glWidget->width(), glWidget->height());
glTexCoord2f(1, 1); glVertex2i(glWidget->width(), 0);
glTexCoord2f(0, 0); glVertex2i(0, glWidget->getDeviceHeight());
glTexCoord2f(1, 0); glVertex2i(glWidget->getDeviceWidth(), glWidget->getDeviceHeight());
glTexCoord2f(1, 1); glVertex2i(glWidget->getDeviceWidth(), 0);
glTexCoord2f(0, 1); glVertex2i(0, 0);
glEnd();
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
@ -275,7 +275,7 @@ bool raySphereIntersect(const glm::vec3 &dir, const glm::vec3 &origin, float r,
QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
Application* application = Application::getInstance();
QGLWidget* glWidget = application->getGLWidget();
GLCanvas* glWidget = application->getGLWidget();
MyAvatar* myAvatar = application->getAvatar();
glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm);
@ -305,8 +305,8 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
float u = asin(collisionPos.x) / (_textureFov)+0.5f;
float v = 1.0 - (asin(collisionPos.y) / (_textureFov)+0.5f);
rv.setX(u * glWidget->width());
rv.setY(v * glWidget->height());
rv.setX(u * glWidget->getDeviceWidth());
rv.setY(v * glWidget->getDeviceHeight());
}
} else {
//if they did not click on the overlay, just set the coords to INT_MAX
@ -323,8 +323,8 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
ndcSpacePos = glm::vec3(clipSpacePos) / clipSpacePos.w;
}
rv.setX(((ndcSpacePos.x + 1.0) / 2.0) * glWidget->width());
rv.setY((1.0 - ((ndcSpacePos.y + 1.0) / 2.0)) * glWidget->height());
rv.setX(((ndcSpacePos.x + 1.0) / 2.0) * glWidget->getDeviceWidth());
rv.setY((1.0 - ((ndcSpacePos.y + 1.0) / 2.0)) * glWidget->getDeviceHeight());
}
return rv;
}
@ -496,11 +496,11 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as
//draw the mouse pointer
glBindTexture(GL_TEXTURE_2D, _crosshairTexture);
const float reticleSize = 40.0f / application->getGLWidget()->width() * quadWidth;
const float reticleSize = 40.0f / application->getGLWidget()->getDeviceWidth() * quadWidth;
x -= reticleSize / 2.0f;
y += reticleSize / 2.0f;
const float mouseX = (application->getMouseX() / (float)application->getGLWidget()->width()) * quadWidth;
const float mouseY = (1.0 - (application->getMouseY() / (float)application->getGLWidget()->height())) * quadHeight;
const float mouseX = (application->getMouseX() / (float)application->getGLWidget()->getDeviceWidth()) * quadWidth;
const float mouseY = (1.0 - (application->getMouseY() / (float)application->getGLWidget()->getDeviceHeight())) * quadHeight;
glBegin(GL_QUADS);
@ -564,7 +564,7 @@ void ApplicationOverlay::renderPointers() {
void ApplicationOverlay::renderControllerPointers() {
Application* application = Application::getInstance();
QGLWidget* glWidget = application->getGLWidget();
GLCanvas* glWidget = application->getGLWidget();
MyAvatar* myAvatar = application->getAvatar();
//Static variables used for storing controller state
@ -671,14 +671,14 @@ void ApplicationOverlay::renderControllerPointers() {
float yAngle = 0.5f - ((atan2(direction.z, direction.y) + M_PI_2));
// Get the pixel range over which the xAngle and yAngle are scaled
float cursorRange = glWidget->width() * application->getSixenseManager()->getCursorPixelRangeMult();
float cursorRange = glWidget->getDeviceWidth() * application->getSixenseManager()->getCursorPixelRangeMult();
mouseX = (glWidget->width() / 2.0f + cursorRange * xAngle);
mouseY = (glWidget->height() / 2.0f + cursorRange * yAngle);
mouseX = (glWidget->getDeviceWidth() / 2.0f + cursorRange * xAngle);
mouseY = (glWidget->getDeviceHeight() / 2.0f + cursorRange * yAngle);
}
//If the cursor is out of the screen then don't render it
if (mouseX < 0 || mouseX >= glWidget->width() || mouseY < 0 || mouseY >= glWidget->height()) {
if (mouseX < 0 || mouseX >= glWidget->getDeviceWidth() || mouseY < 0 || mouseY >= glWidget->getDeviceHeight()) {
_reticleActive[index] = false;
continue;
}
@ -706,11 +706,11 @@ void ApplicationOverlay::renderControllerPointers() {
void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) {
Application* application = Application::getInstance();
QGLWidget* glWidget = application->getGLWidget();
GLCanvas* glWidget = application->getGLWidget();
glm::vec3 cursorVerts[4];
const int widgetWidth = glWidget->width();
const int widgetHeight = glWidget->height();
const int widgetWidth = glWidget->getDeviceWidth();
const int widgetHeight = glWidget->getDeviceHeight();
const float reticleSize = 50.0f;
@ -848,10 +848,10 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) {
void ApplicationOverlay::renderMagnifier(int mouseX, int mouseY, float sizeMult, bool showBorder) const
{
Application* application = Application::getInstance();
QGLWidget* glWidget = application->getGLWidget();
GLCanvas* glWidget = application->getGLWidget();
const int widgetWidth = glWidget->width();
const int widgetHeight = glWidget->height();
const int widgetWidth = glWidget->getDeviceWidth();
const int widgetHeight = glWidget->getDeviceHeight();
const float magnifyWidth = MAGNIFY_WIDTH * sizeMult;
const float magnifyHeight = MAGNIFY_HEIGHT * sizeMult;
@ -960,7 +960,7 @@ void ApplicationOverlay::renderAudioMeter() {
Application* application = Application::getInstance();
QGLWidget* glWidget = application->getGLWidget();
GLCanvas* glWidget = application->getGLWidget();
Audio* audio = application->getAudio();
// Display a single screen-size quad to create an alpha blended 'collision' flash
@ -968,7 +968,8 @@ void ApplicationOverlay::renderAudioMeter() {
float collisionSoundMagnitude = audio->getCollisionSoundMagnitude();
const float VISIBLE_COLLISION_SOUND_MAGNITUDE = 0.5f;
if (collisionSoundMagnitude > VISIBLE_COLLISION_SOUND_MAGNITUDE) {
renderCollisionOverlay(glWidget->width(), glWidget->height(), audio->getCollisionSoundMagnitude());
renderCollisionOverlay(glWidget->getDeviceWidth(), glWidget->getDeviceHeight(),
audio->getCollisionSoundMagnitude());
}
}
@ -1018,16 +1019,16 @@ void ApplicationOverlay::renderAudioMeter() {
if ((audio->getTimeSinceLastClip() > 0.f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
const float MAX_MAGNITUDE = 0.7f;
float magnitude = MAX_MAGNITUDE * (1 - audio->getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
renderCollisionOverlay(glWidget->width(), glWidget->height(), magnitude, 1.0f);
renderCollisionOverlay(glWidget->getDeviceWidth(), glWidget->getDeviceHeight(), magnitude, 1.0f);
}
audio->renderToolBox(MIRROR_VIEW_LEFT_PADDING + AUDIO_METER_GAP,
audioMeterY,
Menu::getInstance()->isOptionChecked(MenuOption::Mirror));
audio->renderScope(glWidget->width(), glWidget->height());
audio->renderScope(glWidget->getDeviceWidth(), glWidget->getDeviceHeight());
audio->renderStats(WHITE_TEXT, glWidget->width(), glWidget->height());
audio->renderStats(WHITE_TEXT, glWidget->getDeviceWidth(), glWidget->getDeviceHeight());
glBegin(GL_QUADS);
if (isClipping) {
@ -1089,7 +1090,7 @@ void ApplicationOverlay::renderStatsAndLogs() {
Application* application = Application::getInstance();
QGLWidget* glWidget = application->getGLWidget();
GLCanvas* glWidget = application->getGLWidget();
const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor();
BandwidthMeter* bandwidthMeter = application->getBandwidthMeter();
NodeBounds& nodeBoundsDisplay = application->getNodeBoundsDisplay();
@ -1103,11 +1104,12 @@ void ApplicationOverlay::renderStatsAndLogs() {
int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
int voxelPacketsToProcess = octreePacketProcessor.packetsToProcessCount();
// Onscreen text about position, servers, etc
Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, application->getFps(), application->getPacketsPerSecond(), application->getBytesPerSecond(), voxelPacketsToProcess);
Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, application->getFps(),
application->getPacketsPerSecond(), application->getBytesPerSecond(), voxelPacketsToProcess);
// Bandwidth meter
if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {
Stats::drawBackground(0x33333399, glWidget->width() - 296, glWidget->height() - 68, 296, 68);
bandwidthMeter->render(glWidget->width(), glWidget->height());
Stats::drawBackground(0x33333399, glWidget->getDeviceWidth() - 296, glWidget->getDeviceHeight() - 68, 296, 68);
bandwidthMeter->render(glWidget->getDeviceWidth(), glWidget->getDeviceHeight());
}
}
@ -1120,7 +1122,8 @@ void ApplicationOverlay::renderStatsAndLogs() {
(Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))
? 80 : 20;
drawText(glWidget->width() - 100, glWidget->height() - timerBottom, 0.30f, 0.0f, 0, frameTimer, WHITE_TEXT);
drawText(glWidget->getDeviceWidth() - 100, glWidget->getDeviceHeight() - timerBottom,
0.30f, 0.0f, 0, frameTimer, WHITE_TEXT);
}
nodeBoundsDisplay.drawOverlay();
}
@ -1243,9 +1246,9 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() {
NodeList* nodeList = NodeList::getInstance();
if (nodeList && !nodeList->getDomainHandler().isConnected()) {
QGLWidget* glWidget = Application::getInstance()->getGLWidget();
int right = glWidget->width();
int bottom = glWidget->height();
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
int right = glWidget->getDeviceWidth();
int bottom = glWidget->getDeviceHeight();
glColor3f(CONNECTION_STATUS_BORDER_COLOR[0],
CONNECTION_STATUS_BORDER_COLOR[1],
@ -1264,7 +1267,7 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() {
}
QOpenGLFramebufferObject* ApplicationOverlay::getFramebufferObject() {
QSize size = Application::getInstance()->getGLWidget()->size();
QSize size = Application::getInstance()->getGLWidget()->getDeviceSize();
if (!_framebufferObject || _framebufferObject->size() != size) {
delete _framebufferObject;

View file

@ -920,7 +920,8 @@ void SetSpannerTool::applyEdit(const AttributePointer& attribute, const SharedOb
Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject()->release();
glViewport(0, 0, Application::getInstance()->getGLWidget()->width(), Application::getInstance()->getGLWidget()->height());
glViewport(0, 0, Application::getInstance()->getGLWidget()->getDeviceWidth(),
Application::getInstance()->getGLWidget()->getDeviceHeight());
// send the images off to the lab for processing
QThreadPool::globalInstance()->start(new Voxelizer(size, cellBounds,

View file

@ -40,9 +40,9 @@ void NodeBounds::draw() {
// Compute ray to find selected nodes later on. We can't use the pre-computed ray in Application because it centers
// itself after the cursor disappears.
Application* application = Application::getInstance();
QGLWidget* glWidget = application->getGLWidget();
float mouseX = application->getMouseX() / (float)glWidget->width();
float mouseY = application->getMouseY() / (float)glWidget->height();
GLCanvas* glWidget = application->getGLWidget();
float mouseX = application->getMouseX() / (float)glWidget->getDeviceWidth();
float mouseY = application->getMouseY() / (float)glWidget->getDeviceHeight();
glm::vec3 mouseRayOrigin;
glm::vec3 mouseRayDirection;
application->getViewFrustum()->computePickRay(mouseX, mouseY, mouseRayOrigin, mouseRayDirection);

View file

@ -56,8 +56,8 @@ Stats::Stats():
_metavoxelReceiveProgress(0),
_metavoxelReceiveTotal(0)
{
QGLWidget* glWidget = Application::getInstance()->getGLWidget();
resetWidth(glWidget->width(), 0);
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
resetWidth(glWidget->getDeviceWidth(), 0);
}
void Stats::toggleExpanded() {
@ -67,7 +67,7 @@ void Stats::toggleExpanded() {
// called on mouse click release
// check for clicks over stats in order to expand or contract them
void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset) {
QGLWidget* glWidget = Application::getInstance()->getGLWidget();
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
if (0 != glm::compMax(glm::abs(glm::ivec2(mouseX - mouseDragStartedX, mouseY - mouseDragStartedY)))) {
// not worried about dragging on stats
@ -114,7 +114,7 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD
// top-right stats click
lines = _expanded ? 11 : 3;
statsHeight = lines * STATS_PELS_PER_LINE + 10;
statsWidth = glWidget->width() - statsX;
statsWidth = glWidget->getDeviceWidth() - statsX;
if (mouseX > statsX && mouseX < statsX + statsWidth && mouseY > statsY && mouseY < statsY + statsHeight) {
toggleExpanded();
return;
@ -122,8 +122,8 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD
}
void Stats::resetWidth(int width, int horizontalOffset) {
QGLWidget* glWidget = Application::getInstance()->getGLWidget();
int extraSpace = glWidget->width() - horizontalOffset -2
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
int extraSpace = glWidget->getDeviceWidth() - horizontalOffset -2
- STATS_GENERAL_MIN_WIDTH
- (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0)
- STATS_GEO_MIN_WIDTH
@ -147,7 +147,7 @@ void Stats::resetWidth(int width, int horizontalOffset) {
_pingStatsWidth += (int) extraSpace / panels;
}
_geoStatsWidth += (int) extraSpace / panels;
_voxelStatsWidth += glWidget->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3);
_voxelStatsWidth += glWidget->getDeviceWidth() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3);
}
}
@ -198,7 +198,7 @@ void Stats::display(
int bytesPerSecond,
int voxelPacketsToProcess)
{
QGLWidget* glWidget = Application::getInstance()->getGLWidget();
GLCanvas* glWidget = Application::getInstance()->getGLWidget();
unsigned int backgroundColor = 0x33333399;
int verticalOffset = 0, lines = 0;
@ -210,7 +210,7 @@ void Stats::display(
std::stringstream voxelStats;
if (_lastHorizontalOffset != horizontalOffset) {
resetWidth(glWidget->width(), horizontalOffset);
resetWidth(glWidget->getDeviceWidth(), horizontalOffset);
_lastHorizontalOffset = horizontalOffset;
}
@ -410,7 +410,8 @@ void Stats::display(
}
}
drawBackground(backgroundColor, horizontalOffset, 0, glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10);
drawBackground(backgroundColor, horizontalOffset, 0, glWidget->getDeviceWidth() - horizontalOffset,
lines * STATS_PELS_PER_LINE + 10);
horizontalOffset += 5;
if (_expanded) {