mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:14:35 +02:00
basic mono preview for the oculus display plugin
This commit is contained in:
parent
073b019458
commit
c4af4c7b10
3 changed files with 33 additions and 6 deletions
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "OculusHelpers.h"
|
#include "OculusHelpers.h"
|
||||||
|
|
||||||
|
#include <plugins/PluginContainer.h>
|
||||||
|
|
||||||
#if (OVR_MAJOR_VERSION >= 6)
|
#if (OVR_MAJOR_VERSION >= 6)
|
||||||
|
|
||||||
// A base class for FBO wrappers that need to use the Oculus C
|
// A base class for FBO wrappers that need to use the Oculus C
|
||||||
|
@ -135,6 +137,19 @@ const QString & OculusDisplayPlugin::getName() const {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const QString MONO_PREVIEW = "Mono Preview";
|
||||||
|
static const QString FRAMERATE = DisplayPlugin::MENU_PATH() + ">Framerate";
|
||||||
|
|
||||||
|
void OculusDisplayPlugin::activate() {
|
||||||
|
|
||||||
|
CONTAINER->addMenuItem(MENU_PATH(), MONO_PREVIEW,
|
||||||
|
[this](bool clicked) {
|
||||||
|
_monoPreview = clicked;
|
||||||
|
}, true, true);
|
||||||
|
CONTAINER->removeMenu(FRAMERATE);
|
||||||
|
OculusBaseDisplayPlugin::activate();
|
||||||
|
}
|
||||||
|
|
||||||
void OculusDisplayPlugin::customizeContext() {
|
void OculusDisplayPlugin::customizeContext() {
|
||||||
WindowOpenGLDisplayPlugin::customizeContext();
|
WindowOpenGLDisplayPlugin::customizeContext();
|
||||||
#if (OVR_MAJOR_VERSION >= 6)
|
#if (OVR_MAJOR_VERSION >= 6)
|
||||||
|
@ -149,7 +164,7 @@ void OculusDisplayPlugin::customizeContext() {
|
||||||
#endif
|
#endif
|
||||||
enableVsync(false);
|
enableVsync(false);
|
||||||
// Only enable mirroring if we know vsync is disabled
|
// Only enable mirroring if we know vsync is disabled
|
||||||
_enableMirror = !isVsyncEnabled();
|
_enablePreview = !isVsyncEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusDisplayPlugin::deactivate() {
|
void OculusDisplayPlugin::deactivate() {
|
||||||
|
@ -169,10 +184,15 @@ void OculusDisplayPlugin::display(GLuint finalTexture, const glm::uvec2& sceneSi
|
||||||
// controlling vsync
|
// controlling vsync
|
||||||
wglSwapIntervalEXT(0);
|
wglSwapIntervalEXT(0);
|
||||||
|
|
||||||
// screen mirroring
|
// screen preview mirroring
|
||||||
if (_enableMirror) {
|
if (_enablePreview) {
|
||||||
auto windowSize = toGlm(_window->size());
|
auto windowSize = toGlm(_window->size());
|
||||||
Context::Viewport(windowSize.x, windowSize.y);
|
if (_monoPreview) {
|
||||||
|
Context::Viewport(windowSize.x * 2, windowSize.y);
|
||||||
|
Context::Scissor(0, windowSize.y, windowSize.x, windowSize.y);
|
||||||
|
} else {
|
||||||
|
Context::Viewport(windowSize.x, windowSize.y);
|
||||||
|
}
|
||||||
glBindTexture(GL_TEXTURE_2D, finalTexture);
|
glBindTexture(GL_TEXTURE_2D, finalTexture);
|
||||||
GLenum err = glGetError();
|
GLenum err = glGetError();
|
||||||
Q_ASSERT(0 == err);
|
Q_ASSERT(0 == err);
|
||||||
|
@ -216,7 +236,7 @@ void OculusDisplayPlugin::display(GLuint finalTexture, const glm::uvec2& sceneSi
|
||||||
otherwise the swapbuffer delay will interefere with the framerate of the headset
|
otherwise the swapbuffer delay will interefere with the framerate of the headset
|
||||||
*/
|
*/
|
||||||
void OculusDisplayPlugin::finishFrame() {
|
void OculusDisplayPlugin::finishFrame() {
|
||||||
if (_enableMirror) {
|
if (_enablePreview) {
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
}
|
}
|
||||||
doneCurrent();
|
doneCurrent();
|
||||||
|
|
|
@ -14,6 +14,7 @@ using SwapFboPtr = QSharedPointer<SwapFramebufferWrapper>;
|
||||||
|
|
||||||
class OculusDisplayPlugin : public OculusBaseDisplayPlugin {
|
class OculusDisplayPlugin : public OculusBaseDisplayPlugin {
|
||||||
public:
|
public:
|
||||||
|
virtual void activate() override;
|
||||||
virtual void deactivate() override;
|
virtual void deactivate() override;
|
||||||
virtual const QString & getName() const override;
|
virtual const QString & getName() const override;
|
||||||
|
|
||||||
|
@ -25,7 +26,8 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
bool _enableMirror{ false };
|
bool _enablePreview { false };
|
||||||
|
bool _monoPreview { true };
|
||||||
|
|
||||||
#if (OVR_MAJOR_VERSION >= 6)
|
#if (OVR_MAJOR_VERSION >= 6)
|
||||||
SwapFboPtr _sceneFbo;
|
SwapFboPtr _sceneFbo;
|
||||||
|
|
|
@ -61,6 +61,8 @@ glm::mat4 StereoDisplayPlugin::getProjection(Eye eye, const glm::mat4& baseProje
|
||||||
return eyeProjection;
|
return eyeProjection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const QString FRAMERATE = DisplayPlugin::MENU_PATH() + ">Framerate";
|
||||||
|
|
||||||
std::vector<QAction*> _screenActions;
|
std::vector<QAction*> _screenActions;
|
||||||
void StereoDisplayPlugin::activate() {
|
void StereoDisplayPlugin::activate() {
|
||||||
auto screens = qApp->screens();
|
auto screens = qApp->screens();
|
||||||
|
@ -76,6 +78,9 @@ void StereoDisplayPlugin::activate() {
|
||||||
[this](bool clicked) { updateScreen(); }, true, checked, "Screens");
|
[this](bool clicked) { updateScreen(); }, true, checked, "Screens");
|
||||||
_screenActions[i] = action;
|
_screenActions[i] = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CONTAINER->removeMenu(FRAMERATE);
|
||||||
|
|
||||||
CONTAINER->setFullscreen(qApp->primaryScreen());
|
CONTAINER->setFullscreen(qApp->primaryScreen());
|
||||||
WindowOpenGLDisplayPlugin::activate();
|
WindowOpenGLDisplayPlugin::activate();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue