Extract indices array and make some offset constants.
authorCarl Hetherington <cth@carlh.net>
Sun, 12 Sep 2021 22:21:44 +0000 (00:21 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 27 Sep 2021 11:41:46 +0000 (13:41 +0200)
src/wx/gl_video_view.cc

index 6bbf87c9da0b4c5867aecae7acc7253900126dff..49a30d7334ab67c605c02a5fe58745fc2b16e151 100644 (file)
@@ -285,6 +285,22 @@ GLVideoView::ensure_context ()
        }
 }
 
+
+/* Offset of video texture triangles in indices */
+static constexpr int indices_video_texture = 0;
+/* Offset of border lines in indices */
+static constexpr int indices_border = 6;
+
+static constexpr unsigned int indices[] = {
+       0, 1, 3, // video texture triangle #1
+       1, 2, 3, // video texture triangle #2
+       4, 5,    // border line #1
+       5, 6,    // border line #2
+       6, 7,    // border line #3
+       7, 4,    // border line #4
+};
+
+
 void
 GLVideoView::setup_shaders ()
 {
@@ -312,15 +328,6 @@ GLVideoView::setup_shaders ()
        get_information (GL_VERSION);
        get_information (GL_SHADING_LANGUAGE_VERSION);
 
-       unsigned int indices[] = {
-               0, 1, 3, // texture triangle #1
-               1, 2, 3, // texture triangle #2
-               4, 5,    // border line #1
-               5, 6,    // border line #2
-               6, 7,    // border line #3
-               7, 4,    // border line #4
-       };
-
        glGenVertexArrays(1, &_vao);
        check_gl_error ("glGenVertexArrays");
        GLuint vbo;
@@ -461,10 +468,10 @@ GLVideoView::draw (Position<int>, dcp::Size)
        glBindVertexArray(_vao);
        check_gl_error ("glBindVertexArray");
        glUniform1i(_fragment_type, _optimise_for_j2k ? 1 : 2);
-       glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
+       glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_INT, reinterpret_cast<void*>(indices_video_texture));
        if (_viewer->outline_content()) {
                glUniform1i(_fragment_type, 1);
-               glDrawElements (GL_LINES, 8, GL_UNSIGNED_INT, reinterpret_cast<void*>(6 * sizeof(int)));
+               glDrawElements (GL_LINES, 8, GL_UNSIGNED_INT, reinterpret_cast<void*>(indices_border * sizeof(int)));
                check_gl_error ("glDrawElements");
        }