diff --git a/examples/osgunittests/osgunittests.cpp b/examples/osgunittests/osgunittests.cpp index 97a25e4d4..27b86a848 100644 --- a/examples/osgunittests/osgunittests.cpp +++ b/examples/osgunittests/osgunittests.cpp @@ -2,6 +2,86 @@ #include #include +#include + + +void testFrustum(double left,double right,double bottom,double top,double zNear,double zFar) +{ + osg::Matrix f; + f.makeFrustum(left,right,bottom,top,zNear,zFar); + + + double c_zNear = f(3,2) / (f(2,2)-1.0f); + double c_zFar = f(3,2) / (1.0f+f(2,2)); + + double c_left = c_zNear * (f(2,0)-1.0f) / f(0,0); + double c_right = c_zNear * (1.0f+f(2,0)) / f(0,0); + + double c_top = c_zNear * (1+f(2,1)) / f(1,1); + double c_bottom = c_zNear * (f(2,1)-1.0f) / f(1,1); + + f.getFrustum(c_left,c_right,c_bottom,c_top,c_zNear,c_zFar); + + std::cout << "testFrustum"<setCommandLineUsage(arguments.getApplicationName()+" [options]"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("qt","Display qualified tests."); + arguments.getApplicationUsage()->addCommandLineOption("matrix","Display qualified tests."); + if (arguments.argc()<=1) + { + arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); + return 1; + } + bool printQualifiedTest = false; while (arguments.read("qt")) printQualifiedTest = true; + bool displayMatrixTest = false; + while (arguments.read("matrix")) displayMatrixTest = true; + // if user request help write it out to cout. if (arguments.read("-h") || arguments.read("--help")) { @@ -34,10 +124,20 @@ int main( int argc, char** argv ) return 1; } - if (arguments.argc()<=1) + + if (displayMatrixTest) { - arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); - return 1; + std::cout<<"****** Running matrix tests ******"<