]> git.cworth.org Git - vogl/blob - src/vogleditor/vogleditor_statetreecontextitem.cpp
Initial vogl checkin
[vogl] / src / vogleditor / vogleditor_statetreecontextitem.cpp
1 #include "vogleditor_statetreecontextitem.h"
2 #include "vogleditor_statetreearbprogramitem.h"
3 #include "vogleditor_statetreearbprogramenvitem.h"
4 #include "vogleditor_statetreedisplaylistitem.h"
5 #include "vogleditor_statetreeframebufferitem.h"
6 #include "vogleditor_statetreematrixitem.h"
7 #include "vogleditor_statetreepolygonstippleitem.h"
8 #include "vogleditor_statetreeprogramitem.h"
9 #include "vogleditor_statetreequeryitem.h"
10 #include "vogleditor_statetreerenderbufferitem.h"
11 #include "vogleditor_statetreeshaderitem.h"
12 #include "vogleditor_statetreesyncitem.h"
13 #include "vogleditor_statetreetexenvitem.h"
14 #include "vogleditor_statetreevertexarrayitem.h"
15 #include "vogl_gl_state_snapshot.h"
16
17 struct vogl_gl_object_state_handle_less_than
18 {
19     inline bool operator()(const vogl_gl_object_state* a, const vogl_gl_object_state* b) const
20     {
21         return a->get_snapshot_handle() < b->get_snapshot_handle();
22     }
23 };
24
25 #define STR_INT(val) tmp.sprintf("%d", val)
26
27 vogleditor_stateTreeContextItem::vogleditor_stateTreeContextItem(QString name, QString value, vogleditor_stateTreeItem* parent, vogl_context_snapshot& contextState)
28     : vogleditor_stateTreeItem(name, value, parent),
29       m_pState(&contextState),
30       m_pDiffBaseState(NULL),
31       m_pAttributesItem(NULL),
32       m_pCreationItem(NULL),
33       m_pDirectItem(NULL),
34       m_pSharedItem(NULL),
35       m_pPolygonStippleItem(NULL),
36       m_pTexEnvItem(NULL)
37 {
38     QString tmp;
39     
40     const vogl_context_desc& desc = contextState.get_context_desc();
41
42     // context desc
43     m_pAttributesItem = new vogleditor_stateTreeContextAttributesItem("Attributes", this, desc);
44     this->appendChild(m_pAttributesItem);
45
46     m_pCreationItem = new vogleditor_stateTreeContextCreationItem("Created by", this, desc);
47     this->appendChild(m_pCreationItem);
48
49     m_pDirectItem = new vogleditor_stateTreeContextDirectItem("Direct", this, desc);
50     this->appendChild(m_pDirectItem);
51
52     m_pSharedItem = new vogleditor_stateTreeContextSharedItem("Shared context", this, desc);
53     this->appendChild(m_pSharedItem);
54
55     const vogl_context_info& info = contextState.get_context_info();
56     vogleditor_stateTreeContextInfoItem* pInfoNode = new vogleditor_stateTreeContextInfoItem("Info", "", this, info);
57     m_contextInfoItems.push_back(pInfoNode);
58     this->appendChild(pInfoNode);
59
60     // in order for the rest of this information to be available, info must be valid
61     if (info.is_valid())
62     {
63         vogl_general_context_state& generalState = contextState.get_general_state();
64         vogleditor_stateTreeContextGeneralItem* pGeneralNode = new vogleditor_stateTreeContextGeneralItem("General", "", this, generalState, info);
65         m_generalStateItems.push_back(pGeneralNode);
66         this->appendChild(pGeneralNode);
67
68         vogl_display_list_state displayListState = contextState.get_display_list_state();
69         vogl_display_list_map& displayLists = displayListState.get_display_list_map();
70         if (displayLists.size() > 0)
71         {
72             vogleditor_stateTreeDisplaylistItem* pDisplayListStateNode = new vogleditor_stateTreeDisplaylistItem("DisplayLists", "", this, &displayListState);
73             this->appendChild(pDisplayListStateNode);
74         }
75
76         vogl_light_state& lightState = contextState.get_light_state();
77         if (lightState.is_valid())
78         {
79             vogleditor_stateTreeItem* pLightStateNode = new vogleditor_stateTreeItem("Lights", tmp.sprintf("[%u]", lightState.get_num_lights()), this);
80             this->appendChild(pLightStateNode);
81
82             for (uint i = 0; i < lightState.get_num_lights(); i++)
83             {
84                 const vogl_state_vector& lightVec = lightState.get_light(i);
85                 vogleditor_stateTreeLightItem* pLightNode = new vogleditor_stateTreeLightItem(tmp.sprintf("GL_LIGHT%u", i), i, pLightStateNode, &lightVec);
86                 m_lightItems.push_back(pLightNode);
87                 pLightStateNode->appendChild(pLightNode);
88             }
89         }
90
91         vogl_material_state& materialState = contextState.get_material_state();
92         if (materialState.is_valid())
93         {
94             vogleditor_stateTreeItem* pMaterialNode = new vogleditor_stateTreeItem("Material", "", this);
95             this->appendChild(pMaterialNode);
96
97             vogleditor_stateTreeContextMaterialItem* pFront = new vogleditor_stateTreeContextMaterialItem("GL_FRONT", materialState.cFront, pMaterialNode, materialState);
98             m_materialItems.push_back(pFront);
99             pMaterialNode->appendChild(pFront);
100
101             vogleditor_stateTreeContextMaterialItem* pBack = new vogleditor_stateTreeContextMaterialItem("GL_BACK", materialState.cBack, pMaterialNode, materialState);
102             m_materialItems.push_back(pBack);
103             pMaterialNode->appendChild(pBack);
104         }
105
106         vogl_matrix_state& matrixState = contextState.get_matrix_state();
107         if (matrixState.is_valid())
108         {
109             vogleditor_stateTreeItem* pMatrixStateNode = new vogleditor_stateTreeItem("Matrix", "", this);
110             this->appendChild(pMatrixStateNode);
111
112             vogleditor_stateTreeItem* pProjectionMatrixNode = new vogleditor_stateTreeItem("GL_PROJECTION stack", tmp.sprintf("[%u]", matrixState.get_matrix_stack_depth(GL_PROJECTION, 0)), pMatrixStateNode);
113             pMatrixStateNode->appendChild(pProjectionMatrixNode);
114             vogleditor_stateTreeItem* pModelviewMatrixNode = new vogleditor_stateTreeItem("GL_MODELVIEW stack", tmp.sprintf("[%u]", matrixState.get_matrix_stack_depth(GL_MODELVIEW, 0)), pMatrixStateNode);
115             pMatrixStateNode->appendChild(pModelviewMatrixNode);
116             vogleditor_stateTreeItem* pColorMatrixNode = new vogleditor_stateTreeItem("GL_COLOR stack", tmp.sprintf("[%u]", matrixState.get_matrix_stack_depth(GL_COLOR, 0)), pMatrixStateNode);
117             pMatrixStateNode->appendChild(pColorMatrixNode);
118
119             { vogleditor_stateTreeMatrixStackItem* pItem = new vogleditor_stateTreeMatrixStackItem("GL_PROJECTION", GL_PROJECTION, 0, pProjectionMatrixNode, matrixState); pProjectionMatrixNode->appendChild(pItem); m_matrixStackItems.push_back(pItem); }
120             { vogleditor_stateTreeMatrixStackItem* pItem = new vogleditor_stateTreeMatrixStackItem("GL_MODELVIEW", GL_MODELVIEW, 0, pModelviewMatrixNode, matrixState); pModelviewMatrixNode->appendChild(pItem); m_matrixStackItems.push_back(pItem); }
121             { vogleditor_stateTreeMatrixStackItem* pItem = new vogleditor_stateTreeMatrixStackItem("GL_COLOR", GL_COLOR, 0, pColorMatrixNode, matrixState); pColorMatrixNode->appendChild(pItem); m_matrixStackItems.push_back(pItem); }
122
123             QString tmpName;
124             vogleditor_stateTreeItem* pTextureMatrixNode = new vogleditor_stateTreeItem("GL_TEXTURE", "", pMatrixStateNode);
125             pMatrixStateNode->appendChild(pTextureMatrixNode);
126             for (uint texcoord_index = 0; texcoord_index < info.get_max_texture_coords(); texcoord_index++)
127             {
128                 vogleditor_stateTreeItem* pTextureStackNode = new vogleditor_stateTreeItem(tmpName.sprintf("GL_TEXTURE%u stack", texcoord_index), tmpName.sprintf("[%u]",matrixState.get_matrix_stack_depth(GL_TEXTURE0 + texcoord_index, texcoord_index)), pTextureMatrixNode);
129                 pTextureMatrixNode->appendChild(pTextureStackNode);
130
131                 { vogleditor_stateTreeMatrixStackItem* pItem = new vogleditor_stateTreeMatrixStackItem(tmpName.sprintf("GL_TEXTURE%u", texcoord_index), GL_TEXTURE0 + texcoord_index, texcoord_index, pTextureStackNode, matrixState); pTextureStackNode->appendChild(pItem); m_matrixStackItems.push_back(pItem); }
132             }
133
134             vogleditor_stateTreeItem* pMatrixMatrixNode = new vogleditor_stateTreeItem("GL_MATRIX", "", pMatrixStateNode);
135             pMatrixStateNode->appendChild(pMatrixMatrixNode);
136             for (uint i = 0; i < info.get_max_arb_program_matrices(); i++)
137             {
138                 vogleditor_stateTreeItem* pMatrixStackNode = new vogleditor_stateTreeItem(tmpName.sprintf("GL_MATRIX%u_ARB stack", i), tmpName.sprintf("[%u]",matrixState.get_matrix_stack_depth(GL_MATRIX0_ARB + i, i)), pMatrixMatrixNode);
139                 pMatrixMatrixNode->appendChild(pMatrixStackNode);
140
141                 { vogleditor_stateTreeMatrixStackItem* pItem = new vogleditor_stateTreeMatrixStackItem(tmpName.sprintf("GL_MATRIX%u_ARB", i), GL_MATRIX0_ARB + i, i, pMatrixStackNode, matrixState); pMatrixStackNode->appendChild(pItem); m_matrixStackItems.push_back(pItem); }
142             }
143         }
144
145         vogl_arb_program_environment_state& programState = contextState.get_arb_program_environment_state();
146         if (programState.is_valid())
147         {
148             vogleditor_stateTreeItem* pProgramStateNode = new vogleditor_stateTreeItem("ARB Program Env", "", this);
149             this->appendChild(pProgramStateNode);
150
151             for (uint i = 0; i < programState.cNumTargets; i++)
152             {
153                 vogleditor_stateTreeArbProgramEnvItem* pProgramNode = new vogleditor_stateTreeArbProgramEnvItem(enum_to_string(programState.get_target_enum(i)), i, pProgramStateNode, programState);
154                 m_arbProgramEnvItems.push_back(pProgramNode);
155                 pProgramStateNode->appendChild(pProgramNode);
156             }
157         }
158
159         vogl_polygon_stipple_state& stippleState = contextState.get_polygon_stipple_state();
160         if (stippleState.is_valid())
161         {
162             m_pPolygonStippleItem = new vogleditor_stateTreePolygonStippleItem("Polygon Stipple", this, stippleState);
163             this->appendChild(m_pPolygonStippleItem);
164         }
165
166         vogl_texenv_state& texEnvState = contextState.get_texenv_state();
167         if (texEnvState.is_valid())
168         {
169             m_pTexEnvItem = new vogleditor_stateTreeTexEnvItem("Texture Env", this, texEnvState, info);
170             this->appendChild(m_pTexEnvItem);
171         }
172
173         // sort all state objects by snapshot handle
174         vogl_gl_object_state_ptr_vec objectState = contextState.get_objects();
175         objectState.sort(vogl_gl_object_state_handle_less_than());
176         vogleditor_stateTreeItem* pObjectsNode = new vogleditor_stateTreeItem("Objects", "", this);
177         this->appendChild(pObjectsNode);
178
179         {
180             // Append a node for each of the state object types
181 #define DEF(x) vogleditor_stateTreeItem* pNode##x = new vogleditor_stateTreeItem(#x "s", "", pObjectsNode);
182             VOGL_GL_OBJECT_STATE_TYPES
183 #undef DEF
184
185             for (vogl_gl_object_state_ptr_vec::iterator iter = objectState.begin(); iter != objectState.end(); iter++)
186             {
187                 switch((*iter)->get_type())
188                 {
189                 case cGLSTTexture:
190                 {
191                     vogl_texture_state* pTexState = static_cast<vogl_texture_state*>(*iter);
192                     QString valueStr;
193                     valueStr = valueStr.sprintf("%s (%u x %u x %u) %s", enum_to_string(pTexState->get_target()).toStdString().c_str(), pTexState->get_texture().get_width(), pTexState->get_texture().get_height(), pTexState->get_texture().get_depth(), enum_to_string(pTexState->get_texture().get_ogl_internal_fmt()).toStdString().c_str());
194                     vogleditor_stateTreeTextureItem* pNode = new vogleditor_stateTreeTextureItem(int64_to_string(pTexState->get_snapshot_handle()), valueStr, pNodeTexture, pTexState, info);
195                     m_textureItems.push_back(pNode);
196                     pNodeTexture->appendChild(pNode);
197                     break;
198                 }
199                 case cGLSTBuffer:
200                 {
201                     vogl_buffer_state* pBuffer = static_cast<vogl_buffer_state*>(*iter);
202                     vogleditor_stateTreeBufferItem* pNode = new vogleditor_stateTreeBufferItem(int64_to_string(pBuffer->get_snapshot_handle()), enum_to_string(pBuffer->get_target()), pNodeBuffer, pBuffer);
203                     m_bufferItems.push_back(pNode);
204                     pNodeBuffer->appendChild(pNode);
205
206                     break;
207                 }
208                 case cGLSTSampler:
209                 {
210                     const vogl_sampler_state* pSampler = static_cast<const vogl_sampler_state*>(*iter);
211                     vogleditor_stateTreeSamplerItem* pNode = new vogleditor_stateTreeSamplerItem(int64_to_string(pSampler->get_snapshot_handle()), "", pNodeSampler, pSampler, info);
212                     m_samplerItems.push_back(pNode);
213                     pNodeSampler->appendChild(pNode);
214
215                     break;
216                 }
217                 case cGLSTQuery:
218                 {
219                     vogl_query_state* pQuery = static_cast<vogl_query_state*>(*iter);
220                     vogleditor_stateTreeQueryItem* pNode = new vogleditor_stateTreeQueryItem(int64_to_string(pQuery->get_snapshot_handle()), pQuery->get_snapshot_handle(), pNodeQuery, pQuery);
221                     m_queryItems.push_back(pNode);
222                     pNodeQuery->appendChild(pNode);
223                     break;
224                 }
225                 case cGLSTRenderbuffer:
226                 {
227                     vogl_renderbuffer_state* pRenderbuffer = static_cast<vogl_renderbuffer_state*>(*iter);
228                     vogleditor_stateTreeRenderbufferItem* pNode = new vogleditor_stateTreeRenderbufferItem(int64_to_string(pRenderbuffer->get_snapshot_handle()), pRenderbuffer->get_snapshot_handle(), pNodeRenderbuffer, *pRenderbuffer);
229                     QString valueStr;
230                     int width = 0;
231                     int height = 0;
232                     int format = 0;
233                     pRenderbuffer->get_desc().get_int(GL_RENDERBUFFER_WIDTH, &width);
234                     pRenderbuffer->get_desc().get_int(GL_RENDERBUFFER_HEIGHT, &height);
235                     pRenderbuffer->get_desc().get_int(GL_RENDERBUFFER_INTERNAL_FORMAT, &format);
236                     valueStr = valueStr.sprintf("(%d x %d) %s", width, height, enum_to_string(format).toStdString().c_str());
237                     pNode->setValue(valueStr);
238                     m_renderbufferItems.push_back(pNode);
239                     pNodeRenderbuffer->appendChild(pNode);
240
241                     break;
242                 }
243                 case cGLSTFramebuffer:
244                 {
245                     vogl_framebuffer_state* pFramebuffer = static_cast<vogl_framebuffer_state*>(*iter);
246                     if (!pFramebuffer->is_valid())
247                     {
248                        break;
249                     }
250
251                     vogleditor_stateTreeFramebufferItem* pNode = new vogleditor_stateTreeFramebufferItem(int64_to_string(pFramebuffer->get_snapshot_handle()), "", pFramebuffer->get_snapshot_handle(), pNodeFramebuffer, pFramebuffer);
252                     m_framebufferItems.push_back(pNode);
253                     pNodeFramebuffer->appendChild(pNode);
254
255                     break;
256                 }
257                 case cGLSTVertexArray:
258                 {
259                     vogl_vao_state* pVAO = static_cast<vogl_vao_state*>(*iter);
260                     if (!pVAO->is_valid())
261                     {
262                         break;
263                     }
264
265                     vogleditor_stateTreeVertexArrayItem* pNode = new vogleditor_stateTreeVertexArrayItem(int64_to_string(pVAO->get_snapshot_handle()), tmp.sprintf("[%u]", info.get_max_vertex_attribs()), pVAO->get_snapshot_handle(), pNodeVertexArray, *pVAO, info);
266                     m_vertexArrayItems.push_back(pNode);
267                     pNodeVertexArray->appendChild(pNode);
268
269                     break;
270                 }
271                 case cGLSTShader:
272                 {
273                     vogl_shader_state* pShader = static_cast<vogl_shader_state*>(*iter);
274                     if (!pShader->is_valid())
275                     {
276                        break;
277                     }
278
279                     vogleditor_stateTreeShaderItem* pNode = new vogleditor_stateTreeShaderItem(int64_to_string(pShader->get_snapshot_handle()), enum_to_string(pShader->get_shader_type()), pNodeShader, *pShader);
280                     m_shaderItems.push_back(pNode);
281                     pNodeShader->appendChild(pNode);
282
283                     break;
284                 }
285                 case cGLSTProgram:
286                 {
287                     vogl_program_state* pProgram = static_cast<vogl_program_state*>(*iter);
288                     if (!pProgram->is_valid())
289                     {
290                        break;
291                     }
292
293                     vogleditor_stateTreeProgramItem* pNode = new vogleditor_stateTreeProgramItem(int64_to_string(pProgram->get_snapshot_handle()), "", pNodeProgram, *pProgram, info);
294                     m_programItems.push_back(pNode);
295                     pNodeProgram->appendChild(pNode);
296
297                     break;
298                 }
299                 case cGLSTSync:
300                 {
301                     vogl_sync_state* pSync = static_cast<vogl_sync_state*>(*iter);
302                     vogleditor_stateTreeSyncItem* pNode = new vogleditor_stateTreeSyncItem(int64_to_string(pSync->get_snapshot_handle()), pNodeSync, *pSync);
303                     m_syncItems.push_back(pNode);
304                     pNodeSync->appendChild(pNode);
305                     break;
306                 }
307                 case cGLSTARBProgram:
308                 {
309                     vogl_arb_program_state* pARBProgram = static_cast<vogl_arb_program_state*>(*iter);
310                     if (!pARBProgram->is_valid())
311                     {
312                        break;
313                     }
314                     vogleditor_stateTreeArbProgramItem* pNode = new vogleditor_stateTreeArbProgramItem(int64_to_string(pARBProgram->get_snapshot_handle()), "", pNodeARBProgram, *pARBProgram);
315                     m_arbProgramItems.push_back(pNode);
316                     pNodeARBProgram->appendChild(pNode);
317                     break;
318                 }
319                 case cGLSTInvalid:
320                 default:
321                 {
322                     // in the Invalid and default case add the object to the invalids
323                     vogleditor_stateTreeItem* pNode = new vogleditor_stateTreeItem(int64_to_string((*iter)->get_snapshot_handle()), get_gl_object_state_type_str((*iter)->get_type()), pNodeARBProgram);
324                     pNodeARBProgram->appendChild(pNode);
325                 }
326                 }
327             } // end for
328
329 // update the value of the list node to reflect the number of elements in that list
330 #define DEF(x) pNode##x->setValue(tmp.sprintf("[%d]", pNode##x->childCount()));
331             VOGL_GL_OBJECT_STATE_TYPES
332 #undef DEF
333
334 // only append list if there are objects of that type
335 #define DEF(x) if (pNode##x->childCount() > 0) pObjectsNode->appendChild(pNode##x);
336             VOGL_GL_OBJECT_STATE_TYPES
337 #undef DEF
338
339         }
340     }
341 }
342
343 vogleditor_stateTreeContextItem::~vogleditor_stateTreeContextItem()
344 {
345     m_pState = NULL;
346     m_pDiffBaseState = NULL;
347     m_pAttributesItem = NULL;
348     m_pCreationItem = NULL;
349     m_pDirectItem = NULL;
350     m_pSharedItem = NULL;
351     m_pPolygonStippleItem = NULL;
352     m_pTexEnvItem = NULL;
353 }
354
355 void vogleditor_stateTreeContextItem::set_diff_base_state(const vogl_context_snapshot* pBaseState)
356 {
357     m_pDiffBaseState = pBaseState;
358
359     if (m_pAttributesItem != NULL)
360     {
361         m_pAttributesItem->set_diff_base_state(&(m_pDiffBaseState->get_context_desc()));
362     }
363
364     if (m_pCreationItem != NULL)
365     {
366         m_pCreationItem->set_diff_base_state(&(m_pDiffBaseState->get_context_desc()));
367     }
368
369     if (m_pDirectItem != NULL)
370     {
371         m_pDirectItem->set_diff_base_state(&(m_pDiffBaseState->get_context_desc()));
372     }
373
374     if (m_pSharedItem != NULL)
375     {
376         m_pSharedItem->set_diff_base_state(&(m_pDiffBaseState->get_context_desc()));
377     }
378
379     if (m_pPolygonStippleItem != NULL)
380     {
381         m_pPolygonStippleItem->set_diff_base_state(&(m_pDiffBaseState->get_polygon_stipple_state()));
382     }
383
384     if (m_pTexEnvItem != NULL)
385     {
386         m_pTexEnvItem->set_diff_base_state(&(m_pDiffBaseState->get_context_info()), &(m_pDiffBaseState->get_texenv_state()));
387     }
388
389     for (vogleditor_stateTreeContextGeneralItem** iter = m_generalStateItems.begin(); iter != m_generalStateItems.end(); iter++)
390     {
391         if (m_pDiffBaseState != NULL)
392         {
393             (*iter)->set_diff_base_state(&(pBaseState->get_general_state()));
394         }
395         else
396         {
397             (*iter)->set_diff_base_state(NULL);
398         }
399     }
400
401     for (vogleditor_stateTreeContextInfoItem** iter = m_contextInfoItems.begin(); iter != m_contextInfoItems.end(); iter++)
402     {
403         if (m_pDiffBaseState != NULL)
404         {
405             (*iter)->set_diff_base_state(&(pBaseState->get_context_info()));
406         }
407         else
408         {
409             (*iter)->set_diff_base_state(NULL);
410         }
411     }
412
413     vogl_gl_object_state_ptr_vec texObjs;
414     m_pDiffBaseState->get_all_objects_of_category(cGLSTTexture, texObjs);
415     for (vogleditor_stateTreeTextureItem** iter = m_textureItems.begin(); iter != m_textureItems.end(); iter++)
416     {
417         for (vogl_gl_object_state** diffIter = texObjs.begin(); diffIter != texObjs.end(); diffIter++)
418         {
419             const vogl_texture_state* pDiffTex = static_cast<const vogl_texture_state*>(*diffIter);
420             if (pDiffTex->get_snapshot_handle() == (*iter)->get_texture_state()->get_snapshot_handle())
421             {
422                 (*iter)->set_diff_base_state(pDiffTex);
423                 break;
424             }
425         }
426     }
427
428     vogl_gl_object_state_ptr_vec queryObjects;
429     m_pDiffBaseState->get_all_objects_of_category(cGLSTQuery, queryObjects);
430     for (vogleditor_stateTreeQueryItem** iter = m_queryItems.begin(); iter != m_queryItems.end(); iter++)
431     {
432         for (vogl_gl_object_state** diffIter = queryObjects.begin(); diffIter != queryObjects.end(); diffIter++)
433         {
434             const vogl_query_state* pDiffState = static_cast<const vogl_query_state*>(*diffIter);
435             if (pDiffState->get_snapshot_handle() == (*iter)->get_handle())
436             {
437                 (*iter)->set_diff_base_state(pDiffState);
438                 break;
439             }
440         }
441     }
442
443     vogl_gl_object_state_ptr_vec renderbufferObjects;
444     m_pDiffBaseState->get_all_objects_of_category(cGLSTRenderbuffer, renderbufferObjects);
445     for (vogleditor_stateTreeRenderbufferItem** iter = m_renderbufferItems.begin(); iter != m_renderbufferItems.end(); iter++)
446     {
447         for (vogl_gl_object_state** diffIter = renderbufferObjects.begin(); diffIter != renderbufferObjects.end(); diffIter++)
448         {
449             const vogl_renderbuffer_state* pDiffState = static_cast<const vogl_renderbuffer_state*>(*diffIter);
450             if (pDiffState->get_snapshot_handle() == (*iter)->get_handle())
451             {
452                 (*iter)->set_diff_base_state(pDiffState);
453                 break;
454             }
455         }
456     }
457
458     vogl_gl_object_state_ptr_vec framebufferObjects;
459     m_pDiffBaseState->get_all_objects_of_category(cGLSTFramebuffer, framebufferObjects);
460     for (vogleditor_stateTreeFramebufferItem** iter = m_framebufferItems.begin(); iter != m_framebufferItems.end(); iter++)
461     {
462         for (vogl_gl_object_state** diffIter = framebufferObjects.begin(); diffIter != framebufferObjects.end(); diffIter++)
463         {
464             const vogl_framebuffer_state* pDiffState = static_cast<const vogl_framebuffer_state*>(*diffIter);
465             if (pDiffState->get_snapshot_handle() == (*iter)->get_handle())
466             {
467                 (*iter)->set_diff_base_state(pDiffState);
468                 break;
469             }
470         }
471     }
472
473     vogl_gl_object_state_ptr_vec samplerObjects;
474     m_pDiffBaseState->get_all_objects_of_category(cGLSTSampler, samplerObjects);
475     for (vogleditor_stateTreeSamplerItem** iter = m_samplerItems.begin(); iter != m_samplerItems.end(); iter++)
476     {
477         for (vogl_gl_object_state** diffIter = samplerObjects.begin(); diffIter != samplerObjects.end(); diffIter++)
478         {
479             const vogl_sampler_state* pDiffObj = static_cast<const vogl_sampler_state*>(*diffIter);
480             if (pDiffObj->get_snapshot_handle() == (*iter)->get_sampler_state()->get_snapshot_handle())
481             {
482                 (*iter)->set_diff_base_state(pDiffObj);
483                 break;
484             }
485         }
486     }
487
488     vogl_gl_object_state_ptr_vec bufferObjects;
489     m_pDiffBaseState->get_all_objects_of_category(cGLSTBuffer, bufferObjects);
490     for (vogleditor_stateTreeBufferItem** iter = m_bufferItems.begin(); iter != m_bufferItems.end(); iter++)
491     {
492         for (vogl_gl_object_state** diffIter = bufferObjects.begin(); diffIter != bufferObjects.end(); diffIter++)
493         {
494             const vogl_buffer_state* pDiffObj = static_cast<const vogl_buffer_state*>(*diffIter);
495             if (pDiffObj->get_snapshot_handle() == (*iter)->get_buffer_state()->get_snapshot_handle())
496             {
497                 (*iter)->set_diff_base_state(pDiffObj);
498                 break;
499             }
500         }
501     }
502
503     vogl_gl_object_state_ptr_vec vertexArrayObjects;
504     m_pDiffBaseState->get_all_objects_of_category(cGLSTVertexArray, vertexArrayObjects);
505     for (vogleditor_stateTreeVertexArrayItem** iter = m_vertexArrayItems.begin(); iter != m_vertexArrayItems.end(); iter++)
506     {
507         for (vogl_gl_object_state** diffIter = vertexArrayObjects.begin(); diffIter != vertexArrayObjects.end(); diffIter++)
508         {
509             const vogl_vao_state* pDiffObj = static_cast<const vogl_vao_state*>(*diffIter);
510             if (pDiffObj->get_snapshot_handle() == (*iter)->get_handle())
511             {
512                 (*iter)->set_diff_base_state(pDiffObj);
513                 break;
514             }
515         }
516     }
517
518     vogl_gl_object_state_ptr_vec shaderObjects;
519     m_pDiffBaseState->get_all_objects_of_category(cGLSTShader, shaderObjects);
520     for (vogleditor_stateTreeShaderItem** iter = m_shaderItems.begin(); iter != m_shaderItems.end(); iter++)
521     {
522         for (vogl_gl_object_state** diffIter = shaderObjects.begin(); diffIter != shaderObjects.end(); diffIter++)
523         {
524             const vogl_shader_state* pDiffObj = static_cast<const vogl_shader_state*>(*diffIter);
525             if (pDiffObj->get_snapshot_handle() == (*iter)->get_current_state()->get_snapshot_handle())
526             {
527                 (*iter)->set_diff_base_state(pDiffObj);
528                 break;
529             }
530         }
531     }
532
533     vogl_gl_object_state_ptr_vec programObjects;
534     m_pDiffBaseState->get_all_objects_of_category(cGLSTProgram, programObjects);
535     for (vogleditor_stateTreeProgramItem** iter = m_programItems.begin(); iter != m_programItems.end(); iter++)
536     {
537         for (vogl_gl_object_state** diffIter = programObjects.begin(); diffIter != programObjects.end(); diffIter++)
538         {
539             const vogl_program_state* pDiffObj = static_cast<const vogl_program_state*>(*diffIter);
540             if (pDiffObj->get_snapshot_handle() == (*iter)->get_current_state()->get_snapshot_handle())
541             {
542                 (*iter)->set_diff_base_state(pDiffObj);
543                 break;
544             }
545         }
546     }
547
548     vogl_gl_object_state_ptr_vec syncObjects;
549     m_pDiffBaseState->get_all_objects_of_category(cGLSTSync, syncObjects);
550     for (vogleditor_stateTreeSyncItem** iter = m_syncItems.begin(); iter != m_syncItems.end(); iter++)
551     {
552         for (vogl_gl_object_state** diffIter = syncObjects.begin(); diffIter != syncObjects.end(); diffIter++)
553         {
554             vogl_sync_state* pDiffObj = static_cast<vogl_sync_state*>(*diffIter);
555             if (pDiffObj->get_snapshot_handle() == (*iter)->get_current_state()->get_snapshot_handle())
556             {
557                 (*iter)->set_diff_base_state(pDiffObj);
558                 break;
559             }
560         }
561     }
562
563     vogl_gl_object_state_ptr_vec arbProgramObjects;
564     m_pDiffBaseState->get_all_objects_of_category(cGLSTARBProgram, arbProgramObjects);
565     for (vogleditor_stateTreeArbProgramItem** iter = m_arbProgramItems.begin(); iter != m_arbProgramItems.end(); iter++)
566     {
567         for (vogl_gl_object_state** diffIter = arbProgramObjects.begin(); diffIter != arbProgramObjects.end(); diffIter++)
568         {
569             const vogl_arb_program_state* pDiffObj = static_cast<const vogl_arb_program_state*>(*diffIter);
570             if (pDiffObj->get_snapshot_handle() == (*iter)->get_current_state()->get_snapshot_handle())
571             {
572                 (*iter)->set_diff_base_state(pDiffObj);
573                 break;
574             }
575         }
576     }
577
578     const vogl_light_state* lightState = &(pBaseState->get_light_state());
579     VOGL_ASSERT(lightState->is_valid() || m_lightItems.size() == 0);
580     if (lightState->is_valid())
581     {
582         for (vogleditor_stateTreeLightItem** iter = m_lightItems.begin(); iter != m_lightItems.end(); iter++)
583         {
584             const vogl_state_vector& lightVec = lightState->get_light((*iter)->get_light_index());
585             (*iter)->set_diff_base_state(&lightVec);
586         }
587     }
588
589     const vogl_arb_program_environment_state* progEnvState = &(pBaseState->get_arb_program_environment_state());
590     VOGL_ASSERT(progEnvState->is_valid() || m_arbProgramEnvItems.size() == 0);
591     if (progEnvState->is_valid())
592     {
593         for (vogleditor_stateTreeArbProgramEnvItem** iter = m_arbProgramEnvItems.begin(); iter != m_arbProgramEnvItems.end(); iter++)
594         {
595             (*iter)->set_diff_base_state(progEnvState);
596         }
597     }
598
599     const vogl_material_state* materialState = &(pBaseState->get_material_state());
600     VOGL_ASSERT(materialState->is_valid() || m_materialItems.size() == 0);
601     if (materialState->is_valid())
602     {
603         for (vogleditor_stateTreeContextMaterialItem** iter = m_materialItems.begin(); iter != m_materialItems.end(); iter++)
604         {
605             (*iter)->set_diff_base_state(materialState);
606         }
607     }
608
609     const vogl_matrix_state* matrixState = &(pBaseState->get_matrix_state());
610     VOGL_ASSERT(matrixState->is_valid() || m_matrixStackItems.size() == 0);
611     if (matrixState->is_valid())
612     {
613         for (vogleditor_stateTreeMatrixStackItem** iter = m_matrixStackItems.begin(); iter != m_matrixStackItems.end(); iter++)
614         {
615             if (m_pDiffBaseState != NULL)
616             {
617                 (*iter)->set_diff_base_state(matrixState);
618             }
619         }
620     }
621 }