Ejemplo n.º 1
0
        protected virtual void DrawXNA(float totalSeconds)
        {
            GLEx gl = process.GL;

            if (gl != null)
            {
                if (!process.Next())
                {
                    return;
                }

                if (isScale)
                {
                    gl.Scale(LSystem.scaleWidth,
                             LSystem.scaleHeight);
                }

                int repaintMode = process.GetRepaintMode();

                switch (repaintMode)
                {
                case Screen.SCREEN_BITMAP_REPAINT:
                    gl.Reset(clear);
                    if (process.GetX() == 0 && process.GetY() == 0)
                    {
                        gl.DrawTexture(process.GetBackground(), 0, 0);
                    }
                    else
                    {
                        gl.DrawTexture(process.GetBackground(), process.GetX(),
                                       process.GetY());
                    }
                    break;

                case Screen.SCREEN_COLOR_REPAINT:
                    LColor c = process.GetColor();
                    if (c != null)
                    {
                        gl.DrawClear(c);
                    }
                    break;

                case Screen.SCREEN_CANVAS_REPAINT:
                    gl.Reset(clear);
                    break;

                case Screen.SCREEN_NOT_REPAINT:
                    gl.Reset(clear);
                    break;

                default:
                    gl.Reset(clear);
                    if (process.GetX() == 0 && process.GetY() == 0)
                    {
                        gl.DrawTexture(
                            process.GetBackground(),
                            repaintMode / 2
                            - LSystem.random.Next(repaintMode),
                            repaintMode / 2
                            - LSystem.random.Next(repaintMode));
                    }
                    else
                    {
                        gl.DrawTexture(process.GetBackground(),
                                       process.GetX() + repaintMode / 2
                                       - LSystem.random.Next(repaintMode),
                                       process.GetY() + repaintMode / 2
                                       - LSystem.random.Next(repaintMode));
                    }
                    break;
                }

                process.Draw();

                process.Drawable(elapsedTime);

                if (isFPS)
                {
                    gl.Reset(false);

                    framecount++;
                    timeSinceLastUpdate += totalSeconds;
                    if (timeSinceLastUpdate > updateInterval)
                    {
                        frameRate            = Convert.ToInt16(framecount / timeSinceLastUpdate);
                        framecount           = 0;
                        timeSinceLastUpdate -= updateInterval;
                    }

                    fps = string.Format(numformat, "FPS:{0}", frameRate);

                    if (gl.UseFont)
                    {
                        gl.DrawString(fps, 5, 5, LColor.white);
                    }
                    else
                    {
                        if (XNAConfig.IsActive() && font == null)
                        {
                            font = XNAConfig.LoadFnt(LSystem.FRAMEWORK_IMG_NAME + "system");
                        }
                        if (font != null)
                        {
                            font.DrawBatchString(5, 5, fps, LColor.white);
                        }
                    }
                }
                process.DrawEmulator();

                gl.RestoreMatrix();
            }
        }
Ejemplo n.º 2
0
        public virtual void CreateUI(GLEx g)
        {
            if (!isVisible)
            {
                return;
            }

            this.Setup();

            int pointsLength = points.Count;

            CycleProgress point;
            int           index;
            int           frameD;
            int           indexD;

            float size = (pointsLength * this.trailLength);

            for (float i = -1, l = size; ++i < l && !this.stopped;)
            {
                index = (int)(frame + i);
                if (index < pointsLength)
                {
                    point = points[index];
                }
                else
                {
                    point = points[index - pointsLength];
                }
                this.alpha = (i / (l - 1));
                frameD     = frame / (pointsLength - 1);
                indexD     = (int)alpha;
                if (lineWidth > 0)
                {
                    g.SetLineWidth(lineWidth);
                }
                if (scaleX != 1 || scaleY != 1)
                {
                    g.Scale(scaleX, scaleY);
                }
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(alpha);
                }
                g.SetColor(color);
                Step(g, point, indexD, frameD, color, alpha);
                g.ResetColor();
                if (alpha > 0 && alpha < 1)
                {
                    g.SetAlpha(1);
                }
                if (lineWidth > 0)
                {
                    g.ResetLineWidth();
                }
                if (scaleX != 1 || scaleY != 1)
                {
                    g.Restore();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 渲染当前组件画面于指定绘图器之上
        /// </summary>
        ///
        /// <param name="g"></param>
        public virtual void CreateUI(GLEx g)
        {
            if (isClose)
            {
                return;
            }
            if (!this.visible)
            {
                return;
            }
            int width  = this.GetWidth();
            int height = this.GetHeight();

            if (rotation != 0)
            {
                float centerX = this.screenX + width / 2;
                float centerY = this.screenY + height / 2;
                g.Rotate(centerX, centerY, rotation);
            }
            else if (!(scaleX == 1f && scaleY == 1f))
            {
                g.Scale(scaleX, scaleY);
            }
            else if (this.elastic)
            {
                g.SetClip(this.screenX, this.screenY, width, height);
            }
            // 变更透明度
            if (alpha > 0.1f && alpha < 1.0f)
            {
                g.SetAlpha(alpha);
                if (background != null)
                {
                    g.DrawTexture(background, this.screenX, this.screenY,
                                  this.width, this.height);
                }
                if (this.customRendering)
                {
                    this.CreateCustomUI(g, this.screenX, this.screenY, this.width,
                                        this.height);
                }
                else
                {
                    this.CreateUI(g, this.screenX, this.screenY, this, this.imageUI);
                }
                g.SetAlpha(1.0F);
                // 不变更
            }
            else
            {
                if (background != null)
                {
                    g.DrawTexture(background, this.screenX, this.screenY,
                                  this.width, this.height);
                }
                if (this.customRendering)
                {
                    this.CreateCustomUI(g, this.screenX, this.screenY, this.width,
                                        this.height);
                }
                else
                {
                    this.CreateUI(g, this.screenX, this.screenY, this, this.imageUI);
                }
            }
            if (rotation != 0 || !(scaleX == 1f && scaleY == 1f))
            {
                g.Restore();
            }
            else if (this.elastic)
            {
                g.ClearClip();
            }
        }