]> git.cworth.org Git - vogl/blob - src/vogleditor/vogleditor_statetreevertexarrayitem.cpp
Initial vogl checkin
[vogl] / src / vogleditor / vogleditor_statetreevertexarrayitem.cpp
1 #include "vogleditor_statetreevertexarrayitem.h"
2
3 vogleditor_stateTreeVertexArrayBoolItem::vogleditor_stateTreeVertexArrayBoolItem(QString name, bool vogl_vertex_attrib_desc::* pVal, vogleditor_stateTreeItem* parent, const vogl_vertex_attrib_desc& state, unsigned int arrayIndex)
4     : vogleditor_stateTreeVertexArrayDiffableItem(name, "", parent, arrayIndex),
5       m_pState(&state),
6       m_pVal(pVal),
7       m_pIntVal(NULL)
8 {
9     bool val = state.*pVal;
10     setValue(val? "GL_TRUE" : "GL_FALSE");
11 }
12
13 vogleditor_stateTreeVertexArrayBoolItem::vogleditor_stateTreeVertexArrayBoolItem(QString name, int vogl_vertex_attrib_desc::* pVal, vogleditor_stateTreeItem* parent, const vogl_vertex_attrib_desc& state, unsigned int arrayIndex)
14     : vogleditor_stateTreeVertexArrayDiffableItem(name, "", parent, arrayIndex),
15       m_pState(&state),
16       m_pVal(NULL),
17       m_pIntVal(pVal)
18 {
19     int val = state.*pVal;
20     setValue((val != 0)? "GL_TRUE" : "GL_FALSE");
21 }
22
23 bool vogleditor_stateTreeVertexArrayBoolItem::hasChanged() const
24 {
25     if (m_pDiffBaseState == NULL)
26         return false;
27
28     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
29     {
30         // the current node does not exist in the base snapshot, so it must be new and different.
31         return true;
32     }
33     else
34     {
35         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
36         if (m_pVal != NULL)
37             return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
38
39         if (m_pIntVal != NULL)
40             return (m_pState->*m_pIntVal) != (baseDesc.*m_pIntVal);
41     }
42
43     return false;
44 }
45
46 QString vogleditor_stateTreeVertexArrayBoolItem::getDiffedValue() const
47 {
48     if (m_pDiffBaseState == NULL)
49         return "";
50
51     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
52     {
53         // the current node does not exist in the base snapshot, so it must be new and different.
54         return "non-existent";
55     }
56     else
57     {
58         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
59         if (m_pVal != NULL)
60         {
61             bool value = baseDesc.*m_pVal;
62             return getValueFromBools(&value, 1);
63         }
64
65         if (m_pIntVal != NULL)
66         {
67             bool value = (baseDesc.*m_pVal != 0);
68             return getValueFromBools(&value, 1);
69         }
70     }
71
72     return "";
73 }
74
75
76 //=============================================================================
77
78 vogleditor_stateTreeVertexArrayEnumItem::vogleditor_stateTreeVertexArrayEnumItem(QString name, GLenum vogl_vertex_attrib_desc::* pVal, vogleditor_stateTreeItem* parent, const vogl_vertex_attrib_desc& state, unsigned int arrayIndex)
79     : vogleditor_stateTreeVertexArrayDiffableItem(name, "", parent, arrayIndex),
80       m_pState(&state),
81       m_pVal(pVal)
82 {
83     GLenum val = state.*pVal;
84     setValue(enum_to_string(val));
85 }
86
87 bool vogleditor_stateTreeVertexArrayEnumItem::hasChanged() const
88 {
89     if (m_pDiffBaseState == NULL)
90         return false;
91
92     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
93     {
94         // the current node does not exist in the base snapshot, so it must be new and different.
95         return true;
96     }
97     else
98     {
99         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
100         return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
101     }
102 }
103
104 QString vogleditor_stateTreeVertexArrayEnumItem::getDiffedValue() const
105 {
106     if (m_pDiffBaseState == NULL)
107         return "";
108
109     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
110     {
111         // the current node does not exist in the base snapshot, so it must be new and different.
112         return "non-existent";
113     }
114     else
115     {
116         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
117
118         GLenum value = baseDesc.*m_pVal;
119         return enum_to_string(value);
120     }
121
122     return "";
123 }
124
125 //=============================================================================
126
127 vogleditor_stateTreeVertexArrayPtrItem::vogleditor_stateTreeVertexArrayPtrItem(QString name, vogl_trace_ptr_value vogl_vertex_attrib_desc::* pVal, vogleditor_stateTreeItem* parent, const vogl_vertex_attrib_desc& state, unsigned int arrayIndex)
128     : vogleditor_stateTreeVertexArrayDiffableItem(name, "", parent, arrayIndex),
129       m_pState(&state),
130       m_pVal(pVal)
131 {
132     vogl_trace_ptr_value val = state.*pVal;
133     setValue((void*)val);
134 }
135
136 bool vogleditor_stateTreeVertexArrayPtrItem::hasChanged() const
137 {
138     if (m_pDiffBaseState == NULL)
139         return false;
140
141     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
142     {
143         // the current node does not exist in the base snapshot, so it must be new and different.
144         return true;
145     }
146     else
147     {
148         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
149         return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
150     }
151 }
152
153 QString vogleditor_stateTreeVertexArrayPtrItem::getDiffedValue() const
154 {
155     if (m_pDiffBaseState == NULL)
156         return "";
157
158     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
159     {
160         // the current node does not exist in the base snapshot, so it must be new and different.
161         return "non-existent";
162     }
163     else
164     {
165         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
166
167         vogl_trace_ptr_value value = baseDesc.*m_pVal;
168         return getValueFromPtrs((int*)&value, 1);
169     }
170
171     return "";
172 }
173
174 //=============================================================================
175
176 vogleditor_stateTreeVertexArrayUIntItem::vogleditor_stateTreeVertexArrayUIntItem(QString name, GLuint vogl_vertex_attrib_desc::* pVal, vogleditor_stateTreeItem* parent, const vogl_vertex_attrib_desc& state, unsigned int arrayIndex)
177     : vogleditor_stateTreeVertexArrayDiffableItem(name, "", parent, arrayIndex),
178       m_pState(&state),
179       m_pVal(pVal)
180 {
181     uint val = state.*pVal;
182     setValue(val);
183 }
184
185 bool vogleditor_stateTreeVertexArrayUIntItem::hasChanged() const
186 {
187     if (m_pDiffBaseState == NULL)
188         return false;
189
190     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
191     {
192         // the current node does not exist in the base snapshot, so it must be new and different.
193         return true;
194     }
195     else
196     {
197         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
198         return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
199     }
200 }
201
202 QString vogleditor_stateTreeVertexArrayUIntItem::getDiffedValue() const
203 {
204     if (m_pDiffBaseState == NULL)
205         return "";
206
207     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
208     {
209         // the current node does not exist in the base snapshot, so it must be new and different.
210         return "non-existent";
211     }
212     else
213     {
214         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
215
216         uint value = baseDesc.*m_pVal;
217         return getValueFromUints(&value, 1);
218     }
219
220     return "";
221 }
222
223 //=============================================================================
224
225 vogleditor_stateTreeVertexArrayIntItem::vogleditor_stateTreeVertexArrayIntItem(QString name, GLint vogl_vertex_attrib_desc::* pVal, vogleditor_stateTreeItem* parent, const vogl_vertex_attrib_desc& state, unsigned int arrayIndex)
226     : vogleditor_stateTreeVertexArrayDiffableItem(name, "", parent, arrayIndex),
227       m_pState(&state),
228       m_pVal(pVal)
229 {
230     uint val = state.*pVal;
231     setValue(val);
232 }
233
234 bool vogleditor_stateTreeVertexArrayIntItem::hasChanged() const
235 {
236     if (m_pDiffBaseState == NULL)
237         return false;
238
239     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
240     {
241         // the current node does not exist in the base snapshot, so it must be new and different.
242         return true;
243     }
244     else
245     {
246         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
247         return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
248     }
249 }
250
251 QString vogleditor_stateTreeVertexArrayIntItem::getDiffedValue() const
252 {
253     if (m_pDiffBaseState == NULL)
254         return "";
255
256     if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
257     {
258         // the current node does not exist in the base snapshot, so it must be new and different.
259         return "non-existent";
260     }
261     else
262     {
263         const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
264
265         int value = baseDesc.*m_pVal;
266         return getValueFromInts(&value, 1);
267     }
268
269     return "";
270 }
271
272 //=============================================================================
273
274 vogleditor_stateTreeVertexArrayItem::vogleditor_stateTreeVertexArrayItem(QString name, QString value, GLuint64 handle, vogleditor_stateTreeItem* parent, vogl_vao_state& state, const vogl_context_info& info)
275     : vogleditor_stateTreeItem(name, value, parent),
276       m_pState(&state),
277       m_handle(handle),
278       m_pDiffBaseState(NULL)
279 {
280     static QString tmp;
281     for (uint i = 0; i < info.get_max_vertex_attribs(); i++)
282     {
283        vogleditor_stateTreeItem* pAttribNode = new vogleditor_stateTreeItem(tmp.sprintf("GL_VERTEX_ATTRIB %u", i), "", this);
284        this->appendChild(pAttribNode);
285
286        const vogl_vertex_attrib_desc& desc = state.get_vertex_attrib_desc(i);
287
288        { vogleditor_stateTreeVertexArrayUIntItem* pItem = new vogleditor_stateTreeVertexArrayUIntItem("GL_ELEMENT_ARRAY_BUFFER_BINDING", &vogl_vertex_attrib_desc::m_element_array_binding, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
289        { vogleditor_stateTreeVertexArrayUIntItem* pItem = new vogleditor_stateTreeVertexArrayUIntItem("GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", &vogl_vertex_attrib_desc::m_array_binding, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
290        { vogleditor_stateTreeVertexArrayBoolItem* pItem = new vogleditor_stateTreeVertexArrayBoolItem("GL_VERTEX_ATTRIB_ARRAY_ENABLED", &vogl_vertex_attrib_desc::m_enabled, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
291        { vogleditor_stateTreeVertexArrayIntItem* pItem = new vogleditor_stateTreeVertexArrayIntItem("GL_VERTEX_ATTRIB_ARRAY_SIZE", &vogl_vertex_attrib_desc::m_size, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
292        { vogleditor_stateTreeVertexArrayEnumItem* pItem = new vogleditor_stateTreeVertexArrayEnumItem("GL_VERTEX_ATTRIB_ARRAY_TYPE", &vogl_vertex_attrib_desc::m_type, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
293        { vogleditor_stateTreeVertexArrayBoolItem* pItem = new vogleditor_stateTreeVertexArrayBoolItem("GL_VERTEX_ATTRIB_ARRAY_NORMALIZED", &vogl_vertex_attrib_desc::m_normalized, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
294        { vogleditor_stateTreeVertexArrayIntItem* pItem = new vogleditor_stateTreeVertexArrayIntItem("GL_VERTEX_ATTRIB_ARRAY_STRIDE", &vogl_vertex_attrib_desc::m_stride, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
295        { vogleditor_stateTreeVertexArrayBoolItem* pItem = new vogleditor_stateTreeVertexArrayBoolItem("GL_VERTEX_ATTRIB_ARRAY_INTEGER", &vogl_vertex_attrib_desc::m_integer, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
296        { vogleditor_stateTreeVertexArrayUIntItem* pItem = new vogleditor_stateTreeVertexArrayUIntItem("GL_VERTEX_ATTRIB_ARRAY_DIVISOR", &vogl_vertex_attrib_desc::m_divisor, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
297        { vogleditor_stateTreeVertexArrayPtrItem* pItem = new vogleditor_stateTreeVertexArrayPtrItem("GL_VERTEX_ATTRIB_ARRAY_POINTER", &vogl_vertex_attrib_desc::m_pointer, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
298     }
299 }