   2d tilemap using Directx...vertex buffer question
  Here is my render loop and update function as it stands now.I am just wondering if there is another way to go about using a vertex buffer so i dont have to go lock and unlock it so much.public void Render(TileMap tileMap,D3DPanel d3dWindow){for(yy = 0; yy< d3dWindow.Height/(this.TileHeight/2); yy++){for(xx = 0; xx< d3dWindow.Width/this.TileWidth; xx++){Tile tile = tileMap.GetTile(xx + _screenOffsetX , yy + _screenOffsetY);tile.UpdateVertexBuffer(d3dWindow.D3DDevice,xx,yy,_tileWidth,_tileHeight,_scrollOffsetX,_scrollOffsetY , _screenOffsetX, _screenOffsetY);d3dWindow.D3DDevice.SetTexture(0,tile.TileImage);d3dWindow.D3DDevice.SetStreamSource( 0, tile.VertBuffer, 0);d3dWindow.D3DDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);}}}public void UpdateVertexBuffer(Device d3dDevice, int x, int y, int w, int h,int scrollX, int scrollY, int screenOffsetX, int screenOffsetY)   {    _w = w;  _h = h;  _centerX = ((x * _w + ((screenOffsetY + y) & 1) * (_w / 2)) + scrollX) + 32;  _centerY = ((y * (_h / 2)) + scrollY) + 16;  this._anchorPoint.X = (int)_centerX;  this._anchorPoint.Y = (int)_centerY;  GraphicsStream stm = _vertBuffer.Lock(0, 0, 0);  if (_verts == null)  { _verts = new CustomVertex.TransformedTextured[4]; _verts[0].Z = 0.0f; _verts[0].Tu = 0.0f; _verts[0].Tv = this._yCoords.vert0_Tv;////0.516f;0.0f; _verts[1].Z = 0.0f; _verts[1].Tu = 1.0f; _verts[1].Tv = this._yCoords.vert1_Tv;//0.0f;//0.034f; _verts[2].Z = 0.0f; _verts[2].Tu = 0.0f; _verts[2].Tv = this._yCoords.vert2_Tv;//1.0f;//1.0f; _verts[3].Z = 0.0f; _verts[3].Tu = 1.0f; _verts[3].Tv = this._yCoords.vert3_Tv;////1.0f;0.515f;  }  _verts[0].X = _centerX - (_w / 2);  _verts[0].Y = _centerY;  _verts[1].X = _centerX;  _verts[1].Y = _centerY - (_h / 2);  _verts[2].X = _centerX;  _verts[2].Y = _centerY + (_h / 2);  _verts[3].X = _centerX + (_w / 2);  _verts[3].Y = _centerY;  stm.Write(_verts);  _vertBuffer.Unlock();   }
  plink   ;  1. Divide tiles into groups, tiles in each single group using same texture.Then you can put each group into its own vertex buffer.1 texture == 1 buffer2. You could put all your tile_textures into one single texture, and tweak texture coordinates for each tile, to access image specific for that tile.Then a single big buffer would suffice for all the tiles.3. You do not have to refill the bufer every time you draw. I understand you're doing it because the tile_map position relative to the screen is changing.That's what you got world_matrix for.Hope it helps.Sorry if I didn't quite get some of the issues.~def   