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(); } }
public override void Draw(GL g) { this.m_onRunning = false; this.m_onPause = false; this.m_onDestroy = false; this.m_onResume = false; lock (m_sync) { m_onRunning = LSystem.isRunning; m_onPause = LSystem.isPaused; m_onDestroy = LSystem.isDestroy; m_onResume = LSystem.isResume; if (LSystem.isResume) { LSystem.isResume = false; } if (LSystem.isPaused) { LSystem.isPaused = false; JavaRuntime.NotifyAll(m_sync); } if (LSystem.isDestroy) { LSystem.isDestroy = false; JavaRuntime.NotifyAll(m_sync); } if (m_onResume) { m_log.I("m_onResume"); timer = LSystem.GetSystemTimer(); lastTimeMicros = timer.GetTimeMicros(); elapsedTime = 0; remainderMicros = 0; m_process.OnResume(); } if (m_onRunning) { if (LSystem.isLogo) { if (logoFlag == null) { LSystem.isLogo = false; return; } logoFlag.Draw(m_process.gl); if (logoFlag.finish) { m_process.gl.SetAlpha(1.0f); m_process.gl.DrawClear(LColor.black); LSystem.isLogo = false; logoFlag.Dispose(); logoFlag = null; return; } return; } if (!m_process.Next()) { return; } m_process.Load(); m_process.Calls(); goalTimeMicros = lastTimeMicros + 1000000L / maxFrames; currTimeMicros = timer.SleepTimeMicros(goalTimeMicros); elapsedTimeMicros = currTimeMicros - lastTimeMicros + remainderMicros; elapsedTime = MathUtils.Max(0, (elapsedTimeMicros / 1000)); remainderMicros = elapsedTimeMicros - elapsedTime * 1000; lastTimeMicros = currTimeMicros; timerContext.millisSleepTime = remainderMicros; timerContext.timeSinceLastUpdate = elapsedTime; ActionControl.Update(elapsedTime); m_process.RunTimer(timerContext); if (LSystem.AUTO_REPAINT) { GLEx gl = m_process.gl; if (gl != null) { if (!m_process.Next()) { return; } //设定graphics.PreferredBackBufferWidth和graphics.PreferredBackBufferHeight时WP会自动缩放画面, //此处无需再缩放一次。 /*if (LSystem.scaleWidth != 1f || LSystem.scaleHeight != 1f) * { * gl.Scale(LSystem.scaleWidth, * LSystem.scaleHeight); * }*/ int repaintMode = m_process.GetRepaintMode(); switch (repaintMode) { case Screen.SCREEN_BITMAP_REPAINT: gl.Reset(true); if (m_process.GetX() == 0 && m_process.GetY() == 0) { gl.DrawTexture(m_process.GetBackground(), 0, 0); } else { gl.DrawTexture(m_process.GetBackground(), m_process.GetX(), m_process.GetY()); } break; case Screen.SCREEN_COLOR_REPAINT: LColor c = m_process.GetColor(); if (c != null) { gl.DrawClear(c); } break; case Screen.SCREEN_CANVAS_REPAINT: gl.Reset(true); break; case Screen.SCREEN_NOT_REPAINT: gl.Reset(true); break; default: gl.Reset(true); if (m_process.GetX() == 0 && m_process.GetY() == 0) { gl.DrawTexture( m_process.GetBackground(), repaintMode / 2 - LSystem.random.Next(repaintMode), repaintMode / 2 - LSystem.random.Next(repaintMode)); } else { gl.DrawTexture(m_process.GetBackground(), m_process.GetX() + repaintMode / 2 - LSystem.random.Next(repaintMode), m_process.GetY() + repaintMode / 2 - LSystem.random.Next(repaintMode)); } break; } m_process.Draw(); m_process.Drawable(elapsedTime); if (isFPS) { this.TickFrames(); fpsFont.DrawString(string.Format(numformat, "FPS:{0}", frameRate), 5, 5, 0, LColor.white); } m_process.DrawEmulator(); m_process.Unload(); gl.Restore(); } } } } }