   C# Direct3D 9.0
  Hi everyone, I have a question.I have started using direct3d with C#.  I don't understand why my rendering is not displaying things in order.  For instance, a box that is behind a pyramid, is actually being displayed as being in front, the geometry is not hiding what's behind it.  I have enabled the zbuffer with device.RenderStates.ZBufferEnable = true in the initialization, it still is not working!!I'm so frustrated.  Someone please help me out. Am I missing something?I've worked for a month on a pretty decent ASE file loader loading transforms, meshanimation, camera and light controls etc.  This one thing is just messing it up.Thanks.   
  You didn't say if you set a depth buffer format so try this instead:PresentParameters pp = new PresentParameters();pp.AutoDepthStencil = DepthBufferFormat.D16pp.EnableAutoDepthStencil = true;I don't remember the exact names for the property and enum that hold the depth buffer formats, but it's something to that effect, so it shouldn't be too hard to find.  Hope this helps.-AJ   ;  Hi,You'll need to provide a proper format under the AutoDepthStencilFormat in the PresentationParameters, and also set AutoDepthStencil to true.Valid formats would be any depth/stencil format (namely, D16, D32, or D24S8).Hope this helps.Edit: beaten, oh the noes.   ;  Hi, well, i added the following lines as suggestedpresentParams.AutoDepthStencilFormat = DepthFormat.D16;presentParams.EnableAutoDepthStencil = true;But it still is not working, there was no difference.Is there a specific DepthFormat I have to use, or can any one work?  Is it a problem with c#?  This may sound like a foolish question, but are there any bugs or incomplete sections for the Direct3D API for C#?  ;  Are you sure the location of the objects is correct.  Let's see some code to [smile].-AJ   ;  Hi, the location of the objects is correct, i'm importing straight from 3d studio .ASE format.  I double check the order by moving the camera around in my engine, so i know what is infront and behind.Does the order of the device.DrawPrimitives have to be in order too, or just once per output direct3d checks the buffer after all the device.drawprimitives have been called for that frame?What type of code would help you help me?Again, thanks a log guys.;Quote:Original post by whereisumarHi, the location of the objects is correct, i'm importing straight from 3d studio .ASE format.  I double check the order by moving the camera around in my engine, so i know what is infront and behind.Does the order of the device.DrawPrimitives have to be in order too, or just once per output direct3d checks the buffer after all the device.drawprimitives have been called for that frame?What type of code would help you help me?Again, thanks a log guys.The order of device.DrawPrimitives shouldn't matter, I don't think, but it helps for efficiency's sake.  The code that would help out would probably be any rendering code and code that handles positioning of the objects in the world.-AJ;  Hi, well below is some related code to my problem.PresentParameters presentParams = new PresentParameters();presentParams.Windowed   = true;presentParams.SwapEffect = SwapEffect.Discard;device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);device.RenderState.Lighting = true;presentParams.AutoDepthStencilFormat = DepthFormat.D16;presentParams.EnableAutoDepthStencil = true;device.RenderState.ZBufferEnable = true; device.RenderState.CullMode = Cull.CounterClockwise;That's all in the initialization.  Below is code regarding positioning, this may be a bit confusing and an overload, because it's taking transformations into account.    while (!CorrectKeyFrameFound)    {    if (Ticks >= TMAnimation.PosTrack[KeyFrame].Frame && Ticks < TMAnimation.PosTrack[KeyFrame+1].Frame)    {    CorrectKeyFrameFound = true;    CurrentFrame = KeyFrame;    }    KeyFrame++;    }    Magnitude = (Ticks - TMAnimation.PosTrack[CurrentFrame].Frame) / 160;    Pos.X = TMAnimation.PosTrackI[CurrentFrame].Pos.X;    Pos.Y = TMAnimation.PosTrackI[CurrentFrame].Pos.Y;    Pos.Z = TMAnimation.PosTrackI[CurrentFrame].Pos.Z;M.M41 += Pos.X;M.M42 += Pos.Y;M.M43 += Pos.Z;   device.Transform.World = M;The above code is fragments from the .Draw() function.  Each object has it's own draw method.  Hope this helps. I really still can't see what i'm doin wrong ;  Are you clearing the z-buffer by including ClearFlags.ZBuffer in your Device.Clear method?   ;  protected virtual void Render(){if (device != null) {device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);device.Clear(ClearFlags.ZBuffer, Color.Black, 1.0f, 0);device.BeginScene();GameObject.Draw(device, Ticks);DateTime StartTime = DateTime.Now;while (DateTime.Now.Ticks < StartTime.Ticks + 191325);Ticks+=160;device.EndScene();device.Present();}}Hi, well i added this line, i'm almost 100% sure i'm doing this wrong, this is the render method.  Is this what you meant?  Also, now when i run it, it just gives me an error and does not start at all. How do you hide geometry!?!?!? i'm goin crazy.   