[vlc-commits] opengl: move code
Thomas Guillem
git at videolan.org
Thu Jan 26 12:47:46 CET 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jan 26 11:15:42 2017 +0100| [1a6a2c360f0abf8667c6383df1339a2c0a91f870] | committer: Thomas Guillem
opengl: move code
No functional changes, needed by the next commit.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1a6a2c360f0abf8667c6383df1339a2c0a91f870
---
modules/video_output/opengl/vout_helper.c | 314 +++++++++++++++---------------
1 file changed, 157 insertions(+), 157 deletions(-)
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 7c4a455..4b8c853 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -139,6 +139,163 @@ struct vout_display_opengl_t {
float f_sar;
};
+static const GLfloat identity[] = {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+};
+
+/* rotation around the Z axis */
+static void getZRotMatrix(float theta, GLfloat matrix[static 16])
+{
+ float st, ct;
+
+ sincosf(theta, &st, &ct);
+
+ const GLfloat m[] = {
+ /* x y z w */
+ ct, -st, 0.f, 0.f,
+ st, ct, 0.f, 0.f,
+ 0.f, 0.f, 1.f, 0.f,
+ 0.f, 0.f, 0.f, 1.f
+ };
+
+ memcpy(matrix, m, sizeof(m));
+}
+
+/* rotation around the Y axis */
+static void getYRotMatrix(float theta, GLfloat matrix[static 16])
+{
+ float st, ct;
+
+ sincosf(theta, &st, &ct);
+
+ const GLfloat m[] = {
+ /* x y z w */
+ ct, 0.f, -st, 0.f,
+ 0.f, 1.f, 0.f, 0.f,
+ st, 0.f, ct, 0.f,
+ 0.f, 0.f, 0.f, 1.f
+ };
+
+ memcpy(matrix, m, sizeof(m));
+}
+
+/* rotation around the X axis */
+static void getXRotMatrix(float phi, GLfloat matrix[static 16])
+{
+ float sp, cp;
+
+ sincosf(phi, &sp, &cp);
+
+ const GLfloat m[] = {
+ /* x y z w */
+ 1.f, 0.f, 0.f, 0.f,
+ 0.f, cp, sp, 0.f,
+ 0.f, -sp, cp, 0.f,
+ 0.f, 0.f, 0.f, 1.f
+ };
+
+ memcpy(matrix, m, sizeof(m));
+}
+
+static void getZoomMatrix(float zoom, GLfloat matrix[static 16]) {
+
+ const GLfloat m[] = {
+ /* x y z w */
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, zoom, 1.0f
+ };
+
+ memcpy(matrix, m, sizeof(m));
+}
+
+/* perspective matrix see https://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml */
+static void getProjectionMatrix(float sar, float fovy, GLfloat matrix[static 16]) {
+
+ float zFar = 1000;
+ float zNear = 0.01;
+
+ float f = 1.f / tanf(fovy / 2.f);
+
+ const GLfloat m[] = {
+ f / sar, 0.f, 0.f, 0.f,
+ 0.f, f, 0.f, 0.f,
+ 0.f, 0.f, (zNear + zFar) / (zNear - zFar), -1.f,
+ 0.f, 0.f, (2 * zNear * zFar) / (zNear - zFar), 0.f};
+
+ memcpy(matrix, m, sizeof(m));
+}
+
+static void orientationTransformMatrix(GLfloat matrix[static 16],
+ video_orientation_t orientation)
+{
+ memcpy(matrix, identity, sizeof(identity));
+
+ const int k_cos_pi = -1;
+ const int k_cos_pi_2 = 0;
+ const int k_cos_n_pi_2 = 0;
+
+ const int k_sin_pi = 0;
+ const int k_sin_pi_2 = 1;
+ const int k_sin_n_pi_2 = -1;
+
+ switch (orientation) {
+
+ case ORIENT_ROTATED_90:
+ matrix[0 * 4 + 0] = k_cos_pi_2;
+ matrix[0 * 4 + 1] = -k_sin_pi_2;
+ matrix[1 * 4 + 0] = k_sin_pi_2;
+ matrix[1 * 4 + 1] = k_cos_pi_2;
+ matrix[3 * 4 + 1] = 1;
+ break;
+ case ORIENT_ROTATED_180:
+ matrix[0 * 4 + 0] = k_cos_pi;
+ matrix[0 * 4 + 1] = -k_sin_pi;
+ matrix[1 * 4 + 0] = k_sin_pi;
+ matrix[1 * 4 + 1] = k_cos_pi;
+ matrix[3 * 4 + 0] = 1;
+ matrix[3 * 4 + 1] = 1;
+ break;
+ case ORIENT_ROTATED_270:
+ matrix[0 * 4 + 0] = k_cos_n_pi_2;
+ matrix[0 * 4 + 1] = -k_sin_n_pi_2;
+ matrix[1 * 4 + 0] = k_sin_n_pi_2;
+ matrix[1 * 4 + 1] = k_cos_n_pi_2;
+ matrix[3 * 4 + 0] = 1;
+ break;
+ case ORIENT_HFLIPPED:
+ matrix[0 * 4 + 0] = -1;
+ matrix[3 * 4 + 0] = 1;
+ break;
+ case ORIENT_VFLIPPED:
+ matrix[1 * 4 + 1] = -1;
+ matrix[3 * 4 + 1] = 1;
+ break;
+ case ORIENT_TRANSPOSED:
+ matrix[0 * 4 + 0] = 0;
+ matrix[1 * 4 + 1] = 0;
+ matrix[2 * 4 + 2] = -1;
+ matrix[0 * 4 + 1] = 1;
+ matrix[1 * 4 + 0] = 1;
+ break;
+ case ORIENT_ANTI_TRANSPOSED:
+ matrix[0 * 4 + 0] = 0;
+ matrix[1 * 4 + 1] = 0;
+ matrix[2 * 4 + 2] = -1;
+ matrix[0 * 4 + 1] = -1;
+ matrix[1 * 4 + 0] = -1;
+ matrix[3 * 4 + 0] = 1;
+ matrix[3 * 4 + 1] = 1;
+ break;
+ default:
+ break;
+ }
+}
+
static inline int GetAlignedSize(unsigned size)
{
/* Return the smallest larger or equal power of 2 */
@@ -763,163 +920,6 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
return ret;
}
-static const GLfloat identity[] = {
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-/* rotation around the Z axis */
-static void getZRotMatrix(float theta, GLfloat matrix[static 16])
-{
- float st, ct;
-
- sincosf(theta, &st, &ct);
-
- const GLfloat m[] = {
- /* x y z w */
- ct, -st, 0.f, 0.f,
- st, ct, 0.f, 0.f,
- 0.f, 0.f, 1.f, 0.f,
- 0.f, 0.f, 0.f, 1.f
- };
-
- memcpy(matrix, m, sizeof(m));
-}
-
-/* rotation around the Y axis */
-static void getYRotMatrix(float theta, GLfloat matrix[static 16])
-{
- float st, ct;
-
- sincosf(theta, &st, &ct);
-
- const GLfloat m[] = {
- /* x y z w */
- ct, 0.f, -st, 0.f,
- 0.f, 1.f, 0.f, 0.f,
- st, 0.f, ct, 0.f,
- 0.f, 0.f, 0.f, 1.f
- };
-
- memcpy(matrix, m, sizeof(m));
-}
-
-/* rotation around the X axis */
-static void getXRotMatrix(float phi, GLfloat matrix[static 16])
-{
- float sp, cp;
-
- sincosf(phi, &sp, &cp);
-
- const GLfloat m[] = {
- /* x y z w */
- 1.f, 0.f, 0.f, 0.f,
- 0.f, cp, sp, 0.f,
- 0.f, -sp, cp, 0.f,
- 0.f, 0.f, 0.f, 1.f
- };
-
- memcpy(matrix, m, sizeof(m));
-}
-
-static void getZoomMatrix(float zoom, GLfloat matrix[static 16]) {
-
- const GLfloat m[] = {
- /* x y z w */
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, zoom, 1.0f
- };
-
- memcpy(matrix, m, sizeof(m));
-}
-
-/* perspective matrix see https://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml */
-static void getProjectionMatrix(float sar, float fovy, GLfloat matrix[static 16]) {
-
- float zFar = 1000;
- float zNear = 0.01;
-
- float f = 1.f / tanf(fovy / 2.f);
-
- const GLfloat m[] = {
- f / sar, 0.f, 0.f, 0.f,
- 0.f, f, 0.f, 0.f,
- 0.f, 0.f, (zNear + zFar) / (zNear - zFar), -1.f,
- 0.f, 0.f, (2 * zNear * zFar) / (zNear - zFar), 0.f};
-
- memcpy(matrix, m, sizeof(m));
-}
-
-static void orientationTransformMatrix(GLfloat matrix[static 16],
- video_orientation_t orientation)
-{
- memcpy(matrix, identity, sizeof(identity));
-
- const int k_cos_pi = -1;
- const int k_cos_pi_2 = 0;
- const int k_cos_n_pi_2 = 0;
-
- const int k_sin_pi = 0;
- const int k_sin_pi_2 = 1;
- const int k_sin_n_pi_2 = -1;
-
- switch (orientation) {
-
- case ORIENT_ROTATED_90:
- matrix[0 * 4 + 0] = k_cos_pi_2;
- matrix[0 * 4 + 1] = -k_sin_pi_2;
- matrix[1 * 4 + 0] = k_sin_pi_2;
- matrix[1 * 4 + 1] = k_cos_pi_2;
- matrix[3 * 4 + 1] = 1;
- break;
- case ORIENT_ROTATED_180:
- matrix[0 * 4 + 0] = k_cos_pi;
- matrix[0 * 4 + 1] = -k_sin_pi;
- matrix[1 * 4 + 0] = k_sin_pi;
- matrix[1 * 4 + 1] = k_cos_pi;
- matrix[3 * 4 + 0] = 1;
- matrix[3 * 4 + 1] = 1;
- break;
- case ORIENT_ROTATED_270:
- matrix[0 * 4 + 0] = k_cos_n_pi_2;
- matrix[0 * 4 + 1] = -k_sin_n_pi_2;
- matrix[1 * 4 + 0] = k_sin_n_pi_2;
- matrix[1 * 4 + 1] = k_cos_n_pi_2;
- matrix[3 * 4 + 0] = 1;
- break;
- case ORIENT_HFLIPPED:
- matrix[0 * 4 + 0] = -1;
- matrix[3 * 4 + 0] = 1;
- break;
- case ORIENT_VFLIPPED:
- matrix[1 * 4 + 1] = -1;
- matrix[3 * 4 + 1] = 1;
- break;
- case ORIENT_TRANSPOSED:
- matrix[0 * 4 + 0] = 0;
- matrix[1 * 4 + 1] = 0;
- matrix[2 * 4 + 2] = -1;
- matrix[0 * 4 + 1] = 1;
- matrix[1 * 4 + 0] = 1;
- break;
- case ORIENT_ANTI_TRANSPOSED:
- matrix[0 * 4 + 0] = 0;
- matrix[1 * 4 + 1] = 0;
- matrix[2 * 4 + 2] = -1;
- matrix[0 * 4 + 1] = -1;
- matrix[1 * 4 + 0] = -1;
- matrix[3 * 4 + 0] = 1;
- matrix[3 * 4 + 1] = 1;
- break;
- default:
- break;
- }
-}
-
static int BuildSphere(unsigned nbPlanes,
GLfloat **vertexCoord, GLfloat **textureCoord, unsigned *nbVertices,
GLushort **indices, unsigned *nbIndices,
More information about the vlc-commits
mailing list