I have created an installer of a demo of Labyrinthica. Everything worked fine on my development PC which use windows XP.
However, on my other computer, which run windows Vista, all the sprites were not showing. The 3D models were showing though.
For some kind of a reason I have used my own custom orthogonal projection to draw the sprites in directX, instead of using ID3DXSprite’s default projection. Under the hood, sprites are drawn as quads or something similar. Quads are simply two triangles forming a rectangle. When the projection is orthogonal and the quad is facing the camera, its almost like drawing a 2D image on the screen. Then why I had a problem on the computer with Vista and not on the computer with Xp?
My custom orthogonal projection had a front plane of 1. That means that every triangle with the distance of all its vertexes from the camera is bellow 1, will not be seen. If I set a quad to be of a distance 0.5 from the camera, then it won’t be seen. In my case I have set the quad to a distance of 1.
Now here is the problem, on the XP computer a quad of distance 1 is still visible, but on the Vista computer it was not.
Perhaps there was some parameter or renderstate I didn’t set, but this might have been an undefined behaviour that is resulting in different behaviour on different platform.
What can help us quickly solve this kind of bug?
First, it might make sense to have a KISS(Keep It Simple Stupid) solution to check against(the default ID3DXSprite projection), in case you want to have something more sophisticated(custom projection). Another thing that might help against this is the axe principle, or cutting your program into two. This is a solution I wish to implement in the future and I will talk about when I get to do it.
What about preventing the bug?
This is kind of difficult to answer, because this bug is pretty unique so I can’t think of another similar case I might have in the future. I guess if I will encounter another bug that is caused by the same problem(Different front plane behaviour), I will have a better idea of what I should prevent.
GPU front plane bug.
September 27th, 2009 by oferPosted in Other blogs
