Wed, 23 Oct 2013 13:14:17 +0300
now compiles again
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | #include "gldata.h" |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | #include "ldtypes.h" |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | #include "colors.h" |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | #include "file.h" |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | #include "misc.h" |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | #include "gldraw.h" |
490 | 7 | #include <QDate> |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
9 | #define DEBUG(...) fprint (stdout, __VA_ARGS__) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
10 | |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
11 | cfg (Bool, gl_blackedges, false); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
12 | static QList<short> g_warnedColors; |
489
0b32138fedcc
Further work on VAO rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
488
diff
changeset
|
13 | VertexCompiler g_vertexCompiler; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | // ----------------------------------------------------------------------------- |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | VertexCompiler::Array::Array() : |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | m_data (null) |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | { |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | clear(); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
25 | VertexCompiler::Array::~Array() |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
26 | { delete[] m_data; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
31 | void VertexCompiler::Array::clear() |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
32 | { delete[] m_data; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
33 | |
443 | 34 | m_data = new Vertex[64]; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | m_size = 64; |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | m_ptr = &m_data[0]; |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
41 | void VertexCompiler::Array::resizeToFit (Size newSize) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
42 | { if (allocatedSize() >= newSize) |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | return; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
44 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | int32 cachedWriteSize = writtenSize(); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
46 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | // Add some lee-way space to reduce the amount of resizing. |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | newSize += 256; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
49 | |
443 | 50 | const Size oldSize = allocatedSize(); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
51 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | // We need to back up the data first |
443 | 53 | Vertex* copy = new Vertex[oldSize]; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | memcpy (copy, m_data, oldSize); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
55 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | // Re-create the buffer |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | delete[] m_data; |
443 | 58 | m_data = new Vertex[newSize]; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | m_size = newSize; |
443 | 60 | m_ptr = &m_data[cachedWriteSize / sizeof (Vertex)]; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
61 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | // Copy the data back |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | memcpy (m_data, copy, oldSize); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | delete[] copy; |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
69 | const VertexCompiler::Vertex* VertexCompiler::Array::data() const |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
70 | { return m_data; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
75 | const VertexCompiler::Array::Size& VertexCompiler::Array::allocatedSize() const |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
76 | { return m_size; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
81 | VertexCompiler::Array::Size VertexCompiler::Array::writtenSize() const |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
82 | { return (m_ptr - m_data) * sizeof (Vertex); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
87 | void VertexCompiler::Array::write (const Vertex& f) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
88 | { // Ensure there's enoughspace for the new vertex |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | resizeToFit (writtenSize() + sizeof f); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
90 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | // Write the float in |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | *m_ptr++ = f; |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
97 | void VertexCompiler::Array::merge (Array* other) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
98 | { // Ensure there's room for both buffers |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | resizeToFit (writtenSize() + other->writtenSize()); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
100 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | memcpy (m_ptr, other->data(), other->writtenSize()); |
443 | 102 | m_ptr += other->writtenSize() / sizeof (Vertex); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | // ----------------------------------------------------------------------------- |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
107 | VertexCompiler::VertexCompiler() : |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
108 | m_file (null) |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
109 | { needMerge(); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
112 | VertexCompiler::~VertexCompiler() {} |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
113 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | // ============================================================================= |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
115 | // Note: we use the top level object's color but the draw object's vertices. |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
116 | // This is so that the index color is generated correctly - it has to reference |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
117 | // the top level object's ID. This is crucial for picking to work. |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
119 | void VertexCompiler::compilePolygon (LDObject* drawobj, LDObject* trueobj, QList< VertexCompiler::CompiledTriangle >& data) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
120 | { const QColor pickColor = getObjectColor (trueobj, PickColor); |
488
0ea49207a4ec
VAO rendering works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
487
diff
changeset
|
121 | LDObject::Type type = drawobj->getType(); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
122 | QList<LDObject*> objs; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
123 | |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
124 | assert (type != LDObject::Subfile); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
125 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
126 | if (type == LDObject::Quad) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
127 | { for (LDTriangle* t : static_cast<LDQuad*> (drawobj)->splitToTriangles()) |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
128 | objs << t; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
129 | } |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
130 | else |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
131 | objs << drawobj; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
132 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
133 | for (LDObject* obj : objs) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
134 | { const LDObject::Type objtype = obj->getType(); |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
135 | const bool isline = (objtype == LDObject::Line || objtype == LDObject::CndLine); |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
136 | const int verts = isline ? 2 : obj->vertices(); |
488
0ea49207a4ec
VAO rendering works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
487
diff
changeset
|
137 | QColor normalColor = getObjectColor (obj, Normal); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
138 | |
488
0ea49207a4ec
VAO rendering works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
487
diff
changeset
|
139 | assert (isline || objtype == LDObject::Triangle); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
140 | |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
141 | CompiledTriangle a; |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
142 | a.rgb = normalColor.rgb(); |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
143 | a.pickrgb = pickColor.rgb(); |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
144 | a.numVerts = verts; |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
145 | a.obj = trueobj; |
488
0ea49207a4ec
VAO rendering works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
487
diff
changeset
|
146 | a.isCondLine = (objtype == LDObject::CndLine); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
147 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
148 | for (int i = 0; i < verts; ++i) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
149 | { a.verts[i] = obj->getVertex (i); |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
150 | a.verts[i].y() = -a.verts[i].y(); |
488
0ea49207a4ec
VAO rendering works now! woo!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
487
diff
changeset
|
151 | a.verts[i].z() = -a.verts[i].z(); |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
152 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
153 | |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
154 | data << a; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
160 | void VertexCompiler::compileObject (LDObject* obj) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
161 | { initObject (obj); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
162 | QList<CompiledTriangle> data; |
490 | 163 | QTime t0; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
164 | |
490 | 165 | for (int i = 0; i < GL::NumArrays; ++i) |
166 | m_objArrays[obj][i].clear(); | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
167 | |
490 | 168 | t0 = QTime::currentTime(); |
169 | compileSubObject (obj, obj, data); | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
170 | DEBUG ("COMPILATION: %1ms\n", t0.msecsTo (QTime::currentTime())); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
171 | |
490 | 172 | t0 = QTime::currentTime(); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
173 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
174 | for (int i = 0; i < GL::NumArrays; ++i) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
175 | { GL::VAOType type = (GL::VAOType) i; |
490 | 176 | const bool islinearray = (type == GL::EdgeArray || type == GL::EdgePickArray); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
177 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
178 | for (const CompiledTriangle& poly : data) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
179 | { if (poly.isCondLine) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
180 | { // Conditional lines go to the edge pick array and the array |
490 | 181 | // specifically designated for conditional lines and nowhere else. |
182 | if (type != GL::EdgePickArray && type != GL::CondEdgeArray) | |
183 | continue; | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
184 | } |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
185 | else |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
186 | { // Lines and only lines go to the line array and only to the line array. |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
187 | if ( (poly.numVerts == 2) ^ islinearray) |
490 | 188 | continue; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
189 | |
490 | 190 | // Only conditional lines go into the conditional line array |
191 | if (type == GL::CondEdgeArray) | |
192 | continue; | |
193 | } | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
194 | |
490 | 195 | Array* verts = postprocess (poly, type); |
196 | m_objArrays[obj][type].merge (verts); | |
197 | delete verts; | |
198 | } | |
199 | } | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
200 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
201 | DEBUG ("POST-PROCESS: %1ms\n", t0.msecsTo (QTime::currentTime())); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
202 | |
490 | 203 | needMerge(); |
204 | } | |
205 | ||
206 | // ============================================================================= | |
207 | // ----------------------------------------------------------------------------- | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
208 | void VertexCompiler::compileSubObject (LDObject* obj, LDObject* topobj, QList< VertexCompiler::CompiledTriangle >& data) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
209 | { QList<LDObject*> objs; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
210 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
211 | switch (obj->getType()) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
212 | { case LDObject::Triangle: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
213 | case LDObject::Line: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
214 | case LDObject::CndLine: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
215 | { compilePolygon (obj, topobj, data); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
216 | } break; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
217 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
218 | case LDObject::Quad: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
219 | { for (LDTriangle * triangle : static_cast<LDQuad*> (obj)->splitToTriangles()) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
220 | compilePolygon (triangle, topobj, data); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
221 | } break; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
222 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
223 | case LDObject::Subfile: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
224 | { QTime t0 = QTime::currentTime(); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
225 | objs = static_cast<LDSubfile*> (obj)->inlineContents (LDSubfile::RendererInline | LDSubfile::DeepCacheInline); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
226 | DEBUG ("\t- INLINE: %1ms\n", t0.msecsTo (QTime::currentTime())); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
227 | DEBUG ("\t- %1 objects\n", objs.size()); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
228 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
229 | t0 = QTime::currentTime(); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
230 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
231 | for (LDObject* obj : objs) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
232 | { compileSubObject (obj, topobj, data); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
233 | delete obj; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
234 | } |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
235 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
236 | DEBUG ("\t- SUB-COMPILATION: %1ms\n", t0.msecsTo (QTime::currentTime())); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
237 | } break; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
238 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
239 | default: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
240 | {} break; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
241 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
246 | void VertexCompiler::compileFile() |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
247 | { for (LDObject * obj : m_file->objects()) |
490 | 248 | compileObject (obj); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
253 | void VertexCompiler::forgetObject (LDObject* obj) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
254 | { auto it = m_objArrays.find (obj); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
255 | |
490 | 256 | if (it != m_objArrays.end()) |
257 | delete *it; | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
258 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | m_objArrays.remove (obj); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
263 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
264 | void VertexCompiler::setFile (LDFile* file) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
265 | { m_file = file; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
270 | const VertexCompiler::Array* VertexCompiler::getMergedBuffer (GL::VAOType type) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
271 | { // If there are objects staged for compilation, compile them now. |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
272 | if (m_staged.size() > 0) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
273 | { for (LDObject * obj : m_staged) |
490 | 274 | compileObject (obj); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
275 | |
490 | 276 | m_staged.clear(); |
277 | } | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
278 | |
489
0b32138fedcc
Further work on VAO rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
488
diff
changeset
|
279 | assert (type < GL::NumArrays); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
280 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
281 | if (m_changed[type]) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
282 | { m_changed[type] = false; |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
283 | m_mainArrays[type].clear(); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
284 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
285 | for (LDObject* obj : m_file->objects()) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
286 | { if (!obj->isScemantic()) |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
287 | continue; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
288 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
289 | auto it = m_objArrays.find (obj); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
290 | |
490 | 291 | if (it != m_objArrays.end()) |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
292 | m_mainArrays[type].merge (& (*it) [type]); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
294 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
295 | DEBUG ("merged array %1: %2 bytes\n", (int) type, m_mainArrays[type].writtenSize()); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
296 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
297 | |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
298 | return &m_mainArrays[type]; |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
299 | } |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
300 | |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
301 | // ============================================================================= |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
302 | // This turns a compiled triangle into usable VAO vertices |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
303 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
304 | VertexCompiler::Array* VertexCompiler::postprocess (const CompiledTriangle& triangle, GL::VAOType type) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
305 | { Array* va = new Array; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
306 | QList<Vertex> verts; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
307 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
308 | for (int i = 0; i < triangle.numVerts; ++i) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
309 | { alias v0 = triangle.verts[i]; |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
310 | Vertex v; |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
311 | v.x = v0.x(); |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
312 | v.y = v0.y(); |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
313 | v.z = v0.z(); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
314 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
315 | switch (type) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
316 | { case GL::MainArray: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
317 | case GL::EdgeArray: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
318 | case GL::CondEdgeArray: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
319 | { v.color = triangle.rgb; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
320 | } break; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
321 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
322 | case GL::PickArray: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
323 | case GL::EdgePickArray: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
324 | { v.color = triangle.pickrgb; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
325 | } break; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
326 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
327 | case GL::BFCArray: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
328 | case GL::NumArrays: |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
329 | break; // handled separately |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
330 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
331 | |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
332 | verts << v; |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
333 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
334 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
335 | if (type == GL::BFCArray) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
336 | { int32 rgb = getObjectColor (triangle.obj, BFCFront).rgb(); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
337 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
338 | for (Vertex v : verts) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
339 | { v.color = rgb; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
340 | va->write (v); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
341 | } |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
342 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
343 | rgb = getObjectColor (triangle.obj, BFCBack).rgb(); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
344 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
345 | for (int i = verts.size() - 1; i >= 0; --i) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
346 | { Vertex v = verts[i]; |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
347 | v.color = rgb; |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
348 | va->write (v); |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
349 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
350 | } |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
351 | else |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
352 | { for (Vertex v : verts) |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
353 | va->write (v); |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
354 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
355 | |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
356 | return va; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | // ============================================================================= |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
360 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
361 | uint32 VertexCompiler::getColorRGB (QColor& color) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
362 | { return |
487
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
363 | (color.red() & 0xFF) << 0x00 | |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
364 | (color.green() & 0xFF) << 0x08 | |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
365 | (color.blue() & 0xFF) << 0x10 | |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
366 | (color.alpha() & 0xFF) << 0x18; |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
367 | } |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
368 | |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
369 | // ============================================================================= |
a350c4b25133
Merge branch 'master' into gl, reworked stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents:
443
diff
changeset
|
370 | // ----------------------------------------------------------------------------- |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
371 | QColor VertexCompiler::getObjectColor (LDObject* obj, ColorType colotype) const |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
372 | { QColor qcol; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
373 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | if (!obj->isColored()) |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | return QColor(); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
376 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
377 | if (colotype == PickColor) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
378 | { // Make the color by the object's ID if we're picking, so we can make the |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | // ID again from the color we get from the picking results. Be sure to use |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | // the top level parent's index since we want a subfile's children point |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | // to the subfile itself. |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | long i = obj->topLevelParent()->id(); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
383 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
384 | // Calculate a color based from this index. This method caters for |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
385 | // 16777216 objects. I don't think that'll be exceeded anytime soon. :) |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
386 | // ATM biggest is 53588.dat with 12600 lines. |
442
4852e815df29
Picking now works with the VAO setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
441
diff
changeset
|
387 | int r = (i / (256 * 256)) % 256, |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
388 | g = (i / 256) % 256, |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
389 | b = i % 256; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
390 | |
442
4852e815df29
Picking now works with the VAO setup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
441
diff
changeset
|
391 | return QColor (r, g, b); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
392 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
393 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
394 | if ((colotype == BFCFront || colotype == BFCBack) && |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
395 | obj->getType() != LDObject::Line && |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
396 | obj->getType() != LDObject::CndLine |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
397 | ) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
398 | { if (colotype == BFCFront) |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
399 | qcol = QColor (40, 192, 0); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
400 | else |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
401 | qcol = QColor (224, 0, 0); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
402 | } |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
403 | else |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
404 | { if (obj->color() == maincolor) |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
405 | qcol = GL::getMainColor(); |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
406 | else |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
407 | { LDColor* col = getColor (obj->color()); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
408 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
409 | if (col) |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | qcol = col->faceColor; |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
412 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
413 | if (obj->color() == edgecolor) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
414 | { qcol = QColor (32, 32, 32); // luma (m_bgcolor) < 40 ? QColor (64, 64, 64) : Qt::black; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
415 | LDColor* col; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
416 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
417 | if (!gl_blackedges && obj->parent() && (col = getColor (obj->parent()->color()))) |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
418 | qcol = col->edgeColor; |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
420 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
421 | if (qcol.isValid() == false) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
422 | { // The color was unknown. Use main color to make the object at least |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
423 | // not appear pitch-black. |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
424 | if (obj->color() != edgecolor) |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
425 | qcol = GL::getMainColor(); |
490 | 426 | else |
427 | qcol = Qt::black; | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
428 | |
490 | 429 | // Warn about the unknown color, but only once. |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
430 | for (short i : g_warnedColors) |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
431 | if (obj->color() == i) |
490 | 432 | return qcol; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
433 | |
489
0b32138fedcc
Further work on VAO rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
488
diff
changeset
|
434 | log ("%1: Unknown color %2!\n", __func__, obj->color()); |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
435 | g_warnedColors << obj->color(); |
490 | 436 | return qcol; |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
437 | } |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
438 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
439 | |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
440 | if (obj->topLevelParent()->selected()) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
441 | { // Brighten it up if selected. |
490 | 442 | const int add = 51; |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
443 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
444 | qcol.setRed (min (qcol.red() + add, 255)); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
445 | qcol.setGreen (min (qcol.green() + add, 255)); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
446 | qcol.setBlue (min (qcol.blue() + add, 255)); |
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
447 | } |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
448 | |
441
a958f6925088
BIG COMMIT -- Moving from display lists to VAOs.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
449 | return qcol; |
490 | 450 | } |
451 | ||
452 | // ============================================================================= | |
453 | // ----------------------------------------------------------------------------- | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
454 | void VertexCompiler::needMerge() |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
455 | { // Set all of m_changed to true |
490 | 456 | memset (m_changed, 0xFF, sizeof m_changed); |
457 | } | |
458 | ||
459 | // ============================================================================= | |
460 | // ----------------------------------------------------------------------------- | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
461 | void VertexCompiler::initObject (LDObject* obj) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
462 | { if (m_objArrays.find (obj) == m_objArrays.end()) |
490 | 463 | m_objArrays[obj] = new Array[GL::NumArrays]; |
464 | } | |
465 | ||
466 | // ============================================================================= | |
467 | // ----------------------------------------------------------------------------- | |
666
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
468 | void VertexCompiler::stageForCompilation (LDObject* obj) |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
469 | { m_staged << obj; |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
470 | removeDuplicates (m_staged); |
c595cfb4791c
now compiles again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
490
diff
changeset
|
471 | } |