Esempio n. 1
0
        public static ShaderAsset GetShaderAsset(string rVsFile, string rPsFile, bool rCanInstance)
        {
            App.Log("Media.cs", 2, "media", "Requested shader: " + rVsFile + " " + rPsFile);

            if (rCanInstance)
            {
                foreach (var i in Media.ShaderList)
                {
                    if (i.VS == rVsFile && i.PS == rPsFile)
                    {
                        if (Agk.IsShaderExists(i.ResourceNumber))
                        {
                            App.Log("Media.cs", 2, "media", " > found shader on " + i.ResourceNumber.ToString());
                            return(i);
                        }
                        else
                        {
                            App.Log("Media.cs", 2, "media", " > found shader on " + i.ResourceNumber.ToString() + "but is not valid: reload it");

                            if (System.IO.File.Exists(rVsFile) && System.IO.File.Exists(rPsFile))
                            {
                                i.ResourceNumber = Agk.LoadShader(rVsFile, rPsFile);
                                return(i);
                            }
                        }
                    }
                }
            }

            if (System.IO.File.Exists(rVsFile) && System.IO.File.Exists(rPsFile))
            {
                App.Log("Media.cs", 2, "media", " > image not loaded: load it");

                var tShd = Agk.LoadShader(rVsFile, rPsFile);
                var i    = new ShaderAsset()
                {
                    ResourceNumber = tShd,
                    VS             = rVsFile,
                    PS             = rPsFile
                };
                Media.ShaderList.Add(i);
                return(i);
            }
            else
            {
                if (rVsFile.Contains("media") || rPsFile.Contains("media"))
                {
                    //if filename does not include the media folder, we are looking for a generated shader from string, just return null and keep running
                    //if filename does include media folder, the file is not found and we got problems.
                    System.Windows.Forms.MessageBox.Show("File not found: " + rVsFile + " " + rPsFile);
                    App.Log("Media.cs", 5, "error", "ERROR: File not found: " + rVsFile + ", " + rPsFile + " on Media.GetShaderAsset");
                    App.StopRunning(true);
                }
            }

            System.Windows.Forms.MessageBox.Show("File not found: " + rVsFile + " " + rPsFile);
            App.StopRunning(true);
            return(null);
        }