Jump to content

  • Log In with Google      Sign In   
  • Create Account


DX7 SDK Sample question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 Kentamanos   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 September 1999 - 07:57 PM

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


Sponsor:

#2 Pseudo   Members   -  Reputation: 100

Like
Likes
Like

Posted 24 September 1999 - 12:42 PM

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.


#3 Facehat   Members   -  Reputation: 696

Like
Likes
Like

Posted 24 September 1999 - 12:53 PM

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


#4 NuFAN   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 September 1999 - 01:56 PM

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


#5 Pseudo   Members   -  Reputation: 100

Like
Likes
Like

Posted 26 September 1999 - 11:50 AM

I beleive that the D3DX utilty library takes care of initializing the matrices. And that example is used to show the basics of D3DX.

#6 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 26 September 1999 - 12:32 PM

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.



#7 Shinkage   Members   -  Reputation: 595

Like
Likes
Like

Posted 26 September 1999 - 01:46 PM

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...

#8 Kentamanos   Members   -  Reputation: 122

Like
Likes
Like

Posted 26 September 1999 - 07:48 PM

The COLORVERTEX did not do it. Apparently that state defaults to true. I am still clueless as to why it is black...

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

-Kentamanos


#9 Kentamanos   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 September 1999 - 07:57 AM

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


#10 mhkrause   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 September 1999 - 07:08 PM

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.


#11 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 27 September 1999 - 07:57 PM

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!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS