Exemplo n.º 1
0
        public void initBuffers(SlimDX.Direct3D11.Device device)
        {
            vertexBuffer = new SlimDX.Direct3D11.Buffer(device, vertices, (12 + 8) * triangleCount * 3, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
            bufferBinding = new VertexBufferBinding(vertexBuffer, 20, 0);
            skyDomeTexture = Texture2D.FromFile(device, "skydome3.bmp");

            /*
            PerlinNoise2D perlinNoise = new PerlinNoise2D();
            ushort[] map = perlinNoise.createMapUniform(10, 16000);

            int mapWidth = 1024;

            Texture2DDescription desc = new Texture2DDescription();
            desc.BindFlags = BindFlags.ShaderResource;
            desc.CpuAccessFlags = CpuAccessFlags.None;
            desc.Format = SlimDX.DXGI.Format.B8G8R8A8_UNorm;
            desc.Height = mapWidth;
            desc.MipLevels = 1;
            desc.OptionFlags = ResourceOptionFlags.None;
            desc.Usage = ResourceUsage.Immutable;
            desc.Width = mapWidth;
            desc.ArraySize = 1;
            desc.SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0);

            byte[] bufferImage = new byte[4 * mapWidth * mapWidth];
            for (int i = 0; i < mapWidth * mapWidth; i++)
            {
                bufferImage[i * 4] = (byte)( (map[i]) >> 8);
                bufferImage[i * 4 + 1] = (byte)( (map[i]) >> 8);
                bufferImage[i * 4 + 2] = (byte)( (map[i]) >> 8);
                bufferImage[i * 4 + 3] = 255;
            }

            DataStream ds = new DataStream(4 * mapWidth * mapWidth, true, true);
            ds.Write(bufferImage,0,bufferImage.Length);
            ds.Position = 0;
            DataRectangle datarect = new DataRectangle(4 * mapWidth, ds);
            skyDomeTexture = new Texture2D(device, desc,datarect);
            */

            //System.Runtime.InteropServices.GCHandle pinnedArray = System.Runtime.InteropServices.GCHandle.Alloc(bufferImage, System.Runtime.InteropServices.GCHandleType.Pinned);
            //IntPtr pointer = pinnedArray.AddrOfPinnedObject();
            //using (System.Drawing.Bitmap image = new System.Drawing.Bitmap(mapWidth, mapWidth, mapWidth * 4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, pointer))
            //{
            //    image.Save("toto.bmp");
            //}
            //pinnedArray.Free();
        }
Exemplo n.º 2
0
 public void initBuffers(Device device)
 {
     vertexBuffer = new Buffer(device, vertices, 12 * 3, ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
     bufferBinding = new VertexBufferBinding(vertexBuffer, 12, 0);
 }
Exemplo n.º 3
0
 void RenderableInterface.initBuffers(SlimDX.Direct3D11.Device device)
 {
     vertexBuffer = new SlimDX.Direct3D11.Buffer(device, vertices, (12 + 8)* triangleCount * 3 , ResourceUsage.Default, BindFlags.VertexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
     bufferBinding = new VertexBufferBinding(vertexBuffer, 20, 0);
     grassTexture = Texture2D.FromFile(device,"grass2.bmp");
 }