Exemplo n.º 1
0
        public void Unsetup(SlimDX.Direct3D10.Device device)
        {
            device.InputAssembler.SetVertexBuffers(0,
                                                   new SlimDX.Direct3D10.VertexBufferBinding(null, 0, 0));

            device.InputAssembler.SetIndexBuffer(null, SlimDX.DXGI.Format.R16_UInt, 0);
        }
Exemplo n.º 2
0
        void SetupCommon(SlimDX.Direct3D10.Device device, SlimDX.Direct3D10.InputLayout layout)
        {
            device.InputAssembler.SetInputLayout(layout);

            if (MeshType == MeshType.Indexed)
            {
                device.InputAssembler.SetPrimitiveTopology(SlimDX.Direct3D10.PrimitiveTopology.TriangleList);
                device.InputAssembler.SetIndexBuffer(IndexBuffer, SlimDX.DXGI.Format.R16_UInt, 0);
            }
            else if (MeshType == MeshType.TriangleStrip)
            {
                device.InputAssembler.SetPrimitiveTopology(SlimDX.Direct3D10.PrimitiveTopology.TriangleStrip);
            }
            else if (MeshType == MeshType.PointList)
            {
                device.InputAssembler.SetPrimitiveTopology(SlimDX.Direct3D10.PrimitiveTopology.PointList);
            }
            else if (MeshType == MeshType.LineStrip)
            {
                device.InputAssembler.SetPrimitiveTopology(SlimDX.Direct3D10.PrimitiveTopology.LineStrip);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemplo n.º 3
0
        public void Setup(SlimDX.Direct3D10.Device device, SlimDX.Direct3D10.InputLayout layout)
        {
            device.InputAssembler.SetVertexBuffers(0,
                                                   new SlimDX.Direct3D10.VertexBufferBinding(VertexBuffer, VertexStreamLayout.Size, 0));

            SetupCommon(device, layout);
        }
Exemplo n.º 4
0
 public ContentPool(SlimDX.Direct3D10.Device device)
 {
     this.Device10 = device;
     LogInit();
     InitStatistics();
     LoadMappersFromAssembly(typeof(Content.ContentPool).Assembly);
 }
Exemplo n.º 5
0
 public override void Render(SlimDX.Direct3D10.Device device, SlimDX.Matrix viewMatrix)
 {
     /*
      * VertexBuffer vertices;
      *
      * device.VertexDeclaration = this.VertexDeclaration;
      * vertices = new VertexBuffer(
      *  device,
      *  block.Vertices.Count * 32,
      *  BufferUsage.WriteOnly);
      * vertices.SetData(block.Vertices.ToArray());
      *
      * device.Vertices[0].SetSource(vertices, 0, 32);
      *
      * var indices = new IndexBuffer(
      *      device,
      *      typeof(short),
      *      block.Faces.Count,
      *      BufferUsage.WriteOnly);
      * indices.SetData(block.Faces.ToArray(), 0, block.Faces.Count);
      * device.Indices = indices;
      *
      * device.Textures[0] = this.TextureDif;
      * device.Textures[1] = this.TextureNrm; // not "working" yet (needs shader~)
      *
      * device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, block.Faces.Count, 0, block.Faces.Count / 3);
      */
 }
Exemplo n.º 6
0
        /*
         #region Vertex Elements
         * public static VertexElement[] VertexElements =
         * {
         *  // first one "should" be Vertex4
         *  new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0),
         *  new VertexElement(0, 16, VertexElementFormat.Vector4, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0),
         * };
         #endregion
         *
         * private Texture TextureDif;
         * private Texture TextureNrm;
         * private VertexDeclaration VertexDeclaration;
         */

        public override void Setup(
            SlimDX.Direct3D10.Device device,
            ShaderLibrary shaderLibrary,
            string basePath)
        {
            /*
             * this.VertexDeclaration = new VertexDeclaration(device, VertexElements);
             *
             * string texturePath;
             *
             * texturePath = Path.Combine(basePath, block.Textures[0]);
             * if (File.Exists(texturePath) == false)
             * {
             *  this.TextureDif = null;
             * }
             * else
             * {
             *  this.TextureDif = Texture.FromFile(device, texturePath);
             * }
             *
             * texturePath = Path.Combine(basePath, block.Textures[1]);
             * if (File.Exists(texturePath) == false)
             * {
             *  this.TextureNrm = null;
             * }
             * else
             * {
             *  this.TextureNrm = Texture.FromFile(device, texturePath);
             * }
             */
        }
Exemplo n.º 7
0
        public void SetupInstanced(SlimDX.Direct3D10.Device device, SlimDX.Direct3D10.InputLayout layout,
                                   SlimDX.Direct3D10.Buffer instanceData, int instanceSize)
        {
            device.InputAssembler.SetVertexBuffers(0,
                                                   new SlimDX.Direct3D10.VertexBufferBinding(VertexBuffer, VertexStreamLayout.Size, 0),
                                                   new SlimDX.Direct3D10.VertexBufferBinding(instanceData, instanceSize, 0));

            SetupCommon(device, layout);
        }
Exemplo n.º 8
0
        public override SlimDX.Direct3D10.Buffer GetD3DBuffer(SlimDX.Direct3D10.Device device)
        {
            var vertices = new DataStream(Data.Length * default(T).Size, false, true);

            vertices.WriteRange(Data);
            vertices.Seek(0, System.IO.SeekOrigin.Begin);
            return(new SlimDX.Direct3D10.Buffer(device, vertices, new SlimDX.Direct3D10.BufferDescription
            {
                BindFlags = SlimDX.Direct3D10.BindFlags.VertexBuffer,
                CpuAccessFlags = SlimDX.Direct3D10.CpuAccessFlags.None,
                OptionFlags = SlimDX.Direct3D10.ResourceOptionFlags.None,
                SizeInBytes = (int)vertices.Length,
                Usage = SlimDX.Direct3D10.ResourceUsage.Default
            }));
        }
Exemplo n.º 9
0
 public void DrawInstanced(SlimDX.Direct3D10.Device device, int nInstances)
 {
     if (MeshType == MeshType.Indexed)
     {
         device.DrawIndexedInstanced(NFaces * 3, nInstances, 0, 0, 0);
     }
     else if (MeshType == MeshType.TriangleStrip || MeshType == MeshType.PointList || MeshType == MeshType.LineStrip)
     {
         device.DrawInstanced(NVertices, nInstances, 0, 0);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Exemplo n.º 10
0
 public abstract SlimDX.Direct3D10.Buffer GetD3DBuffer(SlimDX.Direct3D10.Device device);
Exemplo n.º 11
0
 public void Draw(SlimDX.Direct3D10.Device device)
 {
     Draw(device, 0, NFaces);
 }