By far the most common error would be the way you calculate the aspect ratio. If both the dividend and the divisor are integers, then, depending on the language, you are likely getting an integer division so the aspect ratio is an integer. Solution is to cast either the dividend or the divisor, or both, to a floating point value to force a floating point division.

Put a break point at the point where the matrices are finally calculated, and when they are finally used, and see what the values of the actual matrices. If none of the changes affect anything, then the matrices are ultimately not used. The coordinates you use and the location of the quad ultimately is consistent with an identity matrix.

My advice kind of assume that you know the projection matrix is wrong to begin with. If you don't know that, you don't really know what to look for in the first place.

But, my advice still stands in a more general form; you need to take advantage of the debugger. You are experiencing problems with the viewing, so use the debugger to inspect everything that has anything to do with getting something onto the screen. Break into the debugger when the values are calculated, and ensure that they are exactly as you expect, or even just reasonable. This requires knowledge of linear algebra and experience to actually know what a "reasonable" value is though, and comes with time.

And what if you finally find out that the projection matrix is not as expected? Go back and figure out where the projection matrix is calculated. This would have been a dead give-away; the debugger would not have reached the computePerspective function if it wasn't called.

Another tip to do with aspect ratios is changing them when you write and test the function so you can verify the code works. You don't want the width and height to be const anyway, assuming the window can be resized.

Edited by Paradigm Shifter, 30 October 2013 - 04:51 PM.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley