Esempio n. 1
0
void init(){
	// White color
	glClearColor(1.0, 1.0, 1.0, 0.0);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0, windowWidth, windowHeight, 0.0);

	// Call random point generator
	inputter();
	switch(pointMode){
		case Spiral:
			generateSpiralPoints();
			break;
		case Random:
			generateRandomPoints();
			break;
		case Grid:
			generateGridPoints();
			break;
		default: break;
	}

	generateVoronoi();

}
Esempio n. 2
0
int64_t lzbench_zling_decompress(char *inbuf, size_t insize, char *outbuf, size_t outsize, size_t, size_t, char*)
{
	baidu::zling::MemInputter  inputter((uint8_t*)inbuf, insize);
	baidu::zling::MemOutputter outputter((uint8_t*)outbuf, outsize);
	baidu::zling::Decode(&inputter, &outputter);

	return outputter.GetOutputSize();
} 
Esempio n. 3
0
void init(){



//    glMatrixMode(GL_PROJECTION);
//	glLoadIdentity();
//	gluOrtho2D(0.0, IslandWidth, IslandHeight, 0.0);

	// Call random point generator
	IslandMode = inputter(&pointMode);
	generateRandomPoints(&setPoints, numberofPoints);

	vd = generateVoronoi(&setPoints, numberofPoints);


	// Define elevation
	circlePointCt = terrainInput(elevation, biomesInformation, circleVertices, circleColors, perlinOffsets, pointMode, IslandMode);

	perlinArray = convertToArray(perlinOffsets);

	idx = VoronoiVerticesColors(vd, &voronoiPoints, &voronoiColors);


	// Adjust voronoi points
	voronoiVertices = adjustVoronoi(&voronoiPoints, &voronoiColors, elevation, circleColors, idx);

	// Find coords
	voronoiCoords = findCoords(&voronoiPoints, idx);

	// Find normals
	voronoiNormals = findNormals(voronoiVertices, idx);

	// Initialize shaders
	initShadersVAOS();

}
Esempio n. 4
0
int main(int argc, char** argv) {
    baidu::zling::FileInputter  inputter(stdin);
    baidu::zling::FileOutputter outputter(stdout);
    DemoActionHandler demo_handler;

#if defined(__MINGW32__) || defined(__MINGW64__)
    setmode(fileno(stdin),  O_BINARY);  // set stdio to binary mode for windows
    setmode(fileno(stdout), O_BINARY);
#endif

    // welcome message
    fprintf(stderr, "zling:\n");
    fprintf(stderr, "   light-weight lossless data compression utility\n");
    fprintf(stderr, "   by Zhang Li <zhangli10 at baidu.com>\n");
    fprintf(stderr, "\n");

    // zling <e/d> __argv2__ __argv3__
    if (argc == 4) {
        if (freopen(argv[3], "wb", stdout) == NULL) {
            fprintf(stderr, "error: cannot open file '%s' for write.\n", argv[3]);
            return -1;
        }
        argc = 3;
    }

    // zling <e/d> __argv2__ (stdout)
    if (argc == 3) {
        if (freopen(argv[2], "rb", stdin) == NULL) {
            fprintf(stderr, "error: cannot open file '%s' for read.\n", argv[2]);
            return -1;
        }
        argc = 2;
    }

    // zling <e/d> (stdin) (stdout)
    try {
        if (argc == 2 && strcmp(argv[1], "e4") == 0) {
            return baidu::zling::Encode(&inputter, &outputter, &demo_handler, 4);
        }
        if (argc == 2 && strcmp(argv[1], "e3") == 0) {
            return baidu::zling::Encode(&inputter, &outputter, &demo_handler, 3);
        }
        if (argc == 2 && strcmp(argv[1], "e2") == 0) {
            return baidu::zling::Encode(&inputter, &outputter, &demo_handler, 2);
        }
        if (argc == 2 && strcmp(argv[1], "e1") == 0) {
            return baidu::zling::Encode(&inputter, &outputter, &demo_handler, 1);
        }
        if (argc == 2 && strcmp(argv[1], "e0") == 0) {
            return baidu::zling::Encode(&inputter, &outputter, &demo_handler, 0);
        }

        if (argc == 2 && strcmp(argv[1], "e") == 0) {
            return baidu::zling::Encode(&inputter, &outputter, &demo_handler, 0);
        }
        if (argc == 2 && strcmp(argv[1], "d") == 0) {
            return baidu::zling::Decode(&inputter, &outputter, &demo_handler);
        }

    } catch (const std::runtime_error& e) {
        fprintf(stderr, "zling: runtime error: %s\n", e.what());
        return -1;

    } catch (const std::bad_alloc& e) {
        fprintf(stderr, "zling: allocation failed.");
        return -1;
    }

    // help message
    fprintf(stderr, "usage:\n");
    fprintf(stderr, "   zling e[N=0,1,2,3,4] source target\n");
    fprintf(stderr, "   zling d source target\n");
    fprintf(stderr, "    * source: (default: stdin)\n");
    fprintf(stderr, "    * target: (default: stdout)\n");
    fprintf(stderr, "    * N:      (default: 0) compression level, bigger level for better and slower compression.\n");
    return -1;
}