DirectX texture problem

Started by
1 comment, last by Nevadaes 14 years, 1 month ago
Hey everyone, I was coding a little bit, minding my own business, when I told myself "Hey, I'll add textures to my cubes!" So, to create my cube, I used a DirectX file which contains the information about the cube as well as uv information. I can put a texture on it. The problem, now, is that I draw four cubes. I my code, the third one is the one that has the texture. It appears finely on the screen: only one cube has a texture and the three other don't. The thing is that, when I move a cube around using the arrow keys and when the cube goes in front of the textured cube, well, it goes under. To say it in other terms, the cube with the texture, as well as the fourth cube, which, in the code, is placed right after the declaration of the cube with the texture, are always drawn in front of the screen, no matter what. I tried to move one of my cube as closely as possible of the camera, those two cubes were always in front. It seems the problem comes from the texture, because when I get rid of it, it works fine (Well, I can't see much because every cubes are white in my code), but I don't why it occurs. Do you have a suggestion?
Advertisement
Quote:(Well, I can't see much because every cubes are white in my code)


First, you must be really sure the texture is the source of the problem. If you're not using lighting (I don't know, I'm speculating) and all the cubes have the same color, you won't be able to see which is in the front and which in the back. Is this your case? Do all the sides of all your cubes have exactly the same color?
If yes, try to paint them in different colors (one cube red, one blue etc.) to verify the problem isn't there even without the textures.


Btw, sounds like disabled (or wrong) z-buffering (if you verify that the texture is not the source of the problem).
Hey thanks, I think I just learned something :) I checked, and I forgot to specify the D3DCLEAR_ZBUFFER flag in my Clear function, it works properly now, thanks.

This topic is closed to new replies.

Advertisement