]> git.cworth.org Git - vogl/blob - src/vogleditor/vogleditor_statetreearbprogramitem.cpp
- Fix for restoring FBO's that have attachments that the tracer was not able to query...
[vogl] / src / vogleditor / vogleditor_statetreearbprogramitem.cpp
1 #include "vogleditor_statetreearbprogramitem.h"
2
3 //=============================================================================
4
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),
7       m_pFunc(func)
8 {
9     bool val = (state.*func)();
10     setValue(getValueFromBools(&val, 1));
11 }
12
13 bool vogleditor_stateTreeArbProgramBoolItem::hasChanged() const
14 {
15     if (m_pDiffBaseState == NULL)
16         return false;
17     else
18         return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
19 }
20
21 QString vogleditor_stateTreeArbProgramBoolItem::getDiffedValue() const
22 {
23     if (m_pDiffBaseState == NULL)
24         return "";
25
26     bool val = (m_pDiffBaseState->*m_pFunc)();
27     return getValueFromBools(&val, 1);
28 }
29
30 //=============================================================================
31
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),
34       m_pFunc(func)
35 {
36     uint val = (state.*func)();
37     setValue(getValueFromUints(&val, 1));
38 }
39
40 bool vogleditor_stateTreeArbProgramUIntItem::hasChanged() const
41 {
42     if (m_pDiffBaseState == NULL)
43         return false;
44     else
45         return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
46 }
47
48 QString vogleditor_stateTreeArbProgramUIntItem::getDiffedValue() const
49 {
50     if (m_pDiffBaseState == NULL)
51         return "";
52
53     uint val = (m_pDiffBaseState->*m_pFunc)();
54     return getValueFromUints(&val, 1);
55 }
56
57 //=============================================================================
58
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),
61       m_pFunc(func)
62 {
63     GLint val = (state.*func)();
64     setValue(getValueFromInts(&val, 1));
65 }
66
67 bool vogleditor_stateTreeArbProgramIntItem::hasChanged() const
68 {
69     if (m_pDiffBaseState == NULL)
70         return false;
71     else
72         return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
73 }
74
75 QString vogleditor_stateTreeArbProgramIntItem::getDiffedValue() const
76 {
77     if (m_pDiffBaseState == NULL)
78         return "";
79
80     int val = (m_pDiffBaseState->*m_pFunc)();
81     return getValueFromInts(&val, 1);
82 }
83
84 //=============================================================================
85
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),
88       m_pFunc(func)
89 {
90     GLenum val = (state.*func)();
91     setValue(enum_to_string(val));
92 }
93
94 bool vogleditor_stateTreeArbProgramEnumItem::hasChanged() const
95 {
96     if (m_pDiffBaseState == NULL)
97         return false;
98     else
99         return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
100 }
101
102 QString vogleditor_stateTreeArbProgramEnumItem::getDiffedValue() const
103 {
104     if (m_pDiffBaseState == NULL)
105         return "";
106
107     int val = (m_pDiffBaseState->*m_pFunc)();
108     return getValueFromEnums(&val, 1);
109 }
110
111 //=============================================================================
112
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),
115       m_pFunc(func)
116 {
117     const uint8_vec& value = (state.*func)();
118     setValue((const char*)value.get_const_ptr());
119 }
120
121 bool vogleditor_stateTreeArbProgramStringItem::hasChanged() const
122 {
123     if (m_pDiffBaseState == NULL)
124     {
125         return false;
126     }
127     else
128     {
129         return (m_pState->*m_pFunc)() != (m_pDiffBaseState->*m_pFunc)();
130     }
131 }
132
133 QString vogleditor_stateTreeArbProgramStringItem::getDiffedValue() const
134 {
135     if (m_pDiffBaseState == NULL)
136         return "";
137
138     const uint8_vec& value = (m_pDiffBaseState->*m_pFunc)();
139     return QString((const char*)value.get_const_ptr());
140 }
141
142 //=============================================================================
143
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)
147 {
148     QString tmp;
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]));
151 }
152
153 bool vogleditor_stateTreeArbProgramParamItem::hasChanged() const
154 {
155     if (m_pDiffBaseState == NULL)
156         return false;
157
158     const vec4F_vec& curParams = m_pState->get_program_local_params();
159     if (m_paramIndex >= curParams.size())
160     {
161         // this should be an impossible case to get in.
162         return true;
163     }
164
165     const vec4F_vec& baseParams = m_pDiffBaseState->get_program_local_params();
166     if (m_paramIndex >= baseParams.size())
167     {
168         // this could be possible
169         return true;
170     }
171
172     const vec4F& baseParam = baseParams[m_paramIndex];
173     const vec4F& curParam = curParams[m_paramIndex];
174
175     return (curParam[0] != baseParam[0] ||
176             curParam[1] != baseParam[1] ||
177             curParam[2] != baseParam[2] ||
178             curParam[3] != baseParam[3]);
179 }
180
181 QString vogleditor_stateTreeArbProgramParamItem::getDiffedValue() const
182 {
183     if (m_pDiffBaseState == NULL)
184         return "";
185
186     const vec4F_vec& baseParams = m_pDiffBaseState->get_program_local_params();
187     if (m_paramIndex >= baseParams.size())
188     {
189         // this could be possible
190         return "non-existent";
191     }
192
193     const vec4F& baseParam = baseParams[m_paramIndex];
194     return getValueFromFloats(baseParam.get_ptr(), 1);
195 }
196
197 //=============================================================================
198
199 vogleditor_stateTreeArbProgramItem::vogleditor_stateTreeArbProgramItem(QString name, QString value, vogleditor_stateTreeItem* parentNode, vogl_arb_program_state& state)
200    : vogleditor_stateTreeItem(name, value, parentNode),
201      m_pState(&state)
202 {
203    QString tmp;
204
205    setValue(tmp.sprintf("%d instructions", state.get_num_instructions()));
206
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); }
211
212 //   if (m_pState->get_program_string_size() > 0)
213 //   {
214 //      this->appendChild(new vogleditor_stateTreeArbProgramStringItem("GL_PROGRAM_STRING_ARB", &vogl_arb_program_state::get_program_string, this, state));
215 //   }
216
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);
220
221    for (uint i = 0; i < params.size(); i++)
222    {
223       vogleditor_stateTreeArbProgramParamItem* pItem = new vogleditor_stateTreeArbProgramParamItem(tmp.sprintf("%u", i), i, pParamsNode, state);
224       m_diffableItems.push_back(pItem);
225       pParamsNode->appendChild(pItem);
226    }
227 }