losing primatives in Direct3D

Started by
16 comments, last by Tok 22 years, 5 months ago
First off, I would like to thank each and every one of you, *again* for helping me with this bug. I'm actually kindof embarassed that I can't get it working, but I guess that probably happens to us all, at some time or another.

A 2.9meg zip of the entire working directory of this little project of mine can be found HERE.

As far as video goes, I'm running an GeForce 256 chipset, in an Asus v6600 32meg video card. NO idea what the driver is for that- but it hasn't dissapointed me in any way(that I know of yet).

Thanks again, all.

-Tok.

Edited by - Tok on October 25, 2001 3:18:59 PM
--------------------------~The Feature Creep of the Family~
Advertisement
Now, even with CULL_NONE set, if he didn''t map textures to the other side of the triangle, would it draw it? Just curious.


I''ll download your zip and try it on my Hercules Prophet II when I get home after work.

Rube.
quote:Original post by Rube
Now, even with CULL_NONE set, if he didn''t map textures to the other side of the triangle, would it draw it? Just curious.

Rube.

G''day!

You don''t map textures to a ''side'' of a triangle, they cover the entire face. Typically with culling on you can only see it from one side, but with culling turned off you can see it from either side, the texture will just be backwards when viewed from behind.

I''ll download it when I get home and see what I can see.



Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
G''day!

Wow, I''m surprised it works at all! Just kidding.

First, do you have the Debug version of the SDK installed?
Second, do you have the Debug output turned up? (DirectX icon in your control panel)
If so, you''d see this in your debug output:
Direct3D8: (WARN) :Cannot compute WNear and WFar from the supplied projection matrix

Direct3D8: (WARN) :Setting wNear to 0.0 and wFar to 1.0

Direct3D8: (ERROR) :VertexBuffer not created with this Device. SetStreamSource fails.

The first problem is with your projection matrix. Don''t set the near plane to 0. I set it to 0.1f, and the first 2 WARNings went away.

Second, this is just plain wrong.
g_pd3dDevice->SetStreamSource( 0, &g_pVB[i*40], sizeof(CUSTOMVERTEX) );

g_pVB is just a pointer to a single vertex buffer, not an array of them. You do your indexing (when needed) buy giving offsets to your DrawPrimitive call. I changed it to:
g_pd3dDevice->SetStreamSource( 0,g_pVB, sizeof(CUSTOMVERTEX) );

And the ERROR went away.

The first thing to do is check the Debug Output with the debug level turned up. 90% of the time it at least points you in the direction of the problem.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
Is it just me or is that the illustrious DrunkenHyena himself? The one with the tutorials on D3D? Enough sucking up now...ill go back to my lil box.
quote:Original post by EbonySeraphim
Is it just me or is that the illustrious DrunkenHyena himself? The one with the tutorials on D3D? Enough sucking up now...ill go back to my lil box.


G''day!

Illustrious, eh? Sucking up is definitely not required, it doesn''t hurt though.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
quote:Original post by the Illustrious DrunkenHyena
Wow, I'm surprised it works at all! Just kidding.


Lol... no, kidding required, I assure you. And thank you again for all your help.

quote:
First, do you have the Debug version of the SDK installed?

From DirectX Diagnostics in Control panel: "Several files ddraw.dll, ddraw16.dll, ddrawex.dll, etc.) are debug versions, which will run slower than the retail version." Umm... yes?
quote:Second, do you have the Debug output turned up? (DirectX icon in your control panel)

It was set to the lowest possible setting. doh. And yes, with that little bar turned up (which I honestly didn't know about) I did see those errors.
quote:The first problem is with your projection matrix. Don't set the near plane to 0. I set it to 0.1f, and the first 2 WARNings went away.

So DX has an error if the nearplane is 0.0f, as opposed to 0.1f? (oh, gee- now why didn't *I* think of that!?!?) (j/k)
quote:Second, this is just plain wrong.
g_pd3dDevice->SetStreamSource( 0, &g_pVB[i*40], sizeof(CUSTOMVERTEX) );
g_pVB is just a pointer to a single vertex buffer, not an array of them. You do your indexing (when needed) buy giving offsets to your DrawPrimitive call. I changed it to:
g_pd3dDevice->SetStreamSource( 0,g_pVB, sizeof(CUSTOMVERTEX) );
And the ERROR went away.

Yes, it did.
*holds back tears*
As far as the &g_pVB[i*40] goes, I was trying to call subsets of verticies out of a single buffer. Reason being that after the end of the first row of primatives were drawn, the last two verticies were making a primative with the bottom left corner of my next row of verticies- thus making one very, very long triangle that screwed up the graphics. I knew I could have just implemented a trianglist as opposed to a strip (and had, as one attempt at fixing this error), but I guess I just thought I was saving *huge* chunks of memory with the list. My reasoning for the implementation goes: to render the rows independantly (tall order, having no example of how this might be accomplished), I could set the starting point in/with SetStreamSource to the first vertex of each new row, and tell it to draw just as many triangles as needed to make that row. I was thrown off, by the fact that it seemed to be working.

Well, the code is up and running better than ever, and I have a Dunken Hyena to ultimately thank for it. (I would love to know how you came up with that nick, btw) Thank you to everyone who contributed something to this- it was all very, very appreciated.

-Neil.
===========================
"We all just gotta ride this s**t out." -Baldor the Bold

Edited by - Tok on October 26, 2001 12:08:08 AM
--------------------------~The Feature Creep of the Family~
G''day!

quote:
It was set to the lowest possible setting. doh. And yes, with that little bar turned up (which I honestly didn''t know about) I did see those errors.


Well, now ya do. It''s one the the handiest debugging tools you have when dealing with D3D. Very few people run it at the highest level, I think 2nd highest is the the most people recommend you use as a rule. If you saw how much stuff it put it out, you understand why. But it''s a good idea to run it at the highest level every now and then, even if you''re not seeing problems, the warnings can be invaluable.
quote:
So DX has an error if the nearplane is 0.0f, as opposed to 0.1f? (oh, gee- now why didn''t *I* think of that!?!?) (j/k)

The short explanation is that the math involved ''likes'' it to be > 0. I think you can end up with division by zero errors and all sorts of nasty stuff. Someone better versed in the behind the scenes math could explain it much better than I could.
quote:
I would love to know how you came up with that nick, btw

It''s from a poem I wrote a long time ago. One of these days I''ll get off my butt and post the thing on my site.




Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement