コード例 #1
0
        public override void Draw()
        {
            viewport.Begin();
            var       cam = new LookAtCamera();
            Matrix4x4 rot = Matrix4x4.CreateRotationX(viewport.CameraRotation.Y) *
                            Matrix4x4.CreateRotationY(viewport.CameraRotation.X);
            var dir = Vector3.Transform(-Vector3.UnitZ, rot);
            var to  = Vector3.Zero;

            cam.Update(viewport.RenderWidth, viewport.RenderHeight, viewport.CameraOffset, to, rot);
            shader.SetViewProjection(cam);
            var w = Matrix4x4.Identity;
            var n = Matrix4x4.Identity;

            shader.SetWorld(ref w, ref n);
            shader.Shader.SetVector3(cameraPositionIndex, cam.Position);
            tex.BindTo(0);
            shader.UseProgram();
            for (int i = 0; i < 6; i++)
            {
                sphere.GetDrawParameters((CubeMapFace)i, out int start, out int count, out _);
                sphere.VertexBuffer.Draw(PrimitiveTypes.TriangleList, 0, start, count);
            }
            viewport.End();
        }