Skip to content
Snippets Groups Projects
Commit 428010ac authored by Nicolas Pope's avatar Nicolas Pope
Browse files

VR flip shader

parent a2011637
No related branches found
No related tags found
1 merge request!324Implements #365 aruco align VR pose
Pipeline #28730 passed
......@@ -49,6 +49,7 @@ public:
inline bool isLive() const { return live_; }
inline bool isTouchable() const { return touch_; }
inline bool isMovable() const { return movable_; }
inline bool isVR() const { return vr_; }
ftl::render::Colouriser* colouriser() { return colouriser_.get(); };
ftl::overlay::Overlay* overlay() { return overlay_.get(); }
......
......@@ -377,6 +377,8 @@ CameraView::CameraView(ftl::gui2::Screen* parent, ftl::gui2::Camera* ctrl) :
imview_ = new ftl::gui2::FTLImageView(this);
panel_ = new ftl::gui2::MediaPanel(screen(), ctrl, this);
imview_->setFlipped(ctrl->isVR());
auto *mod = ctrl_->screen->getModule<ftl::gui2::Statistics>();
if (ctrl_->isMovable()) {
imview_->setCursor(nanogui::Cursor::Hand);
......
......@@ -49,13 +49,14 @@ namespace {
R"(#version 330
uniform vec2 scaleFactor;
uniform vec2 position;
uniform float flip_y;
in vec2 vertex;
out vec2 uv;
void main() {
uv = vertex;
vec2 scaledVertex = (vertex * scaleFactor) + position;
gl_Position = vec4(2.0*scaledVertex.x - 1.0,
1.0 - 2.0*scaledVertex.y,
flip_y*(1.0 - 2.0*scaledVertex.y),
0.0, 1.0);
})";
......@@ -322,6 +323,7 @@ void ftl::gui2::ImageView::draw(NVGcontext* ctx) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mImageID);
mShader.setUniform("image", 0);
mShader.setUniform("flip_y", (flipped_) ? -1.0f : 1.0f);
mShader.setUniform("scaleFactor", scaleFactor);
mShader.setUniform("position", imagePosition);
mShader.drawIndexed(GL_TRIANGLES, 0, 2);
......
......@@ -55,6 +55,8 @@ public:
float scale() const { return mScale; }
void setScale(float scale) { mScale = scale > 0.01f ? scale : 0.01f; }
inline void setFlipped(bool flipped) { flipped_ = flipped; }
bool fixedOffset() const { return mFixedOffset; }
void setFixedOffset(bool fixedOffset) { mFixedOffset = fixedOffset; }
bool fixedScale() const { return mFixedScale; }
......@@ -166,6 +168,7 @@ protected:
nanogui::Vector2f mOffset;
bool mFixedScale;
bool mFixedOffset;
bool flipped_ = false;
// Fine-tuning parameters.
float mZoomSensitivity = 1.1f;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment