Content Archived

This content is no longer current.

Beginning Game Development: Part VI - Lights, Materials and Terrain

Sign in to queue

The Discussion

  • User profile image
    Eric Dzikowski

    Just a note to let you know that I think this series is excellent.  It shocks me that you have no comments on any of these articles.  You've done a great job and I hope you continue with this series.

  • User profile image

    im mulimedia & Graphic Programmer And

    I Want professional sample From Directx By C#

  • User profile image

    I have been testing in my pc this guide, and everything seems to be ok, except that the terrain is not being rendered in the screen.

    I dont know why, there is no error.

    I'm using

    WinXP SP2

    .Net framework 2 and 3 installed

    VS.NET 2005 Standar Edition

    December 2006 DirectX SDK

    It just dont render the triangles.

    I was wondering i anyone else has have this problem. or its just me.

    Any hekp will be appreciated.

    Thank you very much

  • User profile image
    Abi George Ullattil

    I think there's a typo in the LoadVertexBuffer() section... the VB corresponds to the LoadIndexBuffer()... and also for some reason i'm getting an error when trying the LoadIndexBuffer function.... i'm doing this in C++.


  • User profile image
    Jeromy Walsh

    I just wanted to thank you for referencing my article about normal computations for heightfield lighting on  It's good to know that it is still providing further use to people.

  • User profile image


    I'm getting the same thing. However, when you rotate the camera around a bit, sometimes you see lots of triangles being drawn all over each other - and this scene changes every frame whether you move or not.

    Not sure where the problem is - any help would be GREATLY appreciated.

  • User profile image
    Bermil Rossiter

    Windows Vista Home Premium

    Microsoft DirectX SDK (August 2007)

    Microsoft Visual C# 2005 Express Edition - ENU

    Microsoft SDKs\Windows\v6.0

    In Parts VI, VII, and VIII I get a run time error from the folloeing code

    The last line of   Render() in class Terrain

    _device.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, _totalNumberOfVertices, 0, _indices.Length - 2);


  • User profile image

    I got stuck on this one for a few days now, but I managed to get it working. Everytime I tried using the IndexBuffer, my GPU crashed on me.

    After trying to simplify the code for a day or two, I started browsing the internet and found out that the indexbuffer can only be filled with SHORT, not INT.

    changed the code to:

    _ib = new IndexBuffer(typeof(short), _indices.Length, _device, Usage.WriteOnly, Pool.Managed);


    _indices[index++] = (short)(x + (z * _numberOfVerticesX));


    _indices = new short[numIndices];

    // Array for the indexes of the vertices

           private short[] _indices;

    All in the terrain class. Working fine now. Guess I will move on to the next part now.. hope there will be more chapters some time soon.

  • User profile image

    Hi, nice tip TankCreator Smiley

    Once again, great tutorial. I've created a Light class, so I  can quickly create many different lights, varying in types, easier, and stored them all in a list, with names, so I can toggle them at will Big Smile

    I am having a problem with the terrain, however: The heightmap loads, but either the light doesn't shine down on the terrain ( and I've tried fixing that Tongue Out ), or the lights arent' getting enabled, which is what I'm thinking, or there's something I'm doing wrong with the material on the terrain itself.

    Anyone else having this problem? or know how to fix objects rendering all black?

    I noticed in your example here that when the lights are off, the car is black, and with lights on, it's textured.

    I'm just trying to see my terrain textured, I can see it as a point list. Also, while viewing it as a trianglestrip, in wireframe, or point mode, The graphics aren't clearing from the screen before the next frame renders. I'm not sure why this happens either :/

    Anyway, I'll continue to fiddle, I know this tutorial is old now but you've still got my compliments Smiley

  • User profile image

    I had also a problem with the lights. I have done it like the source code in the tutorial but it doesn't shine on the obstacles and tanks. I also created a point light but it doesn't shine too.

  • User profile image

    best tutorial about "direct3d and c#" i have read until now. i have experience as c# web developer but still some issues at fully understanding the code but so far i have learnt many great things. thanks a lot...

  • User profile image

    This is Part 4 of an introductory series on game programming using the Microsoft .NET Framework and managed

  • User profile image

    This is Part 2 of an introductory series on game programming using the Microsoft .NET Framework and managed

  • User profile image

    Is there any reason the following should not work? I want to note that I am not trying to build or anything else, I simply just want to be able to create a DirectX font.

    Imports Microsoft.DirectX

    Imports Microsoft.DirectX.Direct3d

    Public Class Form1

       Private font as Microsoft.DirectX.Direct3D.Font

    End Class

    I keep getting an error message stating, 'Type "Microsoft.DirectX.Direct3D.Font" is not defined.' I cannot figure out for the life of me why this is not working.  Thanks in advance.

  • User profile image

    I'm having a problem, because whenever I try to display a mesh in this code it gives me a Direct3DXExeption.

  • User profile image

    Thanks for the tip! I was doing a little custom coding for explosions and shooting... That was really getting me!

  • User profile image

    @ge-force are you using custom code or the sample code provided in the sample.  Also managed direct-x is no longer supported.  I'd heavily suggest using XNA instead.

Add Your 2 Cents