From: Carl Hetherington Date: Mon, 17 Oct 2022 20:37:39 +0000 (+0200) Subject: Extract ublas_to_gl method. X-Git-Tag: v2.16.31~8^2~3 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=fded83c2bc934d27c74227202a6aecf2c24a9e3c Extract ublas_to_gl method. --- diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index efafe6548..05d3eb548 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -453,14 +453,29 @@ GLVideoView::setup_shaders () set_outline_content_colour (program); set_crop_guess_colour (program); + auto ublas_to_gl = [](boost::numeric::ublas::matrix const& ublas, GLfloat* gl) { + gl[0] = static_cast(ublas(0, 0)); + gl[1] = static_cast(ublas(0, 1)); + gl[2] = static_cast(ublas(0, 2)); + gl[3] = 0.0f; + gl[4] = static_cast(ublas(1, 0)); + gl[5] = static_cast(ublas(1, 1)); + gl[6] = static_cast(ublas(1, 2)); + gl[7] = 0.0f; + gl[8] = static_cast(ublas(2, 0)); + gl[9] = static_cast(ublas(2, 1)); + gl[10] = static_cast(ublas(2, 2)); + gl[11] = 0.0f; + gl[12] = 0.0f; + gl[13] = 0.0f; + gl[14] = 0.0f; + gl[15] = 1.0f; + }; + auto conversion = dcp::ColourConversion::rec709_to_xyz(); boost::numeric::ublas::matrix matrix = conversion.xyz_to_rgb (); - GLfloat gl_matrix[] = { - static_cast(matrix(0, 0)), static_cast(matrix(0, 1)), static_cast(matrix(0, 2)), 0.0f, - static_cast(matrix(1, 0)), static_cast(matrix(1, 1)), static_cast(matrix(1, 2)), 0.0f, - static_cast(matrix(2, 0)), static_cast(matrix(2, 1)), static_cast(matrix(2, 2)), 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; + GLfloat gl_matrix[16]; + ublas_to_gl(matrix, gl_matrix); auto xyz_rec709_colour_conversion = glGetUniformLocation(program, "xyz_rec709_colour_conversion"); check_gl_error ("glGetUniformLocation");