示例#1
0
文件: main.cpp 项目: luaman/g3d-cpp
int main(int argc, char* argv[]) {
    (void)argc;
    (void)argv;

    RenderDevice* renderDevice = NULL;

    NetworkDevice* networkDevice = new NetworkDevice();
    if (networkDevice) {networkDevice->init();}

    std::string s;
    System::describeSystem(s);
    printf("%s\n", s.c_str());

    if (networkDevice) {
        networkDevice->describeSystem(s);
        printf("%s\n", s.c_str());
    }


#    ifndef _DEBUG
        printf("Performance analysis:\n\n");

	perfCollisionDetection();

        perfArray();

        perfTable();

        printf("%s\n", System::mallocPerformance().c_str());

        perfQueue();

        perfMatrix3();

        perfTextOutput();

        perfSystemMemcpy();

        perfBinaryIO();

        perfAABSPTree();

        measureMemsetPerformance();
        measureNormalizationPerformance();

	GWindow::Settings settings;
        settings.width = 800;
        settings.height = 600;
        settings.alphaBits = 0;
        settings.rgbBits = 8;
        settings.stencilBits = 0;
        settings.fsaaSamples = 1;

        if (!renderDevice) {
            renderDevice = new RenderDevice();
        }
    
        renderDevice->init(settings);

        if (renderDevice) {
            renderDevice->describeSystem(s);
            printf("%s\n", s.c_str());
        }

        measureRDPushPopPerformance(renderDevice);

	getch();

#   else

    printf("\n\nTests:\n\n");

    testTable();

    testCollisionDetection();    

    testCoordinateFrame();

	testReliableConduit(networkDevice);

	testAABSPTree();

	testQuat();

    testReferenceCount();

    testAtomicInt32();

    testGThread();

    testSystemMemset();

    testSystemMemcpy();

    testQueue();

	// Don't run contrib tests until the new 7.00 build system is in place
    // testMatrix();
    // testGChunk();

    testArray();

    testMeshAlgTangentSpace();

    testConvexPolygon2D();

    testPlane();
    printf("  passed\n");

    testAABox();

    testRandom();
    printf("  passed\n");

    testAABoxCollision();
    printf("  passed\n");
    testAdjacency();
    printf("  passed\n");
    testWildcards();
    printf("  passed\n");

    testFloat();
    printf("  passed\n");
    
    testRandom();

    testTextInput();
    printf("  passed\n");

    testBox();
    printf("  passed\n");

    testColor3uint8Array();
    printf("  passed\n");
    testglFormatOf();
    printf("  passed\n");
    testSwizzle();

    testBinaryIO();

#   ifdef RUN_SLOW_TESTS
        testHugeBinaryIO();
        printf("  passed\n");
#   endif

    printf("%s\n", System::mallocPerformance().c_str());
    System::resetMallocPerformanceCounters();

    printf("\nAll tests succeeded.\n");
#endif

    if (renderDevice) {
        renderDevice->cleanup();
        delete renderDevice;
    }
    
    if (networkDevice) {
		networkDevice->cleanup();
	    delete networkDevice;
	}

    return 0;
}
示例#2
0
int main(int argc, char* argv[]) {
    (void)argc;
    (void)argv;

#   ifdef G3D_WINDOWS
    {
        // Change to the executable directory
        chdir(FilePath::parent(argv[0]).c_str());
    }
#   endif


    char x[2000];
    getcwd(x, sizeof(x));
    
    debugAssertM(FileSystem::exists("apiTest.zip", false), 
                 format("Tests are being run from the wrong directory.  cwd = %s", x));

    RenderDevice* renderDevice = NULL;

    std::string s;
    System::describeSystem(s);
    printf("%s\n", s.c_str());

    NetworkDevice::instance()->describeSystem(s);
    printf("%s\n", s.c_str());


#    ifndef _DEBUG
        printf("Performance analysis:\n\n");

        perfSystemMemcpy();
        perfSystemMemset();

        // Pause so that we can see the values in the debugger
   //     getch();

        printf("%s\n", System::mallocPerformance().c_str());

        perfArray();

        perfBinaryIO();

        perfTable();

        perfHashTrait();

        perfKDTree();

        perfCollisionDetection();

        perfQueue();

        perfMatrix3();

        perfTextOutput();

        perfPointHashGrid();

        measureNormalizationPerformance();

        OSWindow::Settings settings;
        settings.width = 800;
        settings.height = 600;
        settings.alphaBits = 0;
        settings.rgbBits = 8;
        settings.stencilBits = 0;
        settings.msaaSamples = 1;

        if (! renderDevice) {
            renderDevice = new RenderDevice();
        }
    
        renderDevice->init(settings);

        if (renderDevice) {
            renderDevice->describeSystem(s);
            printf("%s\n", s.c_str());
        }

        measureRDPushPopPerformance(renderDevice);

#       ifdef G3D_WIN32
            // Pause so that we can see the values in the debugger
//	        getch();
#       endif

#   else

    printf("\n\nTests:\n\n");

    testunorm16();
    testunorm8();
    testsnorm8();
    testsnorm16();

    testMatrix();

    testAny();

    testBinaryIO();

    testSpeedLoad();

    testReliableConduit(NetworkDevice::instance());

    testFileSystem();

    testCollisionDetection();  

    testTextInput();
    testTextInput2();
    printf("  passed\n");

    testSphere();

    testImageConvert();

    testKDTree();

    testLineSegment2D();

    testGLight();

    testZip();

    testMap2D();

    testfilter();

    testArray();

    testSmallArray();

    testSpline();

    testMatrix3();
    testMatrix4();

    testTable();

    testTableTable();  

    testCoordinateFrame();

    testQuat();

    testReferenceCount();

    testAtomicInt32();

    testGThread();
    
    testWeakCache();
    
    testSystemMemset();

    testSystemMemcpy();

    testuint128();

    testQueue();

    testMeshAlgTangentSpace();

    testConvexPolygon2D();

    testPlane();
    printf("  passed\n");

    testAABox();

    testRandom();
    printf("  passed\n");

    testAABoxCollision();
    printf("  passed\n");
    testAdjacency();
    printf("  passed\n");
    testWildcards();
    printf("  passed\n");

    testFloat();
    printf("  passed\n");
    
    testRandom();

    testFuzzy();
    printf("  passed\n");

    testBox();
    printf("  passed\n");

    testBox2D();
    printf("  passed\n");

    testglFormatOf();
    printf("  passed\n");
    testSwizzle();

    testGCamera();

    testCallback();

    testPointHashGrid();

#   ifdef RUN_SLOW_TESTS
        testHugeBinaryIO();
        printf("  passed\n");
#   endif

    printf("%s\n", System::mallocPerformance().c_str());
    System::resetMallocPerformanceCounters();

    printf("\nAll tests succeeded.\n");
#endif

    if (renderDevice) {
        renderDevice->cleanup();
        delete renderDevice;
    }
    
    NetworkDevice::cleanup();

    return 0;
}