Skip to main content
gamedev.net
🔒 Locked

Problems declaring using VBs whose size is declared implicitly

Started by Martaver 1 reply 200+ views
Original Post
Martaver
Martaver
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.
Martaver
Martaver
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);
Oluseyi
Oluseyi
Pick one forum that is most appropriate and post there. Don't cross-post a topic.

Thread closed. This is the more appropriate forum, but the other thread already has a reply. I'll move that one here.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.