[guilib] fix labelcontrols with auto width always being marked as dirty if they speci...
[vuplus_xbmc] / xbmc / guilib / MatrixGLES.h
1 #pragma once
2 /*
3 *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #include <vector>
23 #include <string.h>
24
25 enum EMATRIXMODE
26 {
27   MM_PROJECTION = 0,
28   MM_MODELVIEW,
29   MM_TEXTURE,
30   MM_MATRIXSIZE  // Must be last! used for size of matrices
31 };
32
33 class CMatrixGLES
34 {
35 public:
36   CMatrixGLES();
37   ~CMatrixGLES();
38   
39   GLfloat* GetMatrix(EMATRIXMODE mode);
40
41   void MatrixMode(EMATRIXMODE mode);
42   void PushMatrix();
43   void PopMatrix();
44   void LoadIdentity();
45   void Ortho(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
46   void Ortho2D(GLfloat l, GLfloat r, GLfloat b, GLfloat t);
47   void Frustum(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
48   void Translatef(GLfloat x, GLfloat y, GLfloat z);
49   void Scalef(GLfloat x, GLfloat y, GLfloat z);
50   void Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
51   void MultMatrixf(const GLfloat *matrix);
52   void LookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx, GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy, GLfloat upz);
53   void PrintMatrix(void);
54   static bool Project(GLfloat objx, GLfloat objy, GLfloat objz, const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4], GLfloat* winx, GLfloat* winy, GLfloat* winz);
55
56 protected:
57
58   struct MatrixWrapper 
59   {
60     MatrixWrapper(){ memset(&m_values, 0, sizeof(m_values)); };
61     MatrixWrapper( const float values[16]) { memcpy(m_values,values,sizeof(m_values)); }
62     MatrixWrapper( const MatrixWrapper &rhs ) { memcpy(m_values, rhs.m_values, sizeof(m_values)); }
63     MatrixWrapper &operator=( const MatrixWrapper &rhs ) { memcpy(m_values, rhs.m_values, sizeof(m_values)); return *this;}
64     operator float*() { return m_values; }
65     operator const float*() const { return m_values; }
66
67     float m_values[16];
68   };
69
70   std::vector<struct MatrixWrapper> m_matrices[(int)MM_MATRIXSIZE];
71   GLfloat *m_pMatrix;
72   EMATRIXMODE m_matrixMode;
73 #if defined(__ARM_NEON__)
74   bool m_has_neon;
75 #endif
76 };
77
78 extern CMatrixGLES g_matrices;