void inittexture(){
	texture_data pic = load_jpg("r.jpg");

	gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pic.width, pic.height, GL_RGB, GL_UNSIGNED_BYTE, pic.data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, pic.width, pic.height, 0, GL_RGB, GL_UNSIGNED_BYTE, pic.data);

	free_texture_data(pic);
}
Exemplo n.º 2
0
///////////////////////////////////////////////////////////////////////////////
//! Init picture info with values
//!
//! @param _bounding_rectangle Main object bounding rectangle
//! @param _matrix_of_calibration Matrix of camera calibration for current image
//! @param file_name Name of the file with image
///////////////////////////////////////////////////////////////////////////////
int PictureInfo::init(const matrix<float> &_bounding_rectangle,
                      const matrix<float> &_matrix_of_calibration,
                      const std::string & file_name)
{
    bounding_rectangle = _bounding_rectangle;
    matrix_of_calibration = _matrix_of_calibration;
    if (!load_jpg(file_name))
    {
        valid = false;
        return 0;
    }

    valid = true;
    return 1;
}
int
main(int argc, char **argv)
{
	BITMAP *bmp;
	PACKFILE *f;
	char *file = NULL, *times = NULL, *memory = NULL;
	int arg, i, n, start, end, size;

	allegro_init();
	install_keyboard();
	install_timer();
	
	jpgalleg_init();
	
	set_color_conversion(COLORCONV_NONE);
	
	for (arg = 1; arg < argc; arg++) {
		if (!strcmp(argv[arg], "-nommx"))
			cpu_capabilities &= ~CPU_MMX;
		else if (!strcmp(argv[arg], "-f"))
			file = argv[++arg];
		else if (!times)
			times = argv[arg];
		else
			about();
	}
	if (times)
		n = atoi(times);
	else
		n = 30;
	if (!file)
		file = "jpgalleg.jpg";
	bmp = load_jpg(file, NULL);
	if (!bmp) {
		printf("Cannot find %s!\n", file);
		return -1;
	}
	size = file_size(file);
	memory = (char *)malloc(size);
	if (!memory) {
		printf("Not enough memory!\n");
		return -1;
	}
	f = pack_fopen(file, F_READ);
	pack_fread(memory, size, f);
	pack_fclose(f);
	
	LOCK_FUNCTION(timer_handler);
	LOCK_VARIABLE(timer);
	
	install_int(timer_handler, 10);
	
	printf("Average timing for %d function calls:\n", n);
	start = timer;
	for (i = 0; i < n; i++)
		bmp = load_jpg(file, NULL);
	end = timer;
	printf("load_jpg: %f seconds\n", ((float)end - (float)start) / 1000.0 / (float)n);

	start = timer;
	for (i = 0; i < n; i++)
		bmp = load_memory_jpg(memory, size, NULL);
	end = timer;
	printf("load_memory_jpg: %f seconds\n", ((float)end - (float)start) / 1000.0 / (float)n);
	
	free(memory);
	return 0;
}
Exemplo n.º 4
0
// Load the menu textures
void load_menus() {
	button_tex = load_png("menubut.png", true, false, true);
	button_tex2 = load_png("menubut2.png", true, false, true);
	menu_bg = load_jpg("menubg.jpg", false, true, true);
}