mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 14:53:01 +02:00
Merge branch 'ice-troubles' of github.com:sethalves/hifi into ice-troubles-1
This commit is contained in:
commit
7dc8a48dba
5 changed files with 99 additions and 9 deletions
|
@ -175,7 +175,7 @@ void DomainServer::parseCommandLine() {
|
||||||
parser.addOption(domainIDOption);
|
parser.addOption(domainIDOption);
|
||||||
|
|
||||||
if (!parser.parse(QCoreApplication::arguments())) {
|
if (!parser.parse(QCoreApplication::arguments())) {
|
||||||
qCritical() << parser.errorText() << endl;
|
qWarning() << parser.errorText() << endl;
|
||||||
parser.showHelp();
|
parser.showHelp();
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ void DomainServer::parseCommandLine() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_iceServerAddr.isEmpty()) {
|
if (_iceServerAddr.isEmpty()) {
|
||||||
qCritical() << "Could not parse an IP address and port combination from" << hostnamePortString;
|
qWarning() << "Could not parse an IP address and port combination from" << hostnamePortString;
|
||||||
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ DomainServer::~DomainServer() {
|
||||||
|
|
||||||
void DomainServer::queuedQuit(QString quitMessage, int exitCode) {
|
void DomainServer::queuedQuit(QString quitMessage, int exitCode) {
|
||||||
if (!quitMessage.isEmpty()) {
|
if (!quitMessage.isEmpty()) {
|
||||||
qCritical() << qPrintable(quitMessage);
|
qWarning() << qPrintable(quitMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
QCoreApplication::exit(exitCode);
|
QCoreApplication::exit(exitCode);
|
||||||
|
|
BIN
interface/resources/images/preview-disabled.png
Normal file
BIN
interface/resources/images/preview-disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
Binary file not shown.
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 59 KiB |
|
@ -88,6 +88,7 @@ bool HmdDisplayPlugin::internalActivate() {
|
||||||
_monoPreview = clicked;
|
_monoPreview = clicked;
|
||||||
_container->setBoolSetting("monoPreview", _monoPreview);
|
_container->setBoolSetting("monoPreview", _monoPreview);
|
||||||
}, true, _monoPreview);
|
}, true, _monoPreview);
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
_disablePreview = true;
|
_disablePreview = true;
|
||||||
#else
|
#else
|
||||||
|
@ -137,6 +138,7 @@ ivec4 HmdDisplayPlugin::getViewportForSourceSize(const uvec2& size) const {
|
||||||
float windowAspect = aspect(windowSize);
|
float windowAspect = aspect(windowSize);
|
||||||
float sceneAspect = aspect(size);
|
float sceneAspect = aspect(size);
|
||||||
float aspectRatio = sceneAspect / windowAspect;
|
float aspectRatio = sceneAspect / windowAspect;
|
||||||
|
|
||||||
uvec2 targetViewportSize = windowSize;
|
uvec2 targetViewportSize = windowSize;
|
||||||
if (aspectRatio < 1.0f) {
|
if (aspectRatio < 1.0f) {
|
||||||
targetViewportSize.x *= aspectRatio;
|
targetViewportSize.x *= aspectRatio;
|
||||||
|
@ -152,6 +154,23 @@ ivec4 HmdDisplayPlugin::getViewportForSourceSize(const uvec2& size) const {
|
||||||
return ivec4(targetViewportPosition, targetViewportSize);
|
return ivec4(targetViewportPosition, targetViewportSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float HmdDisplayPlugin::getLeftCenterPixel() const {
|
||||||
|
glm::mat4 eyeProjection = _eyeProjections[Left];
|
||||||
|
glm::mat4 inverseEyeProjection = glm::inverse(eyeProjection);
|
||||||
|
vec2 eyeRenderTargetSize = { _renderTargetSize.x / 2, _renderTargetSize.y };
|
||||||
|
|
||||||
|
vec4 left = vec4(-1, 0, -1, 1);
|
||||||
|
vec4 right = vec4(1, 0, -1, 1);
|
||||||
|
vec4 right2 = inverseEyeProjection * right;
|
||||||
|
vec4 left2 = inverseEyeProjection * left;
|
||||||
|
left2 /= left2.w;
|
||||||
|
right2 /= right2.w;
|
||||||
|
float width = -left2.x + right2.x;
|
||||||
|
float leftBias = -left2.x / width;
|
||||||
|
float leftCenterPixel = eyeRenderTargetSize.x * leftBias;
|
||||||
|
return leftCenterPixel;
|
||||||
|
}
|
||||||
|
|
||||||
void HmdDisplayPlugin::internalPresent() {
|
void HmdDisplayPlugin::internalPresent() {
|
||||||
PROFILE_RANGE_EX(__FUNCTION__, 0xff00ff00, (uint64_t)presentCount())
|
PROFILE_RANGE_EX(__FUNCTION__, 0xff00ff00, (uint64_t)presentCount())
|
||||||
|
|
||||||
|
@ -164,16 +183,67 @@ void HmdDisplayPlugin::internalPresent() {
|
||||||
if (_monoPreview) {
|
if (_monoPreview) {
|
||||||
sourceSize.x >>= 1;
|
sourceSize.x >>= 1;
|
||||||
}
|
}
|
||||||
auto viewport = getViewportForSourceSize(sourceSize);
|
|
||||||
|
float shiftLeftBy = getLeftCenterPixel() - (sourceSize.x / 2);
|
||||||
|
float newWidth = sourceSize.x - shiftLeftBy;
|
||||||
|
|
||||||
|
const unsigned int RATIO_Y = 9;
|
||||||
|
const unsigned int RATIO_X = 16;
|
||||||
|
glm::uvec2 originalClippedSize { newWidth, newWidth * RATIO_Y / RATIO_X };
|
||||||
|
|
||||||
|
glm::ivec4 viewport = getViewportForSourceSize(sourceSize);
|
||||||
|
glm::ivec4 scissor = viewport;
|
||||||
|
|
||||||
render([&](gpu::Batch& batch) {
|
render([&](gpu::Batch& batch) {
|
||||||
|
|
||||||
|
if (_monoPreview) {
|
||||||
|
auto window = _container->getPrimaryWidget();
|
||||||
|
float devicePixelRatio = window->devicePixelRatio();
|
||||||
|
glm::vec2 windowSize = toGlm(window->size());
|
||||||
|
windowSize *= devicePixelRatio;
|
||||||
|
|
||||||
|
float windowAspect = aspect(windowSize); // example: 1920 x 1080 = 1.78
|
||||||
|
float sceneAspect = aspect(originalClippedSize); // usually: 1512 x 850 = 1.78
|
||||||
|
|
||||||
|
|
||||||
|
bool scaleToWidth = windowAspect < sceneAspect;
|
||||||
|
|
||||||
|
float ratio;
|
||||||
|
int scissorOffset;
|
||||||
|
|
||||||
|
if (scaleToWidth) {
|
||||||
|
ratio = (float)windowSize.x / (float)newWidth;
|
||||||
|
} else {
|
||||||
|
ratio = (float)windowSize.y / (float)originalClippedSize.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
float scaledShiftLeftBy = shiftLeftBy * ratio;
|
||||||
|
|
||||||
|
int scissorSizeX = originalClippedSize.x * ratio;
|
||||||
|
int scissorSizeY = originalClippedSize.y * ratio;
|
||||||
|
|
||||||
|
int viewportSizeX = sourceSize.x * ratio;
|
||||||
|
int viewportSizeY = sourceSize.y * ratio;
|
||||||
|
int viewportOffset = ((int)windowSize.y - viewportSizeY) / 2;
|
||||||
|
|
||||||
|
if (scaleToWidth) {
|
||||||
|
scissorOffset = ((int)windowSize.y - scissorSizeY) / 2;
|
||||||
|
scissor = ivec4(0, scissorOffset, scissorSizeX, scissorSizeY);
|
||||||
|
viewport = ivec4(-scaledShiftLeftBy, viewportOffset, viewportSizeX, viewportSizeY);
|
||||||
|
} else {
|
||||||
|
scissorOffset = ((int)windowSize.x - scissorSizeX) / 2;
|
||||||
|
scissor = ivec4(scissorOffset, 0, scissorSizeX, scissorSizeY);
|
||||||
|
viewport = ivec4(scissorOffset - scaledShiftLeftBy, viewportOffset, viewportSizeX, viewportSizeY);
|
||||||
|
}
|
||||||
|
|
||||||
|
viewport.z *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.resetViewTransform();
|
batch.resetViewTransform();
|
||||||
batch.setFramebuffer(gpu::FramebufferPointer());
|
batch.setFramebuffer(gpu::FramebufferPointer());
|
||||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(0));
|
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(0));
|
||||||
batch.setStateScissorRect(viewport);
|
batch.setStateScissorRect(scissor); // was viewport
|
||||||
if (_monoPreview) {
|
|
||||||
viewport.z *= 2;
|
|
||||||
}
|
|
||||||
batch.setViewportTransform(viewport);
|
batch.setViewportTransform(viewport);
|
||||||
batch.setResourceTexture(0, _compositeFramebuffer->getRenderBuffer(0));
|
batch.setResourceTexture(0, _compositeFramebuffer->getRenderBuffer(0));
|
||||||
batch.setPipeline(_presentPipeline);
|
batch.setPipeline(_presentPipeline);
|
||||||
|
@ -181,7 +251,13 @@ void HmdDisplayPlugin::internalPresent() {
|
||||||
});
|
});
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
} else if (_clearPreviewFlag) {
|
} else if (_clearPreviewFlag) {
|
||||||
auto image = QImage(PathUtils::resourcesPath() + "images/preview.png");
|
QImage image;
|
||||||
|
if (_vsyncEnabled) {
|
||||||
|
image = QImage(PathUtils::resourcesPath() + "images/preview.png");
|
||||||
|
} else {
|
||||||
|
image = QImage(PathUtils::resourcesPath() + "images/preview-disabled.png");
|
||||||
|
}
|
||||||
|
|
||||||
image = image.mirrored();
|
image = image.mirrored();
|
||||||
image = image.convertToFormat(QImage::Format_RGBA8888);
|
image = image.convertToFormat(QImage::Format_RGBA8888);
|
||||||
if (!_previewTexture) {
|
if (!_previewTexture) {
|
||||||
|
@ -197,6 +273,7 @@ void HmdDisplayPlugin::internalPresent() {
|
||||||
|
|
||||||
if (getGLBackend()->isTextureReady(_previewTexture)) {
|
if (getGLBackend()->isTextureReady(_previewTexture)) {
|
||||||
auto viewport = getViewportForSourceSize(uvec2(_previewTexture->getDimensions()));
|
auto viewport = getViewportForSourceSize(uvec2(_previewTexture->getDimensions()));
|
||||||
|
|
||||||
render([&](gpu::Batch& batch) {
|
render([&](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.resetViewTransform();
|
batch.resetViewTransform();
|
||||||
|
@ -213,6 +290,17 @@ void HmdDisplayPlugin::internalPresent() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
postPreview();
|
postPreview();
|
||||||
|
|
||||||
|
// If preview is disabled, we need to check to see if the window size has changed
|
||||||
|
// and re-render the no-preview message
|
||||||
|
if (_disablePreview) {
|
||||||
|
auto window = _container->getPrimaryWidget();
|
||||||
|
glm::vec2 windowSize = toGlm(window->size());
|
||||||
|
if (windowSize != _lastWindowSize) {
|
||||||
|
_clearPreviewFlag = true;
|
||||||
|
_lastWindowSize = windowSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HMD specific stuff
|
// HMD specific stuff
|
||||||
|
|
|
@ -102,11 +102,13 @@ protected:
|
||||||
bool _disablePreview{ true };
|
bool _disablePreview{ true };
|
||||||
private:
|
private:
|
||||||
ivec4 getViewportForSourceSize(const uvec2& size) const;
|
ivec4 getViewportForSourceSize(const uvec2& size) const;
|
||||||
|
float getLeftCenterPixel() const;
|
||||||
|
|
||||||
bool _disablePreviewItemAdded { false };
|
bool _disablePreviewItemAdded { false };
|
||||||
bool _monoPreview { true };
|
bool _monoPreview { true };
|
||||||
bool _clearPreviewFlag { false };
|
bool _clearPreviewFlag { false };
|
||||||
gpu::TexturePointer _previewTexture;
|
gpu::TexturePointer _previewTexture;
|
||||||
|
glm::vec2 _lastWindowSize;
|
||||||
|
|
||||||
struct OverlayRenderer {
|
struct OverlayRenderer {
|
||||||
gpu::Stream::FormatPointer format;
|
gpu::Stream::FormatPointer format;
|
||||||
|
|
Loading…
Reference in a new issue