DirectX: Simple FVF - Triangle Strip - What kind of render states do I need to set?

Posted on 2006-05-23
Medium Priority
Last Modified: 2013-12-26

Do I need lighting for this?

What kind of render states do I need to set to get this viewable and pretty?

I've got my vertices all setup with colors - but I'm confused about which render states to use.


Question by:oxygen_728

Accepted Solution

nullmind earned 2000 total points
ID: 16782886
Hi. As I stated in another post, I'm not using C++ (using C#), but the Direct3d method calls should be the same.

In my C# programs I created meshes dynamicly (creating a tree) and used lighting. I'll save you some trouble in letting you know that you DO need to handle the device reset errors, because these do happen. If, for the time being, you don't want to handle device lost/reset errors, then make sure to set all your render flags before you render each frame. If the device gets reset, and you didn't handle it, your original render states and transforms are lost. Here is how I set my render states in C#:

                  dev.RenderState.ZBufferEnable = true;
                  dev.RenderState.Lighting = true;
                  dev.RenderState.Ambient = Color.Gray;

The ambient light color is for things that are out of the range of any lighting.

First you'll need a mesh or object with normals. The D3DX methods that create primitives (spheres, etc.) are good because they generate normals properly.

To have lighting in the scene you NEED a light! In C# I use the following dummy light to test. It just points at the world origin (0, 0, 0) and has some dummy values to test my lighting:

                  dev.Lights[0].Type = LightType.Directional;                  
                  dev.Lights[0].Position = new Vector3(1, 3, 0);
                  dev.Lights[0].Direction = new Vector3(-1, -1, 0);
                  dev.Lights[0].Diffuse = Color.White;
                  dev.Lights[0].Enabled = true;

In C++ you'll need to it a bit different, but that's the general idea. If you have some existing code I may be able to help.

Author Comment

ID: 16783006
Thanks again

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question