示例#1
0
        internal static void Init()
        {
            string baseDir = Path.Combine(AppContext.BaseDirectory, "EngineAssets/Shaders/");

            GameAsset.SetNextID("single-color-shader");
            SingleColor = Shader.FromSourceFile("single-color",
                                                Path.Combine(baseDir, "single-color.vert"),
                                                Path.Combine(baseDir, "single-color.frag"));

            GameAsset.SetNextID("shadowmap-shader");
            ShadowMap = Shader.FromSourceFile("shadowmap",
                                              Path.Combine(baseDir, "shadowmap.vert"),
                                              Path.Combine(baseDir, "shadowmap.frag"));

            GameAsset.SetNextID("text-shader");
            Text = Shader.FromSourceFile("text",
                                         Path.Combine(baseDir, "text.vert"),
                                         Path.Combine(baseDir, "text.frag"));

            GameAsset.SetNextID("lit-shader");
            Lit = Shader.FromSourceFile("lit",
                                        Path.Combine(baseDir, "lit.vert"),
                                        Path.Combine(baseDir, "lit.frag"));

            GameAsset.SetNextID("skybox-shader");
            Skybox = Shader.FromSourceFile("skybox",
                                           Path.Combine(baseDir, "skybox.vert"),
                                           Path.Combine(baseDir, "skybox.frag"));
        }
示例#2
0
        public static void LoadAssetsFromFile(string path)
        {
            using (FileStream stream = new FileStream(path, FileMode.Open))
            {
                BinaryReader reader = new BinaryReader(stream);

                int assetsCount = reader.ReadInt32();
                for (int i = 0; i < assetsCount; i++)
                {
                    string        id        = reader.ReadString();
                    GameAssetType assetType = (GameAssetType)reader.ReadInt32();

                    GameAssetSerializer serializer = GetSuitableSerializer(assetType);
                    if (serializer == null)
                    {
                        throw new Exception("No suitable serializer found!");
                    }

                    GameAsset.SetNextID(id);
                    serializer.ReadFromStream(reader);
                }
            }
        }