示例#1
0
/* ...initialize GL-processing context */
static int app_context_init(widget_data_t *widget, void *data)
{
    app_data_t     *app = data;
    window_data_t  *window = (window_data_t *)widget;
    int             W = widget_get_width(widget);
    int             H = widget_get_height(widget);
    
    /* ...initialize surround-view engine (dimensions are fixed?) */
    CHK_ERR(app->sv = sview_engine_init(app->sv_cfg, 1280, 800), -errno);

    
    
    /* ...create UI layer */
    CHK_ERR(app->gui = gui_create(window, app), -errno);

//    /* ...display context is shared with all windows; context is surfaceless */
//    eglMakeCurrent(display->egl.dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, display->egl.ctx);
//    BUG(eglGetCurrentContext() == EGL_NO_CONTEXT, _x("invalid egl context"));
//    
//    sview_engine_destroy(app->sv);
//    app->sv = sview_engine_init(app->sv_cfg, 1280, 800);
//    
//    sview_engine_destroy(app->sv);
//    app->sv = sview_engine_init(app->sv_cfg, 1280, 800);
//    
//    sview_bv_reinit(app->sv,app->sv_cfg, 1280, 800);
    
    TRACE(INIT, _b("run-time initialized: %u*%u"), W, H);

    return 0;
}
示例#2
0
文件: example.c 项目: blackball/gui
/* A simple usage here */
int
main(int argc, char *argv[]) {
        gui_create(300, 300);
        gui_settrans(gui_hwnd(), 70); /* set 70% non-transperant */
        //gui_show(img->imageData, img->width, img->height, img->widthStep, 3);
        gui_wait(0);
        gui_destroy();
        return 0;
}
示例#3
0
文件: fbxkb.c 项目: kba/fbxkb
static void
create_all()
{
    ENTER;
    get_group_info();
    gui_create();
    gui_update();
    gui_extra_rebuild();
    RET();
}
示例#4
0
void app_start_gui_for_session(session *s, app_context_t *app_context) {
  session_service *serv = app_context->session_serv;
  gui_context_t *gc = gui_create(s, serv);
  pair_session_with_gui(s, (void *) gc, (void *) app_context);
  jnx_thread *user_input_thread =
      jnx_thread_create(read_user_input_loop, (void *) gc);
  jnx_char *message;
  while (0 < session_message_read(s, (jnx_uint8 **) &message)) {
    gui_receive_message(gc, message);
  }
  if (QUIT_NONE == gc->quit_hint) {
    gc->quit_hint = QUIT_ON_NEXT_USER_INPUT;
  }
  // wait for user input thread to complete
  pthread_join(user_input_thread->system_thread, NULL);
}
示例#5
0
文件: gfx.c 项目: bentley/puNES
BYTE gfx_init(void) {
	const SDL_VideoInfo *video_info;

	/* casi particolari provenienti dal settings_file_parse() e cmd_line_parse() */
	if ((cfg->scale == X1) && (cfg->filter != NO_FILTER)) {
		cfg->scale = X2;
	}

	if (gui_create() == EXIT_ERROR) {
		fprintf(stderr, "gui initialization failed\n");
		return (EXIT_ERROR);
	}

#if defined (__WIN64__)
	sprintf(SDL_windowhack, "SDL_WINDOWID=%I64u", (uint64_t) gui_screen_id());
#else
	sprintf(SDL_windowhack, "SDL_WINDOWID=%i", (int) gui_screen_id());
#endif

	sdl_wid();

	/* inizializzazione SDL */
	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		fprintf(stderr, "SDL initialization failed: %s\n", SDL_GetError());
		return (EXIT_ERROR);
	}

	gui_after_set_video_mode();

	video_info = SDL_GetVideoInfo();

	/*
	 * modalita' video con profondita' di colore
	 * inferiori a 15 bits non sono supportate.
	 */
	if (video_info->vfmt->BitsPerPixel < 15) {
		fprintf(stderr, "Sorry but video mode at 256 color are not supported\n");
		return (EXIT_ERROR);
	}

	/* il filtro hqx supporta solo i 32 bit di profondita' di colore */
	if (((cfg->filter >= HQ2X) || (cfg->filter <= HQ4X)) && (video_info->vfmt->BitsPerPixel < 32)) {
		cfg->filter = NO_FILTER;
	}

	/* controllo se e' disponibile l'accelerazione hardware */
	if (video_info->hw_available) {
		software_flags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_ASYNCBLIT;
	} else {
		software_flags = SDL_SWSURFACE | SDL_ASYNCBLIT;
	}

	/* per poter inizializzare il glew devo creare un contesto opengl prima */
	if (!(surface_sdl = SDL_SetVideoMode(0, 0, 0, SDL_OPENGL))) {
		opengl.supported = FALSE;

		cfg->render = RENDER_SOFTWARE;
		gfx_set_render(cfg->render);

		if ((cfg->filter >= PHOSPHOR) && (cfg->filter <= CRT_NO_CURVE)) {
			cfg->filter = NO_FILTER;
		}

		fprintf(stderr, "INFO: OpenGL not supported.\n");
	} else {
		opengl.supported = TRUE;
	}

	/* casi particolari provenienti dal settings_file_parse() e cmd_line_parse()*/
	if (cfg->fullscreen == FULLSCR) {
		if (!gfx.opengl) {
			cfg->fullscreen = NO_FULLSCR;
		} else {
			gfx.scale_before_fscreen = cfg->scale;
		}
	}
	sdl_init_gl();

	/*
	 * inizializzo l'ntsc che utilizzero' non solo
	 * come filtro ma anche nel gfx_set_screen() per
	 * generare la paletta dei colori.
	 */
	if (ntsc_init(0, 0, 0, 0, 0) == EXIT_ERROR) {
		return (EXIT_ERROR);
	}

	/*
	 * mi alloco una zona di memoria dove conservare la
	 * paletta nel formato di visualizzazione.
	 */
	if (!(palette_win = (uint32_t *) malloc(NUM_COLORS * sizeof(uint32_t)))) {
		fprintf(stderr, "Unable to allocate the palette\n");
		return (EXIT_ERROR);
	}

	if (cfg->fullscreen) {
		gfx_set_screen(cfg->scale, cfg->filter, NO_FULLSCR, cfg->palette, FALSE, FALSE);
		cfg->fullscreen = NO_FULLSCR;
		cfg->scale = gfx.scale_before_fscreen;
		gui_fullscreen();
	} else {
		gfx_set_screen(cfg->scale, cfg->filter, NO_FULLSCR, cfg->palette, FALSE, FALSE);
		/*
		 * nella versione windows (non so in quella linux), sembra che
		 * il VSync (con alcune schede video) non venga settato correttamente
		 * al primo gfx_set_screen. E' necessario fare un gfx_reset_video
		 * e poi nuovamente un gfx_set_screen. Nella versione linux il gui_reset_video()
		 * non fa assolutamente nulla.
		 */
		gui_reset_video();
	}

	if (!surface_sdl) {
		fprintf(stderr, "SDL initialization failed: %s\n", SDL_GetError());
		return (EXIT_ERROR);
	}

	return (EXIT_OK);
}
示例#6
0
// Main function that handles events
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    LRESULT result;
    RECT rect;

    switch (message)
    {
    // On create event
  case WM_CREATE:
        // Create a 1-object layout
        gui_new_tab_layout(&gui_main_layout, 1);
        // Create one graph object
        GUI_TAB_ADD_ENTRY(gui_main_layout,
             (XSCREEN - GRAPH_WIDTH)/2,
             (XSCREEN - GRAPH_WIDTH)/2,
             GRAPH_WIDTH, GRAPH_HEIGHT,
             0, GUI_TYPE_PAINT, "", 0, GraphProcedure);
        // Create the layout
        gui_create(&gui_main_layout, hwnd);
        break;

    // On timer event
    case WM_TIMER:
        // Read new data
        get_data(_filename);
        // Update the view
        GetClientRect(hwnd, &rect);
        InvalidateRect(hwnd, &rect, FALSE);
        break;

    // On resize event
    case WM_SIZE:
        // Calculate the scale values of the display
        scale_x = ((float) LOWORD(lParam))/((float) XSCREEN);
        scale_y = ((float) HIWORD(lParam))/((float) YSCREEN);
        // Rescale the display
        gui_rescale(&gui_main_layout, scale_x, scale_y, FALSE);
        // Update the view
        GetClientRect(hwnd, &rect);
        InvalidateRect(hwnd, &rect, TRUE);
        break;
    }

    // Switch events to the sub event handler functions
    result = gui_proc(&gui_main_layout, hwnd, message, wParam, lParam);

    switch(message)
    {
    // On destroy event
  case WM_DESTROY:
        // Delete data
        ASSERT(_data);
        free(_data);
        // Quit the application
      PostQuitMessage(0);
      result = 1;
      break;
    }

    if (!result)
       result = DefWindowProc(hwnd, message, wParam, lParam);

    return result;
}
int main(int argc, char ** argv)
{	
	eecs467_init(argc, argv);

	state_t * state = (state_t*) calloc(1, sizeof(state_t));
	global_state = state;
	state->gopt = getopt_create();
	state->app.display_finished = display_finished;
	state->app.display_started = display_started;
	state->app.impl = state;
	state->update_arm_cont = 0;
	state->update_arm = 0;
	state->arm = new RexArm();
	state->body = new Body();
	state->ds = new DataSmoother(0.4, 0.3, 0, 0);
	state->running = 1;
	state->set_cbs = 0;

	state->controlBoxColor[GRIPPER] = vx_green;
	state->controlBoxColor[WRIST] = vx_yellow;
	state->controlBoxColor[ARM] = vx_orange;
	state->controlBoxColor[ROTATE] = vx_red;

	for (int i = 0; i < NUM_CONTROL_BOXES; i++) {
		state->controlBoxes[i] = new BoundingBox();
		state->controlBoxes[i]->setDimensions(CB_WIDTH, CB_HEIGHT, CB_DEPTH);
	}

	lcm_t * lcm = lcm_create (NULL);
	state->lcm = lcm;
	
	BoundingBox floorBoard, base;

	floorBoard.setPosition(0, 0, 0);
	floorBoard.setDimensions(100, 100, 10);
	state->cfs.addBoundingBox(&floorBoard);
	base.setPosition(0, 0, 4);
	base.setDimensions(7, 7, 8);
	state->cfs.addBoundingBox(&base);

	//signal(SIGINT, terminal_signal_handler);

	pthread_mutex_init(&state->layer_mutex, NULL);
	pthread_mutex_init(&state->lcm_mutex, NULL);
	pthread_mutex_init(&state->running_mutex, NULL);
	pthread_mutex_init(&state->fsm_mutex, NULL);

	state->layer_map = zhash_create(sizeof(vx_display_t*), sizeof(vx_layer_t*), zhash_uint64_hash, zhash_uint64_equals);

	getopt_add_bool(state->gopt, 'h', "help", 0, "Show this help");
	//getopt_add_bool(state->gopt, 'v', "verbose", 0, "Show extra debugging output");
	//getopt_add_int (state->gopt, 'l', "limitKBs", "-1", "Remote display bandwidth limit. < 0: unlimited.");
	//getopt_add_double (state->gopt, 'd', "decimate", "0", "Decimate image by this amount before showing in vx");

	if (!getopt_parse(state->gopt, argc, argv, 0) ||
		getopt_get_bool(state->gopt,"help")) {
		getopt_do_usage(state->gopt);
		exit(-1);
	}

	pthread_create(&state->lcm_handle_thread, NULL, lcm_handle_loop, state);
	//pthread_create(&state->gui_thread,  NULL, gui_create, state);
	pthread_create(&state->arm_commander_thread, NULL, arm_commander, state);
	pthread_create(&state->fsm_thread, NULL, FSM, state);
	//pthread_join(state->gui_thread, NULL);
	gui_create(state);
	printf("after gui_create\n");

	// clean up
	delete state->arm;
	delete state->body;
	delete state->ds;
	for (int i = 0; i < NUM_CONTROL_BOXES; i++) {
		delete state->controlBoxes[i];
	}
	vx_global_destroy();
    getopt_destroy(state->gopt);

    printf("Exited Cleanly!\n");
    return 0;
}
示例#8
0
int main(int argc, char **argv)
{
    cardmanager_t* CTX;
    cardreader_t* READER;
    int opt;
    int opt_index = 0;
    int run_gui = 1;
    char* reader_name = NULL;
    char* exec_command = NULL;

#ifndef _WIN32
    SSL_load_error_strings();
#endif

    signal(SIGSEGV, save_what_can_be_saved);

    path_config_init();

    log_open_file();

    while ((opt = getopt_long(argc,argv,"r:e:vh",long_options,&opt_index))!=-1)
    {
        switch (opt)
        {
        case 'r':
            reader_name = g_strdup(optarg);
            break;
        case 'e':
            exec_command = optarg;
            break;
        case 'v':
            display_readers_and_version();
            run_gui = 0;
            break;
        default:
            display_help(argv[0]);
            run_gui = 0;
        }
    }

    if (run_gui)
    {
        /* if we want threads:
           gdk_threads_init();
           gdk_threads_enter();
         */

        gui_init(&argc,&argv);

        gui_create();

        log_printf(LOG_INFO,"Running %s",system_string_info());

        install_dot_file();

        luax_init();


        CTX = cardmanager_new();

        if (reader_name == NULL)
        {
            reader_name = gui_select_reader(cardmanager_count_readers(CTX),
                                            cardmanager_reader_name_list(CTX));
        }

        READER = cardreader_new(reader_name);

        cardmanager_free(CTX);

        if (READER)
        {
            luax_set_card_reader(READER);

            cardreader_set_callback(READER,gui_readerview_print,NULL);

            if (exec_command)
                g_idle_add(run_command_from_cli,exec_command);
            else
                update_cardpeek();
            /*else
              g_idle_add(run_update_checks,NULL);
             */
            gui_run();

            cardreader_free(READER);
        }
        else
        {
            fprintf(stderr,"Failed to open smart card reader '%s'.\n",reader_name);
            log_printf(LOG_ERROR,"Failed to open smart card reader '%s'.", reader_name);
        }

        luax_config_table_save();

        luax_release();

        /* if we want threads:
           gdk_threads_leave();
         */
    }

    if (reader_name) g_free(reader_name);

    log_close_file();

    path_config_release();

    ERR_free_strings();

    return 0;
}