Beispiel #1
0
        /// <summary>
        /// 画像をキャッシュから探し、もしなければ読み込みます。
        /// </summary>
        public AnimationTexture GetAnimationTexture(string imagePath,
                                                    int count)
        {
            if (this.context != GraphicsContext.CurrentContext)
            {
                throw new GLException(
                          "OpenGLコンテキストが正しく設定れていません><");
            }

            if (string.IsNullOrEmpty(imagePath))
            {
                throw new ArgumentNullException("imagePath");
            }

            if (count <= 0)
            {
                throw new ArgumentException("count");
            }

            try
            {
                var key = new AnimationTextureKey(imagePath, count);

                return(this.cache.GetOrCreate(key));
            }
            catch (Exception ex)
            {
                Util.ThrowIfFatal(ex);
                Log.ErrorException(ex,
                                   "'{0}' テクスチャの読み込みに失敗しました。",
                                   imagePath);

                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 分割されたアニメーション用テクスチャを読み込みます。
        /// </summary>
        private AnimationTexture CreateAnimationTexture(AnimationTextureKey key)
        {
            var animTexture = new AnimationTexture();

            animTexture.Load(key.ImagePath, key.Count);
            return(animTexture);
        }