Still not getting it

theHollow

Newcomer
Joined
Jan 4, 2005
Messages
9
I just don't seem to understand what the h*ll I am doing wrong. I know that there is something I haven't quite understood, but I just can't 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.

That's 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 something's 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.

I've updated your game.vb class and attached it - if you compare this one to your copy you will see the differences mainly
Visual Basic:
'added to your initialize routine
D3Dpp.EnableAutoDepthStencil = True
D3Dpp.AutoDepthStencilFormat = DepthFormat.D16
and
Visual Basic:
'Used to clear the device
 D3Ddev.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, bgColor, 1, 0)
and also
Visual Basic:
'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. I've been looking for this solution for quite a while now.

Again...thank you!
 
Back
Top