Skip to content
Browse files

Do not allow setting an output mode for the display() function.

Instead, only allow to toggle the swap_eyes flag, which is enough to allow
Equalizer to choose between left and right view.
  • Loading branch information...
1 parent c7bf4d5 commit 3ffdada26337776eb88bbc4d46abc798933b4ca7 @marlam marlam committed
Showing with 29 additions and 24 deletions.
  1. +7 −7 src/player_equalizer.cpp
  2. +18 −14 src/video_output_opengl.cpp
  3. +4 −3 src/video_output_opengl.h
View
14 src/player_equalizer.cpp
@@ -156,15 +156,15 @@ class video_output_opengl_eq_window : public video_output_opengl
{
}
- void eq_display(enum video_output::mode mode, float x, float y, float w, float h)
+ void eq_display(bool toggle_swap_eyes, float x, float y, float w, float h)
{
- video_output_opengl::display(mode, x, y, w, h);
+ video_output_opengl::display(toggle_swap_eyes, x, y, w, h);
}
void eq_initialize(int src_width, int src_height, float src_aspect_ratio,
enum decoder::video_frame_format src_preferred_frame_format)
{
- set_mode(stereo); // just to ensure that prepare() handles both left and right view
+ set_mode(mono_left); // to display the right view, we can toggle the swap_eyes flag
set_source_info(src_width, src_height, src_aspect_ratio, src_preferred_frame_format);
initialize();
}
@@ -809,9 +809,9 @@ class eq_window : public eq::Window
{
}
- void display(enum video_output::mode mode, float x, float y, float w, float h)
+ void display(bool toggle_swap_eyes, float x, float y, float w, float h)
{
- _video_output.eq_display(mode, x, y, w, h);
+ _video_output.eq_display(toggle_swap_eyes, x, y, w, h);
}
protected:
@@ -925,8 +925,8 @@ class eq_channel : public eq::Channel
// Display
eq_window *window = static_cast<eq_window *>(getWindow());
- window->display(getEye() == eq::EYE_RIGHT ? video_output::mono_right : video_output::mono_left,
- quad_x, quad_y, quad_w, quad_h);
+ bool toggle_swap_eyes = (getEye() == eq::EYE_RIGHT);
+ window->display(toggle_swap_eyes, quad_x, quad_y, quad_w, quad_h);
}
};
View
32 src/video_output_opengl.cpp
@@ -349,7 +349,7 @@ static void draw_quad(float x, float y, float w, float h)
glEnd();
}
-void video_output_opengl::display(enum video_output::mode mode, float x, float y, float w, float h)
+void video_output_opengl::display(bool toggle_swap_eyes, float x, float y, float w, float h)
{
glClear(GL_COLOR_BUFFER_BIT);
if (!_have_valid_data[_active_tex_set])
@@ -365,13 +365,17 @@ void video_output_opengl::display(enum video_output::mode mode, float x, float y
{
std::swap(left, right);
}
+ if (toggle_swap_eyes)
+ {
+ std::swap(left, right);
+ }
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
- if ((mode == even_odd_rows || mode == checkerboard) && (screen_pos_y() + viewport[1]) % 2 == 0)
+ if ((_mode == even_odd_rows || _mode == checkerboard) && (screen_pos_y() + viewport[1]) % 2 == 0)
{
std::swap(left, right);
}
- if ((mode == even_odd_columns || mode == checkerboard) && (screen_pos_x() + viewport[0]) % 2 == 1)
+ if ((_mode == even_odd_columns || _mode == checkerboard) && (screen_pos_x() + viewport[0]) % 2 == 1)
{
std::swap(left, right);
}
@@ -468,14 +472,14 @@ void video_output_opengl::display(enum video_output::mode mode, float x, float y
glUseProgram(_render_prg);
glUniform1i(glGetUniformLocation(_render_prg, "rgb_l"), left);
glUniform1i(glGetUniformLocation(_render_prg, "rgb_r"), right);
- if (mode == even_odd_rows || mode == even_odd_columns || mode == checkerboard)
+ if (_mode == even_odd_rows || _mode == even_odd_columns || _mode == checkerboard)
{
glUniform1i(glGetUniformLocation(_render_prg, "mask_tex"), 2);
glUniform1f(glGetUniformLocation(_render_prg, "step_x"), 1.0f / static_cast<float>(viewport[2]));
glUniform1f(glGetUniformLocation(_render_prg, "step_y"), 1.0f / static_cast<float>(viewport[3]));
}
- if (mode == stereo)
+ if (_mode == stereo)
{
glActiveTexture(GL_TEXTURE0);
glDrawBuffer(GL_BACK_LEFT);
@@ -485,7 +489,7 @@ void video_output_opengl::display(enum video_output::mode mode, float x, float y
glBindTexture(GL_TEXTURE_2D, _srgb_tex[right]);
draw_quad(x, y, w, h);
}
- else if (mode == even_odd_rows || mode == even_odd_columns || mode == checkerboard)
+ else if (_mode == even_odd_rows || _mode == even_odd_columns || _mode == checkerboard)
{
float vpw = static_cast<float>(viewport[2]);
float vph = static_cast<float>(viewport[3]);
@@ -513,10 +517,10 @@ void video_output_opengl::display(enum video_output::mode mode, float x, float y
glVertex2f(x, y + h);
glEnd();
}
- else if (mode == anaglyph_red_cyan_monochrome
- || mode == anaglyph_red_cyan_full_color
- || mode == anaglyph_red_cyan_half_color
- || mode == anaglyph_red_cyan_dubois)
+ else if (_mode == anaglyph_red_cyan_monochrome
+ || _mode == anaglyph_red_cyan_full_color
+ || _mode == anaglyph_red_cyan_half_color
+ || _mode == anaglyph_red_cyan_dubois)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _srgb_tex[left]);
@@ -527,19 +531,19 @@ void video_output_opengl::display(enum video_output::mode mode, float x, float y
}
draw_quad(x, y, w, h);
}
- else if (mode == mono_left)
+ else if (_mode == mono_left)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _srgb_tex[left]);
draw_quad(x, y, w, h);
}
- else if (mode == mono_right)
+ else if (_mode == mono_right)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _srgb_tex[right]);
draw_quad(x, y, w, h);
}
- else if (mode == left_right || mode == left_right_half)
+ else if (_mode == left_right || _mode == left_right_half)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _srgb_tex[left]);
@@ -548,7 +552,7 @@ void video_output_opengl::display(enum video_output::mode mode, float x, float y
glBindTexture(GL_TEXTURE_2D, _srgb_tex[right]);
draw_quad(0.0f, -1.0f, 1.0f, 2.0f);
}
- else if (mode == top_bottom || mode == top_bottom_half)
+ else if (_mode == top_bottom || _mode == top_bottom_half)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _srgb_tex[left]);
View
7 src/video_output_opengl.h
@@ -86,9 +86,10 @@ class video_output_opengl : public video_output
// Swap the texture sets (one active, one for preparing the next video frame)
void swap_tex_set();
- // Display the current texture set
- void display(enum video_output::mode mode, float x, float y, float w, float h);
- void display() { display(_mode, -1.0f, -1.0f, 2.0f, 2.0f); }
+ // Display the current texture set. The first version of this function is used
+ // by Equalizer; simple windows will use the second version.
+ void display(bool toggle_swap_eyes, float x, float y, float w, float h);
+ void display() { display(false, -1.0f, -1.0f, 2.0f, 2.0f); }
// Call this when the GL window was resized:
void reshape(int w, int h);

0 comments on commit 3ffdada

Please sign in to comment.
Something went wrong with that request. Please try again.