1 #include "vogleditor_statetreearbprogramitem.h"
3 //=============================================================================
5 vogleditor_stateTreeArbProgramBoolItem::vogleditor_stateTreeArbProgramBoolItem(QString name, bool (vogl_arb_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_arb_program_state& state)
6 : vogleditor_stateTreeArbProgramDiffableItem(name, "", parent, state),
9 bool val = (state.*func)();
10 setValue(getValueFromBools(&val, 1));
13 bool vogleditor_stateTreeArbProgramBoolItem::hasChanged() const
15 if (m_pDiffBaseState == NULL)
18 return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
21 QString vogleditor_stateTreeArbProgramBoolItem::getDiffedValue() const
23 if (m_pDiffBaseState == NULL)
26 bool val = (m_pDiffBaseState->*m_pFunc)();
27 return getValueFromBools(&val, 1);
30 //=============================================================================
32 vogleditor_stateTreeArbProgramUIntItem::vogleditor_stateTreeArbProgramUIntItem(QString name, uint (vogl_arb_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_arb_program_state& state)
33 : vogleditor_stateTreeArbProgramDiffableItem(name, "", parent, state),
36 uint val = (state.*func)();
37 setValue(getValueFromUints(&val, 1));
40 bool vogleditor_stateTreeArbProgramUIntItem::hasChanged() const
42 if (m_pDiffBaseState == NULL)
45 return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
48 QString vogleditor_stateTreeArbProgramUIntItem::getDiffedValue() const
50 if (m_pDiffBaseState == NULL)
53 uint val = (m_pDiffBaseState->*m_pFunc)();
54 return getValueFromUints(&val, 1);
57 //=============================================================================
59 vogleditor_stateTreeArbProgramIntItem::vogleditor_stateTreeArbProgramIntItem(QString name, GLint (vogl_arb_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_arb_program_state& state)
60 : vogleditor_stateTreeArbProgramDiffableItem(name, "", parent, state),
63 GLint val = (state.*func)();
64 setValue(getValueFromInts(&val, 1));
67 bool vogleditor_stateTreeArbProgramIntItem::hasChanged() const
69 if (m_pDiffBaseState == NULL)
72 return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
75 QString vogleditor_stateTreeArbProgramIntItem::getDiffedValue() const
77 if (m_pDiffBaseState == NULL)
80 int val = (m_pDiffBaseState->*m_pFunc)();
81 return getValueFromInts(&val, 1);
84 //=============================================================================
86 vogleditor_stateTreeArbProgramEnumItem::vogleditor_stateTreeArbProgramEnumItem(QString name, GLenum (vogl_arb_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_arb_program_state& state)
87 : vogleditor_stateTreeArbProgramDiffableItem(name, "", parent, state),
90 GLenum val = (state.*func)();
91 setValue(enum_to_string(val));
94 bool vogleditor_stateTreeArbProgramEnumItem::hasChanged() const
96 if (m_pDiffBaseState == NULL)
99 return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
102 QString vogleditor_stateTreeArbProgramEnumItem::getDiffedValue() const
104 if (m_pDiffBaseState == NULL)
107 int val = (m_pDiffBaseState->*m_pFunc)();
108 return getValueFromEnums(&val, 1);
111 //=============================================================================
113 vogleditor_stateTreeArbProgramStringItem::vogleditor_stateTreeArbProgramStringItem(QString name, const uint8_vec& (vogl_arb_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_arb_program_state& state)
114 : vogleditor_stateTreeArbProgramDiffableItem(name, "", parent, state),
117 const uint8_vec& value = (state.*func)();
118 setValue((const char*)value.get_const_ptr());
121 bool vogleditor_stateTreeArbProgramStringItem::hasChanged() const
123 if (m_pDiffBaseState == NULL)
129 return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
133 QString vogleditor_stateTreeArbProgramStringItem::getDiffedValue() const
135 if (m_pDiffBaseState == NULL)
138 const uint8_vec& value = (m_pDiffBaseState->*m_pFunc)();
139 return QString((const char*)value.get_const_ptr());
142 //=============================================================================
144 vogleditor_stateTreeArbProgramParamItem::vogleditor_stateTreeArbProgramParamItem(QString name, unsigned int paramIndex, vogleditor_stateTreeItem* parent, const vogl_arb_program_state& state)
145 : vogleditor_stateTreeArbProgramDiffableItem(name, "", parent, state),
146 m_paramIndex(paramIndex)
149 const vec4F_vec& params = m_pState->get_program_local_params();
150 setValue(tmp.sprintf("%f, %f, %f, %f", params[paramIndex][0], params[paramIndex][1], params[paramIndex][2], params[paramIndex][3]));
153 bool vogleditor_stateTreeArbProgramParamItem::hasChanged() const
155 if (m_pDiffBaseState == NULL)
158 const vec4F_vec& curParams = m_pState->get_program_local_params();
159 if (m_paramIndex >= curParams.size())
161 // this should be an impossible case to get in.
165 const vec4F_vec& baseParams = m_pDiffBaseState->get_program_local_params();
166 if (m_paramIndex >= baseParams.size())
168 // this could be possible
172 const vec4F& baseParam = baseParams[m_paramIndex];
173 const vec4F& curParam = curParams[m_paramIndex];
175 return (curParam[0] != baseParam[0] ||
176 curParam[1] != baseParam[1] ||
177 curParam[2] != baseParam[2] ||
178 curParam[3] != baseParam[3]);
181 QString vogleditor_stateTreeArbProgramParamItem::getDiffedValue() const
183 if (m_pDiffBaseState == NULL)
186 const vec4F_vec& baseParams = m_pDiffBaseState->get_program_local_params();
187 if (m_paramIndex >= baseParams.size())
189 // this could be possible
190 return "non-existent";
193 const vec4F& baseParam = baseParams[m_paramIndex];
194 return getValueFromFloats(baseParam.get_ptr(), 1);
197 //=============================================================================
199 vogleditor_stateTreeArbProgramItem::vogleditor_stateTreeArbProgramItem(QString name, QString value, vogleditor_stateTreeItem* parentNode, vogl_arb_program_state& state)
200 : vogleditor_stateTreeItem(name, value, parentNode),
205 setValue(tmp.sprintf("%d instructions", state.get_num_instructions()));
207 { vogleditor_stateTreeArbProgramEnumItem* pItem = new vogleditor_stateTreeArbProgramEnumItem("GL_PROGRAM_FORMAT_ARB", &vogl_arb_program_state::get_program_format, this, state); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
208 { vogleditor_stateTreeArbProgramIntItem* pItem = new vogleditor_stateTreeArbProgramIntItem("GL_PROGRAM_INSTRUCTIONS_ARB", &vogl_arb_program_state::get_num_instructions, this, state); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
209 { vogleditor_stateTreeArbProgramBoolItem* pItem = new vogleditor_stateTreeArbProgramBoolItem("GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB", &vogl_arb_program_state::is_native, this, state); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
210 { vogleditor_stateTreeArbProgramUIntItem* pItem = new vogleditor_stateTreeArbProgramUIntItem("GL_PROGRAM_LENGTH_ARB", &vogl_arb_program_state::get_program_string_size, this, state); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
212 // if (m_pState->get_program_string_size() > 0)
214 // this->appendChild(new vogleditor_stateTreeArbProgramStringItem("GL_PROGRAM_STRING_ARB", &vogl_arb_program_state::get_program_string, this, state));
217 const vec4F_vec& params = m_pState->get_program_local_params();
218 vogleditor_stateTreeItem* pParamsNode = new vogleditor_stateTreeItem("GL_PROGRAM_PARAMETERS_ARB", tmp.sprintf("[%d]", params.size()), this);
219 this->appendChild(pParamsNode);
221 for (uint i = 0; i < params.size(); i++)
223 vogleditor_stateTreeArbProgramParamItem* pItem = new vogleditor_stateTreeArbProgramParamItem(tmp.sprintf("%u", i), i, pParamsNode, state);
224 m_diffableItems.push_back(pItem);
225 pParamsNode->appendChild(pItem);