Jump to content
  • Advertisement
Sign in to follow this  

3d objects in the distance being draw in the front of closer objects

This topic is 2760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, i have been following an example code in a book and have now finished the book and the last example is a mock solor system.

The code is Frame based the frames are Scene, Sun, Planets, Earth and Moon.

The Scene is the parent of sun which is the parent of the Planets and Earth and earth is the parent of Moon.

now all of the objects rotate around each other in the expected way and when they pass behind the Sun they are drawn behind it. the problem occurs when they pass infront of the sun. The sun is still drawn infront evan though it is smaller and further away from my view.

i dont really want to post the code as there are many lines and im not sure which parts will be relavent so could you advise me as to why this is happening? i have enabled the z buffer but i think i may not have done it correctly?

i will post any code or all of it if you think it would be easier to help me.

the Frames have objects added to them all of which are derived from a base class which has a function Render() so when i come to render them all i call the Scene's Render function which goes through the list of Frames and Objects and calls all of thier Render functions. could it be the order that they are called? or should the z buffer sort this out for me?

well thanks for your help in advance :)

Share this post

Link to post
Share on other sites
ah ok cool sorry im still a noob atm how do i enable the writes? and where should i enable it every frame? or just in my main init function?

thanks for the reply :)

Share this post

Link to post
Share on other sites
Sorry guys i have managed to solve this one and it seems to of been a mistake made by me when trying to fix the code before i had set the viewport max to 2.0f...
but now it acts as it should. incase any one in the future does a similar thing.

typedef struct D3DVIEWPORT9 {
DWORD Width;
DWORD Height;
float MinZ;
float MaxZ; // set to 1.0f if you get the problem i had

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!