public bool Frame() { // Update the system stats. FPS.Frame(); // Do the zone frame processing. if (!Zone.Frame(D3D, Input, ShaderManager, TextureManager, Timer.FrameTime, FPS.FPS)) { return(false); } return(true); }
public bool Frame(float frameTime) { // Update the system stats. FPS.Frame(); CPU.Frame(); // Update the FPS value in the text object. if (!Text.SetFps(FPS.FPS, D3D.DeviceContext)) { return(false); } // Update the CPU usage value in the text object. if (!Text.SetCpu(CPU.CPUUsage, D3D.DeviceContext)) { return(false); } // Do the frame input processing. if (!HandleInput(frameTime)) { return(false); } // Do the water frame processing. WaterModel.Frame(); // Do the sky plane frame processing. SkyPlane.Frame(); // Render the refraction of the scene to a texture. if (!RenderRefractionToTexture()) { return(false); } // Render the reflection of the scene to a texture. if (!RenderReflectionToTexture()) { return(false); } // Render the graphics. if (!Render()) { return(false); } return(true); }
public bool Frame(float frameTime) { // Update the system stats. FPS.Frame(); CPU.Frame(); // Update the FPS value in the text object. if (!Text.SetFps(FPS.FPS, D3D.DeviceContext)) { return(false); } // Update the CPU usage value in the text object. if (!Text.SetCpu(CPU.CPUUsage, D3D.DeviceContext)) { return(false); } // Do the frame input processing. if (!HandleInput(frameTime)) { return(false); } // Get the current position of the camera. Vector3 cameraPosition = Camera.GetPosition(); // Get the height of the triangle that is directly underneath the given camera position. // If there was a triangle under the camera then position the camera just above it by two units. float height; if (QuadTree.GetHeightAtPosition(cameraPosition.X, cameraPosition.Z, out height)) { Camera.SetPosition(cameraPosition.X, height + 2.0f, cameraPosition.Z); } // Render the graphics. if (!RenderGraphics()) { return(false); } return(true); }
private void Frame() { //tricky part is, some classes have render and other frame // pick one and make Composite out of it fps.Frame(); timer.Frame(); //input.Frame(); //recentMouseX = mouseX; //recentMouseY = mouseY; //input.GetMouseLocation(out mouseX, out mouseY); //if (recentMouseY != mouseY || recentMouseX != mouseX) //{ // float dx = recentMouseX - mouseX; // float dy = recentMouseY - mouseY; // D3DGraphic.Rotation = dy; // //Debug.Write("Graphic.Frame :: mouse coord x = " + dx.ToString() + "and y = " + dy.ToString()); //} graphic.FPS = fps.Value; //set the frame time for calculating the updated position graphic.FrameTime = timer.FrameTime; //for simplicty, if mouse is moving, rotate //if (input.IsMouseMoving()) { } //position.TurnLeft(); position.FrameTime = timer.FrameTime; graphic.Position = position; graphic.Frame(); //graphic.Render(); }
public void Run() { // handle events and render the frame while (Window.Open) { _fps.Tick(); Window.HandleEvents(); RelativeMouse.HandleEvents(); if (!IsElapsedFrame()) { continue; } _fps.Frame(); UpdateScene(); _renderer.Clear(); _blockTexture.Use(); foreach (var axis in _axis) { var renderable = (OpenGLRenderable)axis.Renderable; var shader = renderable.Geometry.Program; shader.Use(); shader["Color"].SetValue(axis.Color); _renderer.Render(_mainCamera, renderable); } _renderer.Render(_mainCamera, _chunkMeshes); //_renderer.Render(_mainCamera, _cube); //UserInterface.Draw(); SwapBuffers(); } }
public bool Frame() { // Check if the user pressed escape and wants to exit the application. if (!Input.Frame() || Input.IsEscapePressed()) { return(false); } // Update the system stats. CPU.Frame(); FPS.Frame(); // Performance Logging. Timer.Frame2(); if (DPerfLogger.IsTimedTest) { DPerfLogger.Frame(Timer.FrameTime); if (Timer.CumulativeFrameTime >= DPerfLogger.TestTimeInSeconds * 1000) { return(false); } } // Do the frame processing for the graphics object. if (!Graphics.Frame(FPS.Value, CPU.Value, Timer.FrameTime)) { return(false); } // Finally render the graphics to the screen.mouseX, mouseY if (!Graphics.Render()) { return(false); } return(true); }
/// <summary> /// Implementation of capturing from the render target of the Direct3D9 Device (or DeviceEx) /// </summary> /// <param name="device"></param> private void DoCaptureRenderTarget(Device device, string hook) { FPS.Frame(); if (CaptureThisFrame) #region CompasRenderLoop { try { if (imGuiRender == null && device != null && device.NativePointer != IntPtr.Zero) { Trace.Write("Creating ImGui"); var handle = CurrentProcess.MainWindowHandle; var rect = new NativeMethods.Rect(); NativeMethods.GetWindowRect(handle, ref rect); _sprite = ToDispose(new Sprite(device)); IntialiseElementResources(device); imGuiRender = ToDispose(new ImGuiRender(device, rect, Interface, CurrentProcess)); } else if (imGuiRender != null) { if (Services.CompassSettings.ShowRenderTime) { PerfomanseTester.Reset(); PerfomanseTester.Start(); } else if (PerfomanseTester.IsRunning) { PerfomanseTester.Stop(); } _sprite.Begin(SpriteFlags.AlphaBlend); imGuiRender.GetNewFrame(); var CompassViewModel = PacketProcessor.Instance?.CompassViewModel; CompassViewModel?.Render(_sprite); //ImGui.ShowDemoWindow(); if (Services.CompassSettings.ShowRenderTime) { var draw_list = ImGui.GetOverlayDrawList(); draw_list.AddText(new Vector2(10, 100), $"RenderingTime(ms) = {Elapsed.Milliseconds}", Color.Red.ToDx9ARGB()); draw_list.AddText(new Vector2(10, 50), DateTime.Now.ToString("HH: mm:ss.fff"), Color.White.ToDx9ARGB()); } if (Services.CompassSettings.ShowFPS) { ImGui.SetNextWindowBgAlpha(0); if (ImGui.Begin("FPS counter", ref Services.CompassSettings._showFps, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize)) { ImGui.SetWindowFontScale(1.3F); ImGui.Text($"{FPS.GetFPS():n0} fps"); } ImGui.End(); } _sprite.End(); imGuiRender.Draw(); if (Services.CompassSettings.ShowRenderTime && PerfomanseTester.IsRunning) { PerfomanseTester.Stop(); Elapsed = PerfomanseTester.Elapsed; } } } catch (Exception e) { DebugMessage(e.ToString()); _sprite.End(); } } #endregion }