Sign in to follow this  

Trouble with VBs declared with implicit size.

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm using Managed DX 9.0b and I'm having some trouble trying to use (Vertex/Index)Buffers that are created by declaring their size implicitly (in bytes) rather than passing it a Type and number of vertices. In other words using the following constructor: VertexBuffer (Device, Int32, Usage, VertexFormats, Pool) I have a setup that creates the vertexbuffer, hooks its created event and fills it with data etc. When it comes to rendering the data I have the following code: RenderState.Device3D.Indices = ib ; RenderState.Device3D.SetStreamSource(0, vbMatt, 0, DXHelp.GetTypeSize(typeof(CustomVertex.PositionColored))); RenderState.Device3D.VertexFormat = CustomVertex.PositionColored.Format; RenderState.Device3D.DrawIndexedPrimitives(PrimitiveType.TriangleList,0,0,8,0,12) ; Pretty standard stuff. It all works fine with VBs declared by specifying a Type and number of verts, but if I switch my VertexBuffer declaration over to the 'sizeInBytes' constructor, my DrawPrimitives call breaks. DX gives me the following error meesage: Stream 0 is not set and FVF vertex declaration is used. I checked and this is the error message recieved when u don't bind a VertexBuffer to a stream before you try to render. But... as you can see above I AM making that call. I get similiar problems when trying to declare IndexBuffers the same way. Anyone have any ideas? This is driving me nuts.

Share this post


Link to post
Share on other sites
Oh, and my VB declaration code is:

vbMatt = new VertexBuffer(RenderState.Device3D,
DXHelp.GetTypeSize(typeof(CustomVertex.PositionColored))*8,
Usage.WriteOnly,
CustomVertex.PositionColored.Format,
Pool.Default);

Share this post


Link to post
Share on other sites
Your vertexbuffer probably didn't get created due to faulty arguments, and thus the vertexbufferobject is NULL. Always check the results of your calls.
Ofcourse, there may be stuff in C# that doesn't let you do this, but then again, it's current revision is a joke and shouldn't be used, so that shouldn't be a problem ;)

Share this post


Link to post
Share on other sites
Hmm... My reference to the vertexbuffer isn't null, and my call to load data into the vertexbuffer doesn't have any complaints either. Do you mean created on some other level?

P.S. Sorry about the duplicate thread - still trying to feel out this forum.

Share this post


Link to post
Share on other sites

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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