// tick for OpenGL rendering code public void RenderGL() { if (useRenderTarget) { // enable render target target.Bind(); // render scene to render target sceneGraph.Render(shader); // render quad target.Unbind(); quad.Render(postproc, target.GetTextureID()); } else { // render scene directly to the screen sceneGraph.Render(shader); } }
// tick for OpenGL rendering code public void RenderGL() { // measure frame duration frameDuration = timer.ElapsedMilliseconds; timer.Reset(); timer.Start(); // prepare matrix for vertex shader CamMatrix = new Matrix4(); CamMatrix.Diagonal = new Vector4(1, 1, 1, 1); //Console.WriteLine(y); OpenTK.Input.Mouse.GetCursorState(); // update rotation //a += 0.001f * frameDuration; //if (a > 2 * PI) a -= 2 * PI; /*if (useRenderTarget) * { * // enable render target * target.Bind(); * * // render scene to render target * mesh.Render(shader, CamMatrix, wood); * floor.Render(shader, CamMatrix, wood); * * // render quad * target.Unbind(); * quad.Render(postproc, target.GetTextureID()); * } * else * { * // render scene directly to the screen * mesh.Render(shader, CamMatrix, wood); * floor.Render(shader, CamMatrix, wood); * }*/ //Keyboard Control //new Render scene sceneGraph.Render(CamMatrix); GL.UseProgram(postproc.programID); Vector3 fx = new Vector3(chromaticOn ? 1 : 0, vignetteOn ? 1 : 0, shinyOn ? 1 : 0); GL.Uniform3(fxId, ref fx); }
// tick for OpenGL rendering code public void RenderGL() { // measure frame duration float frameDuration = timer.ElapsedMilliseconds; timer.Reset(); timer.Start(); // The translation relative to the camera Matrix4 transform = Matrix4.CreateFromAxisAngle(new Vector3(0, 1, 0), a); Matrix4 toWorld = transform; transform *= Matrix4.CreateTranslation(0, -4, 15) * Matrix4.CreateTranslation(c.cameraPos) * Matrix4.CreateFromAxisAngle(new Vector3(0,0,1), c.zRotate) * Matrix4.LookAt(Vector3.Zero, c.cameraDir, c.up); transform *= Matrix4.CreatePerspectiveFieldOfView(1.2f, 1.3f, .1f, 1000); // update rotation a += 0.001f * frameDuration; if (a > 2 * PI) a -= 2 * PI; if (c.vRotate < 0) c.vRotate = 2 * PI; // render scene to render target if (useRenderTarget) { // enable render target target.Bind(); floorNode.Render(shader, transform, toWorld); // render quad target.Unbind(); quad.Render(postproc, target.GetTextureID()); } else { target.Bind(); floorNode.nodeMesh.Render(shader, transform, toWorld, wood); floorNode.nodeChildren[0].nodeMesh.Render(shader, transform, toWorld, wood); target.Unbind(); quad.Render(postproc, target.GetTextureID()); } }
// tick for OpenGL rendering code public void RenderGL() { // measure frame duration float frameDuration = timer.ElapsedMilliseconds; timer.Reset(); timer.Start(); GL.UseProgram(shader.programID); Matrix4 cameraPos = cam.GetViewMatrix(); GL.Uniform3(shader.camPosition, new Vector3(cameraPos.M13, cameraPos.M23, cameraPos.M33)); // enable render target target.Bind(); viewProjectMatrix = cameraPos * Matrix4.CreatePerspectiveFieldOfView(1.2f, 1.3f, .1f, 1000); // render the scene scene.Render(shader, viewProjectMatrix, frameDuration); // render quad target.Unbind(); quad.Render(postproc, target.GetTextureID(), colorCube.id); }
// tick for OpenGL rendering code public void RenderGL() { CameraUpdate(); scenegraph.Render(camera); Tick(); }
// Calls the render method from the SceneGraph public void RenderGL() { scenegraph.Render(); }
// tick for OpenGL rendering code public void RenderGL() { // measure frame duration float frameDuration = timer.ElapsedMilliseconds; timer.Reset(); timer.Start(); var keyboard = OpenTK.Input.Keyboard.GetState(); if (keyboard[OpenTK.Input.Key.W]) { cam *= Matrix4.CreateTranslation(0, 0, acceleration * 0.1f); } if(keyboard[OpenTK.Input.Key.S]) { cam *= Matrix4.CreateTranslation(0, 0, acceleration * -0.1f); } if (keyboard[OpenTK.Input.Key.Space]) { cam *= Matrix4.CreateTranslation(0, acceleration * -0.1f, 0); } if (keyboard[OpenTK.Input.Key.ShiftLeft]) { cam *= Matrix4.CreateTranslation(0, acceleration * 0.1f, 0); } if (keyboard[OpenTK.Input.Key.A]) { cam *= Matrix4.CreateTranslation(acceleration * 0.1f, 0, 0); } if (keyboard[OpenTK.Input.Key.D]) { cam *= Matrix4.CreateTranslation(acceleration * -0.1f, 0, 0); } if (keyboard[OpenTK.Input.Key.I]) { cam *= Matrix4.CreateRotationX(acceleration * 0.01f); } if (keyboard[OpenTK.Input.Key.Q]) { cam *= Matrix4.CreateRotationY(acceleration * -0.01f); } if (keyboard[OpenTK.Input.Key.E]) { cam *= Matrix4.CreateRotationY(acceleration * 0.01f); } if (keyboard[OpenTK.Input.Key.K]) { cam *= Matrix4.CreateRotationX(acceleration * -0.01f); } if (keyboard[OpenTK.Input.Key.J]) { cam *= Matrix4.CreateRotationZ(acceleration * -0.01f); } if (keyboard[OpenTK.Input.Key.L]) { cam *= Matrix4.CreateRotationZ(acceleration * 0.01f); } // prepare matrix for vertex shader Matrix4 transform = Matrix4.CreateFromAxisAngle( new Vector3( 0, 1, 0 ), a ); transform *= Matrix4.CreateTranslation( 0, -4, -15 ); transform *= cam; transform *= Matrix4.CreatePerspectiveFieldOfView( 1.2f, 1.3f, .1f, 1000 ); // update rotation if (automaticRotation) a += 0.001f * frameDuration; if (a > 2 * PI) a -= 2 * PI; // render scene scenegraph.Render(transform, lights, camera, Matrix4.Identity); }