Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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...

test3.zip

Edited by PlausiblyDamp
  • Administrators
Posted

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

'added to your initialize routine
D3Dpp.EnableAutoDepthStencil = True
D3Dpp.AutoDepthStencilFormat = DepthFormat.D16

and

'Used to clear the device
D3Ddev.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, bgColor, 1, 0)

and also

'following line modified in SetupMatrices
D3Ddev.Transform.Projection = Matrix.PerspectiveFovLH(Math.PI / 3.0F, 1.0F, 1.0F, 10.0F)

GameClass.zip

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...