Direct3D Z order question

Joseph Garvin k04jg02 at
Sat Feb 11 16:06:24 CST 2006

In OpenGL, when you specify depth coordinates with glOrtho, they're 
relative to the 'eye' which is pointing down the z-axis. So -30 actually 
evaluates to +30 in absolute coordinates. Maybe something similar is 
happening here? What happens when you draw a third triangle with z=0.5? 
What if you make the red triangle z=0.1 and the blue one z=1.0? (it 
could be a corner case for when z=0)

Stefan Dösinger wrote:

>I have written a small Direct3D7 test application which draws two overlapping 
>triangles, a red one and a blue one. The red triangle has the z value 0.0
>(closest to the viewer), the blue one 1.0(far away). Strangely, the blue 
>triangle overlaps the red one on Windows.
>The same happens on the current ddraw implementation, but in WineD3D the red 
>triangle overlaps the blue one, which is mathematically correct. I've studied 
>the ddraw and wined3d drawing code over and over, but I couldn't find any 
>difference. It seems that on Windows, the triangle that is drawn last 
>overlaps the other one in the output, and the z value seems to be ignored 
>completely. Can someone explain me what's going on here????
>The reason for this is the Direct3D mode of Half-Life 1. I've got it working 
>with WineD3D after a long struggle with 
>IDirect3DVertexBuffer::ProcessVertices, except of the HUD, which is hidden. 
>If I force the z value in the [0.0, 1.0] range, it is shown, but the rest is 
>broken obviously.
>How to run my test program: I've attached a source file and a Makefile which 
>builds a .exe with mingw, and a precompiled exe file. When you run it, it 
>shows a black screen, and if you click anywhere, it draws the triangles. I've 
>some bug in the flipping code, so you have to click two times actually. 
>Pressing esc exits.
>PS: If anyone needs the d3d7->wined3d code to look at, I can send patches. But 
>it's quite messy now ;)

More information about the wine-devel mailing list