minor cleanup, and adjusted includes per austin's suggestion

This commit is contained in:
David Kelly 2017-07-03 15:54:54 -07:00
parent 99bf100ff8
commit 2a3b4b3bfb
3 changed files with 5 additions and 10 deletions

View file

@ -8,7 +8,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "Application.h"
//#include "Application.h"
#include "ResourceImageItem.h"
#include <QOpenGLFramebufferObjectFormat>
@ -16,7 +16,6 @@
#include <QOpenGLExtraFunctions>
#include <QOpenGLContext>
#include <DependencyManager.h>
void ResourceImageItem::setUrl(const QString& url) {
if (url != m_url) {
@ -42,7 +41,6 @@ void ResourceImageItemRenderer::onUpdateTimer() {
qDebug() << "couldn't get a lock, using last frame";
}
}
update();
}

View file

@ -12,6 +12,8 @@
#ifndef hifi_ResourceImageItem_h
#define hifi_ResourceImageItem_h
#include "Application.h"
#include <QQuickFramebufferObject>
#include <QQuickWindow>
#include <QTimer>

View file

@ -829,18 +829,16 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne
GLuint sourceTexture = glBackend->getTextureID(networkTexture->getGPUTexture());
GLuint targetTexture = target->texture();
GLuint fbo[2] {0, 0};
qDebug() << "initial" << glGetError();
// need mipmaps for blitting texture
glGenerateTextureMipmap(sourceTexture);
// create 2 fbos (one for initial texture, second for scaled one)
glCreateFramebuffers(2, fbo);
qDebug() << "error" << glGetError();
// setup source fbo
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);
@ -848,11 +846,10 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne
// setup destination fbo
glBindFramebuffer(GL_FRAMEBUFFER, fbo[1]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTexture, 0);
qDebug() << "error" << glGetError();
// maintain aspect ratio, filling the width first if possible. If that makes the height too
// much, fill height instead.
// much, fill height instead. TODO: only do this when texture changes
GLint newX = 0;
GLint newY = 0;
float aspectRatio = (float)texHeight / (float)texWidth;
@ -866,11 +863,9 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne
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!
glDeleteFramebuffers(2, fbo);
qDebug() << "error" << glGetError();
*fenceSync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
});
}