fix hmd preview

This commit is contained in:
David Kelly 2017-07-11 10:54:35 -07:00
parent 78d12f27ed
commit e1df3feb5c
4 changed files with 16 additions and 9 deletions

View file

@ -514,8 +514,14 @@ void OpenGLDisplayPlugin::renderFromTexture(gpu::Batch& batch, const gpu::Textur
batch.setPipeline(_presentPipeline);
batch.draw(gpu::TRIANGLE_STRIP, 4);
if (copyFbo) {
gpu::Vec4i rect {0, 0, scissor.z, scissor.w};
batch.blit(fbo, rect, copyFbo, rect);
gpu::Vec4i sourceRect(scissor.x, scissor.y, scissor.x + scissor.z, scissor.y + scissor.w);
gpu::Vec4i copyRect(0, 0, copyFbo->getWidth(), copyFbo->getHeight());
batch.setFramebuffer(copyFbo);
batch.resetViewTransform();
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(0));
batch.setViewportTransform(copyRect);
batch.setStateScissorRect(copyRect);
batch.blit(fbo, sourceRect, copyFbo, copyRect);
}
}
@ -849,9 +855,9 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne
// setup source fbo
glBindFramebuffer(GL_FRAMEBUFFER, fbo[0]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sourceTexture, 0);
GLint texWidth, texHeight;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &texWidth);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &texHeight);
GLint texWidth = networkTexture->getWidth();
GLint texHeight = networkTexture->getHeight();
// setup destination fbo
glBindFramebuffer(GL_FRAMEBUFFER, fbo[1]);

View file

@ -286,7 +286,8 @@ void HmdDisplayPlugin::internalPresent() {
viewport.z *= 2;
}
auto fbo = DependencyManager::get<TextureCache>()->getHmdPreviewFramebuffer();
// TODO: only bother getting and passing in the hmdPreviewFramebuffer if the camera is on
auto fbo = DependencyManager::get<TextureCache>()->getHmdPreviewFramebuffer(scissor.z, scissor.w);
renderFromTexture(batch, _compositeFramebuffer->getRenderBuffer(0), viewport, scissor, fbo);
});
swapBuffers();

View file

@ -1001,9 +1001,9 @@ NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl)
return NetworkTexturePointer();
}
const gpu::FramebufferPointer& TextureCache::getHmdPreviewFramebuffer() {
const gpu::FramebufferPointer& TextureCache::getHmdPreviewFramebuffer(int width, int height) {
if (!_hmdPreviewFramebuffer) {
_hmdPreviewFramebuffer.reset(gpu::Framebuffer::create("hmdPreview",gpu::Element::COLOR_SRGBA_32, 2040, 1024));
_hmdPreviewFramebuffer.reset(gpu::Framebuffer::create("hmdPreview",gpu::Element::COLOR_SRGBA_32, width, height));
}
return _hmdPreviewFramebuffer;
}

View file

@ -170,7 +170,7 @@ public:
NetworkTexturePointer getResourceTexture(QUrl resourceTextureUrl);
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer();
void resetSpectatorCameraFramebuffer(int width, int height);
const gpu::FramebufferPointer& getHmdPreviewFramebuffer();
const gpu::FramebufferPointer& getHmdPreviewFramebuffer(int width, int height);
protected:
// Overload ResourceCache::prefetch to allow specifying texture type for loads