src/glShared.h

changeset 1400
ae83213bdd63
parent 1371
b8df4748d04e
child 1404
16eb4257e662
equal deleted inserted replaced
1399:f52ea4078f5d 1400:ae83213bdd63
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19 #pragma once 19 #pragma once
20
21 #include <QOpenGLFunctions> 20 #include <QOpenGLFunctions>
22 #include <QGenericMatrix> 21 #include <QGenericMatrix>
23 #include "basics.h" 22 #include "basics.h"
23 #include "colors.h"
24 #include "generics/enums.h"
24 #include "types/vertex.h" 25 #include "types/vertex.h"
25 26
26 inline void glMultMatrixf(const GLRotationMatrix& matrix) 27 inline void glMultMatrixf(const GLRotationMatrix& matrix)
27 { 28 {
28 glMultMatrixf(matrix.constData()); 29 glMultMatrixf(matrix.constData());
40 41
41 class LDObject; 42 class LDObject;
42 43
43 struct LDPolygon 44 struct LDPolygon
44 { 45 {
45 char num; 46 enum class Type : qint8 { InvalidPolygon, EdgeLine, Triangle, Quadrilateral, ConditionalEdge };
46 Vertex vertices[4]; 47 Type type = Type::InvalidPolygon;
47 int color; 48 Vertex vertices[4];
49 LDColor color;
48 50
49 inline int numPolygonVertices() const 51 inline int numPolygonVertices() const
50 { 52 {
51 return (num == 5) ? 2 : num; 53 if (type == Type::ConditionalEdge)
54 return 2;
55 else
56 return numVertices();
52 } 57 }
53 58
54 inline int numVertices() const 59 inline int numVertices() const
55 { 60 {
56 return (num == 5) ? 4 : num; 61 switch (type)
62 {
63 case Type::EdgeLine:
64 return 2;
65
66 case Type::Triangle:
67 return 3;
68
69 case Type::ConditionalEdge:
70 case Type::Quadrilateral:
71 return 4;
72
73 case Type::InvalidPolygon:
74 return 0;
75 }
76
77 return 0;
78 }
79
80 bool isValid() const
81 {
82 return type != Type::InvalidPolygon;
57 } 83 }
58 }; 84 };
59 85
60 Q_DECLARE_METATYPE(LDPolygon) 86 Q_DECLARE_METATYPE(LDPolygon)
61 87

mercurial