Jump to content
  • Advertisement
Sign in to follow this  
killan

DrawIndexedPrimitives error with SoftwareVertexProcessing

This topic is 4173 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

Hello, I have a problem with the method DrawIndexedPrimitives in the SoftwareVertexProcessing But the error target is in DX libs and not in my code. So i don't know my error. It's running good with HardwareVertexProcessing My draw code :
public void Draw(Device dev)
{
	dev.VertexFormat = CustomVertex.PositionColored.Format;
	dev.SetStreamSource(0, vb, 0);
	dev.Indices = ib;
	dev.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, indices.Length, 0, indices.Length/3);
}

My vb & ib init code :
//Prépa VertexBuffer : Usage.WriteOnly ne permet pas de modifier en live mais le FPS est >, sans c'est l'inverse
vb = new VertexBuffer(typeof(CustomVertex.PositionColored), pre2, dev, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default);

//Initié les vertex
verts = new CustomVertex.PositionColored[pre2]; //pre2 = 102 * 102

v = 0;
for (j = 0; j <= div + 1; j++) //Lignes
{
	for (i = 0; i <= div + 1; i++) //Colonnes
	{
		...do values...
	}
}

vb.SetData(verts, 0, LockFlags.None);



indices = new int[nbfaces * 2 * 3]; //nbfaces = 10201

x = 0; //Var temp
for (j = 0; j < div; j++)
{
	for (i = 0; i < div; i++)
	{
		...do values
	}
}

//Prépa IndexBuffer
ib = new IndexBuffer(typeof(int), indices.Length, dev, Usage.WriteOnly, Pool.Default);
ib.SetData(indices, 0, LockFlags.None);

if you have any ideas i take it :) it's very bizard :s thanks

Share this post


Link to post
Share on other sites
Advertisement
Try replaceing indices.Length in DrawIndexedPrimatives to the number of vertices( in the VB ).

Share this post


Link to post
Share on other sites
but it's dynamic, not all time the same values (it's depend of the options of the program at start)

:s

Share this post


Link to post
Share on other sites
Quote:
Original post by killan
but it's dynamic, not all time the same values (it's depend of the options of the program at start)

:s

Yes, it is, but both verts.length and pre2 hold that value. Just use that.

Share this post


Link to post
Share on other sites
the error say (in visual editor)

Une exception non gérée du type 'System.NullReferenceException' s'est produite dans microsoft.directx.direct3dx.dll

Informations supplémentaires : La référence d'objet n'est pas définie à une instance d'un objet.

and only machine code (asm) can be displayed, nothing in my code :s

i don't know if this can help you to help me

Share this post


Link to post
Share on other sites
Quote:
Original post by sirob
Yes, it is, but both verts.length and pre2 hold that value. Just use that.


ok i'have try it, it's running but not completly, i have used to test verts.length to replace indices.length, but i'haven't all the vertex

and why with HardwareVertexProcessing it's running good with indices.length

i not understand :s

Share this post


Link to post
Share on other sites
i have test this


dev.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, verts.Length, 0, indices.Length/3);



indices.length = 726 / 3 = 242 (is not the correct number of faces)

so i have try this :


dev.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, verts.Length, 0, divs * divs * 2);



verts.length = 144

where div = 10 (number of face) in horizontale, the same for the vertical and there are 2 triangles in each face.


both work on my pc in SoftwareVertexProcessing

but on one other pc : portable (S3 Graphics PROSavage DDR) it's not working good

it drawing the alf of the faces and all last point (of the alf of point) return to the origine. it's difficult to explain


the final goal is to render a terrain, we decide the number of divisions (divs) and i create the vb and ib, but DrawIndexedPrimitives give me errors or not the good result in SoftwareVertexProcessing.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!