コード例 #1
0
ファイル: gxruntime.cpp プロジェクト: kfprimm/blitz3d-ng
gxRuntime::~gxRuntime(){
	if( graphics ) closeGraphics( graphics );
	denumGfx();
	DestroyWindow( Frame::hwnd );
	UnregisterClass( "Blitz Runtime Class",hinst );

	CoUninitialize();
}
コード例 #2
0
int main(int argc, char** argv)
{
    freopen("CON", "w", stdout); // redirects stdout because SDL redirects it to a file.

    /* Parsing the input parameters. */
    if (argc < 6)
    {
        std::cout << "Missing some input parametr. Needed at least 5 but got only " << argc - 1 << std::endl;
        return -1;
    }

	if (!initGraphics(RESX, RESY)) return -1;
	renderScene();
	displayVFB(vfb);

    try
	{
		Puzzle puzzle;
		if (!puzzle.loadMap(argv[1]))
			throw "Something is wrong with the map file!";

        puzzle.setMonsterAndFoodCoords(fromStringToInt(argv[2]), fromStringToInt(argv[3]), fromStringToInt(argv[4]), fromStringToInt(argv[5]));

        // The flag for the SDL visualization
        if (argc >= 7)
        {
            puzzle.setVisualizationFlag(fromStringToInt(argv[6]));
        }

        // The flag for the SDL visualization
        if (argc >= 8)
        {
            puzzle.setDelay(fromStringToInt(argv[7]));
        }
		puzzle.printMap(std::cout);
		puzzle.solveAndVizualize(std::cout);
		puzzle.visualizeThePath();
		puzzle.basicVisualizePath(std::cout);
		puzzle.printFormatedPath(std::cout);

	}
	catch (const char * msg)
	{
		std::cout << "Error: " << msg << std::endl;
	}
	catch (const string msg)
	{
		std::cout << "Error: " << msg << std::endl;
	}


	waitForUserExit();
	closeGraphics();
	return 0;
}
コード例 #3
0
void test_random()
{
	initGraphics(1024, 1024);
	Random rnd(time(NULL));
	//
	for (int i = 0; i < 200; i++)
		printf("mt: %u\n", rnd._next());

	SDL_WM_SetCaption("Testing MTRandom", NULL);

	grand = &rnd;

	testSpeed("unitDiscSample()s", genrandpair);

	testSpeed("SDL_ThreadID()s", threadid);

	double delayFactor = 1000.0;
	// test the random generator graphically:
	for (int i = 0; i < 30000; i++) {
		// generate new 1000 integer points:
		for (int j = 0; j < 1000; j++)
			int_buff[rnd.randint(0, 511)][rnd.randint(0, 511)]++;

		// generate new 1000 floatingpoint points:
		for (int j = 0; j < 1000; j++) {
			float x = rnd.randfloat()*512;
			float y = rnd.randfloat()*512;
			int x0 = (int) floor(x);
			int y0 = (int) floor(y);
			int x1 = (x0 + 1) % 512;
			int y1 = (y0 + 1) % 512;
			float p = x - x0;
			float q = y - y0;
			float_buff[y0][x0] += (1 - p) * (1 - q);
			float_buff[y0][x1] += (    p) * (1 - q);
			float_buff[y1][x0] += (1 - p) * (    q);
			float_buff[y1][x1] += (    p) * (    q);
		}

		// generate new 1000 circle points:
		for (int j = 0; j < 1000; j++) {
			double cx, cy;
			rnd.unitDiscSample(cx, cy);
			float x = float(cx * 256 + 256);
			float y = float(cy * 256 + 256);
			int x0 = (int) floor(x);
			int y0 = (int) floor(y);
			int x1 = (x0 + 1) % 512;
			int y1 = (y0 + 1) % 512;
			float p = x - x0;
			float q = y - y0;
			circle_buff[y0][x0] += (1 - p) * (1 - q);
			circle_buff[y0][x1] += (    p) * (1 - q);
			circle_buff[y1][x0] += (1 - p) * (    q);
			circle_buff[y1][x1] += (    p) * (    q);
		}

		// generate new 5000 normally-distributed points:
		for (int j = 0; j < 5000; j++) {
			double x = rnd.gaussian(256, 256.0/3.0);
			if (x < 0 || x >= 511) continue;
			double p = x - floor(x);
			int x0 = floor(x);
			norm_buff[x0] += (1 - p);
			norm_buff[x0 + 1] += p;
		}
		//
		displayCharts((i + 1) * 5000);
		displayVFB(vfb);
		SDL_Delay((int) delayFactor);
		delayFactor *= 0.9;
	}
	waitForUserExit();
	closeGraphics();
}