protected override void OnRenderFrame(FrameEventArgs e) { GL.Viewport(0, 0, Width, Height); Title = $"Ryujinx Screen - (Vsync: {VSync} - FPS: {1f / e.Time:0})"; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Renderer.RunActions(); Renderer.Render(); SwapBuffers(); }
protected override void OnRenderFrame(FrameEventArgs e) { Ns.Statistics.StartSystemFrame(); Title = $"Ryujinx Screen - (Vsync: {VSync} - FPS: {Ns.Statistics.SystemFrameRate:0} - Guest FPS: " + $"{Ns.Statistics.GameFrameRate:0})"; Renderer.RunActions(); Renderer.Render(); SwapBuffers(); Ns.Statistics.EndSystemFrame(); Ns.Os.SignalVsync(); }
protected override void OnRenderFrame(FrameEventArgs e) { GL.Viewport(0, 0, 1280, 720); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); RenderFb(); GL.UseProgram(PrgShaderHandle); Renderer.RunActions(); Renderer.BindTexture(0); Renderer.Render(); SwapBuffers(); }
private void Render() { while (true) { // Update HidControllerKeys CurrentButton = 0; JoystickPosition LeftJoystick; JoystickPosition RightJoystick; int LeftJoystickDX = 0; int LeftJoystickDY = 0; int RightJoystickDX = 0; int RightJoystickDY = 0; LeftJoystick = new JoystickPosition { DX = LeftJoystickDX, DY = LeftJoystickDY }; RightJoystick = new JoystickPosition { DX = RightJoystickDX, DY = RightJoystickDY }; Ns.Hid.SendControllerButtons(HidControllerID.CONTROLLER_HANDHELD, HidControllerLayouts.Main, CurrentButton, LeftJoystick, RightJoystick); // Draw ScreenTex.UploadBitmap(); Renderer.RunActions(); Renderer.BindTexture(0); Renderer.Render(); if (ScreenTex.Pixels != null) { ImageBitmap.CopyPixelsFromBuffer(IntBuffer.Wrap(ScreenTex.Pixels)); } RunOnUiThread(() => ImageView.SetImageBitmap(ImageBitmap)); } }
protected override void OnRenderFrame(FrameEventArgs e) { GL.Viewport(0, 0, 1280, 720); Title = $"Ryujinx Screen - (Vsync: {VSync} - FPS: {1f / e.Time:0})"; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); RenderFb(); GL.UseProgram(PrgShaderHandle); Renderer.RunActions(); Renderer.BindTexture(0); Renderer.Render(); SwapBuffers(); }
protected override void OnRenderFrame(FrameEventArgs e) { //TODO: Figure out why we can't render a frame! base.OnRenderFrame(e); GL.Viewport(0, 0, Width, Height); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); RenderFb(); GL.UseProgram(PrgShaderHandle); Renderer.RunActions(); Renderer.BindTexture(0); Renderer.Render(); SwapBuffers(); }
protected override void OnRenderFrame(FrameEventArgs e) { Ns.Statistics.StartSystemFrame(); GL.Viewport(0, 0, Width, Height); Title = $"Ryujinx Screen - (Vsync: {VSync} - FPS: {Ns.Statistics.SystemFrameRate:0} - Guest FPS: " + $"{Ns.Statistics.GameFrameRate:0})"; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Renderer.RunActions(); Renderer.Render(); SwapBuffers(); Ns.Statistics.EndSystemFrame(); Ns.Os.SignalVsync(); }
private void RenderLoop() { MakeCurrent(); Stopwatch chrono = new Stopwatch(); chrono.Start(); long ticksPerFrame = Stopwatch.Frequency / TargetFps; long ticks = 0; while (Exists && !IsExiting) { if (_device.WaitFifo()) { _device.ProcessFrame(); } _renderer.RunActions(); if (_resizeEvent) { _resizeEvent = false; _renderer.RenderTarget.SetWindowSize(Width, Height); } ticks += chrono.ElapsedTicks; chrono.Restart(); if (ticks >= ticksPerFrame) { RenderFrame(); // Queue max. 1 vsync ticks = Math.Min(ticks - ticksPerFrame, ticksPerFrame); } } }
private void RenderLoop() { MakeCurrent(); Stopwatch Chrono = new Stopwatch(); Chrono.Start(); long TicksPerFrame = Stopwatch.Frequency / TargetFPS; long Ticks = 0; while (Exists && !IsExiting) { if (Ns.WaitFifo()) { Ns.ProcessFrame(); } Renderer.RunActions(); if (ResizeEvent) { ResizeEvent = false; Renderer.FrameBuffer.SetWindowSize(Width, Height); } Ticks += Chrono.ElapsedTicks; Chrono.Restart(); if (Ticks >= TicksPerFrame) { RenderFrame(); //Queue max. 1 vsync Ticks = Math.Min(Ticks - TicksPerFrame, TicksPerFrame); } } }
protected override void OnUpdateFrame(FrameEventArgs e) { HidControllerButtons CurrentButton = 0; HidJoystickPosition LeftJoystick; HidJoystickPosition RightJoystick; int LeftJoystickDX = 0; int LeftJoystickDY = 0; int RightJoystickDX = 0; int RightJoystickDY = 0; if (Keyboard.HasValue) { KeyboardState Keyboard = this.Keyboard.Value; if (Keyboard[Key.Escape]) { this.Exit(); } //RightJoystick if (Keyboard[(Key)Config.FakeJoyCon.Left.StickUp]) { LeftJoystickDY = short.MaxValue; } if (Keyboard[(Key)Config.FakeJoyCon.Left.StickDown]) { LeftJoystickDY = -short.MaxValue; } if (Keyboard[(Key)Config.FakeJoyCon.Left.StickLeft]) { LeftJoystickDX = -short.MaxValue; } if (Keyboard[(Key)Config.FakeJoyCon.Left.StickRight]) { LeftJoystickDX = short.MaxValue; } //LeftButtons if (Keyboard[(Key)Config.FakeJoyCon.Left.StickButton]) { CurrentButton |= HidControllerButtons.KEY_LSTICK; } if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadUp]) { CurrentButton |= HidControllerButtons.KEY_DUP; } if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadDown]) { CurrentButton |= HidControllerButtons.KEY_DDOWN; } if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadLeft]) { CurrentButton |= HidControllerButtons.KEY_DLEFT; } if (Keyboard[(Key)Config.FakeJoyCon.Left.DPadRight]) { CurrentButton |= HidControllerButtons.KEY_DRIGHT; } if (Keyboard[(Key)Config.FakeJoyCon.Left.ButtonMinus]) { CurrentButton |= HidControllerButtons.KEY_MINUS; } if (Keyboard[(Key)Config.FakeJoyCon.Left.ButtonL]) { CurrentButton |= HidControllerButtons.KEY_L; } if (Keyboard[(Key)Config.FakeJoyCon.Left.ButtonZL]) { CurrentButton |= HidControllerButtons.KEY_ZL; } //RightJoystick if (Keyboard[(Key)Config.FakeJoyCon.Right.StickUp]) { RightJoystickDY = short.MaxValue; } if (Keyboard[(Key)Config.FakeJoyCon.Right.StickDown]) { RightJoystickDY = -short.MaxValue; } if (Keyboard[(Key)Config.FakeJoyCon.Right.StickLeft]) { RightJoystickDX = -short.MaxValue; } if (Keyboard[(Key)Config.FakeJoyCon.Right.StickRight]) { RightJoystickDX = short.MaxValue; } //RightButtons if (Keyboard[(Key)Config.FakeJoyCon.Right.StickButton]) { CurrentButton |= HidControllerButtons.KEY_RSTICK; } if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonA]) { CurrentButton |= HidControllerButtons.KEY_A; } if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonB]) { CurrentButton |= HidControllerButtons.KEY_B; } if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonX]) { CurrentButton |= HidControllerButtons.KEY_X; } if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonY]) { CurrentButton |= HidControllerButtons.KEY_Y; } if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonPlus]) { CurrentButton |= HidControllerButtons.KEY_PLUS; } if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonR]) { CurrentButton |= HidControllerButtons.KEY_R; } if (Keyboard[(Key)Config.FakeJoyCon.Right.ButtonZR]) { CurrentButton |= HidControllerButtons.KEY_ZR; } } LeftJoystick = new HidJoystickPosition { DX = LeftJoystickDX, DY = LeftJoystickDY }; RightJoystick = new HidJoystickPosition { DX = RightJoystickDX, DY = RightJoystickDY }; bool HasTouch = false; //Get screen touch position from left mouse click //OpenTK always captures mouse events, even if out of focus, so check if window is focused. if (Focused && Mouse?.LeftButton == ButtonState.Pressed) { MouseState Mouse = this.Mouse.Value; int ScrnWidth = Width; int ScrnHeight = Height; if (Width > Height * TouchScreenRatioX) { ScrnWidth = (int)(Height * TouchScreenRatioX); } else { ScrnHeight = (int)(Width * TouchScreenRatioY); } int StartX = (Width - ScrnWidth) >> 1; int StartY = (Height - ScrnHeight) >> 1; int EndX = StartX + ScrnWidth; int EndY = StartY + ScrnHeight; if (Mouse.X >= StartX && Mouse.Y >= StartY && Mouse.X < EndX && Mouse.Y < EndY) { int ScrnMouseX = Mouse.X - StartX; int ScrnMouseY = Mouse.Y - StartY; int MX = (int)(((float)ScrnMouseX / ScrnWidth) * TouchScreenWidth); int MY = (int)(((float)ScrnMouseY / ScrnHeight) * TouchScreenHeight); HidTouchPoint CurrentPoint = new HidTouchPoint { X = MX, Y = MY, //Placeholder values till more data is acquired DiameterX = 10, DiameterY = 10, Angle = 90 }; HasTouch = true; Ns.Hid.SetTouchPoints(CurrentPoint); } } if (!HasTouch) { Ns.Hid.SetTouchPoints(); } Ns.Hid.SetJoyconButton( HidControllerId.CONTROLLER_HANDHELD, HidControllerLayouts.Handheld_Joined, CurrentButton, LeftJoystick, RightJoystick); Ns.Hid.SetJoyconButton( HidControllerId.CONTROLLER_HANDHELD, HidControllerLayouts.Main, CurrentButton, LeftJoystick, RightJoystick); Ns.ProcessFrame(); Renderer.RunActions(); }