private static void Draw(VeldridDrawingFactory factory, VRContext vrContext) { var poses = vrContext.WaitForPoses(); var lv = poses.CreateView(VREye.Left, _userPosition, -Vector3.UnitZ, Vector3.UnitY); var lp = poses.LeftEyeProjection; var rv = poses.CreateView(VREye.Right, _userPosition, -Vector3.UnitZ, Vector3.UnitY); var rp = poses.RightEyeProjection; // why it works reversing the eyes !??? DrawEye(factory, vrContext.LeftEyeFramebuffer, rv, rp); DrawEye(factory, vrContext.RightEyeFramebuffer, lv, lp); }
public static void Run(string[] args) { // Create the window and the graphics device if (!VeldridInit(out var window, out var graphicsDevice, out var vrContext)) { Console.WriteLine("This sample requires an Oculus or OpenVR-capable headset."); return; } var factory = new VeldridDrawingFactory(graphicsDevice); // We run the game loop here and do our drawing inside of it. VeldridRunLoop(window, graphicsDevice, vrContext, () => Draw(factory, vrContext)); factory.Dispose(); graphicsDevice.Dispose(); }
private static void DrawEye(VeldridDrawingFactory factory, Framebuffer target, Matrix4x4 view, Matrix4x4 proj) { using (var dc3 = factory.CreateDrawing3DContext(target, view, proj)) { dc3.FillFrame(System.Drawing.Color.CornflowerBlue); dc3.DrawSphere((0, 0, -3), 1, System.Drawing.Color.Yellow); dc3.DrawSphere((1, 0, -3), 1, System.Drawing.Color.Yellow); dc3.DrawSphere((-1, 0, -3), 1, System.Drawing.Color.Yellow); dc3.DrawSphere((0, 1.5f, -3), 1, System.Drawing.Color.Yellow); dc3.DrawSphere((0, -1.5f, -3), 1, System.Drawing.Color.Yellow); dc3.DrawSegment((1.5f, 1.5f, -3), (1, 0.2f, -1), 0.1f, System.Drawing.Color.Red); dc3.DrawSphere((0, -1.5f, -10), 1, System.Drawing.Color.Yellow); dc3.DrawSphere((0, 0f, -0.20f), 0.1f, System.Drawing.Color.Yellow); } }