Sign in to follow this  

DrawIndexedPrimitives error with SoftwareVertexProcessing

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

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