Sign in to follow this  
mugai

basic questions

Recommended Posts

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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this