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

Posted on 2006-05-23
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
    LVL 1

    Accepted Solution

    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

    Thanks again

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
    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…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    731 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now