mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:56:54 +02:00
commit
91ffb003fd
7 changed files with 69 additions and 23 deletions
|
@ -360,6 +360,8 @@ Rectangle {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'showPreviewTextureNotInstructions':
|
case 'showPreviewTextureNotInstructions':
|
||||||
|
console.log('showPreviewTextureNotInstructions recvd', JSON.stringify(message));
|
||||||
|
spectatorCameraPreview.url = message.url;
|
||||||
spectatorCameraPreview.visible = message.setting;
|
spectatorCameraPreview.visible = message.setting;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -497,16 +497,26 @@ void OpenGLDisplayPlugin::submitFrame(const gpu::FramePointer& newFrame) {
|
||||||
_newFrameQueue.push(newFrame);
|
_newFrameQueue.push(newFrame);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer texture, glm::ivec4 viewport, const glm::ivec4 scissor) {
|
void OpenGLDisplayPlugin::renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer texture, glm::ivec4 viewport, const glm::ivec4 scissor) {
|
||||||
|
renderFromTexture(batch, texture, viewport, scissor, gpu::FramebufferPointer());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLDisplayPlugin::renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer texture, glm::ivec4 viewport, const glm::ivec4 scissor, gpu::FramebufferPointer copyFbo /*=gpu::FramebufferPointer()*/) {
|
||||||
|
auto fbo = gpu::FramebufferPointer();
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.resetViewTransform();
|
batch.resetViewTransform();
|
||||||
batch.setFramebuffer(gpu::FramebufferPointer());
|
batch.setFramebuffer(fbo);
|
||||||
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(0));
|
batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, vec4(0));
|
||||||
batch.setStateScissorRect(scissor);
|
batch.setStateScissorRect(scissor);
|
||||||
batch.setViewportTransform(viewport);
|
batch.setViewportTransform(viewport);
|
||||||
batch.setResourceTexture(0, texture);
|
batch.setResourceTexture(0, texture);
|
||||||
batch.setPipeline(_presentPipeline);
|
batch.setPipeline(_presentPipeline);
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
if (copyFbo) {
|
||||||
|
gpu::Vec4i rect {0, 0, scissor.z, scissor.w};
|
||||||
|
batch.blit(fbo, rect, copyFbo, rect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::updateFrameData() {
|
void OpenGLDisplayPlugin::updateFrameData() {
|
||||||
|
|
|
@ -113,6 +113,7 @@ protected:
|
||||||
// Plugin specific functionality to send the composed scene to the output window or device
|
// Plugin specific functionality to send the composed scene to the output window or device
|
||||||
virtual void internalPresent();
|
virtual void internalPresent();
|
||||||
|
|
||||||
|
void renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer texture, glm::ivec4 viewport, const glm::ivec4 scissor, gpu::FramebufferPointer fbo);
|
||||||
void renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer texture, glm::ivec4 viewport, const glm::ivec4 scissor);
|
void renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer texture, glm::ivec4 viewport, const glm::ivec4 scissor);
|
||||||
virtual void updateFrameData();
|
virtual void updateFrameData();
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,6 @@ void HmdDisplayPlugin::internalPresent() {
|
||||||
|
|
||||||
glm::ivec4 viewport = getViewportForSourceSize(sourceSize);
|
glm::ivec4 viewport = getViewportForSourceSize(sourceSize);
|
||||||
glm::ivec4 scissor = viewport;
|
glm::ivec4 scissor = viewport;
|
||||||
|
|
||||||
render([&](gpu::Batch& batch) {
|
render([&](gpu::Batch& batch) {
|
||||||
|
|
||||||
if (_monoPreview) {
|
if (_monoPreview) {
|
||||||
|
@ -287,9 +286,11 @@ void HmdDisplayPlugin::internalPresent() {
|
||||||
|
|
||||||
viewport.z *= 2;
|
viewport.z *= 2;
|
||||||
}
|
}
|
||||||
renderFromTexture(batch, _compositeFramebuffer->getRenderBuffer(0), viewport, scissor);
|
auto fbo = DependencyManager::get<TextureCache>()->getHmdPreviewFramebuffer();
|
||||||
|
renderFromTexture(batch, _compositeFramebuffer->getRenderBuffer(0), viewport, scissor, fbo);
|
||||||
});
|
});
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
|
|
||||||
} else if (_clearPreviewFlag) {
|
} else if (_clearPreviewFlag) {
|
||||||
QImage image;
|
QImage image;
|
||||||
if (_vsyncEnabled) {
|
if (_vsyncEnabled) {
|
||||||
|
|
|
@ -54,6 +54,7 @@ const std::string TextureCache::KTX_EXT { "ktx" };
|
||||||
|
|
||||||
static const QString RESOURCE_SCHEME = "resource";
|
static const QString RESOURCE_SCHEME = "resource";
|
||||||
static const QUrl SPECTATOR_CAMERA_FRAME_URL("resource://spectatorCameraFrame");
|
static const QUrl SPECTATOR_CAMERA_FRAME_URL("resource://spectatorCameraFrame");
|
||||||
|
static const QUrl HMD_PREVIEW_FRAME_URL("resource://hmdPreviewFrame");
|
||||||
|
|
||||||
static const float SKYBOX_LOAD_PRIORITY { 10.0f }; // Make sure skybox loads first
|
static const float SKYBOX_LOAD_PRIORITY { 10.0f }; // Make sure skybox loads first
|
||||||
static const float HIGH_MIPS_LOAD_PRIORITY { 9.0f }; // Make sure high mips loads after skybox but before models
|
static const float HIGH_MIPS_LOAD_PRIORITY { 9.0f }; // Make sure high mips loads after skybox but before models
|
||||||
|
@ -969,7 +970,6 @@ void ImageReader::read() {
|
||||||
Q_ARG(int, texture->getHeight()));
|
Q_ARG(int, texture->getHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl) {
|
NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl) {
|
||||||
gpu::TexturePointer texture;
|
gpu::TexturePointer texture;
|
||||||
if (resourceTextureUrl == SPECTATOR_CAMERA_FRAME_URL) {
|
if (resourceTextureUrl == SPECTATOR_CAMERA_FRAME_URL) {
|
||||||
|
@ -984,10 +984,30 @@ NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// FIXME: Generalize this, DRY up this code
|
||||||
|
if (resourceTextureUrl == HMD_PREVIEW_FRAME_URL) {
|
||||||
|
if (!_hmdPreviewNetworkTexture) {
|
||||||
|
_hmdPreviewNetworkTexture.reset(new NetworkTexture(resourceTextureUrl));
|
||||||
|
}
|
||||||
|
if (_hmdPreviewFramebuffer) {
|
||||||
|
texture = _hmdPreviewFramebuffer->getRenderBuffer(0);
|
||||||
|
if (texture) {
|
||||||
|
_hmdPreviewNetworkTexture->setImage(texture, texture->getWidth(), texture->getHeight());
|
||||||
|
return _hmdPreviewNetworkTexture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NetworkTexturePointer();
|
return NetworkTexturePointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gpu::FramebufferPointer& TextureCache::getHmdPreviewFramebuffer() {
|
||||||
|
if (!_hmdPreviewFramebuffer) {
|
||||||
|
_hmdPreviewFramebuffer.reset(gpu::Framebuffer::create("hmdPreview",gpu::Element::COLOR_SRGBA_32, 2040, 1024));
|
||||||
|
}
|
||||||
|
return _hmdPreviewFramebuffer;
|
||||||
|
}
|
||||||
|
|
||||||
const gpu::FramebufferPointer& TextureCache::getSpectatorCameraFramebuffer() {
|
const gpu::FramebufferPointer& TextureCache::getSpectatorCameraFramebuffer() {
|
||||||
if (!_spectatorCameraFramebuffer) {
|
if (!_spectatorCameraFramebuffer) {
|
||||||
resetSpectatorCameraFramebuffer(2048, 1024);
|
resetSpectatorCameraFramebuffer(2048, 1024);
|
||||||
|
|
|
@ -170,6 +170,7 @@ public:
|
||||||
NetworkTexturePointer getResourceTexture(QUrl resourceTextureUrl);
|
NetworkTexturePointer getResourceTexture(QUrl resourceTextureUrl);
|
||||||
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer();
|
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer();
|
||||||
void resetSpectatorCameraFramebuffer(int width, int height);
|
void resetSpectatorCameraFramebuffer(int width, int height);
|
||||||
|
const gpu::FramebufferPointer& getHmdPreviewFramebuffer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overload ResourceCache::prefetch to allow specifying texture type for loads
|
// Overload ResourceCache::prefetch to allow specifying texture type for loads
|
||||||
|
@ -202,6 +203,9 @@ private:
|
||||||
|
|
||||||
NetworkTexturePointer _spectatorCameraNetworkTexture;
|
NetworkTexturePointer _spectatorCameraNetworkTexture;
|
||||||
gpu::FramebufferPointer _spectatorCameraFramebuffer;
|
gpu::FramebufferPointer _spectatorCameraFramebuffer;
|
||||||
|
|
||||||
|
NetworkTexturePointer _hmdPreviewNetworkTexture;
|
||||||
|
gpu::FramebufferPointer _hmdPreviewFramebuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_TextureCache_h
|
#endif // hifi_TextureCache_h
|
||||||
|
|
|
@ -218,10 +218,18 @@
|
||||||
// 3. Camera is on; "Monitor Shows" is "HMD Preview": "url" is ""
|
// 3. Camera is on; "Monitor Shows" is "HMD Preview": "url" is ""
|
||||||
// 4. Camera is on; "Monitor Shows" is "Camera View": "url" is "resource://spectatorCameraFrame"
|
// 4. Camera is on; "Monitor Shows" is "Camera View": "url" is "resource://spectatorCameraFrame"
|
||||||
function setDisplay(showCameraView) {
|
function setDisplay(showCameraView) {
|
||||||
var url = (camera && showCameraView) ? "resource://spectatorCameraFrame" : "";
|
|
||||||
sendToQml({ method: 'showPreviewTextureNotInstructions', setting: !!url });
|
var url = (camera) ? (showCameraView ? "resource://spectatorCameraFrame" : "resource://hmdPreviewFrame") : "";
|
||||||
|
sendToQml({ method: 'showPreviewTextureNotInstructions', setting: !!url, url: url});
|
||||||
|
|
||||||
|
// FIXME: temporary hack to avoid setting the display texture to hmdPreviewFrame
|
||||||
|
// until it is the correct mono.
|
||||||
|
if (url === "resource://hmdPreviewFrame") {
|
||||||
|
Window.setDisplayTexture("");
|
||||||
|
} else {
|
||||||
Window.setDisplayTexture(url);
|
Window.setDisplayTexture(url);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const MONITOR_SHOWS_CAMERA_VIEW_DEFAULT = false;
|
const MONITOR_SHOWS_CAMERA_VIEW_DEFAULT = false;
|
||||||
var monitorShowsCameraView = !!Settings.getValue('spectatorCamera/monitorShowsCameraView', MONITOR_SHOWS_CAMERA_VIEW_DEFAULT);
|
var monitorShowsCameraView = !!Settings.getValue('spectatorCamera/monitorShowsCameraView', MONITOR_SHOWS_CAMERA_VIEW_DEFAULT);
|
||||||
function setMonitorShowsCameraView(showCameraView) {
|
function setMonitorShowsCameraView(showCameraView) {
|
||||||
|
|
Loading…
Reference in a new issue