Tech Off Post

Single Post Permalink

View Thread: Discuss the Beginning Game Development series on Coding 4 Fun
  • User profile image

    After pulling my hair out trying to figure out why I'm not intelligent enough to get this tutorial to build I finally figured out that I was working with the 2.0 version of DirectX managed.  The only change I had to make to get the tutorial code to build was in the CreateCrossHairVertexArrayTop and Bottom methods.  Instead of returning a PositionColored[] it needs to return a GraphicsBuffer to the DrawUserPrimitives method.  Not an earthbreaking change but maybe someone else can benefit from not wasting valuable hair strands on this simple issue.  The code I used is:

    private GraphicsBuffer<PositionColored> CreateCrossHairVertexArrayTop ( )
       GraphicsBuffer<PositionColored> crossHair = new GraphicsBuffer<PositionColored>(7);
       float zval = 0f;
       Color col = Color.Green;

       crossHair.Write(new PositionColored(-1f, 1f, zval, col));
       crossHair.Write(new PositionColored(-1f, 2f, zval, col));
       crossHair.Write(new PositionColored(0f, 2f, zval, col));
       crossHair.Write(new PositionColored(0f, 3f, zval, col));
       crossHair.Write(new PositionColored(0f, 2f, zval, col));
       crossHair.Write(new PositionColored(1f, 2f, zval, col));
       crossHair.Write(new PositionColored(1f, 1f, zval, col));

       return crossHair;

    Hope this helps someone out.  Not sure the performance implications of using Generics instead of arrays, but I don't see any framerate difference in the tutorial application using DX 2 or DX 1.4 on my admitedly subpar gaming machine.