Пример #1
0
struct view_app *view_app_setup(unsigned int w, unsigned int h)
{

    view_init(&view.base, load, render, keydown);
    box_init(&view.titlebox);
    box_init(&view.shortbox);
    box_init(&view.menubox);
    box_setpartsize(&view.titlebox, w / 10, h / 10, 0, 0, 10, 2);
    box_setpartsize(&view.shortbox, w / 10, h / 10, 0, 1, 10, 6);
    box_setpartsize(&view.menubox, w / 10, h / 10, 0, 6, 10, 4);
    menu_init(&view.menu, view.menuitems, 3);
    menu_inititem(&view.menuitems[0], "Run", 0);
    menu_inititem(&view.menuitems[1], "Install", 0);
    menu_inititem(&view.menuitems[2], "Uninstall", 0);
    menu_setrow(&view.menu, 0);

    view.menu.onselect = menu_onselect;
    view.installview = view_install_setup(w, h);
    view.installview->base.onquit = xinstallview_onquit;
    view.installview->onload = installview_onload;
    view.uninstallview = view_uninstall_setup(w, h);
    view.uninstallview->base.onquit = xinstallview_onquit;
    view.uninstallview->onload = uninstallview_onload;

    return &view;

}
Пример #2
0
box_t* box_join(ap_manager_t* man, bool destructive, box_t* a1, box_t* a2)
{
  size_t i;
  size_t nbdims;
  box_t* res;

  man->result.flag_best = true;
  man->result.flag_exact = false;
  res = destructive ? a1 : box_alloc(a1->intdim,a1->realdim);
  if (a1->p==NULL){
    if (a2->p!=NULL){
      man->result.flag_exact = true;
      box_set(res,a2);
    }
    return res;
  }
  else if (a2->p==NULL){
    man->result.flag_exact = true;
    if (!destructive) box_set(res,a1);
    return res;
  }
  man->result.flag_exact = false;
  if (!destructive){
    box_init(res);
  }
  nbdims = a1->intdim + a2->realdim;
  for (i=0; i<nbdims; i++){
    itv_join(res->p[i],a1->p[i],a2->p[i]);
  }
  return res;
}
Пример #3
0
box_t* box_meet(ap_manager_t* man, bool destructive, box_t* a1, box_t* a2)
{
  size_t i;
  bool exc;
  size_t nbdims;
  box_t* res;
  box_internal_t* intern = (box_internal_t*)man->internal;

  man->result.flag_best = true;
  man->result.flag_exact = true;
  res = destructive ? a1 : box_alloc(a1->intdim,a1->realdim);
  if (a1->p==NULL || a2->p==NULL){
    box_set_bottom(res);
    return res;
  }
  if (!destructive){
    box_init(res);
  }
  nbdims = a1->intdim + a1->realdim;
  for (i=0; i<nbdims; i++){
    exc = itv_meet(intern->itv,res->p[i],a1->p[i],a2->p[i]);
    if (exc){
      box_set_bottom(res);
      break;
    }
  }
  return res;
}
Пример #4
0
group::group(sphere *spheres_, int start_, unsigned int count_) :
    negative(NULL),
    positive(NULL),
    spheres(spheres_),
    start(start_),
    count(count_)
{
    box_init(boxmin, boxmax);
    for(unsigned int i = 0; i < count; i++) {
        add_sphere(&boxmin, &boxmax, spheres[start + i].center, spheres[start + i].radius);
    }
}
Пример #5
0
int main(int argc, char** argv)
{
	char input[128];
	int boxes;
	int dimensions;
	int dimension[10];
	box_t box[30];
	int i, j;
	int result[30];
	int result_length;

	while (fgets(input, 128, stdin)) {
		sscanf(input, "%d %d", &boxes, &dimensions);

		result_length = 0;
		for (i = 0; i < 30; i++) {
			result[i] = 0;
		}

		for (i = 0; i < boxes; i++) {
			fgets(input, 128, stdin);
			sscanf(input, "%d %d %d %d %d %d %d %d %d %d", dimension+0, dimension+1, dimension+2, dimension+3, dimension+4, dimension+5, dimension+6, dimension+7, dimension+8, dimension+9);

			qsort(dimension, dimensions, sizeof(int), intcmp);

			box_init(&box[i], i + 1, dimension, dimensions);
		}

		for (i = 0; i < boxes; i++) {
			for (j = i + 1; j < boxes; j++) {
				if (boxcmp(&box[i], &box[j]) < 0) {
					box_append_fits_in(&box[i], &box[j]);
					box_append_fits_out(&box[j], &box[i]);
				}
				else if (boxcmp(&box[i], &box[j]) > 0) {
					box_append_fits_in(&box[j], &box[i]);
					box_append_fits_out(&box[i], &box[j]);
				}
			}
		}

		for (i = 0; i < boxes; i++) {
			do_magic(&box[i], result, &result_length, 1);
		}

		print_result(result, result_length);
	}

	return EXIT_SUCCESS;
}
Пример #6
0
void game_init(void)
{
	tft_fill(GAME_BGC);
	bar_init();
	box_init();
	switch (game.mode) {
	case 1:
		game_display_score(1);
	case 0:
	case 2:
		game_display_score(0);
		break;
	case 3:
		game_display_score(1);
	}
}
Пример #7
0
struct view_repolist *view_repolist_setup(unsigned int w, unsigned int h)
{

