/// <summary>
        /// Render all lines added this frame
        /// </summary>
        public void Render(LineManager3DLines nLines, ICamera cam)
        {
            nLines.UpdateVertexBuffer(device);
            // Need to build vertex buffer?


            // Render lines if we got any lines to render
            if (nLines.NumOfPrimitives > 0)
            {
                try
                {
                    device.ImmediateContext.InputAssembler.InputLayout       = layout;
                    device.ImmediateContext.InputAssembler.PrimitiveTopology =
                        PrimitiveTopology.LineList;
                    device.ImmediateContext.InputAssembler.SetVertexBuffers(0,
                                                                            new VertexBufferBinding
                                                                                (nLines.VertexBuffer,
                                                                                vertexStride, 0));

                    worldViewProjParam.SetMatrix(cam.ViewProjection);

                    pass.Apply(device.ImmediateContext);
                    device.ImmediateContext.Draw(nLines.NumOfPrimitives * 2, 0);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        /// <summary>
        /// Init LineManager
        /// TODO: this class should be adapted so that it can be fully created even when the device isn't fully initialized.
        /// </summary>
        public LineManager3D(Device device)
        {
            this.device = device;
            initialize();
            //var stream = new DataStream(3 * vertexStride, true, true);
            //stream.Position = 0;

            /*var vertices = new SlimDX.Direct3D11.Buffer(device, stream, new BufferDescription()
             * {
             *  BindFlags = BindFlags.VertexBuffer,
             *  CpuAccessFlags = CpuAccessFlags.None,
             *  OptionFlags = ResourceOptionFlags.None,
             *  SizeInBytes = 3 * vertexStride,
             *  Usage = ResourceUsage.Default
             * });
             * //stream.Dispose();*/


            //var diffuseShaderVariable = effect.GetVariableByName("txDiffuse").AsResource();



            /*if ( HoofdObject.XNAGame.Graphics.GraphicsDevice  == null )
             *  throw new NullReferenceException(
             *      "XNA device is not initialized, can't init line manager." );*/

            lines = new LineManager3DLines(device);
            lines.SetMaxLines(1024 * 32);

            //shader = BasicShader.LoadFromFXFile( game, game.EngineFiles.LineRenderingShader );

            WorldMatrix = Matrix.Identity;
        }