mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:53:32 +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
libraries/display-plugins/src/display-plugins
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "OculusHelpers.h"
|
||||
|
||||
#include <plugins/PluginContainer.h>
|
||||
|
||||
#if (OVR_MAJOR_VERSION >= 6)
|
||||
|
||||
// A base class for FBO wrappers that need to use the Oculus C
|
||||
|
@ -135,6 +137,19 @@ const QString & OculusDisplayPlugin::getName() const {
|
|||
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() {
|
||||
WindowOpenGLDisplayPlugin::customizeContext();
|
||||
#if (OVR_MAJOR_VERSION >= 6)
|
||||
|
@ -149,7 +164,7 @@ void OculusDisplayPlugin::customizeContext() {
|
|||
#endif
|
||||
enableVsync(false);
|
||||
// Only enable mirroring if we know vsync is disabled
|
||||
_enableMirror = !isVsyncEnabled();
|
||||
_enablePreview = !isVsyncEnabled();
|
||||
}
|
||||
|
||||
void OculusDisplayPlugin::deactivate() {
|
||||
|
@ -169,10 +184,15 @@ void OculusDisplayPlugin::display(GLuint finalTexture, const glm::uvec2& sceneSi
|
|||
// controlling vsync
|
||||
wglSwapIntervalEXT(0);
|
||||
|
||||
// screen mirroring
|
||||
if (_enableMirror) {
|
||||
// screen preview mirroring
|
||||
if (_enablePreview) {
|
||||
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);
|
||||
GLenum err = glGetError();
|
||||
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
|
||||
*/
|
||||
void OculusDisplayPlugin::finishFrame() {
|
||||
if (_enableMirror) {
|
||||
if (_enablePreview) {
|
||||
swapBuffers();
|
||||
}
|
||||
doneCurrent();
|
||||
|
|
|
@ -14,6 +14,7 @@ using SwapFboPtr = QSharedPointer<SwapFramebufferWrapper>;
|
|||
|
||||
class OculusDisplayPlugin : public OculusBaseDisplayPlugin {
|
||||
public:
|
||||
virtual void activate() override;
|
||||
virtual void deactivate() override;
|
||||
virtual const QString & getName() const override;
|
||||
|
||||
|
@ -25,7 +26,8 @@ protected:
|
|||
|
||||
private:
|
||||
static const QString NAME;
|
||||
bool _enableMirror{ false };
|
||||
bool _enablePreview { false };
|
||||
bool _monoPreview { true };
|
||||
|
||||
#if (OVR_MAJOR_VERSION >= 6)
|
||||
SwapFboPtr _sceneFbo;
|
||||
|
|
|
@ -61,6 +61,8 @@ glm::mat4 StereoDisplayPlugin::getProjection(Eye eye, const glm::mat4& baseProje
|
|||
return eyeProjection;
|
||||
}
|
||||
|
||||
static const QString FRAMERATE = DisplayPlugin::MENU_PATH() + ">Framerate";
|
||||
|
||||
std::vector<QAction*> _screenActions;
|
||||
void StereoDisplayPlugin::activate() {
|
||||
auto screens = qApp->screens();
|
||||
|
@ -76,6 +78,9 @@ void StereoDisplayPlugin::activate() {
|
|||
[this](bool clicked) { updateScreen(); }, true, checked, "Screens");
|
||||
_screenActions[i] = action;
|
||||
}
|
||||
|
||||
CONTAINER->removeMenu(FRAMERATE);
|
||||
|
||||
CONTAINER->setFullscreen(qApp->primaryScreen());
|
||||
WindowOpenGLDisplayPlugin::activate();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue