mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 10:02:24 +02:00
Allow movement in frameplayer app
This commit is contained in:
parent
2446080a23
commit
ab9a4a55f8
3 changed files with 59 additions and 9 deletions
|
@ -64,11 +64,37 @@ void PlayerWindow::loadFrame() {
|
|||
}
|
||||
|
||||
void PlayerWindow::keyPressEvent(QKeyEvent* event) {
|
||||
bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);
|
||||
float moveScale = isShifted ? 10.0f : 1.0f;
|
||||
switch (event->key()) {
|
||||
case Qt::Key_F1:
|
||||
loadFrame();
|
||||
return;
|
||||
|
||||
case Qt::Key_W:
|
||||
_renderThread.move(vec3{ 0, 0, -0.1f } * moveScale);
|
||||
return;
|
||||
|
||||
case Qt::Key_S:
|
||||
_renderThread.move(vec3{ 0, 0, 0.1f } * moveScale);
|
||||
return;
|
||||
|
||||
case Qt::Key_A:
|
||||
_renderThread.move(vec3{ -0.1f, 0, 0 } * moveScale);
|
||||
return;
|
||||
|
||||
case Qt::Key_D:
|
||||
_renderThread.move(vec3{ 0.1f, 0, 0 } * moveScale);
|
||||
return;
|
||||
|
||||
case Qt::Key_E:
|
||||
_renderThread.move(vec3{ 0, 0.1f, 0 } * moveScale);
|
||||
return;
|
||||
|
||||
case Qt::Key_F:
|
||||
_renderThread.move(vec3{ 0, -0.1f, 0 } * moveScale);
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -106,5 +132,4 @@ void PlayerWindow::loadFrame(const QString& path) {
|
|||
}
|
||||
resize(size.x, size.y);
|
||||
}
|
||||
_renderThread.submitFrame(frame);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,11 @@ void RenderThread::resize(const QSize& newSize) {
|
|||
_pendingSize.push(newSize);
|
||||
}
|
||||
|
||||
void RenderThread::move(const glm::vec3& v) {
|
||||
std::unique_lock<std::mutex> lock(_frameLock);
|
||||
_correction = glm::inverse(glm::translate(mat4(), v)) * _correction;
|
||||
}
|
||||
|
||||
void RenderThread::initialize(QWindow* window) {
|
||||
std::unique_lock<std::mutex> lock(_frameLock);
|
||||
setObjectName("RenderThread");
|
||||
|
@ -105,6 +110,13 @@ void RenderThread::renderFrame(gpu::FramePointer& frame) {
|
|||
#ifdef USE_GL
|
||||
_context.makeCurrent();
|
||||
#endif
|
||||
if (_correction != glm::mat4()) {
|
||||
std::unique_lock<std::mutex> lock(_frameLock);
|
||||
if (_correction != glm::mat4()) {
|
||||
_backend->setCameraCorrection(_correction, _activeFrame->view);
|
||||
//_prevRenderView = _correction * _activeFrame->view;
|
||||
}
|
||||
}
|
||||
_backend->recycle();
|
||||
_backend->syncCache();
|
||||
|
||||
|
@ -139,18 +151,29 @@ void RenderThread::renderFrame(gpu::FramePointer& frame) {
|
|||
using namespace vks::debug::marker;
|
||||
beginRegion(commandBuffer, "executeFrame", glm::vec4{ 1, 1, 1, 1 });
|
||||
#endif
|
||||
auto& glbackend = (gpu::gl::GLBackend&)(*_backend);
|
||||
glm::uvec2 fboSize{ frame->framebuffer->getWidth(), frame->framebuffer->getHeight() };
|
||||
auto fbo = glbackend.getFramebufferID(frame->framebuffer);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
|
||||
glClearColor(0, 0, 0, 1);
|
||||
glClearDepth(0);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
//_gpuContext->enableStereo(true);
|
||||
if (frame && !frame->batches.empty()) {
|
||||
_gpuContext->executeFrame(frame);
|
||||
}
|
||||
|
||||
#ifdef USE_GL
|
||||
auto& glbackend = (gpu::gl::GLBackend&)(*_backend);
|
||||
glm::uvec2 fboSize{ frame->framebuffer->getWidth(), frame->framebuffer->getHeight() };
|
||||
auto fbo = glbackend.getFramebufferID(frame->framebuffer);
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
glBlitNamedFramebuffer(fbo, 0, 0, 0, fboSize.x, fboSize.y, 0, 0, windowSize.width(), windowSize.height(),
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
//glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glBlitFramebuffer(
|
||||
0, 0, fboSize.x, fboSize.y,
|
||||
0, 0, windowSize.width(), windowSize.height(),
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
(void)CHECK_GL_ERROR();
|
||||
_context.swapBuffers();
|
||||
|
@ -183,11 +206,11 @@ bool RenderThread::process() {
|
|||
pendingFrames.swap(_pendingFrames);
|
||||
pendingSize.swap(_pendingSize);
|
||||
}
|
||||
|
||||
|
||||
while (!pendingFrames.empty()) {
|
||||
_activeFrame = pendingFrames.front();
|
||||
_gpuContext->consumeFrameUpdates(_activeFrame);
|
||||
pendingFrames.pop();
|
||||
_gpuContext->consumeFrameUpdates(_activeFrame);
|
||||
}
|
||||
|
||||
while (!pendingSize.empty()) {
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
std::queue<QSize> _pendingSize;
|
||||
gpu::FramePointer _activeFrame;
|
||||
uint32_t _externalTexture{ 0 };
|
||||
void move(const glm::vec3& v);
|
||||
glm::mat4 _correction;
|
||||
|
||||
|
||||
void resize(const QSize& newSize);
|
||||
|
|
Loading…
Reference in a new issue