Exemplo n.º 1
0
void
tabs_init()
{
	char *tab_label_menu = _("Menu");
	char *tab_label_contacts = _("Contacts");
	char *tab_label_broadcast = _("Global");
	struct tab *t;
	struct view *v;

	t = tab_new("Log");
	v = view_init("log");
	tab_push_view(t, v);
	view_log_print(VLT_INFO, "Begin logging...");

	t = tab_new(tab_label_menu);
	v = view_init("menu");
	tab_push_view(t, v);
	tab_show(t);

	t = tab_new(tab_label_contacts);
	v = view_init("contacts");
	tab_push_view(t, v);

	t = tab_new(tab_label_broadcast);
	v = view_init("chat");
	view_chat_set_contact(v, NULL);
	tab_push_view(t, v);
}
Exemplo n.º 2
0
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
	struct wlr_xdg_surface_v6 *xdg_surface = data;

	if (xdg_surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
		sway_log(SWAY_DEBUG, "New xdg_shell_v6 popup");
		return;
	}

	sway_log(SWAY_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'",
		xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
	wlr_xdg_surface_v6_ping(xdg_surface);

	struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
		calloc(1, sizeof(struct sway_xdg_shell_v6_view));
	if (!sway_assert(xdg_shell_v6_view, "Failed to allocate view")) {
		return;
	}

	view_init(&xdg_shell_v6_view->view, SWAY_VIEW_XDG_SHELL_V6, &view_impl);
	xdg_shell_v6_view->view.wlr_xdg_surface_v6 = xdg_surface;

	xdg_shell_v6_view->map.notify = handle_map;
	wl_signal_add(&xdg_surface->events.map, &xdg_shell_v6_view->map);

	xdg_shell_v6_view->unmap.notify = handle_unmap;
	wl_signal_add(&xdg_surface->events.unmap, &xdg_shell_v6_view->unmap);

	xdg_shell_v6_view->destroy.notify = handle_destroy;
	wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_v6_view->destroy);

	xdg_surface->data = xdg_shell_v6_view;
}
Exemplo n.º 3
0
Arquivo: game.c Projeto: rlk/neverball
int game_init(const char *s)
{
    int i;

    jump_e = 1;
    jump_b = 0;

    idle_t = 1.0f;

    view_init();

    if (!(state = sol_load_full(&file, s, config_get_d(CONFIG_SHADOW))))
        return 0;

    sol_init_sim(&file.vary);

    for (i = 0; i < file.base.dc; i++)
    {
        const char *k = file.base.av + file.base.dv[i].ai;
        const char *v = file.base.av + file.base.dv[i].aj;

        if (strcmp(k, "idle") == 0)
        {
            sscanf(v, "%f", &idle_t);

            if (idle_t < 1.0f)
                idle_t = 1.0f;
        }
    }
    return 1;
}
Exemplo n.º 4
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;

}
Exemplo n.º 5
0
void
prepare(void)
{
    struct rt_i *rtip = APP.a_rt_i;

    RT_CK_RTI(rtip);

    if (debug)  fprintf(stderr, "prepare()\n");

    /*
     * initialize application -- it will allocate 1 line and
     * set buf_mode=1, as well as do mlib_init().
     */
    (void)view_init(&APP, title_file, title_obj, 0, 0);

    do_prep(rtip);

    if (rtip->nsolids <= 0)
	bu_exit(3, "ph_matrix: No solids remain after prep.\n");

    grid_setup();

    /* initialize lighting */
    view_2init(&APP, NULL);

    rtip->nshots = 0;
    rtip->nmiss_model = 0;
    rtip->nmiss_tree = 0;
    rtip->nmiss_solid = 0;
    rtip->nmiss = 0;
    rtip->nhits = 0;
    rtip->rti_nrays = 0;

}
Exemplo n.º 6
0
void game_init(const char *s)
{
    jump_e = 1;
    jump_b = 0;

    view_init();
    sol_load_gl(&file, s,
                config_get_d(CONFIG_TEXTURES),
                config_get_d(CONFIG_SHADOW));
}
Exemplo n.º 7
0
/* initialize blue and opengl stuff */
void blue_gl_init(INITFUNC_ARGS){
    /* Blue type initialization */
    window_type = window_init(lib, Module);
    view_type   = view_init(lib, Module);
    layer_type  = layer_init(lib, Module);
    shape_type  = shape_init(lib, Module);
    image_type  = image_init(lib, Module);
    light_type  = light_init(lib, Module);
    text_type  = text_init(lib, Module);
}
Exemplo n.º 8
0
Easel *
easel_new (Canvas   *canvas)
{
  Easel *easel = g_malloc0 (sizeof (Easel));
  View  *view  = (View*) easel;
  
  view_init (view, canvas);
  view_set_event (view, easel_event, NULL);
  
  return easel;
}
Exemplo n.º 9
0
/*
 * Start here
 */
