Example #1
0
        /// 描画処理
        public override bool DoDraw2(DemoGame.GraphicsDevice graphDev, Vector3 BasePos)
        {
            if (!sprite.Visible)
            {
                return(false);
            }
//			sprite.SetDrawRect(0,0,10,10);
            var currentMatrix = CalcSpriteMatrix(graphDev.GetCurrentCamera().Pos, BasePos);
            var modelMatrix   = sprite.CreateModelMatrix(0, 0);
            var worldViewProj = graphDev.GetCurrentCamera().Projection *graphDev.GetCurrentCamera().View *currentMatrix *modelMatrix;

            textureShaderProgram.SetUniformValue(0, ref worldViewProj);

            float alphaRate   = 1.0f;
            int   alphaRateId = textureShaderProgram.FindUniform("AlphaRate");

            if (alphaRateId >= 0)
            {
                textureShaderProgram.SetUniformValue(alphaRateId, alphaRate);
            }

            graphDev.Graphics.SetShaderProgram(textureShaderProgram);
            graphDev.Graphics.SetVertexBuffer(0, sprite.Vertices);
            graphDev.Graphics.SetTexture(0, sprite.Texture);

            graphDev.Graphics.Enable(EnableMode.Blend);
            graphDev.Graphics.Disable(EnableMode.DepthTest);
            graphDev.Graphics.Disable(EnableMode.CullFace);
            graphDev.Graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcAlpha, BlendFuncFactor.OneMinusSrcAlpha);

            graphDev.Graphics.DrawArrays(DrawMode.TriangleFan, 0, 4);
            return(true);
        }