🎉 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!

Simple D3D questions.

Started by
6 comments, last by Rock2000 24 years, 6 months ago
Alright, I''ve got the triangle demo working (woohoo!), but I''ve got some questions. 1) Why doesn''t it draw the back of the triangle? I have 6 verticies defined, with an inverted normal for the back one, but it only draws the front polygon. When the triangle spins around the Y axis, it disappears from 90 to 270 degrees. 2) How can I set a different color for different polygons. (i.e: I wanted to set the back of the triangle to another color). 3) Can a scene be drawn without using lighting? Can I just assign colors to polygons, or use texture mapping without lighting? Thanks Rock
Advertisement
1) Check the arguments of DrawPrimitive. You have to draw 6 Vertices. You have also to check the order of the back one. It has to be P1, P3, P2 and not P1, P2, P3.
Check this out: Matthew Studios
2) You only have to change the current material with D3DDevice->SetMaterial()

3) Use D3DDevice->SetRenderState() to increase the ambient light, which light up everything in the scene
1) Make sure your triangle is being drawn in a clockwise manner with respect to the surface normal (i.e., try swapping point 3 with 1 on one of the triangles and then rendering) D3D by default (this can be disabled) culls primitives drawn otherwise.
Aha. I had the verticies in the same order for both (dang I thought I cut and pasted from the DX tutorial. Guess not). Thanks.

As for color, I tried separating the two triangles into 2 calls to drawprimitive, and changing the ambient material color in between, but both sides show up as the second color. Why is the ambient material property global? Why can''t I embed it into the vertex list like it seems I can do with diffuse/specular (haven''t tried, just reading the docs).

Rock
do you change the ambient material before drawing the first triangle?

if you just change the material after the first triangle and before the second the material will stay the same.
Uhhh, yes? I''m not sure I follow you. I set the ambient material for the device to blue, then draw the first triangle. Then a set the ambient material to green, draw the 2nd triangle, and end the scene. When it draws, both the triangles are green.
I have the solution for your problem. You only have to use the D3DLVERTEX structure instead of the D3DVERTEX structure.
There you can define the color of one point by a D3DCOLOR value. Look into the DirectX 7 SDK documentation for more details. Have fun with this new experience of 3D-programming.
Check this out: Matthew Studios

This topic is closed to new replies.

Advertisement