[SlimDX] Trouble with vertex buffers...
Am I using the wrong constructor to create the vertex buffers? Reason I say is that I had trouble with rendertargets using new Texture() and when I switched to Surface.CreateRenderTarget now everything is fine.
I create the vertex buffers:
new VertexBuffer()
is there some other way to do it? They keep crashing on DrawPrim calls.
Thanks,
Devin
In the March 2009 SlimDX, there is no constructor for a VertexBuffer that takes no arguments.
What version of SlimDX are you using?
What version of SlimDX are you using?
What do the debug runtimes say?
How are you creating your vertex buffer?
How are you populating your vertex buffer?
How are you binding your vertex buffer to the device?
How are you drawing your vertex buffer?
How are you creating your vertex buffer?
How are you populating your vertex buffer?
How are you binding your vertex buffer to the device?
How are you drawing your vertex buffer?
These are sections from different areas obviously but here is the entire system pretty much... fragmented...
I wasn't aware of any binding requirements.
//Create Buffer this.vbuffer = new SlimDX.Direct3D9.VertexBuffer( this.Device, this.numVerts * this.VerticeStrideSize, SlimDX.Direct3D9.Usage.Dynamic, this.VerticeFormat, SlimDX.Direct3D9.Pool.Default); //Write custom vertex data to buffer using (SlimDX.DataStream g = this.vbuffer.Lock(0, 0, 0)) { g.WriteRange<ModelVerticeStructure>(verts); this.vbuffer.Unlock(); } //Set device vertex buffer this.Device.SetStreamSource( 0, this.modelEngine.VertexManager.DefaultTriangleEngine.VertexBuffer, 0, this.modelEngine.VertexManager.DefaultTriangleEngine.VerticeStrideSize ); this.Device.Indices = this.modelEngine.VertexManager.DefaultTriangleEngine.IndexBuffer; this.Device.VertexDeclaration = Model.Vertex.ModelVerticeStructure.VertexDeclaration; //Draw Scene this.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, base.BackgroundColor, 1f, 0); for (int i = 0; i < passes; i++) { se.Effect.BeginPass(i); this.Device.DrawIndexedPrimitives( PrimitiveType.TriangleList, 0, 0, this.modelEngine.VertexManager.DefaultTriangleEngine.NumberOfVertices, 0, this.modelEngine.VertexManager.DefaultTriangleEngine.NumberOfPrimitives); se.Effect.EndPass(); } se.Effect.End();
I wasn't aware of any binding requirements.
Quote:Original post by devronious
These are sections from different areas obviously but here is the entire system pretty much... fragmented...
*** Source Snippet Removed ***
I wasn't aware of any binding requirements.
By "binding" I was refering to the SetStreamSource call, sorry for being unclear.
From what you've posted I can't tell what is going on since I don't know the values of the various variables (or where they come from).
Get the debug runtimes going and see what they say, that's the best way forward. You'll have to enable unmanaged debugging.
Open up the DirectX Control Panel (it comes with the SDK), set the slider to one less than more (otherwise you'll see some non-errors), then select the Debug radio button (remember to switch this back when you're done with development for the day, or want to play a game etc.)
Then in Visual Studio (or Visual C#), for any project you want to see the debug output for, open it up, then go Project -> [Project Name] Properties -> Debug -> Tick "Enable unmanaged code debugging"
You can then see the DirectX debug output in the Output window (Ctrl + W, O if it's not open already).
Then in Visual Studio (or Visual C#), for any project you want to see the debug output for, open it up, then go Project -> [Project Name] Properties -> Debug -> Tick "Enable unmanaged code debugging"
You can then see the DirectX debug output in the Output window (Ctrl + W, O if it's not open already).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement