Ejemplo n.º 1
0
        public void Render(DwarfTime time, SpriteBatch batch, Vector2 globalOffset)
        {
            GlobalOffset = globalOffset;


            RootComponent.LocalBounds = new Rectangle((int)globalOffset.X, (int)globalOffset.Y, 0, 0);
            RootComponent.UpdateTransformsRecursive();
            RootComponent.Render(time, batch);

            if (FocusComponent != null)
            {
                FocusComponent.Render(time, batch);
            }


            foreach (GUIComponent component in DrawAfter)
            {
                component.Render(time, batch);
            }


            DrawAfter.Clear();

            if (DebugDraw)
            {
                RootComponent.DebugRender(time, batch);
            }
        }
Ejemplo n.º 2
0
        private void OnRenderFrame(object sender, FrameEventArgs e)
        {
            if (FPS >= 30 && mElapsedTime < mWaitTime)
            {
                return;
            }

            mWaitTime = Math.Max((1.0f - (mTimer.Elapsed.TotalSeconds * FPS / 1 - FPS * mWaitTime)) / FPS, 0.0f);  // Calculate the dt between frames
            mTimer.Restart();

            //mPerformanceLabel.Visible = ShowPerformanceInfo;
            //if (mPerformanceLabel.Visible)
            //{
            //    mPerformanceLabel.BringFront();
            //    mFrameCounter++;
            //    if (mPerformanceLabelTimer.Elapsed.TotalSeconds >= 0.5f)
            //    {
            //        mFrameDates.AddLast(DateTime.Now);
            //        var wFrameCounter = mFrameCounter;
            //        if (mFrameDates.Count >= 3)
            //        {
            //            Dispatcher.BeginInvoke(() =>
            //            {
            //                var wPerformanceInfos = new List<string>
            //                {
            //                    $"FPS: {Math.Round(wFrameCounter / (mFrameDates.Last.Value - mFrameDates.First.Value).TotalSeconds)}",
            //                    $"CPU utilization: {PerformanceInfo.CPUUtilization}%",
            //                    $"Used RAM: {PerformanceInfo.UsedRam}MB",
            //                    $"Available RAM: {PerformanceInfo.AvailableRAM}MB",
            //                    $"Total used RAM: {PerformanceInfo.TotalUsedRAM}MB",
            //                    $"Total RAM: {PerformanceInfo.TotalRAM}MB"
            //                };
            //                mPerformanceLabel.Text = string.Join("\r\n", wPerformanceInfos);
            //            });
            //            mFrameDates.RemoveFirst();
            //            mFrameCounter = 0;
            //        }
            //        mPerformanceLabelTimer.Restart();
            //    }
            //}

            GL.ClearColor(0.1f, 0.2f, 0.3f, 1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.BindTexture(TextureTarget.Texture2D, mWallpaperTexture.Id);
            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(0, 0); GL.Vertex2(0, 0);
            GL.TexCoord2(1, 0); GL.Vertex2(Width, 0);
            GL.TexCoord2(1, 1); GL.Vertex2(Width, Height);
            GL.TexCoord2(0, 1); GL.Vertex2(0, Height);
            GL.End();
            GL.BindTexture(TextureTarget.Texture2D, 0);

            mRoot.Render();

            mWindow.SwapBuffers();
        }