コード例 #1
0
ファイル: ParticleSystem.cs プロジェクト: ElonGame/OpenSAGE
        private static StaticBuffer <ushort> CreateIndexBuffer(GraphicsDevice graphicsDevice, int maxParticles)
        {
            var uploadBatch = new ResourceUploadBatch(graphicsDevice);

            uploadBatch.Begin();

            var indices      = new ushort[maxParticles * 2 * 3]; // Two triangles per particle.
            var indexCounter = 0;

            for (ushort i = 0; i < maxParticles * 4; i += 4)
            {
                indices[indexCounter++] = (ushort)(i + 0);
                indices[indexCounter++] = (ushort)(i + 2);
                indices[indexCounter++] = (ushort)(i + 1);

                indices[indexCounter++] = (ushort)(i + 1);
                indices[indexCounter++] = (ushort)(i + 2);
                indices[indexCounter++] = (ushort)(i + 3);
            }

            var result = StaticBuffer.Create(
                graphicsDevice,
                uploadBatch,
                indices);

            uploadBatch.End();

            return(result);
        }
コード例 #2
0
ファイル: TextureLoader.cs プロジェクト: ElonGame/OpenSAGE
        public TextureLoader(GraphicsDevice graphicsDevice)
        {
            var uploadBatch = new ResourceUploadBatch(graphicsDevice);

            uploadBatch.Begin();

            PlaceholderValue = AddDisposable(Texture.CreatePlaceholderTexture2D(
                                                 graphicsDevice,
                                                 uploadBatch));

            uploadBatch.End();
        }