aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-05-01 00:05:52 +0200
committerdec05eba <dec05eba@protonmail.com>2020-05-01 00:05:52 +0200
commit106472071d1777ca0907c72424fbcb47784ce717 (patch)
tree8adda478c4116c1bcf68cb56e9df446d8aff5106
parent15c04087196b2e0be5b6e1992bf44cde75f0183d (diff)
Add option to switch left and right view and to disable video stretching
-rw-r--r--README.md4
-rw-r--r--src/main.cpp23
2 files changed, 25 insertions, 2 deletions
diff --git a/README.md b/README.md
index 49a95cc..12faf8d 100644
--- a/README.md
+++ b/README.md
@@ -9,3 +9,7 @@ vr video player can be built using [sibs](https://github.com/DEC05EBA/sibs) or i
# How to use
Start a video in your video player of choice (tested with mpv) and then get the x11 window id (this can be done with xwininfo) and then fullscreen the video (for best quality).
Then launch `vr_video_player` with the x11 window id.
+
+If the video is not meant to be viewed as a sphere but as a rectangle, then pass the `--flat` option when running vr video player.\
+If the video is flipped where the right eye is on the left side, then pass the `--right-left` option when running vr video player.\
+If the video is stretched, then pass the `--no-stretch`option when running vr video player. Note: This option only works when also using the `--flat` option.
diff --git a/src/main.cpp b/src/main.cpp
index 9706ff1..8f53ade 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -278,8 +278,15 @@ private: // X compositor
GLint pixmap_texture_width = 0;
GLint pixmap_texture_height = 0;
+ enum class ViewMode {
+ LEFT_RIGHT,
+ RIGHT_LEFT
+ };
+
bool sphere_projection = true;
double zoom = 0.0;
+ ViewMode view_mode = ViewMode::LEFT_RIGHT;
+ bool stretch = true;
};
@@ -369,7 +376,7 @@ void dprintf( const char *fmt, ... )
}
static void usage() {
- fprintf(stderr, "usage: vr-video-player [--flat] [--zoom zoom-level] <window_id>\n");
+ fprintf(stderr, "usage: vr-video-player [--flat] [--left-right|--right-left] [--stretch|--no-stretch] [--zoom zoom-level] <window_id>\n");
exit(1);
}
@@ -413,6 +420,14 @@ CMainApplication::CMainApplication( int argc, char *argv[] )
} else if(strcmp(argv[i], "--zoom") == 0 && i < argc - 1) {
zoom = atof(argv[i + 1]);
++i;
+ } else if(strcmp(argv[i], "--left-right") == 0) {
+ view_mode = ViewMode::LEFT_RIGHT;
+ } else if(strcmp(argv[i], "--right-left") == 0) {
+ view_mode = ViewMode::RIGHT_LEFT;
+ } else if(strcmp(argv[i], "--stretch") == 0) {
+ stretch = true;
+ } else if(strcmp(argv[i], "--no-stretch") == 0) {
+ stretch = false;
} else if(argv[i][0] == '-') {
fprintf(stderr, "Invalid flag: %s\n", argv[i]);
usage();
@@ -1524,7 +1539,7 @@ void CMainApplication::AddCubeToScene( const glm::mat4 &mat, std::vector<float>
}
else
{
- double width = 1.0 * width_ratio;
+ double width = (stretch ? 1.0 : 0.5) * width_ratio;
double height = 0.5;
AddCubeVertex(-width, height, zoom, 1.0, 0.0, vertdata);
AddCubeVertex(width, height, zoom, 0.0, 0.0, vertdata);
@@ -1837,11 +1852,15 @@ void CMainApplication::RenderScene( vr::Hmd_Eye nEye )
if( nEye == vr::Eye_Left )
{
float offset = 0.0f;
+ if(view_mode == ViewMode::RIGHT_LEFT)
+ offset = 0.5f;
glUniform1fv(m_nSceneTextureOffsetXLocation, 1, &offset);
}
else if( nEye == vr::Eye_Right )
{
float offset = 0.5f;
+ if(view_mode == ViewMode::RIGHT_LEFT)
+ offset = 0.0f;
glUniform1fv(m_nSceneTextureOffsetXLocation, 1, &offset);
}