int simulator::main(int argc, char*argv[])
{
	glutInit(&argc, argv);

	view_init();

	simul.init();
	simul.resume();

	glutMainLoop();
	return 0;
}
Exemplo n.º 10
0
static int
view_contacts_key_tab(int k)
{
	struct view_edit_contact *v;

	v = (struct view_edit_contact *) view_init("edit_contact");
	/* TODO: Fix this. */
//	view_edit_contact_set_contact((struct view *) v, view_contacts_contact_current);
	tab_push_view(tab_current, (struct view *) v);

	return CONTROLLERS_STOP;
}
Exemplo n.º 11
0
int game_init(const char *file_name,
              const char *back_name,
              const char *grad_name, int t, int e)
{
    my_clock = (float) t / 100.f;

    if (game_state)
        game_free();

    game_ix = 0.f;
    game_iz = 0.f;
    game_rx = 0.f;
    game_rz = 0.f;

    /* Initialize jump and goal states. */

    jump_e = 1;
    jump_b = 0;

    goal_e = e ? 1    : 0;
    goal_k = e ? 1.0f : 0.0f;

    /* Reset the hud. */

    hud_ball_pulse(0.f);
    hud_time_pulse(0.f);
    hud_coin_pulse(0.f);

    /* Initialise the level, background, particles, fade, and view. */

    fade_k =  1.0f;
    fade_d = -2.0f;

    part_reset(GOAL_HEIGHT);
    view_init();
    back_init(grad_name, config_get_d(CONFIG_GEOMETRY));

    if (sol_load(&back, config_data(back_name),
                 config_get_d(CONFIG_TEXTURES), 0) &&
        sol_load(&file, config_data(file_name),
                 config_get_d(CONFIG_TEXTURES), config_get_d(CONFIG_SHADOW)))
        return (game_state = 1);
    else
        return (game_state = 0);
}
Exemplo n.º 12
0
void
widget_init (Widget *widget,
             Canvas *canvas)
{
  View   *view   = (View*) widget;
  view_init (view, canvas);

  widget->primary_color[0] = 65536 * 0.0;
  widget->primary_color[1] = 65536 * 0.0;
  widget->primary_color[2] = 65536 * 0.0;
  
  widget->secondary_color[0] = 65536 * 1.0;
  widget->secondary_color[1] = 65536 * 1.0;
  widget->secondary_color[2] = 65536 * 1.0;

  widget->background_color[0] = 65536 * 0.75;
  widget->background_color[1] = 65536 * 0.75;
  widget->background_color[2] = 65536 * 0.75;
}
Exemplo n.º 13
0
static int
view_contacts_key_enter(int k)
{
	struct view *v;
	struct tab *t;

	v = view_chat_find_by_contact(view_contacts_contact_current->c_key);
	if (v == NULL) {
		t = tab_new(view_contacts_contact_current->c_nickname);
		v = view_init("chat");
		view_chat_set_contact(v, view_contacts_contact_current->c_key);
		tab_push_view(t, v);
		tab_show(t);
	} else {
		tab_show(v->v_tab);
	}
	chat_connect(view_contacts_contact_current);

	return CONTROLLERS_STOP;
}
Exemplo n.º 14
0
int
xdiff_view (const char *file1, const char *file2)
{
    int error;
    WDiff *view;
    WButtonBar *bar;
    Dlg_head *view_dlg;

    /* Create dialog and widgets, put them on the dialog */
    view_dlg =
	create_dlg(0, 0, LINES, COLS, NULL, view_dialog_callback,
		   "[Binary Diff Viewer]", NULL, DLG_WANT_TAB);

    view = g_new0(WDiff, 1);

    init_widget(&view->widget, 0, 0, LINES - 1, COLS,
		(callback_fn)view_callback,
		(mouse_h)view_event);

    widget_want_cursor(view->widget, 0);

    bar = buttonbar_new(1);

    add_widget(view_dlg, bar);
    add_widget(view_dlg, view);

    error = view_init(view, file1, file2);

    /* Please note that if you add another widget,
     * you have to modify view_adjust_size to
     * be aware of it
     */
    if (!error) {
	run_dlg(view_dlg);
	view_search(view, -1);
	view_fini(view, 1);
    }
    destroy_dlg(view_dlg);

    return error;
}
Exemplo n.º 15
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;

}
Exemplo n.º 16
0
/** Documented at declaration */
int
view_glut(struct view* view)
{
    int argc = 0;
    glutInit(&argc, NULL);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA);
    glutCreateWindow("OpenGL and CUDA");
    glutReshapeWindow(view->window_width, view->window_height);
    glutDisplayFunc(view_glut_render);
    glutKeyboardFunc(view_glut_keyboard);
    glutIdleFunc(view_glut_render);

    view_init(view);
    
    g_glut_view = view;
    
    glutPostRedisplay();
    while( g_glut_view != NULL ) {
        glutMainLoopEvent();
    }
    glutHideWindow();
    
    return 0;
}
Exemplo n.º 17
0
Arquivo: main.c Projeto: bartman/wmii
void
init_screens(void) {
	Rectangle *rects;
	View *v;
	int i, n, m;

#ifdef notdef
	d.x = Dx(scr.rect) - Dx(screen->r);
	d.y = Dy(scr.rect) - Dy(screen->r);
	for(v=view; v; v=v->next) {
		v->r.max.x += d.x;
		v->r.max.y += d.y;
	}
#endif

	/* Reallocate screens, zero any new ones. */
	rects = xinerama_screens(&n);
	m = max(n, nscreens);
	screens = erealloc(screens, (m + 1) * sizeof *screens);
	screens[m] = nil;
	for(v=view; v; v=v->next) {
		v->areas = erealloc(v->areas, m * sizeof *v->areas);
		v->r = erealloc(v->r, m * sizeof *v->r);
		v->pad = erealloc(v->pad, m * sizeof *v->pad);
	}

	for(i=nscreens; i < m; i++) {
		screens[i] = emallocz(sizeof *screens[i]);
		for(v=view; v; v=v->next)
			view_init(v, i);
	}

	nscreens = m;

	/* Reallocate buffers. */
	freeimage(ibuf);
	freeimage(ibuf32);
	ibuf = allocimage(Dx(scr.rect), Dy(scr.rect), scr.depth);
	ibuf32 = nil; /* Probably shouldn't do this until it's needed. */
	if(render_visual)
		ibuf32 = allocimage(Dx(scr.rect), Dy(scr.rect), 32);
	disp.ibuf = ibuf;
	disp.ibuf32 = ibuf32;

	/* Resize and initialize screens. */
	for(i=0; i < nscreens; i++) {
		screen = screens[i];
		screen->idx = i;

		screen->showing = i < n;
		if(screen->showing)
			screen->r = rects[i];
		else
			screen->r = rectsetorigin(screen->r, scr.rect.max);
		def.snap = Dy(screen->r) / 63;
		bar_init(screens[i]);
	}
	screen = screens[0];
	if(selview)
		view_update(selview);
}
Exemplo n.º 18
0
/* since a lot of routines depend on the current_panel variable */
void set_display_type (int num, int type)
{
    int x, y, cols, lines;
    int    the_other;		/* Index to the other panel */
    char   *file_name = 0;	/* For Quick view */
    Widget *new_widget, *old_widget;
    WPanel  *the_other_panel;

    x =y = cols = lines = 0;
    old_widget = 0;
    if (num >= MAX_VIEWS){
	fprintf (stderr, "Could not allocate more that %d views\n", MAX_VIEWS);
	abort ();
    }

    /* Check that we will have a WPanel * at least */
    the_other = 0;
    if (type != view_listing){
	the_other = num == 0 ? 1 : 0;

	if (panels [the_other].type != view_listing)
	    return;

    }
    
    /* Get rid of it */
    if (panels [num].widget){
	Widget *w = panels [num].widget;
	WPanel *panel = (WPanel *) panels [num].widget;
	
	x = w->x;
	y = w->y;
	cols  = w->cols;
	lines = w->lines;
	old_widget = panels [num].widget;

	if (panels [num].type == view_listing){
	    if (panel->frame_size == frame_full && type != view_listing){
		cols = COLS - first_panel_size;
		if (num == 1)
		    x = first_panel_size;
	    }
	}
#ifdef HAVE_TK
	tk_evalf ("container_clean %s", panel->widget.wcontainer);
#endif
    }

    new_widget = 0;
    
    switch (type){
    case view_listing:
	new_widget = (Widget *) panel_new (get_nth_panel_name (num));
	break;
	
    case view_info:
	new_widget = (Widget *) info_new ();
	
	break;

    case view_tree:
	new_widget = (Widget *) tree_new (1, 0, 0, 0, 0);
	break;

    case view_quick:
	new_widget = (Widget *) view_new (0, 0, 0, 0, 1);
	the_other_panel = (WPanel *) panels [the_other].widget;
	if (the_other_panel)
	    file_name =
		the_other_panel->dir.list[the_other_panel->selected].fname;
	else
	    file_name = "";
	
	view_init ((WView *) new_widget, 0, file_name, 0);
	break;
    }
    panels [num].type = type;
    panels [num].widget = (Widget *) new_widget;
    
    /* We set the same size the old widget had */
    widget_set_size ((Widget *) new_widget, y, x, lines, cols);
    
    /* We wanna the new widget at the same position */
    /* XView sets wcontainer to !0 <- Not XView, but we, when we create it */
    /* Ok, the XView support code does it */
    if (old_widget && old_widget->wcontainer){
	new_widget->wcontainer = old_widget->wcontainer;
	new_widget->area = old_widget->area;
    }

    /* We use replace to keep the circular list of the dialog in the */
    /* same state.  Maybe we could just kill it and then replace it  */
    if (midnight_dlg && old_widget){
	dlg_replace_widget (midnight_dlg, old_widget, panels [num].widget);
    }
    if (type == view_listing){
	if (num == 0)
	    left_panel = (WPanel *) new_widget;
	else
	    right_panel = (WPanel *) new_widget;
    }

    if (type == view_tree)
	the_tree = (WTree *) new_widget;

    /* Prevent current_panel's value from becoming invalid.
     * It's just a quick hack to prevent segfaults. Comment out and
     * try following:
     * - select left panel
     * - invoke menue left/tree
     * - as long as you stay in the left panel almost everything that uses
     *   cpanel causes segfault, e.g. C-Enter, C-x c, ...
     */

    if (type != view_listing)
	if (cpanel == (WPanel *) old_widget)
	    current_panel = num == 0 ? right_panel : left_panel;
}
Exemplo n.º 19
0
int
view (char *_command, char *_file, int *move_dir_p, int start_line)
{
	Dlg_head   *our_dlg;
	GtkWidget  *toplevel, *status, *scrollbar, *hbox;
	GtkVBox    *vbox;
	WView      *wview;
	WButtonBar *bar;
	int        midnight_colors [4];
	int        error;
	
	/* Create dialog and widgets, put them on the dialog */
	our_dlg = create_dlg (0, 0, 0, 0, midnight_colors,
			      gnome_view_callback, "[Internal File Viewer]",
			      "view",
			      DLG_NO_TED | DLG_GNOME_APP);
	
	toplevel = GTK_WIDGET (our_dlg->wdata);
	vbox   = GTK_VBOX (gtk_vbox_new (0, 0));
	
	gtk_window_set_policy (GTK_WINDOW (toplevel), TRUE, TRUE, TRUE);
	gnome_app_set_contents (GNOME_APP (toplevel), GTK_WIDGET (vbox));

	gtk_window_set_title (GTK_WINDOW (toplevel),
			      _command ? _command : _file);
	wview = view_new (0, 0, 80, 25, 0);

	bar = buttonbar_new (1);
	
	add_widget (our_dlg, wview);
	add_widget (our_dlg, bar);
	
	error = view_init (wview, _command, _file, start_line);
	if (move_dir_p)
		*move_dir_p = 0;

	/* Please note that if you add another widget,
	 * you have to modify view_adjust_size to
	 * be aware of it
	 */
	if (error)
		return !error;

	status = gview_status (wview);
	gnome_app_create_menus_with_data (GNOME_APP (toplevel), gview_top_menu, wview);

	/* Setup the menus checkboxes correctly */
	GTK_CHECK_MENU_ITEM (gview_mode_menu [WRAP_POS].widget)->active = wview->wrap_mode;
	GTK_CHECK_MENU_ITEM (gview_mode_menu [FORMAT_POS].widget)->active = wview->viewer_nroff_flag;
	GTK_CHECK_MENU_ITEM (gview_mode_menu [HEX_POS].widget)->active = wview->hex_mode;
		
	init_dlg (our_dlg);
	
	gtk_box_pack_start (GTK_BOX (vbox), status, 0, 1, 0);

	wview->sadj = gtk_adjustment_new (0.0, 0.0, 1000000.0, 1.0, 25.0, 25.0);
	scrollbar = gtk_vscrollbar_new (wview->sadj);
	gtk_signal_connect (GTK_OBJECT (wview->sadj), "value_changed",
			    GTK_SIGNAL_FUNC(scrollbar_moved), wview);

	gtk_signal_connect (GTK_OBJECT (toplevel), "delete_event",
			    GTK_SIGNAL_FUNC (quit_view), wview);
	
	hbox = gtk_hbox_new (0, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, 1, 1, 0);
	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (wview->widget.wdata), 1, 1, 0);
	gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (scrollbar), 0, 1, 0);
	
	gtk_widget_show_all (toplevel);
	
	return 1;
}
Exemplo n.º 20
0
/*
 *			M A I N
 */
