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); }
public TextureLoader(GraphicsDevice graphicsDevice) { var uploadBatch = new ResourceUploadBatch(graphicsDevice); uploadBatch.Begin(); PlaceholderValue = AddDisposable(Texture.CreatePlaceholderTexture2D( graphicsDevice, uploadBatch)); uploadBatch.End(); }