Beispiel #1
0
        public void Initialize(IntPtr handle, Viewport viewport)
        {
            this.viewport = viewport;

            gl = new OpenGL();
            gl.Create(RenderContextType.NativeWindow, viewport.Width, viewport.Height, 32, handle);
            gl.MakeCurrent();

            ShaderManager.Initialize(gl);
            MaterialManager.Initialize(gl);

            renderer = new Renderer();
            renderer.Initialize(gl);

            camera = new PerspectiveCamera();
            camera.LocalTranslate(new Vector(0, 0, 3));

            var mesh = new Mesh(gl, MeshType.Points);

            mesh.AddBuffer(
                new Buffer <Point>(gl,
                                   new Point(-2, -2, 0),
                                   new Point(-1, -1, 0),
                                   new Point(0, 0, 0),
                                   new Point(1, -1, 0),
                                   new Point(2, -2, 0)));

            scene = new Scene();
            scene.Add(camera);

            for (int j = -10; j < 10; j++)
            {
                for (int i = -10; i < 10; i++)
                {
                    var e = new PhysicalEntity(mesh, MaterialManager.GetMaterial("Voxels"));
                    e.GlobalTranslate(Vector.UnitZ * -5 * i);
                    e.GlobalTranslate(Vector.UnitX * -5 * j);
                    scene.Add(e);
                }
            }

            gl.MakeNothingCurrent();
        }
Beispiel #2
0
        public void Initialize(IntPtr handle, Viewport viewport)
        {
            this.viewport = viewport;

            gl = new OpenGL();
            gl.Create(RenderContextType.NativeWindow, viewport.Width, viewport.Height, 32, handle);
            gl.MakeCurrent();

            ShaderManager.Initialize(gl);
            MaterialManager.Initialize(gl);

            renderer = new Renderer();
            renderer.Initialize(gl);

            camera = new PerspectiveCamera();
            camera.LocalTranslate(new Vector(0, 0, 3));

            var mesh = new Mesh(gl, MeshType.Points);
            mesh.AddBuffer(
                new Buffer<Point>(gl,
                    new Point(-2, -2, 0),
                    new Point(-1, -1, 0),
                    new Point( 0,  0, 0),
                    new Point( 1, -1, 0),
                    new Point( 2, -2, 0)));

            scene = new Scene();
            scene.Add(camera);

            for (int j = -10; j < 10; j++)
            for (int i = -10; i < 10; i++)
            {
                var e = new PhysicalEntity(mesh, MaterialManager.GetMaterial("Voxels"));
                e.GlobalTranslate(Vector.UnitZ * -5 * i);
                e.GlobalTranslate(Vector.UnitX * -5 * j);
                scene.Add(e);
            }

            gl.MakeNothingCurrent();
        }