1 #include "vogleditor_statetreevertexarrayitem.h"
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),
9 bool val = state.*pVal;
10 setValue(val? "GL_TRUE" : "GL_FALSE");
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),
19 int val = state.*pVal;
20 setValue((val != 0)? "GL_TRUE" : "GL_FALSE");
23 bool vogleditor_stateTreeVertexArrayBoolItem::hasChanged() const
25 if (m_pDiffBaseState == NULL)
28 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
30 // the current node does not exist in the base snapshot, so it must be new and different.
35 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
37 return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
39 if (m_pIntVal != NULL)
40 return (m_pState->*m_pIntVal) != (baseDesc.*m_pIntVal);
46 QString vogleditor_stateTreeVertexArrayBoolItem::getDiffedValue() const
48 if (m_pDiffBaseState == NULL)
51 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
53 // the current node does not exist in the base snapshot, so it must be new and different.
54 return "non-existent";
58 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
61 bool value = baseDesc.*m_pVal;
62 return getValueFromBools(&value, 1);
65 if (m_pIntVal != NULL)
67 bool value = (baseDesc.*m_pVal != 0);
68 return getValueFromBools(&value, 1);
76 //=============================================================================
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),
83 GLenum val = state.*pVal;
84 setValue(enum_to_string(val));
87 bool vogleditor_stateTreeVertexArrayEnumItem::hasChanged() const
89 if (m_pDiffBaseState == NULL)
92 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
94 // the current node does not exist in the base snapshot, so it must be new and different.
99 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
100 return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
104 QString vogleditor_stateTreeVertexArrayEnumItem::getDiffedValue() const
106 if (m_pDiffBaseState == NULL)
109 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
111 // the current node does not exist in the base snapshot, so it must be new and different.
112 return "non-existent";
116 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
118 GLenum value = baseDesc.*m_pVal;
119 return enum_to_string(value);
125 //=============================================================================
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),
132 vogl_trace_ptr_value val = state.*pVal;
133 setValue((void*)val);
136 bool vogleditor_stateTreeVertexArrayPtrItem::hasChanged() const
138 if (m_pDiffBaseState == NULL)
141 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
143 // the current node does not exist in the base snapshot, so it must be new and different.
148 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
149 return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
153 QString vogleditor_stateTreeVertexArrayPtrItem::getDiffedValue() const
155 if (m_pDiffBaseState == NULL)
158 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
160 // the current node does not exist in the base snapshot, so it must be new and different.
161 return "non-existent";
165 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
167 vogl_trace_ptr_value value = baseDesc.*m_pVal;
168 return getValueFromPtrs((int*)&value, 1);
174 //=============================================================================
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),
181 uint val = state.*pVal;
185 bool vogleditor_stateTreeVertexArrayUIntItem::hasChanged() const
187 if (m_pDiffBaseState == NULL)
190 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
192 // the current node does not exist in the base snapshot, so it must be new and different.
197 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
198 return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
202 QString vogleditor_stateTreeVertexArrayUIntItem::getDiffedValue() const
204 if (m_pDiffBaseState == NULL)
207 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
209 // the current node does not exist in the base snapshot, so it must be new and different.
210 return "non-existent";
214 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
216 uint value = baseDesc.*m_pVal;
217 return getValueFromUints(&value, 1);
223 //=============================================================================
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),
230 uint val = state.*pVal;
234 bool vogleditor_stateTreeVertexArrayIntItem::hasChanged() const
236 if (m_pDiffBaseState == NULL)
239 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
241 // the current node does not exist in the base snapshot, so it must be new and different.
246 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
247 return (m_pState->*m_pVal) != (baseDesc.*m_pVal);
251 QString vogleditor_stateTreeVertexArrayIntItem::getDiffedValue() const
253 if (m_pDiffBaseState == NULL)
256 if (m_arrayIndex >= m_pDiffBaseState->get_vertex_attrib_count())
258 // the current node does not exist in the base snapshot, so it must be new and different.
259 return "non-existent";
263 const vogl_vertex_attrib_desc& baseDesc = m_pDiffBaseState->get_vertex_attrib_desc(m_arrayIndex);
265 int value = baseDesc.*m_pVal;
266 return getValueFromInts(&value, 1);
272 //=============================================================================
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),
278 m_pDiffBaseState(NULL)
281 for (uint i = 0; i < info.get_max_vertex_attribs(); i++)
283 vogleditor_stateTreeItem* pAttribNode = new vogleditor_stateTreeItem(tmp.sprintf("GL_VERTEX_ATTRIB %u", i), "", this);
284 this->appendChild(pAttribNode);
286 const vogl_vertex_attrib_desc& desc = state.get_vertex_attrib_desc(i);
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); }