public static void Bind(FrameBuffer frameBuffer) { if (frameBuffer != null) frameBuffer.Bind(); else GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); }
public FrameBuffer GetFrameBuffer(string name, string src) { for (var i = 0; i < frameBuffers.Count; i++) { if( frameBuffers[i].name == name ) return frameBuffers[i]; } if( src != null && src.Length > 0 ) { // Doesnt exist, load it now FrameBuffer frameBuffer = new FrameBuffer(this, name, src); frameBuffers.Add(frameBuffer); return frameBuffer; } return null; }
public RenderPass(Scene scene, string name, string src) : base(scene, name, src) { // Load the source try { XmlDocument rpXML = new XmlDocument(); rpXML.Load(src); // Get the attribute properties foreach( XmlAttribute attrib in rpXML.DocumentElement.Attributes ) { switch( attrib.Name ) { case "sortMode": sortMode = attrib.Value; break; case "clearMode": string clearMode = attrib.Value; clearColor = (clearMode.IndexOf("color") >= 0); clearDepth = (clearMode.IndexOf("depth") >= 0); clearStencil = (clearMode.IndexOf("stencil") >= 0); break; case "clearDepth": clearDepthValue = Convert.ToSingle(attrib.Value); break; case "clearStencil": clearStencilValue = Convert.ToSingle(attrib.Value); break; case "clearColor": string[] clearColors = attrib.Value.Split(','); clearColorRed = Convert.ToSingle(clearColors[0]) / 255.0f; clearColorGreen = Convert.ToSingle(clearColors[1]) / 255.0f; clearColorBlue = Convert.ToSingle(clearColors[2]) / 255.0f; break; default: break; } } foreach( XmlNode child in rpXML.DocumentElement.ChildNodes ) { if (child.NodeType == XmlNodeType.Element) { string objName = child.Attributes.GetNamedItem("name").Value; string objSrc = child.Attributes.GetNamedItem("src").Value; if (child.Name == "viewport") { viewport = scene.GetViewport(objName, objSrc); } else if (child.Name == "camera") { camera = scene.GetCamera(objName, objSrc); } else if (child.Name == "frameBuffer") { frameBuffer = scene.GetFrameBuffer(objName, objSrc); } else if (child.Name == "overrideShader") { overrideShader = scene.GetShader(objName, objSrc); } } } } catch(Exception e) { System.Windows.Forms.MessageBox.Show("Failed to load render pass: "******"\r\n" + e.Message); } }