    view_init(&view.base, load, render, keydown);
    box_init(&view.menubox);
    box_setpartsize(&view.menubox, w, h, 0, 0, 1, 1);
    menu_init(&view.menu, view.menuitems, 4);
    menu_inititem(&view.menuitems[0], "All", "0 items");
    menu_inititem(&view.menuitems[1], "Installed", "0 items");
    menu_inititem(&view.menuitems[2], "New", "0 items");
    menu_inititem(&view.menuitems[3], "Updated", "0 items");
    menu_setrow(&view.menu, 0);

    view.menu.onselect = menu_onselect;
    view.applistview = view_applist_setup(w, h);
    view.applistview->onload = applistview_onload;
    view.applistview->base.onquit = applistview_onquit;

    return &view;

}
Пример #8
0
static void stereo_fb_layout_from_mode(struct stereo_fb_layout *layout,
				       drmModeModeInfo *mode)
{
	unsigned int format = mode->flags & DRM_MODE_FLAG_3D_MASK;
	const int hdisplay = mode->hdisplay, vdisplay = mode->vdisplay;
	int middle;

	switch (format) {
	case DRM_MODE_FLAG_3D_TOP_AND_BOTTOM:
		layout->fb_width = hdisplay;
		layout->fb_height = vdisplay;

		middle = vdisplay / 2;
		box_init(&layout->left, 0, 0, hdisplay, middle);
		box_init(&layout->right,
			 0, middle, hdisplay, vdisplay - middle);
		break;
	case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF:
		layout->fb_width = hdisplay;
		layout->fb_height = vdisplay;

		middle = hdisplay / 2;
		box_init(&layout->left, 0, 0, middle, vdisplay);
		box_init(&layout->right,
			 middle, 0, hdisplay - middle, vdisplay);
		break;
	case DRM_MODE_FLAG_3D_FRAME_PACKING:
	{
		int vactive_space = mode->vtotal - vdisplay;

		layout->fb_width = hdisplay;
		layout->fb_height = 2 * vdisplay + vactive_space;

		box_init(&layout->left,
			 0, 0, hdisplay, vdisplay);
		box_init(&layout->right,
			 0, vdisplay + vactive_space, hdisplay, vdisplay);
		break;
	}
	default:
		igt_assert(0);
	}
}
Пример #9
0
group* make_tree(sphere* spheres, int start, unsigned int count, int level = 0)
{
    if(level == 0) {
        previous = time(NULL);
        if(getenv("DEBUG_BVH") != NULL) {
            bvh_spheres_debug_output = fopen("bvh.r9", "w");
        }
    }
    if(time(NULL) > previous) {
        fprintf(stderr, "total treed = %d\n", total_treed);
        previous = time(NULL);
    }

    if((level >= bvh_max_depth) || count <= bvh_leaf_max) {
        total_treed += count;
        group* g = new group(spheres, start, count);
        if(bvh_spheres_debug_output != NULL) {
            // fprintf(bvh_spheres_debug_output, "sphere 7 %f %f %f %f 1 1 1 # %d\n", g->radius, g->center.x, g->center.y, g->center.z, level );
            if(level == 0) {
                fclose(bvh_spheres_debug_output);
                bvh_spheres_debug_output = NULL;
            }
        }
        bvh_leaf_size_counts[std::min(63U, count)]++;
        bvh_leaf_count++;
        bvh_level_counts[level]++;
        bvh_node_count++;
        return g;
    }

    vec3 split_pivot;
    vec3 split_plane_normal;

    // find bounding box
    vec3 boxmin, boxmax;
    box_init(boxmin, boxmax);
    for(unsigned int i = 0; i < count; i++) {
        sphere &s = spheres[start + i];
        vec3 spheremin = vec3_subtract(s.center, vec3(s.radius));
        vec3 spheremax = vec3_add(s.center, vec3(s.radius));
        box_extend(boxmin, boxmax, spheremin, spheremax);
    }

    split_pivot = vec3_scale(vec3_add(boxmin, boxmax), .5);

    vec3 boxdim = vec3_subtract(boxmax, boxmin);
    if(boxdim.x > boxdim.y && boxdim.x > boxdim.z) {
        split_plane_normal = vec3(1, 0, 0);
    } else if(boxdim.y > boxdim.z) {
        split_plane_normal = vec3(0, 1, 0);
    } else {
        split_plane_normal = vec3(0, 0, 1);
    }

    // XXX output split plane to BVH debug file

    int startA;
    int countA;
    int startB;
    int countB;

    if(!bvh_split_median) {

        int s1 = start - 1;
        int s2 = start + count;

        do {
            // from start to s1, not including s1, is negative
            // from s2 to start + count - 1 is positive
            do {
                s1 += 1;
            } while((s1 < s2) && vec3_dot(vec3_subtract(spheres[s1].center, split_pivot), split_plane_normal) < 0);

            // If there wasn't a positive sphere before s2, done.
            if(s1 >= s2)
                break;

            // s1 is now location of lowest positive sphere 

            do {
                s2 -= 1;
            } while((s1 < s2) && vec3_dot(vec3_subtract(spheres[s2].center, split_pivot), split_plane_normal) >= 0);


            // If there wasn't a negative sphere between s1 and s2, done
            if(s1 >= s2)
                break;

            // s2 is now location of highest negative sphere 
            std::swap(spheres[s1], spheres[s2]);
        } while(true);

        // s1 is the first of the positive spheres
        startA = start;
        countA = s1 - startA;
        startB = s1;
        countB = start + count - s1;

    } else {

        sphere_sorter sorter(split_plane_normal);
        std::sort(spheres + start, spheres + start + count - 1, sorter);

        startA = start;
        countA = count / 2;
        startB = startA + countA;
        countB = count - countA;

    }

    group *g;

    if(countA > 0 && countB > 0) {

        // get a tighter bound around children than hierarchical bounds
        vec3 boxmin, boxmax;
        box_init(boxmin, boxmax);
        for(unsigned int i = 0; i < count; i++) {
            add_sphere(&boxmin, &boxmax, spheres[start + i].center, spheres[start + i].radius);
        }

        // construct children
        group *g1 = make_tree(spheres, startA, countA, level + 1);
        g = new group(spheres, g1, NULL, split_plane_normal, boxmin, boxmax);
        group *g2 = make_tree(spheres, startB, countB, level + 1);
        g->positive = g2;
        bvh_level_counts[level]++;
        bvh_node_count++;

    } else {

        total_treed += count;
        fprintf(stderr, "Leaf node at %d, %u spheres, total %d\n", level, count, total_treed);
        g = new group(spheres, start, count);
        bvh_leaf_size_counts[std::min(63U, count)]++;
        bvh_leaf_count++;
        bvh_level_counts[level]++;
        bvh_node_count++;
    }

    if(bvh_spheres_debug_output != NULL) {
        // fprintf(bvh_spheres_debug_output, "sphere 7 %f %f %f %f 1 1 1 # %d\n", g->radius, g->center.x, g->center.y, g->center.z, level );
        if(level == 0) {
            fclose(bvh_spheres_debug_output);
            bvh_spheres_debug_output = NULL;
        }
    }

    return g;
}