Still not getting it

theHollow

Member
Joined
Jan 4, 2005
Messages
9
I just dont seem to understand what the h*ll I am doing wrong. I know that there is something I havent quite understood, but I just cant seem to figure out what.

I have created two rectangles, one blue and one red.
Each rectangle are created by four triangles, where the two first are facing out, the other in. Just to avoid transparency when the object is rotated.

Thats at least what I thought.

Here are two images. The first is what I like it to be. The second image is the source of my frustrations. The two images (screenshots) are taken while the two rectangles are rotating.

I use VB.NET, and I have attached my code if somethings missing. I am just so close to giving up. I have read various tutorials on this forum, but no luck.

Please help...
 

Attachments

Last edited by a moderator:
You need to tell DirectX to manage your Z-Buffer - then it can handle depth correctly. clicky has a good tutorial on Z-buffer use.

Ive updated your game.vb class and attached it - if you compare this one to your copy you will see the differences mainly
Code:
added to your initialize routine
D3Dpp.EnableAutoDepthStencil = True
D3Dpp.AutoDepthStencilFormat = DepthFormat.D16
and
Code:
Used to clear the device
 D3Ddev.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, bgColor, 1, 0)
and also
Code:
following line modified in SetupMatrices
 D3Ddev.Transform.Projection = Matrix.PerspectiveFovLH(Math.PI / 3.0F, 1.0F, 1.0F, 10.0F)
 

Attachments

Ah!
Thank you very, very, very much. Ive been looking for this solution for quite a while now.

Again...thank you!
 
Back
Top