void LoadAndSetupScene() { FrameworkScene pScene = new FrameworkScene("dp_scene.xml"); List<NodeRef> nodes = new List<NodeRef>(); nodes.Add(pScene.FindNode("cube")); nodes.Add(pScene.FindNode("rightBar")); nodes.Add(pScene.FindNode("leaningBar")); nodes.Add(pScene.FindNode("spinBar")); g_lightNumBinder = new UniformIntBinder(); AssociateUniformWithNodes(nodes, g_lightNumBinder, "numberOfLights"); SetStateBinderWithNodes(nodes, g_lightNumBinder); int unlit = pScene.FindProgram("p_unlit"); int lit = pScene.FindProgram("p_lit"); Mesh pSphereMesh = pScene.FindMesh("m_sphere"); //No more things that can throw. g_spinBarOrient = nodes[3].NodeGetOrient(); g_unlitProg = unlit; GL.UseProgram(unlit); g_unlitModelToCameraMatrixUnif = GL.GetUniformLocation(unlit, "modelToCameraMatrix"); g_unlitCameraToClipMatrixUnif = GL.GetUniformLocation(unlit, "cameraToClipMatrix"); g_unlitObjectColorUnif = GL.GetUniformLocation(unlit, "objectColor"); GL.UseProgram(0); g_litProg = lit; GL.UseProgram(lit); g_litCameraToClipMatrixUnif = GL.GetUniformLocation(lit, "cameraToClipMatrix"); GL.UseProgram(0); g_nodes = nodes; g_pSphereMesh = pSphereMesh; g_pScene = pScene; }
void AssociateUniformWithNodes(List<NodeRef> nodes, UniformIntBinder binder, string unifName) { foreach (NodeRef nr in nodes) { binder.AssociateWithProgram(nr.GetProgram(), unifName); } }