Example #1
0
        /// <summary>
        /// パーティクル用のテクスチャを取得します。
        /// </summary>
        private static GLUtil.Texture GetParticleTexture()
        {
            var context = GraphicsContext.CurrentContext;

            if (context == null)
            {
                throw new GLUtil.GLException(
                          "OpenGLコンテキストが設定されていません。");
            }

            GLUtil.Texture texture;
            if (particleDic.TryGetValue(context, out texture))
            {
                return(texture);
            }

            var bitmap = Properties.Resources.particle;

            if (bitmap == null)
            {
                throw new RagnarokException(
                          "リソース画像'particle'の読み込みに失敗しました。");
            }

            texture = new GLUtil.Texture();
            if (!texture.Create(bitmap))
            {
                texture.Destroy();
                return(null);
            }

            particleDic.Add(context, texture);
            return(texture);
        }
Example #2
0
        /// <summary>
        /// エフェクトのアニメーション画像の位置などを修正します。
        /// </summary>
        private void UpdateTexture()
        {
            if (ImageUri == null)
            {
                Texture = null;
                return;
            }

            var animTexture = GLUtil.TextureCache.GetAnimationTexture(
                MakeContentPath(ImageUri),
                AnimationImageCount);
            if (animTexture == null)
            {
                Texture = null;
                return;
            }

            // メッシュがない場合はデフォルトのメッシュで初期化します。
            if (Mesh == null)
            {
                Mesh = Mesh.CreateDefault(1, 1, 0, 0);
            }

            var list = animTexture.TextureList;
            Texture = list[AnimationImageIndex % list.Count()];
        }
Example #3
0
        /// <summary>
        /// エフェクトのアニメーション画像の位置などを修正します。
        /// </summary>
        private void UpdateTexture()
        {
            if (ImageUri == null)
            {
                Texture = null;
                return;
            }

            var animTexture = GLUtil.TextureCache.GetAnimationTexture(
                MakeContentPath(ImageUri),
                AnimationImageCount);

            if (animTexture == null)
            {
                Texture = null;
                return;
            }

            // メッシュがない場合はデフォルトのメッシュで初期化します。
            if (Mesh == null)
            {
                Mesh = Mesh.CreateDefault(1, 1, 0, 0);
            }

            var list = animTexture.TextureList;

            Texture = list[AnimationImageIndex % list.Count()];
        }
Example #4
0
        /// <summary>
        /// パーティクル用のテクスチャを取得します。
        /// </summary>
        private static GLUtil.Texture GetParticleTexture()
        {
            var context = GraphicsContext.CurrentContext;
            if (context == null)
            {
                throw new GLUtil.GLException(
                    "OpenGLコンテキストが設定されていません。");
            }

            GLUtil.Texture texture;
            if (particleDic.TryGetValue(context, out texture))
            {
                return texture;
            }

            var bitmap = Properties.Resources.particle;
            if (bitmap == null)
            {
                throw new RagnarokException(
                    "リソース画像'particle'の読み込みに失敗しました。");
            }

            texture = new GLUtil.Texture();
            if (!texture.Create(bitmap))
            {
                texture.Destroy();
                return null;
            }

            particleDic.Add(context, texture);
            return texture;
        }
Example #5
0
        /// <summary>
        /// ビットマップからテクスチャを読み込みます。
        /// </summary>
        private GLUtil.Texture LoadTexture(Bitmap bitmap)
        {
            var tex = new GLUtil.Texture();

            if (!tex.Create(bitmap))
            {
                throw new RagnarokException(
                          "テクスチャの作成に失敗しました。");
            }

            return(tex);
        }
Example #6
0
        /// <summary>
        /// OpenGL初期化後の描画関係の初期化を行います。
        /// </summary>
        public override void OnOpenGLInitialized(EventArgs e)
        {
            base.OnOpenGLInitialized(e);

            this.boardTexture    = new GLUtil.Texture();
            this.pieceTexture    = new GLUtil.Texture();
            this.pieceBoxTexture = new GLUtil.Texture();

            // イベントハンドラの設定後にテクスチャの実体化を行います。
            BoardBitmapUpdated(this, null);
            PieceBitmapUpdated(this, null);
            PieceBoxBitmapUpdated(this, null);
        }
Example #7
0
 /// <summary>
 /// テクスチャを読み込みます。
 /// </summary>
 private void LoadTexture(GLUtil.Texture texture, Bitmap bitmap)
 {
     if (bitmap != null)
     {
         if (!texture.Create(bitmap))
         {
             throw new RagnarokException(
                       "テクスチャの作成に失敗しました。");
         }
     }
     else
     {
         texture.Destroy();
     }
 }
Example #8
0
        /// <summary>
        /// 描画オブジェクトを追加します。
        /// </summary>
        public void AddRender(GLUtil.Texture texture, BlendType blend,
                              RectangleF bounds, Matrix44d transform,
                              double zorder, double opacity = 1.0)
        {
            if (texture == null || texture.TextureName == 0)
            {
                return;
            }

            var alphaByte  = (byte)Math.Min(256 * opacity, 255);
            var color      = Color.FromArgb(alphaByte, Color.White);
            var transform2 = ToMatrix(bounds, transform);

            AddRender(texture, blend, color, transform2, zorder);
        }
Example #9
0
        /// <summary>
        /// 描画関係の終了処理を行います。
        /// </summary>
        private void TerminateDraw()
        {
            if (this.boardTexture != null)
            {
                this.boardTexture.Destroy();
                this.boardTexture = null;
            }

            if (this.pieceTexture != null)
            {
                this.pieceTexture.Destroy();
                this.pieceTexture = null;
            }

            if (this.pieceBoxTexture != null)
            {
                this.pieceBoxTexture.Destroy();
                this.pieceBoxTexture = null;
            }
        }
Example #10
0
        /// <summary>
        /// ビットマップからテクスチャを読み込みます。
        /// </summary>
        private GLUtil.Texture LoadTexture(Bitmap bitmap)
        {
            var tex = new GLUtil.Texture();
            if (!tex.Create(bitmap))
            {
                throw new RagnarokException(
                    "テクスチャの作成に失敗しました。");
            }

            return tex;
        }
Example #11
0
        /// <summary>
        /// OpenGL初期化後の描画関係の初期化を行います。
        /// </summary>
        public override void OnOpenGLInitialized(EventArgs e)
        {
            base.OnOpenGLInitialized(e);

            this.boardTexture = new GLUtil.Texture();
            this.pieceTexture = new GLUtil.Texture();
            this.pieceBoxTexture = new GLUtil.Texture();

            // イベントハンドラの設定後にテクスチャの実体化を行います。
            BoardBitmapUpdated(this, null);
            PieceBitmapUpdated(this, null);
            PieceBoxBitmapUpdated(this, null);
        }
Example #12
0
        /// <summary>
        /// 描画関係の終了処理を行います。
        /// </summary>
        private void TerminateDraw()
        {
            if (this.boardTexture != null)
            {
                this.boardTexture.Destroy();
                this.boardTexture = null;
            }

            if (this.pieceTexture != null)
            {
                this.pieceTexture.Destroy();
                this.pieceTexture = null;
            }

            if (this.pieceBoxTexture != null)
            {
                this.pieceBoxTexture.Destroy();
                this.pieceBoxTexture = null;
            }
        }