protected override void SolveInstance(IGH_DataAccess data) { string resourceName = ""; string defines = ""; data.GetData(0, ref resourceName); data.GetData(1, ref defines); defines = defines.Replace("\\n", "\n"); if (!resourceName.Equals(_resourceName) || !defines.Equals(_defines)) { _resourceName = resourceName; _defines = defines; _model = new GLSLViewModel(); } if (_firstTime && !string.IsNullOrWhiteSpace(_model.VertexShaderCode) && !string.IsNullOrWhiteSpace(_resourceName)) { if (_model.CompileProgram()) { if (_model.ProgramId != 0) { RHC_UpdateShader(_resourceName, _defines, _model.ProgramId); _model.RecycleCurrentProgram = false; var doc = Rhino.RhinoDoc.ActiveDoc; if (doc != null) { doc.Views.Redraw(); } GLShaderComponentBase.RedrawViewportControl(); } } } _firstTime = false; }
static void AddToActiveComponentList(GLShaderComponentBase comp) { AnimationTimerEnabled = false; foreach (var component in _activeShaderComponents) { if (comp == component) { return; } } _activeShaderComponents.Add(comp); SortComponents(); }
public static System.Drawing.Bitmap GetTextureImage(GLShaderComponentBase component, bool colorBuffer) { string id = colorBuffer ? $"{component.InstanceGuid}:color".ToLowerInvariant() : $"{component.InstanceGuid}:depth".ToLowerInvariant(); if (_componentSamplers.TryGetValue(id.ToLowerInvariant(), out IntPtr ptrColorTexture)) { GLShaderComponentBase.ActivateGlContext(); return(Rhino7NativeMethods.RhTexture2dToDib(ptrColorTexture)); } return(null); }
private void DisplayPipeline_PreDrawObjects(object sender, Rhino.Display.DrawEventArgs e) { GLShaderComponentBase.UpdateContext(e); if (_model.ProgramId != 0) { if (Rhino.Runtime.HostUtils.RunningOnWindows) { WindowsMethods.RHC_UpdateShader(_resourceName, _defines, _model.ProgramId); } else { MacMethods.RHC_UpdateShader(_resourceName, _defines, _model.ProgramId); } _model.RecycleCurrentProgram = false; } }
public GlShaderComponentAttributes(GLShaderComponentBase component, Action doubleClickAction) : base(component) { _component = component; _doubleClickAction = doubleClickAction; }
public static void SaveColorTexture(GLShaderComponentBase component, IntPtr ptrTexture) { string id = $"{component.InstanceGuid}:color".ToLowerInvariant(); _componentSamplers[id] = ptrTexture; }
/// <summary> /// Return true if the output depth buffer from a given component is used downstream /// </summary> /// <param name="component"></param> /// <returns></returns> public static bool IsDepthTextureUsed(GLShaderComponentBase component) { string id = $"{component.InstanceGuid}:depth".ToLowerInvariant(); return(_componentSamplers.ContainsKey(id)); }