1 #ifndef VOGLEDITOR_STATETREECONTEXTITEM_H
2 #define VOGLEDITOR_STATETREECONTEXTITEM_H
4 #include "vogleditor_statetreeitem.h"
5 #include "vogleditor_statetreearbprogramitem.h"
6 #include "vogleditor_statetreearbprogramenvitem.h"
7 #include "vogleditor_statetreebufferitem.h"
8 #include "vogleditor_statetreecontextinfoitem.h"
9 #include "vogleditor_statetreecontextgeneralitem.h"
10 #include "vogleditor_statetreeframebufferitem.h"
11 #include "vogleditor_statetreelightitem.h"
12 #include "vogleditor_statetreepolygonstippleitem.h"
13 #include "vogleditor_statetreeprogramitem.h"
14 #include "vogleditor_statetreequeryitem.h"
15 #include "vogleditor_statetreerenderbufferitem.h"
16 #include "vogleditor_statetreesampleritem.h"
17 #include "vogleditor_statetreeshaderitem.h"
18 #include "vogleditor_statetreesyncitem.h"
19 #include "vogleditor_statetreetexenvitem.h"
20 #include "vogleditor_statetreetextureitem.h"
21 #include "vogleditor_statetreematrixitem.h"
22 #include "vogleditor_statetreevertexarrayitem.h"
24 #include "vogl_gl_state_snapshot.h"
25 #include "vogl_sync_object.h"
27 class vogleditor_stateTreeContextAttributesItem : public vogleditor_stateTreeItem
30 vogleditor_stateTreeContextAttributesItem(QString name, vogleditor_stateTreeItem* parent, const vogl_context_desc& desc)
31 : vogleditor_stateTreeItem(name, "", parent),
33 m_pDiffBaseState(NULL)
35 setValue(attribsToString(desc.get_attribs()));
38 virtual ~vogleditor_stateTreeContextAttributesItem() { m_pState = NULL; m_pDiffBaseState = NULL; }
40 void set_diff_base_state(const vogl_context_desc* pBaseState) { m_pDiffBaseState = pBaseState; }
42 virtual bool hasChanged() const
44 if (m_pDiffBaseState == NULL)
49 const vogl_context_attribs& attribs = m_pState->get_attribs();
51 for (uint i = 0; i < attribs.size(); i++)
53 if (i < m_pDiffBaseState->get_attribs().size())
55 if (attribs[i] != m_pDiffBaseState->get_attribs()[i])
65 virtual QString getDiffedValue() const
67 if (m_pDiffBaseState == NULL)
72 return attribsToString(m_pDiffBaseState->get_attribs());
76 const vogl_context_desc* m_pState;
77 const vogl_context_desc* m_pDiffBaseState;
79 QString attribsToString(const vogl_context_attribs& attribs) const
83 for (uint i = 0; i < attribs.size(); i++)
90 GLenum id = attribs[i];
92 // final value should always be 0, and should not be handled like the other attribs
99 tmp = g_gl_enums.find_glx_name(id);
100 if (tmp.isEmpty() || tmp.isNull())
102 tmp = tmp.sprintf("0x%x", id);
107 // check for a value to go with the above attrib
108 if (i + 1 < attribs.size())
111 attribStr += tmp.sprintf(" = 0x%x", attribs[i]);
115 if (attribStr.isEmpty())
123 class vogleditor_stateTreeContextCreationItem : public vogleditor_stateTreeItem
126 vogleditor_stateTreeContextCreationItem(QString name, vogleditor_stateTreeItem* parent, const vogl_context_desc& desc)
127 : vogleditor_stateTreeItem(name, "", parent),
129 m_pDiffBaseState(NULL)
131 const gl_entrypoint_desc_t &creation_func_entrypoint_desc = g_vogl_entrypoint_descs[desc.get_creation_func()];
133 setValue(QString(creation_func_entrypoint_desc.m_pName));
136 virtual ~vogleditor_stateTreeContextCreationItem() { m_pState = NULL; m_pDiffBaseState = NULL; }
138 void set_diff_base_state(const vogl_context_desc* pBaseState) { m_pDiffBaseState = pBaseState; }
140 virtual bool hasChanged() const
142 if (m_pDiffBaseState == NULL)
147 return m_pState->get_creation_func() != m_pDiffBaseState->get_creation_func();
150 virtual QString getDiffedValue() const
152 if (m_pDiffBaseState == NULL)
157 const gl_entrypoint_desc_t &creation_func_entrypoint_desc = g_vogl_entrypoint_descs[m_pDiffBaseState->get_creation_func()];
158 return QString(creation_func_entrypoint_desc.m_pName);
162 const vogl_context_desc* m_pState;
163 const vogl_context_desc* m_pDiffBaseState;
167 class vogleditor_stateTreeContextDirectItem : public vogleditor_stateTreeItem
170 vogleditor_stateTreeContextDirectItem(QString name, vogleditor_stateTreeItem* parent, const vogl_context_desc& desc)
171 : vogleditor_stateTreeItem(name, "", parent),
173 m_pDiffBaseState(NULL)
175 setValue((bool)desc.get_direct());
178 virtual ~vogleditor_stateTreeContextDirectItem() { m_pState = NULL; m_pDiffBaseState = NULL; }
180 void set_diff_base_state(const vogl_context_desc* pBaseState) { m_pDiffBaseState = pBaseState; }
182 virtual bool hasChanged() const
184 if (m_pDiffBaseState == NULL)
189 return m_pState->get_direct() != m_pDiffBaseState->get_direct();
192 virtual QString getDiffedValue() const
194 if (m_pDiffBaseState == NULL)
199 bool value = m_pDiffBaseState->get_direct();
200 return getValueFromBools(&value, 1);
204 const vogl_context_desc* m_pState;
205 const vogl_context_desc* m_pDiffBaseState;
208 class vogleditor_stateTreeContextSharedItem : public vogleditor_stateTreeItem
211 vogleditor_stateTreeContextSharedItem(QString name, vogleditor_stateTreeItem* parent, const vogl_context_desc& desc)
212 : vogleditor_stateTreeItem(name, "", parent),
214 m_pDiffBaseState(NULL)
216 setValue((void*)desc.get_trace_share_context());
219 virtual ~vogleditor_stateTreeContextSharedItem() { m_pState = NULL; m_pDiffBaseState = NULL; }
221 void set_diff_base_state(const vogl_context_desc* pBaseState) { m_pDiffBaseState = pBaseState; }
223 virtual bool hasChanged() const
225 if (m_pDiffBaseState == NULL)
230 return m_pState->get_trace_share_context() != m_pDiffBaseState->get_trace_share_context();
233 virtual QString getDiffedValue() const
235 if (m_pDiffBaseState == NULL)
240 vogl_trace_ptr_value value = m_pDiffBaseState->get_trace_share_context();
241 return getValueFromPtrs((int*)&value, 1);
245 const vogl_context_desc* m_pState;
246 const vogl_context_desc* m_pDiffBaseState;
249 class vogleditor_stateTreeContextMaterialItem : public vogleditor_stateTreeItem
252 vogleditor_stateTreeContextMaterialItem(QString name, unsigned int face, vogleditor_stateTreeItem* parent, vogl_material_state& state)
253 : vogleditor_stateTreeItem(name, "", parent),
256 m_pDiffBaseState(NULL)
258 vogl_state_vector* pStateVec = state.get_state_vector(face);
260 int iVals[4] = {0,0,0,0};
261 float fVals[4] = {0,0,0,0};
262 #define GET_FLOAT(side, name, num) if (pStateVec->get<float>(name, 0, fVals, num)) { vogleditor_stateTreeStateVecFloatItem* pItem = new vogleditor_stateTreeStateVecFloatItem(#name, name, 0, *(pStateVec), fVals, num, false, this); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
263 #define GET_INT(side, name, num) if (pStateVec->get<int>(name, 0, iVals, num)) { vogleditor_stateTreeStateVecIntItem* pItem = new vogleditor_stateTreeStateVecIntItem(#name, name, 0, *(pStateVec), iVals, num, false, this); m_diffableItems.push_back(pItem); this->appendChild(pItem); }
264 VOGL_ASSERT(pStateVec->size() == 6);
265 GET_FLOAT(face, GL_AMBIENT, 4);
266 GET_FLOAT(face, GL_DIFFUSE, 4);
267 GET_FLOAT(face, GL_SPECULAR, 4);
268 GET_FLOAT(face, GL_EMISSION, 4);
269 GET_FLOAT(face, GL_SHININESS, 1);
270 GET_INT(face, GL_COLOR_INDEXES, 3);
275 virtual ~vogleditor_stateTreeContextMaterialItem() { m_pState = NULL; m_pDiffBaseState = NULL;}
277 void set_diff_base_state(const vogl_material_state* pBaseState)
279 m_pDiffBaseState = pBaseState;
281 for (vogleditor_stateTreeStateVecDiffableItem** iter = m_diffableItems.begin(); iter != m_diffableItems.end(); iter++)
283 (*iter)->set_diff_base_state(m_pDiffBaseState->get_state_vector(m_face));
288 const unsigned int m_face;
289 const vogl_material_state* m_pState;
290 const vogl_material_state* m_pDiffBaseState;
291 vogl::vector<vogleditor_stateTreeStateVecDiffableItem*> m_diffableItems;
295 class vogleditor_stateTreeContextItem : public vogleditor_stateTreeItem
299 vogleditor_stateTreeContextItem(QString name, QString value, vogleditor_stateTreeItem* parent, vogl_context_snapshot& contextState);
301 virtual ~vogleditor_stateTreeContextItem();
303 void set_diff_base_state(const vogl_context_snapshot* pBaseState);
305 vogl::vector<vogleditor_stateTreeProgramItem*> get_program_objects()
307 return m_programItems;
311 vogl_context_snapshot* m_pState;
312 const vogl_context_snapshot* m_pDiffBaseState;
313 vogleditor_stateTreeContextAttributesItem* m_pAttributesItem;
314 vogleditor_stateTreeContextCreationItem* m_pCreationItem;
315 vogleditor_stateTreeContextDirectItem* m_pDirectItem;
316 vogleditor_stateTreeContextSharedItem* m_pSharedItem;
317 vogleditor_stateTreePolygonStippleItem* m_pPolygonStippleItem;
318 vogleditor_stateTreeTexEnvItem* m_pTexEnvItem;
319 vogl::vector<vogleditor_stateTreeContextInfoItem*> m_contextInfoItems;
320 vogl::vector<vogleditor_stateTreeContextGeneralItem*> m_generalStateItems;
321 vogl::vector<vogleditor_stateTreeStateVecDiffableItem*> m_diffableItems;
322 vogl::vector<vogleditor_stateTreeTextureItem*> m_textureItems;
323 vogl::vector<vogleditor_stateTreeSamplerItem*> m_samplerItems;
324 vogl::vector<vogleditor_stateTreeBufferItem*> m_bufferItems;
325 vogl::vector<vogleditor_stateTreeLightItem*> m_lightItems;
326 vogl::vector<vogleditor_stateTreeContextMaterialItem*> m_materialItems;
327 vogl::vector<vogleditor_stateTreeMatrixStackItem*> m_matrixStackItems;
328 vogl::vector<vogleditor_stateTreeQueryItem*> m_queryItems;
329 vogl::vector<vogleditor_stateTreeRenderbufferItem*> m_renderbufferItems;
330 vogl::vector<vogleditor_stateTreeVertexArrayItem*> m_vertexArrayItems;
331 vogl::vector<vogleditor_stateTreeFramebufferItem*> m_framebufferItems;
332 vogl::vector<vogleditor_stateTreeShaderItem*> m_shaderItems;
333 vogl::vector<vogleditor_stateTreeProgramItem*> m_programItems;
334 vogl::vector<vogleditor_stateTreeSyncItem*> m_syncItems;
335 vogl::vector<vogleditor_stateTreeArbProgramItem*> m_arbProgramItems;
336 vogl::vector<vogleditor_stateTreeArbProgramEnvItem*> m_arbProgramEnvItems;
339 #endif // VOGLEDITOR_STATETREECONTEXTITEM_H