mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
aspect ratio preserved upon blitting, minor qml tweak, warnings fixed
This commit is contained in:
parent
5f015ec77f
commit
373bd0cc8a
3 changed files with 21 additions and 4 deletions
|
@ -242,7 +242,7 @@ Rectangle {
|
|||
size: 32;
|
||||
color: hifi.colors.blueHighlight;
|
||||
anchors.top: spectatorCameraPreview.bottom;
|
||||
anchors.topMargin: 12;
|
||||
anchors.topMargin: 20;
|
||||
anchors.left: parent.left;
|
||||
}
|
||||
// "Monitor Shows" Switch Label
|
||||
|
|
|
@ -841,14 +841,31 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, fbo[0]);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sourceTexture, 0);
|
||||
qDebug() << "error" << glGetError();
|
||||
GLint texWidth, texHeight;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &texWidth);
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &texHeight);
|
||||
|
||||
// setup destination fbo
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo[1]);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTexture, 0);
|
||||
qDebug() << "error" << glGetError();
|
||||
|
||||
// TODO: perhaps maintain aspect ratio
|
||||
glBlitNamedFramebuffer(fbo[0], fbo[1], 0, 0, networkTexture->getWidth(), networkTexture->getHeight(), 0, 0, target->width(), target->height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
// maintain aspect ratio, filling the width first if possible. If that makes the height too
|
||||
// much, fill height instead.
|
||||
GLint newX = 0;
|
||||
GLint newY = 0;
|
||||
float aspectRatio = (float)texHeight / (float)texWidth;
|
||||
GLint newWidth = target->width();
|
||||
GLint newHeight = std::round(aspectRatio * (float) target->width());
|
||||
if (newHeight > target->height()) {
|
||||
newHeight = target->height();
|
||||
newWidth = std::round((float)target->height() / aspectRatio);
|
||||
newX = (target->width() - newWidth) / 2;
|
||||
} else {
|
||||
newY = (target->height() - newHeight) / 2;
|
||||
}
|
||||
glBlitNamedFramebuffer(fbo[0], fbo[1], 0, 0, texWidth, texHeight, newX, newY, newWidth, newHeight, GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
qDebug() << "error" << glGetError();
|
||||
|
||||
// don't delete the textures!
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
// Three threads, one for rendering, one for texture transfers, one reserved for the GL driver
|
||||
int getRequiredThreadCount() const override { return 3; }
|
||||
|
||||
void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target, GLsync* fenceSync);
|
||||
void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target, GLsync* fenceSync) override;
|
||||
|
||||
protected:
|
||||
friend class PresentThread;
|
||||
|
|
Loading…
Reference in a new issue