🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DX7 SDK Sample question

Started by
9 comments, last by Kentamanos 24 years, 9 months ago
Rules for reading MS Sample apps.
1) Don't.

That's it. From all the samples I've read in the DX6 sdk, I can't think of one that didn't confuse me even more than I was when I started. I will admit that I haven't yet had time to look at the DX7 apps, but I am willing to bet that rule #1 is here to stay.

Advertisement
I have to disagree. I don't like how the samples are programed, but you can still learn alot from them. It might take a while, but once you figure out their programming standards the samples can be very helpful.

Just make sure that you don't try and learn from the samples alone, and also take a look at the SDK Docs.

--TheGoop

Yeah, sometimes the samples are really ugly, but, for example, if I see the particle sample for D3DX, I just wanna read the code because it looks great. I learned most from reading through the sources, I use another style, but get knowing what to do when is easy when reading through many sample codes.

CU

------------------
Skullpture Entertainment
#40842461

Graphix Coding @Skullpture Entertainmenthttp://www.skullpture.de
I beleive that the D3DX utilty library takes care of initializing the matrices. And that example is used to show the basics of D3DX.
The triagle is black because the sample writer forgot to enable the D3DRENDERSTATE_COLORVERTEX render state. As the D3D docs state:

Other than these requirements, you have the flexibility to use, or disregard, the other vertex components. For example, if you want to include a diffuse or specular color with your untransformed vertices, you can. (This wasn't possible before DirectX 6.0). Including individual colors for each vertex makes it possible to achieve shading effects that are much more subtle and flexible than lighting calculations that use only the material color. Keep in mind that you must enable per-vertex color through the D3DRENDERSTATE_COLORVERTEX render state. Untransformed, unlit vertices can also include up to eight sets of texture coordinates.

Hmm, was wondering that myself. Thing is, I seem to remember using colored vertices in a D3DLVERTEX structure before and getting the proper results. Stupid Microsoft been screwing with default render states? Oy, hope they didn't mess up anything else I count on...
The COLORVERTEX did not do it. Apparently that state defaults to true. I am still clueless as to why it is black...

------------------

-Kentamanos

-Kentamanos
It turns out that the renderstate called LIGHTING defaults to TRUE, meaning that DX will apply it's lighting model to renderings. You have to called SetRenderState to set the D3DRENDERSTATE_LIGHTING to FALSE.

As far as the matrices go, the World and View matrices default to identity, and the projection defaults to a 45 degree view supposedly. I still don't know where this is documented.

------------------

-Kentamanos

-Kentamanos
Default values for matrices in D3DX is documented in the SDK Help under Direct3D\Direct3DX Utility Library\Reference\Functions\General Purpose Functions\D3DXCreateContextEx .

The reason for the lighting is that D3D lighting is being applied to the primitive in addition to the vertex colors. And in D3D 7 the default material is all black, which, when modulated with the vertex colors comes out black.

I am looking at a sample in the DX7 SDK. The sample is TrivFS (although the same exact questions are the same for the TrivWin windowed version). This sample is under their D3DX section, and gets installed in your start menu.

The sample uses the vertex format D3DFVF_LVERTEX, which indicates the vertices are pre-lit (they do not have DX apply lighting to them), but are untransformed. In otherwords the vertices use a set color and the vertices are in model coordinates. The 3 vertices for the triangle have diffuse colors of red, green, and blue.

So I have 2 questions:
1) Why is the triangle black? Shouldn't the format of the vertex just make the color of these vertices red, green, and blue. I expected a blended triangle.

2) Do the World, View, and Projection matrices have default values? SetTransform is NEVER called in this example.

Can someone please tell me what I am missing here? I am a newbie to D3D, and this one has me stumped.

------------------

-Kentamanos

-Kentamanos

This topic is closed to new replies.

Advertisement