int main(int argc, char **argv)
{
    struct rt_i *rtip = NULL;
    char *title_file = NULL, *title_obj = NULL;	/* name of file and first object */
    char idbuf[RT_BUFSIZE] = {0};		/* First ID record info */
    void	application_init();
    struct bu_vls	times;
    int i;

#if defined(_WIN32) && !defined(__CYGWIN__)
    setmode(fileno(stdin), O_BINARY);
    setmode(fileno(stdout), O_BINARY);
    setmode(fileno(stderr), O_BINARY);
#else
    bu_setlinebuf( stdout );
    bu_setlinebuf( stderr );
#endif

#ifdef HAVE_SBRK
    beginptr = (char *) sbrk(0);
#endif
    azimuth = 35.0;			/* GIFT defaults */
    elevation = 25.0;

    AmbientIntensity=0.4;
    background[0] = background[1] = 0.0;
    background[2] = 1.0/255.0; /* slightly non-black */

    /* Before option processing, get default number of processors */
    npsw = bu_avail_cpus();		/* Use all that are present */
    if ( npsw > MAX_PSW )  npsw = MAX_PSW;

    /* Before option processing, do application-specific initialization */
    RT_APPLICATION_INIT( &ap );
    application_init();

    /* Process command line options */
    if ( !get_args( argc, argv ) )  {
	(void)fputs(usage, stderr);
	return 1;
    }
    /* Identify the versions of the libraries we are using. */
    if (rt_verbosity & VERBOSE_LIBVERSIONS) {
	(void)fprintf(stderr, "%s%s%s%s\n",
		      brlcad_ident(title),
		      rt_version(),
		      bn_version(),
		      bu_version()
	    );
    }
#if defined(DEBUG)
    (void)fprintf(stderr, "Compile-time debug symbols are available\n");
#endif
#if defined(NO_BOMBING_MACROS) || defined(NO_MAGIC_CHECKING) || defined(NO_BADRAY_CECHKING) || defined(NO_DEBUG_CHECKING)
    (void)fprintf(stderr, "WARNING: Run-time debugging is disabled and may enhance performance\n");
#endif

    /* Identify what host we're running on */
    if (rt_verbosity & VERBOSE_LIBVERSIONS) {
	char	hostname[512] = {0};
#ifndef _WIN32
	if ( gethostname( hostname, sizeof(hostname) ) >= 0 &&
	     hostname[0] != '\0' )
	    (void)fprintf(stderr, "Running on %s\n", hostname);
#else
	sprintf(hostname, "Microsoft Windows");
	(void)fprintf(stderr, "Running on %s\n", hostname);
#endif
    }

    if ( bu_optind >= argc )  {
	fprintf(stderr, "%s:  MGED database not specified\n", argv[0]);
	(void)fputs(usage, stderr);
	return 1;
    }

    if (rpt_overlap)
	ap.a_logoverlap = ((void (*)())0);
    else
	ap.a_logoverlap = rt_silent_logoverlap;

    /* If user gave no sizing info at all, use 512 as default */
    if ( width <= 0 && cell_width <= 0 )
	width = 512;
    if ( height <= 0 && cell_height <= 0 )
	height = 512;

    /* If user didn't provide an aspect ratio, use the image
     * dimensions ratio as a default.
     */
    if (aspect <= 0.0) {
	aspect = (fastf_t)width / (fastf_t)height;
    }

    if ( sub_grid_mode ) {
	/* check that we have a legal subgrid */
	if ( sub_xmax >= width || sub_ymax >= height ) {
	    fprintf( stderr, "rt: illegal values for subgrid %d,%d,%d,%d\n",
		     sub_xmin, sub_ymin, sub_xmax, sub_ymax );
	    fprintf( stderr, "\tFor a %d X %d image, the subgrid must be within 0, 0,%d,%d\n",
		     width, height, width-1, height-1 );
	    return 1;
	}
    }

    if ( incr_mode )  {
	int x = height;
	if ( x < width )  x = width;
	incr_nlevel = 1;
	while ( (1<<incr_nlevel) < x )
	    incr_nlevel++;
	height = width = 1<<incr_nlevel;
	if (rt_verbosity & VERBOSE_INCREMENTAL)
	    fprintf(stderr,
		    "incremental resolution, nlevels = %d, width=%d\n",
		    incr_nlevel, width);
    }

    /*
     *  Handle parallel initialization, if applicable.
     */
#ifndef PARALLEL
    npsw = 1;			/* force serial */
#endif

    if ( npsw < 0 )  {
	/* Negative number means "all but" npsw */
	npsw = bu_avail_cpus() + npsw;
    }


    /* allow debug builds to go higher than the max */
    if (!(bu_debug & BU_DEBUG_PARALLEL)) {
	if ( npsw > MAX_PSW ) {
	    npsw = MAX_PSW;
	}
    }

    if (npsw > 1) {
	rt_g.rtg_parallel = 1;
	if (rt_verbosity & VERBOSE_MULTICPU)
	    fprintf(stderr, "Planning to run with %d processors\n", npsw );
    } else {
	rt_g.rtg_parallel = 0;
    }

    /* Initialize parallel processor support */
    bu_semaphore_init( RT_SEM_LAST );

    /*
     *  Do not use bu_log() or bu_malloc() before this point!
     */

    if ( bu_debug )  {
	bu_printb( "libbu bu_debug", bu_debug, BU_DEBUG_FORMAT );
	bu_log("\n");
    }

    if ( RT_G_DEBUG )  {
	bu_printb( "librt rt_g.debug", rt_g.debug, DEBUG_FORMAT );
	bu_log("\n");
    }
    if ( rdebug )  {
	bu_printb( "rt rdebug", rdebug, RDEBUG_FORMAT );
	bu_log("\n");
    }

    /* We need this to run rt_dirbuild */
    rt_init_resource( &rt_uniresource, MAX_PSW, NULL );
    bn_rand_init( rt_uniresource.re_randptr, 0 );

    title_file = argv[bu_optind];
    title_obj = argv[bu_optind+1];
    nobjs = argc - bu_optind - 1;
    objtab = &(argv[bu_optind+1]);

    if ( nobjs <= 0 )  {
	bu_log("%s: no objects specified -- raytrace aborted\n", argv[0]);
	return 1;
    }

    /* Echo back the command line arugments as given, in 3 Tcl commands */
    if (rt_verbosity & VERBOSE_MODELTITLE) {
	struct bu_vls str;
	bu_vls_init(&str);
	bu_vls_from_argv( &str, bu_optind, (const char **)argv );
	bu_vls_strcat( &str, "\nopendb "  );
	bu_vls_strcat( &str, title_file );
	bu_vls_strcat( &str, ";\ntree " );
	bu_vls_from_argv( &str,
			  nobjs <= 16 ? nobjs : 16,
			  (const char **)argv+bu_optind+1 );
	if ( nobjs > 16 )
	    bu_vls_strcat( &str, " ...");
	else
	    bu_vls_putc( &str, ';' );
	bu_log("%s\n", bu_vls_addr(&str) );
	bu_vls_free(&str);
    }

    /* Build directory of GED database */
    bu_vls_init( &times );
    rt_prep_timer();
    if ( (rtip=rt_dirbuild(title_file, idbuf, sizeof(idbuf))) == RTI_NULL ) {
	bu_log("rt:  rt_dirbuild(%s) failure\n", title_file);
	return 2;
    }
    ap.a_rt_i = rtip;
    (void)rt_get_timer( &times, NULL );
    if (rt_verbosity & VERBOSE_MODELTITLE)
	bu_log("db title:  %s\n", idbuf);
    if (rt_verbosity & VERBOSE_STATS)
	bu_log("DIRBUILD: %s\n", bu_vls_addr(&times) );
    bu_vls_free( &times );
    memory_summary();

    /* Copy values from command line options into rtip */
    rtip->rti_space_partition = space_partition;
    rtip->rti_nugrid_dimlimit = nugrid_dimlimit;
    rtip->rti_nu_gfactor = nu_gfactor;
    rtip->useair = use_air;
    rtip->rti_save_overlaps = save_overlaps;
    if ( rt_dist_tol > 0 )  {
	rtip->rti_tol.dist = rt_dist_tol;
	rtip->rti_tol.dist_sq = rt_dist_tol * rt_dist_tol;
    }
    if ( rt_perp_tol > 0 )  {
	rtip->rti_tol.perp = rt_perp_tol;
	rtip->rti_tol.para = 1 - rt_perp_tol;
    }
    if (rt_verbosity & VERBOSE_TOLERANCE)
	rt_pr_tol( &rtip->rti_tol );

    /* before view_init */
    if ( outputfile && strcmp( outputfile, "-") == 0 )
	outputfile = (char *)0;

    /*
     *  Initialize application.
     *  Note that width & height may not have been set yet,
     *  since they may change from frame to frame.
     */
    if ( view_init( &ap, title_file, title_obj, outputfile!=(char *)0, framebuffer!=(char *)0 ) != 0 )  {
	/* Framebuffer is desired */
	register int xx, yy;
	int	zoom;

	/* Ask for a fb big enough to hold the image, at least 512. */
	/* This is so MGED-invoked "postage stamps" get zoomed up big enough to see */
	xx = yy = 512;
	if ( width > xx || height > yy )  {
	    xx = width;
	    yy = height;
	}
	bu_semaphore_acquire( BU_SEM_SYSCALL );
	fbp = fb_open( framebuffer, xx, yy );
	bu_semaphore_release( BU_SEM_SYSCALL );
	if ( fbp == FBIO_NULL )  {
	    fprintf(stderr, "rt:  can't open frame buffer\n");
	    return 12;
	}

	bu_semaphore_acquire( BU_SEM_SYSCALL );
	/* If fb came out smaller than requested, do less work */
	if ( fb_getwidth(fbp) < width )  width = fb_getwidth(fbp);
	if ( fb_getheight(fbp) < height )  height = fb_getheight(fbp);

	/* If the fb is lots bigger (>= 2X), zoom up & center */
	if ( width > 0 && height > 0 )  {
	    zoom = fb_getwidth(fbp)/width;
	    if ( fb_getheight(fbp)/height < zoom )
		zoom = fb_getheight(fbp)/height;
	} else {
	    zoom = 1;
	}
	(void)fb_view( fbp, width/2, height/2,
		       zoom, zoom );
	bu_semaphore_release( BU_SEM_SYSCALL );
    }
    if ( (outputfile == (char *)0) && (fbp == FBIO_NULL) )  {
	/* If not going to framebuffer, or to a file, then use stdout */
	if ( outfp == NULL )  outfp = stdout;
	/* output_is_binary is changed by view_init, as appropriate */
	if ( output_is_binary && isatty(fileno(outfp)) )  {
	    fprintf(stderr, "rt:  attempting to send binary output to terminal, aborting\n");
	    return 14;
	}
    }

    /*
     *  Initialize all the per-CPU memory resources.
     *  The number of processors can change at runtime, init them all.
     */
    for ( i=0; i < MAX_PSW; i++ )  {
	rt_init_resource( &resource[i], i, rtip );
	bn_rand_init( resource[i].re_randptr, i );
    }
    memory_summary();

#ifdef SIGUSR1
    (void)signal( SIGUSR1, siginfo_handler );
#endif
#ifdef SIGINFO
    (void)signal( SIGINFO, siginfo_handler );
#endif

    if ( !matflag )  {
	int frame_retval;
	def_tree( rtip );		/* Load the default trees */
	do_ae( azimuth, elevation );
	frame_retval = do_frame( curframe );
	if (frame_retval != 0) {
	    /* Release the framebuffer, if any */
	    if ( fbp != FBIO_NULL ) {
		fb_close(fbp);
	    }

	    return 1;
	}
    } else if ( !isatty(fileno(stdin)) && old_way( stdin ) )  {
	; /* All is done */
    } else {
	register char	*buf;
	register int	ret;
	/*
	 * New way - command driven.
	 * Process sequence of input commands.
	 * All the work happens in the functions
	 * called by rt_do_cmd().
	 */
	while ( (buf = rt_read_cmd( stdin )) != (char *)0 )  {
	    if ( R_DEBUG&RDEBUG_PARSE )
		fprintf(stderr, "cmd: %s\n", buf );
	    ret = rt_do_cmd( rtip, buf, rt_cmdtab );
	    bu_free( buf, "rt_read_cmd command buffer" );
	    if ( ret < 0 )
		break;
	}
	if ( curframe < desiredframe )  {
	    fprintf(stderr,
		    "rt:  Desired frame %d not reached, last was %d\n",
		    desiredframe, curframe);
	}
    }

    /* Release the framebuffer, if any */
    if (fbp != FBIO_NULL) {
	fb_close(fbp);
    }

    return(0);
}
Exemplo n.º 21
0
/** Documented at declaration */
int
view_glx(struct view* view)
{    
    // Open display
    view->glx_display = XOpenDisplay(0);
    if ( view->glx_display == NULL ) {
        fprintf(stderr, "Failed to open X display!\n");
        pthread_exit(0);
    }

    // Choose visual
    static int attributes[] = {
        GLX_RGBA,
        GLX_DOUBLEBUFFER,
        GLX_RED_SIZE,   1,
        GLX_GREEN_SIZE, 1,
        GLX_BLUE_SIZE,  1,
        None
    };
    XVisualInfo* visual = glXChooseVisual(view->glx_display, DefaultScreen(view->glx_display), attributes);
    if ( visual == NULL ) {
        fprintf(stderr, "Failed to choose visual!\n");
        pthread_exit(0);
    }

    // Create OpenGL context
    view->glx_context = glXCreateContext(view->glx_display, visual, 0, GL_TRUE);
    if ( view->glx_context == NULL ) {
        fprintf(stderr, "Failed to create OpenGL context!\n");
        pthread_exit(0);
    }

    // Create window
    Colormap colormap = XCreateColormap(view->glx_display, RootWindow(view->glx_display, visual->screen), visual->visual, AllocNone);
    XSetWindowAttributes swa;
    swa.colormap = colormap;
    swa.border_pixel = 0;
    swa.event_mask = KeyPressMask;
    view->glx_window = XCreateWindow(
        view->glx_display, 
        RootWindow(view->glx_display, visual->screen), 
        0, 0, view->window_width, view->window_height,
        0, visual->depth, InputOutput, visual->visual,
        CWBorderPixel | CWColormap | CWEventMask, 
        &swa
    );
    XStoreName(view->glx_display, view->glx_window, "OpenGL and CUDA interoperability");
    XMapWindow(view->glx_display, view->glx_window);
    
    view_opengl_attach(view);
    view_init(view);
    
    while ( 1 ) {
        view_glx_render(view);
        
        XEvent event;
        if ( XCheckWindowEvent(view->glx_display, view->glx_window, KeyPressMask, &event)) {
            int keycode = (int)event.xkey.keycode;
            char* key = XKeysymToString(XKeycodeToKeysym(view->glx_display, keycode, 0));
            if ( view_glx_keyboard(keycode, key) != 0 )
                break;
        }
    }
    
    view_opengl_detach(view);
    
    // Cleanup
    glXDestroyContext(view->glx_display, view->glx_context);
    XDestroyWindow(view->glx_display, view->glx_window);
    XCloseDisplay(view->glx_display);

    return 0;
}
Exemplo n.º 22
0
int main(int argc, char **argv)
{
    int retval = 0;

    struct timeval timeout, timeout_def;

    pa_mainloop * ml = pa_mainloop_new();
    pa_mainloop_api * api = pa_mainloop_get_api(ml);
    pa_context_state_t pa_state;

    pa_context * context = pa_context_new(api, "pa-mixer");
    pa_context_connect(context, NULL, 0, NULL);
    pa_context_set_state_callback(context, pa_state_changed, &pa_state);

    /*
    struct sigaction sigint_handler;
    sigint_handler.sa_handler = handle_sig_int;
    sigemptyset(&sigint_handler.sa_mask);
    sigint_handler.sa_flags = 0;
    sigaction(SIGINT, &sigint_handler, NULL);
    */

    int init_done = 0;

    initscr();
    keypad(stdscr, TRUE);
    start_color();
    curs_set(0);
    cbreak();
    noecho();
    init_pair(1, COLOR_WHITE, COLOR_BLACK);
    init_pair(2, COLOR_WHITE, COLOR_BLUE);

    fd_set read_set, test_set;
    FD_ZERO(&read_set);
    FD_SET(0, &read_set);
    timeout_def.tv_sec = 0;
    timeout_def.tv_usec = 1000;

    view_init();

    while(running) {
        if(pa_state == PA_CONTEXT_UNCONNECTED) {
            pa_mainloop_iterate(ml, 1, NULL);
            continue;
        }
        if(pa_state == PA_CONTEXT_FAILED || pa_state == PA_CONTEXT_TERMINATED) {
            running = 0;
            retval = -1;
        }
        if(pa_state == PA_CONTEXT_READY) {
            if(!init_done) {
                pa_context_set_subscribe_callback(context, on_event, NULL);
                pa_context_subscribe(context, PA_SUBSCRIPTION_MASK_ALL, NULL, NULL);
                pa_context_get_sink_input_info_list(context, on_sink_input_update, context);
                pa_context_get_sink_info_list(context, on_sink_update, context);
            }
            init_done = 1;
        }

        test_set = read_set;
        timeout = timeout_def;
        int r = select(1, &test_set, NULL, NULL, &timeout);
        if(r == 0) {
            /* timeout */
            pa_mainloop_iterate(ml, 0, NULL);
        }
        if(FD_ISSET(0, &test_set)) {
            /* stdin ready */

            int key = getch();
            switch(key) {
                case KEY_UP:
                    view_select_prev();
                    view_show();
                    break;
                case KEY_DOWN:
                    view_select_next();
                    view_show();
                    break;
                case KEY_LEFT:
                    change_sel_vol(context, VOL_DOWN);
                    break;
                case KEY_RIGHT:
                    change_sel_vol(context, VOL_UP);
                    break;
                case 'n':
                    change_sel_vol(context, VOL_NORM);
                    break;
                case 'm':
                    change_sel_vol(context, VOL_MUTE);
                    break;
                case 'q':
                    running = 0;
                    break;
                case KEY_RESIZE:
                    view_show();
                    refresh();
                    break;
            }
        }

    }

    pa_context_disconnect(context);
    pa_context_unref(context);
    pa_mainloop_free(ml);

    endwin();

    return retval;
}
Exemplo n.º 23
0
int 
adios_read_icee_schedule_read_byid(const ADIOS_FILE *adiosfile,
                                   const ADIOS_SELECTION *sel,
                                   int varid,
                                   int from_steps,
                                   int nsteps,
                                   void *data)
{   
    int i;
    icee_fileinfo_rec_ptr_t fp = (icee_fileinfo_rec_ptr_t) adiosfile->fh;
    log_debug("%s (%d:%s)\n", __FUNCTION__, varid, fp->fname);
    //assert((varid < fp->nvars) || (fp->nvars == 0));

    if (nsteps != 1)
    {
        adios_error (err_invalid_timestep,
                     "Only one step can be read from a stream at a time. "
                     "You requested % steps in adios_schedule_read()\n", 
                     nsteps);
        return err_invalid_timestep;
    }
    
    icee_varinfo_rec_ptr_t vp = NULL;
    vp = icee_varinfo_search_byname(fp->varinfo, adiosfile->var_namelist[varid]);
    if (adios_verbose_level > 5) icee_varinfo_print(vp);

    if (!vp)
    {
        adios_error(err_invalid_varid, "Invalid variable id: %d\n", varid);
        return adios_errno;
    }

    while (fp->merge_count != fp->nchunks)
    {
        log_debug("Waiting the rest of blocks (%d/%d)\n", fp->merge_count, fp->nchunks);
        
        usleep(0.1*1E6);
    }

    if (sel==0)
        memcpy(data, vp->data, vp->varlen);
    else
        switch(sel->type)
        {
        case ADIOS_SELECTION_WRITEBLOCK:
        {
            //DUMP("fp->rank: %d", fp->rank);
            //DUMP("u.block.index: %d", sel->u.block.index);

            if (fp->comm_rank != sel->u.block.index)
                adios_error(err_unspecified,
                            "Block id missmatch. "
                            "Not yet supported by ICEE\n");

            // Possible memory overwrite
            memcpy(data, vp->data, vp->varlen);
            break;
        }
        case ADIOS_SELECTION_BOUNDINGBOX:
        {
            if (vp->ndims != sel->u.bb.ndim)
                adios_error(err_invalid_dimension,
                            "Dimension mismatch\n");

            log_debug("Merging operation (total nvars: %d).\n", fp->nchunks);
            if (adios_verbose_level > 5) icee_sel_bb_print(sel);

            while (vp != NULL)
            {
                icee_matrix_t m_sel;
                icee_matrix_t m_var;
                icee_matrix_view_t v_sel;
                icee_matrix_view_t v_var;
                uint64_t start[10];
                int64_t count[10]; // should be signed to check validity
                uint64_t s_offsets[10], v_offsets[10];
                int i;

                if (adios_verbose_level > 5) icee_varinfo_print(vp);
                    
                mat_init(&m_sel, vp->typesize, vp->ndims, sel->u.bb.count, data);
                mat_init(&m_var, vp->typesize, vp->ndims, vp->ldims, vp->data);

                for (i=0; i<vp->ndims; i++)
                    start[i] = MYMAX(sel->u.bb.start[i], vp->offsets[i]);

                for (i=0; i<vp->ndims; i++)
                {
                    count[i] = 
                        MYMIN(sel->u.bb.start[i]+sel->u.bb.count[i],
                              vp->offsets[i]+vp->ldims[i]) - start[i];
                }
                    
                for (i=0; i<vp->ndims; i++)
                {
                    if (count[i] <= 0)
                    {
                        log_debug("No ROI. Skip\n");
                        goto next;
                    }
                }

                for (i=0; i<vp->ndims; i++)
                    s_offsets[i] = start[i] - sel->u.bb.start[i];

                for (i=0; i<vp->ndims; i++)
                    v_offsets[i] = start[i] - vp->offsets[i];

                view_init (&v_sel, &m_sel, count, s_offsets);
                view_init (&v_var, &m_var, count, v_offsets);
                view_copy (&v_sel, &v_var);
                    
            next:
                vp = icee_varinfo_search_byname(vp->next, adiosfile->var_namelist[varid]);
            }
            break;
        }
        case ADIOS_SELECTION_AUTO:
        {
            // Possible memory overwrite
            memcpy(data, vp->data, vp->varlen);
            break;
        }
        case ADIOS_SELECTION_POINTS:
        {
            adios_error(err_operation_not_supported,
                        "ADIOS_SELECTION_POINTS not yet supported by ICEE.\n");
            break;
        }
        }

    return adios_errno;
}
Exemplo n.º 24
0
Arquivo: main.c Projeto: LADI/ladish
int main(int argc, char** argv)
{
  #if ENABLE_NLS
    bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);
  #endif

  gtk_init(&argc, &argv);

  if (!dbus_init())
  {
    return 1;
  }

  if (!conf_proxy_init())
  {
    return 1;
  }

  if (!canvas_init())
  {
    log_error("Canvas initialization failed.");
    return 1;
  }

  if (!init_gtk_builder())
  {
    return 1;
  }

  g_main_win = get_gtk_builder_widget("main_win");

  init_dialogs();

  if (!create_studio_lists())
  {
    return 1;
  }

  init_statusbar();
  init_jack_widgets();

  create_room_dialog_init();

  world_tree_init();
  view_init();

  init_actions_and_accelerators();

  if (!menu_init())
  {
    return 1;
  }

  buffer_size_clear();

  if (!toolbar_init())
  {
    return 1;
  }

  if (!conf_register(LADISH_CONF_KEY_DAEMON_NOTIFY, NULL, NULL))
  {
    return 1;
  }

  if (!conf_register(LADISH_CONF_KEY_DAEMON_SHELL, NULL, NULL))
  {
    return 1;
  }

  if (!conf_register(LADISH_CONF_KEY_DAEMON_TERMINAL, NULL, NULL))
  {
    return 1;
  }

  if (!conf_register(LADISH_CONF_KEY_DAEMON_STUDIO_AUTOSTART, NULL, NULL))
  {
    return 1;
  }

  if (!conf_register(LADISH_CONF_KEY_DAEMON_JS_SAVE_DELAY, NULL, NULL))
  {
    return 1;
  }

  if (!conf_register(LADISH_CONF_KEY_JACK_CONF_TOOL, NULL, NULL))
  {
    return 1;
  }

  if (!init_jack())
  {
    return 1;
  }

  if (!a2j_proxy_init())
  {
    return 1;
  }

  if (!control_proxy_init())
  {
    return 1;
  }

  if (!studio_proxy_init())
  {
    return 1;
  }

  set_studio_callbacks();
  set_room_callbacks();

  g_signal_connect(G_OBJECT(g_main_win), "destroy", G_CALLBACK(gtk_main_quit), NULL);
  g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_quit")), "activate", G_CALLBACK(gtk_main_quit), NULL);
  g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_view_arrange")), "activate", G_CALLBACK(arrange), NULL);
  g_signal_connect(G_OBJECT(get_gtk_builder_widget("menu_item_help_about")), "activate", G_CALLBACK(show_about), NULL);

  gtk_widget_show(g_main_win);

  gtk_main();

  studio_proxy_uninit();
  control_proxy_uninit();
  a2j_proxy_uninit();
  uninit_jack();
  menu_uninit();
  create_room_dialog_uninit();
  destroy_studio_lists();
  uninit_gtk_builder();

  conf_proxy_uninit();
  dbus_uninit();

  return 0;
}