Ejemplo n.º 1
0
        public static void Initialize(Device device, int resX, int resY)
        {
            int numQuads            = resX * resY;
            int numIndices          = numQuads * 6;
            int numParticlesMax     = 1024 * 1024; // million particles max
            int numIndicesParticles = numParticlesMax * 6;
            int numRandomNumbers    = 1024 * 1024; // million

            var indices          = new DataStream(sizeof(System.Int32) * numIndices, true, true);
            var indicesParticles = new DataStream(sizeof(System.Int32) * numIndicesParticles, true, true);

            var randomNumbers = new DataStream(sizeof(System.Single) * numRandomNumbers, true, true);

            for (int i = 0; i < numQuads; i++)
            {
                indices.Write(i * 4 + 0);
                indices.Write(i * 4 + 1);
                indices.Write(i * 4 + 2);

                indices.Write(i * 4 + 1);
                indices.Write(i * 4 + 3);
                indices.Write(i * 4 + 2);
            }
            indices.Position = 0;

            for (int i = 0; i < numParticlesMax; i++)
            {
                indicesParticles.Write(i * 4 + 0);
                indicesParticles.Write(i * 4 + 1);
                indicesParticles.Write(i * 4 + 2);

                indicesParticles.Write(i * 4 + 1);
                indicesParticles.Write(i * 4 + 3);
                indicesParticles.Write(i * 4 + 2);
            }
            indicesParticles.Position = 0;

            System.Random rand = new System.Random();

            for (int i = 0; i < numRandomNumbers; i++)
            {
                randomNumbers.Write((float)rand.NextDouble());
            }
            randomNumbers.Position = 0;

            // create the vertex layout and buffer
            m_FullResTriangleGridIndexBuffer = new Buffer(device, indices, sizeof(System.Int32) * numIndices, ResourceUsage.Default, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
            m_ParticleHelperIndexBuffer      = new Buffer(device, indicesParticles, sizeof(System.Int32) * numIndicesParticles, ResourceUsage.Default, BindFlags.IndexBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0);
            m_RandomNumbersBuffer            = GPUBufferObject.CreateBuffer(device, numRandomNumbers, 4, randomNumbers, true, false);
        }
Ejemplo n.º 2
0
        public static void Initialize(Device device, int resolutionX, int resolutionY)
        {
            RenderTargetSet.RenderTargetDescriptor rtDesc = new RenderTargetSet.RenderTargetDescriptor()
            {
                m_Format      = SlimDX.DXGI.Format.R8G8B8A8_UNorm,
                m_HasDepth    = false,
                m_Width       = resolutionX,
                m_Height      = resolutionY,
                m_NumSurfaces = 1,
            };

            m_DebugRenderTarget = RenderTargetManager.RequestRenderTargetFromPool(rtDesc);
            m_DebugAppendBuffer = GPUBufferObject.CreateBuffer(device, 1024, 8 * sizeof(uint), null, true, true);
        }