DrawIndexedPrimitives error with SoftwareVertexProcessing

Started by
8 comments, last by killan 16 years, 11 months ago
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
Killan - www.daaboo.net
Advertisement
Try replaceing indices.Length in DrawIndexedPrimatives to the number of vertices( in the VB ).
but it's dynamic, not all time the same values (it's depend of the options of the program at start)

:s
Killan - www.daaboo.net
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.
Sirob Yes.» - status: Work-O-Rama.
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
Killan - www.daaboo.net
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
Killan - www.daaboo.net
You probably have nVidia hardware. It ignores MinIndex and VertexCount. ATI, Software, and the REF device all require correct values.
I have ATI radeon 9600
Killan - www.daaboo.net
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.
Killan - www.daaboo.net
nobody have an answer for me ? please help me to understand this problem :s
Killan - www.daaboo.net

This topic is closed to new replies.

Advertisement