basic questions

Started by
1 comment, last by mugai 17 years ago
when moving objects within world, do i change my world position and then draw the object? scenario i created a shape class that has an array of CustomVertex.PositionColored when the shape class is initialized i setup the vertexes. do i upate the vertex position or do i move the world and then draw my object.. and then reposition my world and continue on with the next object? also, for a rectangle made up of 8 triangles.. i draw a triangle strip of 9 vertexes.. is that the best way to go about it? what is the difference or benefits of using one of the following 2 methods this.vb.SetData(this.triangles, 0, LockFlags.None); or GraphicsStream gs = this.vb.Lock(0, 0, LockFlags.None); gs.Write(this.triangles); thank you
Advertisement
To move an object in the world, you want to move the world and draw your object. In general, you want to touch your vertex buffer data as little as possible.

Using a graphics stream allows a more general way of writing to the buffer by letting the vertex buffer work with things that take an abstract Stream object.

You probably want to use SetData, as it's pretty easy to use and is really just combining a lock, write, and unlock for you. How handy!
what about the triangle strip.. is that the best method to use for that rectangle?

i plan on making other shapes as well.. such as a T and L etc.. much like tetris (shape wise).. and they will all inherit from a base class, so i'd like to take the best approach.

thank you for the quick reply!

This topic is closed to new replies.

Advertisement