SetData() public method

Copies array data to the index buffer.
public SetData ( int data ) : void
data int
return void
Exemplo n.º 1
0
		public PointsGisLayerCPU(Game game, int maxPointsCount, bool isDynamic = true) : base(game)
		{
			PointsCountToDraw = maxPointsCount;
			indeces = new int[maxPointsCount*6];
			PointsDrawOffset = 0;

			SizeMultiplier = 1;

			var vbOptions = isDynamic ? VertexBufferOptions.Dynamic : VertexBufferOptions.Default;

			currentBuffer	= new VertexBuffer(Game.GraphicsDevice, typeof(Gis.CartPoint), maxPointsCount * 4, vbOptions);
			PointsCpu		= new Gis.CartPoint[maxPointsCount*4];

			indBuf = new IndexBuffer(Game.GraphicsDevice, indeces.Length);
			for (int i = 0; i < maxPointsCount; i += 1) {
				indeces[i*6 + 0] = i*4 + 0;
				indeces[i*6 + 1] = i*4 + 1;
				indeces[i*6 + 2] = i*4 + 2;

				indeces[i*6 + 3] = i*4 + 1;
				indeces[i*6 + 4] = i*4 + 3;
				indeces[i*6 + 5] = i*4 + 2;
			}
			indBuf.SetData(indeces);

			shader	= Game.Content.Load<Ubershader>("globe.Debug.hlsl");
			factory = shader.CreateFactory(typeof(PointFlags), Primitive.TriangleList, VertexInputElement.FromStructure<Gis.CartPoint>(), BlendState.AlphaBlend, RasterizerState.CullCW, DepthStencilState.None);

		}
Exemplo n.º 2
0
		/// <summary>
		/// Creates buffer from given indices
		/// </summary>
		/// <param name="device"></param>
		/// <param name="indices"></param>
		/// <returns></returns>
		public static IndexBuffer Create ( GraphicsDevice device, int[] indices )
		{
			var ib = new IndexBuffer( device, indices.Length );
			ib.SetData( indices );
			return ib;
		}
Exemplo n.º 3
0
		void GenerateTileGrid(int density, ref VertexBuffer vb, out IndexBuffer ib, double left, double right, double top, double bottom, int zoom)
		{
			int[]			indexes;
			Gis.GeoPoint[]	vertices;

			DisposableBase.SafeDispose(ref vb);

			CalculateVertices(out vertices, out indexes, density, left, right, top, bottom);

			vb = new VertexBuffer(Game.GraphicsDevice, typeof(Gis.GeoPoint), vertices.Length);
			ib = new IndexBuffer(Game.GraphicsDevice, indexes.Length);
			ib.SetData(indexes);
			vb.SetData(vertices, 0, vertices.Length);
		}
Exemplo n.º 4
0
		protected void Initialize(Gis.GeoPoint[] points, int[] indeces, bool isDynamic)
		{
			shader		= Game.Content.Load<Ubershader>("globe.Poly.hlsl");
			factory		= shader.CreateFactory(typeof(PolyFlags), EnumFunc);
			factoryXray = shader.CreateFactory(typeof(PolyFlags), Primitive.TriangleList, VertexInputElement.FromStructure<Gis.GeoPoint>(), BlendState.Additive, RasterizerState.CullCW, DepthStencilState.None);

			var vbOptions = isDynamic ? VertexBufferOptions.Dynamic : VertexBufferOptions.Default;

			firstBuffer = new VertexBuffer(Game.GraphicsDevice, typeof(Gis.GeoPoint), points.Length, vbOptions);
			firstBuffer.SetData(points);
			currentBuffer = firstBuffer;

			indexBuffer = new IndexBuffer(Game.Instance.GraphicsDevice, indeces.Length);
			indexBuffer.SetData(indeces);

			PointsCpu = points;

			cb			= new ConstantBuffer(Game.GraphicsDevice, typeof(ConstData));
			constData	= new ConstData();
			constData.Data = Vector4.One;
		}