Beispiel #1
0
 public override object Load(LoadedAsset asset)
 {
     string text = "";
     StreamReader reader = new StreamReader(asset.Data);
     text = reader.ReadToEnd();
     reader.Close();
     return text;
 }
Beispiel #2
0
        public override object Load(LoadedAsset asset)
        {
            string       text   = "";
            StreamReader reader = new StreamReader(asset.Data);

            text = reader.ReadToEnd();
            reader.Close();
            return(text);
        }
Beispiel #3
0
        public override object Load(LoadedAsset asset)
        {
            string       shaderText = "";
            StreamReader reader     = new StreamReader(asset.Data);
            string       res        = ApexEngine.Rendering.Util.ShaderUtil.FormatShaderIncludes(asset.FilePath, reader.ReadToEnd());

            reader.Close();
            return(res);
        }
        public static object Load(string filePath, AssetLoader loader)
        {
            //  object alreadyLoaded = null;
             //   if (loadedAssets.TryGetValue(filePath, out alreadyLoaded))
              //  {
              //      return alreadyLoaded;
              //  }

            if (!System.IO.File.Exists(filePath))
                throw new System.IO.FileNotFoundException("The file \"" + filePath + "\" does not exist!");
            loader.ResetLoader();

            Stream stream = new FileStream(filePath, FileMode.Open);

            LoadedAsset asset = new LoadedAsset(stream, filePath);

            object loaded = loader.Load(asset);

            stream.Close();

              //  loadedAssets.Add(filePath, loaded);

            return loaded;
        }
Beispiel #5
0
 public override object Load(LoadedAsset asset)
 {
     return(RenderManager.Renderer.LoadAudio(asset));
 }
Beispiel #6
0
        public override Texture2D LoadTexture2D(LoadedAsset asset)
        {
            Bitmap bmp = null;
            if (asset.FilePath.EndsWith(".tga"))
            {
                bmp = ApexEngine.Assets.Util.TargaImage.LoadTargaImage(asset.Data);
            }
            else
                bmp = new Bitmap(asset.Data);
            BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            Texture2D tex = new Texture2D(Texture.GenTextureID());
            tex.TexturePath = asset.FilePath;
            tex.Use();
            tex.SetWrap(Convert.ToInt32(TextureWrapMode.Repeat), Convert.ToInt32(TextureWrapMode.Repeat));
            tex.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, bmp_data.Width, bmp_data.Height, 0,
                OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
            tex.GenerateMipmap();
            tex.Width = bmp.Width;
            tex.Height = bmp.Height;

            bmp.UnlockBits(bmp_data);
            Texture2D.Clear();
            return tex;
        }
Beispiel #7
0
        public override Sound LoadAudio(LoadedAsset asset)
        {
            Sound sound = new Sound();

            if (openALSupported)
            {

                int buffer = AL.GenBuffer();
                int source = AL.GenSource();
                int state;

                if (asset.FilePath.EndsWith("wav"))
                {
                    // Load wav
                    int channels, bits_per_sample, sample_rate;
                    byte[] wavData = LoadWave(asset.Data, out channels, out bits_per_sample, out sample_rate);

                    AL.BufferData(buffer, GetSoundFormat(channels, bits_per_sample), wavData, wavData.Length, sample_rate);
                    AL.Source(source, ALSourcei.Buffer, buffer);

                    sound.Source = source;
                    sound.Buffer = buffer;
                }

            }

            return sound;
        }
Beispiel #8
0
 public override object Load(LoadedAsset asset)
 {
     return(Rendering.Texture.LoadTexture(asset));
 }
 public abstract object Load(LoadedAsset asset);
Beispiel #10
0
 public static Texture LoadTexture(LoadedAsset asset)
 {
     return RenderManager.Renderer.LoadTexture2D(asset);
 }
Beispiel #11
0
 /// <summary>
 /// Load a 2D texture
 /// </summary>
 /// <param name="n"></param>
 /// <param name="textures"></param>
 public abstract Texture2D LoadTexture2D(LoadedAsset asset);
Beispiel #12
0
 public abstract Sound LoadAudio(LoadedAsset asset);
Beispiel #13
0
 public abstract object Load(LoadedAsset asset);
 public override object Load(LoadedAsset asset)
 {
     return Rendering.Texture.LoadTexture(asset);
 }
Beispiel #15
0
 public override object Load(LoadedAsset asset)
 {
     return RenderManager.Renderer.LoadAudio(asset);
 }