# What can be wrong?

This topic is 4138 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am rendering a set of triangles(more than 10k tris) using the Directx8's DrawPrimitive function. Its a cylinder and half the triangles are missing on the cylindrical face. I can think of 2 possible problems 1. The normal of the triangles can be wrong - This cannot be the case as I am setting CULL_NONE. So even if the normals are wrong it should render anyway. 2. Some triangles are missing from the data - This may not be the case as it is a closed model and the no of nodes is approx equal to twice the no of tris. Is there anything in directx which can cause this kind of problem? Any clue?

##### Share on other sites
Do you know of Pix? check it out into the DX SDK documentation. It will help you when you have such kind of issues.

##### Share on other sites
Quote:
 Do you know of Pix? check it out into the DX SDK documentation. It will help you when you have such kind of issues.

This is D3D8, so you can't use Pix. However, you still can check for some debug runtime output - have you done that?

Since you already tried turning off backface culling, I would look to (2). Check to make sure that you are constructing your primitives correctly (whether they are tri lists or strips, or whatever). Perhaps posting code for this part would be helpful.

I would also verify that your parameters to DrawPrimitive() are correct. Perhaps you are drawing a lower number of primitives because of an incorrect argument.

##### Share on other sites
I am drawing each triangle as a D3DPT_TRIANGLELIST. So my assumption is that if there is a problem in drawing(the arguments to function etc) then all triangles should have the same problem. I am pasting the code below.

Public Sub RenderScene()
Dim l As Line
'Clear the buffer
m_d3d.Clear C_WHITE

'Start the rendering
m_d3d.BeginScene

m_d3d.Device.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE
m_d3d.Device.SetRenderState D3DRS_FILLMODE, D3DFILL_SOLID

'Draw the triangle
For i = 0 To m_count - 1
m_triangle(i).Draw
Next

'Stop the rendering
m_d3d.EndScene

m_d3d.Present
End Sub

Triangle draw is as follows

Public Sub Draw()
If d3d Is Nothing Then
Exit Sub
End If

'Set source vertex buffer for rendering
d3d.Device.SetStreamSource 0, m_vbData, VertexSize

'Draw the triangle
d3d.Device.DrawPrimitive D3DPT_TRIANGLELIST, 0, 1
End Sub

The triangle data I am reading from an existing file. I am not sure how to confirm if all triangles are present. But i would consider the probability of the problem in input data as very less because an external 3rd party program draws the model correctly.

I am a newbie in directx and probably i am doing something which is obviously wrong.

##### Share on other sites
Check your data to see if you are generating some degenerate triangles (2 points in a row have the same vertex data for 'half the triangles' ) ????

##### Share on other sites
Thanks for everyone who took a look at the thread. wodinoneeye you got it right. The problem was in the construction of the triangles.

##### Share on other sites
Also note that this is the slow way to do things. In general you want to have only one DrawPrimitive per renderstate or texture change so you can get very high fps. To do this you might have to put your vertices into a vertex buffer (this can be what your .Draw does) and then render the entire thing at once, for example using a triangleList.

Get even fancier and use index buffers for even more speed... my VB code is something like

mD3DDevice.SetIndices mIndexBuffer, 0mD3DDevice.DrawIndexedPrimitive D3DPT_TRIANGLELIST, mlStartVertex, mlIndexCount, mlStartIndex, mlIndexCount / 3

##### Share on other sites
Hi, sounds Like what I had and I was not clearing the D3DCLEAR_ZBUFFER

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631746
• Total Posts
3002021
×