DrawIndexedPrimitives +"InvalidCallException"

Topics: Developer Forum, Project Management Forum
Apr 21, 2007 at 11:14 PM
In the testQuadTree1 project I get an "InvalidCallException" thrown on the with "graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, numVerts, 0, numLines);" ln349, (game1.cs)

Any would you guys know what I am doing wrong?

my graphics card is a "Mobile Intel(R) 945GM Express Chipset Family".
Coordinator
Apr 22, 2007 at 5:33 AM
I'm not familiar with that graphics card chipset. Can you run other XNA demos? does it have shader 1.1 or 2.0 support (you can find that out in the DX SDK DirectX Caps Viewer.
Apr 23, 2007 at 1:12 AM
According to the Caps Viewer I have pixel shader version 2.0. I can run other XNA demos such as the ChunkedLOD example (http://www.codeplex.com/xnadevru). However, this test project and the tank game (http://www.codeplex.com/tanksgame) have the same problem described above. (the game probably uses your component).

Do you have any idea why there would be a problem?

It seems to work on computers with high end graphics cards, but if I had an average card would there be some modification I can do to the code to get the test project to run?

Thanks
eishi
Coordinator
Apr 23, 2007 at 1:41 PM
Have you tried commenting out the call to ShowNodesDrawn() in the Draw method (or make showNodesDrawn=false by default)? Will everything else run then?
I would be interested if this is the only problem with your graphics card and the Quadtree project.
Coordinator
Apr 23, 2007 at 1:59 PM
If the above works, how many nodes are being drawn? maxNodeVerts limits the number of nodes that can be shown in the HUD to 1024. If this is exceeded, there may be a problem in the ShowNodesDrawn() method. It should read "for (i = 0; i < numVerts - 4; i += 4)" instead of "for (i = 0; i <= numVerts - 4; i += 4)" and the same for the index building loop where it says "for (i = 0; i <= numIndices - 8; i += 8)" it should be changed to "for (i = 0; i < numIndices - 8; i += 8)". Although, that should have caused problems before the call the DrawIndexedPrimitives....
Apr 30, 2007 at 5:33 AM
Hi, sorry for the later reply.

When I comment out ShowNodesDrawn(), the test program worked. However, your second suggestion with the maxNodeVerts didn't help. I played around for a bit and found that commented "graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, numVerts, 0, numLines);" worked.

I asked a friend about this and he suggested that maybe my video card didn't support LineList and that I should try using triangles.

What do you think?
Coordinator
May 1, 2007 at 3:09 AM
Triangles won't work since what the call is trying to do is draw the HUD to show what nodes are being drawn. These are boxes (4 lines each).
I would be surprised if your card doesn't draw lines........
What is the size of your heightmap (wxh)? Have you changed the default sector size or farclip?
May 4, 2007 at 1:19 PM
The reason this happens is because you are using an Intel mobility chipset video adapter.
They have annoying feature that reports the card is PS2.0 compatible (give some strange results in the Racing Game Sample), but, really the hardware can support PS2.0 but there are no drivers written (not even by Intel) to make use of it.

It is very frustrating but there it is, when the app is trying to draw the HUD view on top of the existing screen the video adapter falls over as it is too much for it or its architecture breaks down, hardware / driver limitation I'm afraid.

As stated above you can comment it out ant the project works fine, you just have to be aware of such limitations with the Intel mobility cards.

I eventually went and put my XNA dev environment on my games rig and it runs fine so there isn't a problem with the code, which is a damn shame as I like dev'ing on my laptop. I just ave to live with certain restrictions when it comes to testing.

Darkside