• Advertisement

Archived

This topic is now archived and is closed to further replies.

DX7 SDK Sample question

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
I beleive that the D3DX utilty library takes care of initializing the matrices. And that example is used to show the basics of D3DX.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
The COLORVERTEX did not do it. Apparently that state defaults to true. I am still clueless as to why it is black...

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

-Kentamanos

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I was a littled puzzled about the differences between DX6.x and DX7 until I read this from Tim Sweeney:

"The API's simplicity has also improved, which is something you don't often see: usually code just gets more complex as it evolves. Porting Unreal Tournament's code from DirectX6 to DirectX7 only took 3.5 hours, and mostly consisted of deleting now-redundant code and changing function calls and interfaces. I'm very glad to see the IDirect3DTexture, IDirect3DViewport, and IDirect3DLight interfaces gone, and replaced by much simpler state-setting code. Direct3D's abuses of object-oriented programming are now gone."

What an insightful dude!

Share this post


Link to post
Share on other sites

  • Advertisement