Exemplo n.º 1
0
        public static void Initialize()
        {
            if (null == _glslifyClient)
            {
                _glslifyClient = new System.Net.Http.HttpClient();
            }

            if (_packageRetriever == null)
            {
                _packageRetriever = Task.Run <List <GlslifyPackage> >(async() => {
                    List <GlslifyPackage> packages = new List <GlslifyPackage>();
                    try
                    {
                        var jsonSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                        var msg            = await _glslifyClient.GetAsync(PackageServerUrl + "/packages");
                        {
                            string packageList      = await msg.Content.ReadAsStringAsync();
                            var packageDictionaries = jsonSerializer.Deserialize <Dictionary <string, string>[]>(packageList);
                            foreach (var dict in packageDictionaries)
                            {
                                GlslifyPackage package = new GlslifyPackage(dict);
                                packages.Add(package);
                            }
                        }
                    }
                    catch (Exception) {
                        // throw away
                    }
                    return(packages);
                });
            }
        }
Exemplo n.º 2
0
        void InsertGlslifyFunction(GlslifyPackage package)
        {
            var shaderCtrl = ActiveEditorControl();

            if (shaderCtrl != null)
            {
                string text = package.PragmaLine(null);
                shaderCtrl.InsertText(shaderCtrl.CurrentPosition, text);
            }
        }
Exemplo n.º 3
0
 protected GLShaderComponentBase(string name, string nickname, string description)
     : base(name, nickname, description, "Display", "Preview")
 {
     if (!_initializeCallbackSet)
     {
         // set up callback to perform one time OpenGL initialization during the
         // next draw function
         _initializeCallbackSet = true;
         GlslifyPackage.Initialize();
         DisplayPipeline.DrawForeground += DisplayPipeline_DrawForeground;
         var doc = Rhino.RhinoDoc.ActiveDoc;
         doc?.Views.Redraw();
     }
     _model.PropertyChanged += ModelPropertyChanged;
 }
Exemplo n.º 4
0
        void GlslifyCode()
        {
            var model      = DataContext as GLSLViewModel;
            var shaderCtrl = ActiveEditorControl();

            if (shaderCtrl == null || model == null)
            {
                return;
            }

            string code = model.GetCode(shaderCtrl.ShaderType);

            if (code.Contains("#pragma glslify:"))
            {
                string processedCode = GlslifyPackage.GlslifyCode(code);
                shaderCtrl.Text = processedCode;
                //model.SetCode(shaderCtrl.ShaderType, processedCode);
            }
        }