add vFlip detection algorithm

This commit is contained in:
jrkb 2023-04-07 09:47:45 +02:00
parent e6a1ecd971
commit 14072ce026
2 changed files with 64 additions and 0 deletions

45
src/Utils.cpp Normal file
View file

@ -0,0 +1,45 @@
#include "Utils.h"
namespace ofxVariableLab {
void getVFlip(const VFlipBehaviour & vFlipBehaviour,
const glm::mat4 & orientationMatrix,
VFlipState & vFlip){
switch(vFlipBehaviour){
case V_FLIP_ONCE_AUTO: {
if(vFlip != V_FLIP_UNKNOWN){
break;
}
}
case V_FLIP_ALWAYS_AUTO: {
if(orientationMatrix == glm::mat4(1)){
vFlip = V_FLIP_OFF;
}else{
vFlip = V_FLIP_ON;
}
break;
}
case V_FLIP_ALWAYS_ON: {
vFlip = V_FLIP_ON;
break;
}
case V_FLIP_ALWAYS_OFF: {
vFlip = V_FLIP_OFF;
break;
}
}
}
//getVFlip(settings.vFlipBehaviour,
//ofGetCurrentOrientationMatrix(),
//vFlip);
//if(vFlip == V_FLIP_OFF){
//ofTranslate(pl * magic, (pt * magic) + (-1 * h), 0);
////ofTranslate(pl * magic, -1 * pt * magic, 0);
//}else{
//ofTranslate(pl * magic, -1 * pt * magic, 0);
//}
}

View file

@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <glm/glm.hpp>
namespace ofxVariableLab {
@ -21,5 +22,23 @@ inline void hash_combine(std::size_t & seed, const T & v){
std::hash <T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
enum VFlipState {
V_FLIP_UNKNOWN = 0,
V_FLIP_ON,
V_FLIP_OFF
};
enum VFlipBehaviour {
/// probe view matrix every frame
V_FLIP_ALWAYS_AUTO = 0,
/// probe view matrix once and remember
V_FLIP_ONCE_AUTO,
/// never probe and force off
V_FLIP_ALWAYS_OFF,
/// never probe and force on
V_FLIP_ALWAYS_ON
};
void getVFlip(const VFlipBehaviour & vFlipBehaviour,
const glm::mat4 & orientationMatrix,
VFlipState & vFlip);
}