void SPECTRUM_INDICATOR__TYPE_CIRCLE::setup(int _N)
{
	/********************
	********************/
	setup_gui();
	init_vbo();
	
	/********************
	********************/
	const int TargetNum = 50;
	N = _N;
	
	if(TargetNum < N){
		NUM_DISP_SPECTRUMS = TargetNum;
	}else{
		NUM_DISP_SPECTRUMS = N;
	}
	IndicatorAngleStep = float(360) / NUM_DISP_SPECTRUMS;
	
	for(int GroupNum = SIZE_S; GroupNum < NUM_INDICATORS; GroupNum++){
		BaseAngle[GroupNum] = 0;
	}
	
	/********************
	********************/
	update_DynamicParam();
}
Ejemplo n.º 2
0
int
main (int argc, char *argv[])
{

  GstElement *pipeline = NULL;

#ifndef GST_DISABLE_PARSE
  GError *error = NULL;
#endif
  GstElement *volume;
  GstBus *bus;

#ifdef GST_DISABLE_PARSE
  g_print ("GStreamer was built without pipeline parsing capabilities.\n");
  g_print
      ("Please rebuild GStreamer with pipeline parsing capabilities activated to use this example.\n");
  return 1;
#else
  gst_init (&argc, &argv);
  gtk_init (&argc, &argv);

  pipeline = gst_parse_launchv ((const gchar **) &argv[1], &error);
  if (error) {
    g_print ("pipeline could not be constructed: %s\n", error->message);
    g_print ("Please give a complete pipeline  with a 'volume' element.\n");
    g_print ("Example: audiotestsrc ! volume ! %s\n", DEFAULT_AUDIOSINK);
    g_error_free (error);
    return 1;
  }
#endif
  volume = gst_bin_get_by_name (GST_BIN (pipeline), "volume0");
  if (volume == NULL) {
    g_print ("Please give a pipeline with a 'volume' element in it\n");
    return 1;
  }

  /* setup message handling */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
  g_signal_connect (bus, "message::error", (GCallback) message_received,
      pipeline);
  g_signal_connect (bus, "message::warning", (GCallback) message_received,
      pipeline);
  g_signal_connect (bus, "message::eos", (GCallback) eos_message_received,
      pipeline);

  /* setup GUI */
  setup_gui (volume);

  /* go to main loop */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  gtk_main ();
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);

  return 0;
}
Ejemplo n.º 3
0
//--------------------------------------------------------------
void ofApp::setup(){
	/********************
	********************/
	ofBackground(0);
	ofSetFrameRate(30);
	ofEnableAlphaBlending();
	ofEnableSmoothing();
	// ofSetSphereResolution(100);

	ofSetGlobalAmbientColor(ofColor(0, 0, 0));
	ofSetSmoothLighting(true);
	
	/********************
	********************/
	glEnable(GL_DEPTH_TEST);
	
	/********************
	http://www.komoto.org/opengl/sample10.html
	
	ポリゴンの表裏は、処理軽くするために使われます。
	つまり、ポリゴンのおもて面のみを描き、裏を描かないようにすることで、描くポリゴンを減らし、処理を軽くします。
	使う関数は、次の2つです。
		glEnable(GL_CULL_FACE)			...片面表示を有効にします。
		void glCullFace(GLenum mode)	...どの面を描画しないようにするかを指定します。
		
	modeは、
		GL_FRONT
		GL_BACK
		GL_FRONT_AND_BACK
	のいずれかです。
	GL_FRONTを指定すると、表面を描画しない、つまり、裏面のみを描画します。
	GL_BACKなら、表面のみが描かれ、GL_FRONT_AND_BACKなら、ポリゴンは描かれなくなります。

  まとめると、次のようになります。
		両面を描く
			glDisable(GL_CULL_FACE);
			
		表面のみを描く
			glEnable(GL_CULL_FACE); 
			glCullFace(GL_BACK);
			
		裏面のみを描く
			glEnable(GL_CULL_FACE); 
			glCullFace(GL_FRONT);
	********************/
	glDisable(GL_CULL_FACE);
	
	/********************
	********************/
	setup_gui();
	init();
	
	/********************
	********************/
	b_test = false;
}
void SPECTRUM_INDICATOR__TYPE_POINT::setup(int _N)
{
	/********************
	********************/
	setup_gui();
	init_vbo();
	
	/********************
	********************/
	N = _N;
	
	/********************
	********************/
	update_DynamicParam();
}
Ejemplo n.º 5
0
Archivo: ttx.c Proyecto: djcb/ttx
int
main (int argc, char *argv[])
{
	Opts opts;
	GError *err;
	TTXProviderMgr *prov_mgr;
	int rv;

	if (!setup_l10n ())
		return 1;

	rv	 = 1;
	err	 = NULL;

	prov_mgr = ttx_provider_mgr_new ();

	memset (&opts, 0, sizeof(Opts));

	if (!process_options (&opts, &argc, &argv, &err))
		goto leave;

	if (opts.version)
		return version ();

	if(!get_address_maybe (prov_mgr, &opts, &err))
		goto leave;

	gtk_init (&argc, &argv);

	if (!setup_gui (prov_mgr, &opts))
		goto leave;

	gtk_main ();
	rv = 0;

leave:
	free_opts (&opts);

	ttx_provider_mgr_destroy (prov_mgr);
	if (err) {
		g_printerr ("%s\n", err ? err->message :
			    _("an error occurred"));
		g_clear_error (&err);
	}

	return rv;
}
Ejemplo n.º 6
0
ETableConfig *
e_table_config_construct (ETableConfig        *config,
			  const char          *header,
			  ETableSpecification *spec,
			  ETableState         *state,
			  GtkWindow           *parent_window)
{
	ETableColumnSpecification **column;

	g_return_val_if_fail (config != NULL, NULL);
	g_return_val_if_fail (header != NULL, NULL);
	g_return_val_if_fail (spec != NULL, NULL);
	g_return_val_if_fail (state != NULL, NULL);

	config->source_spec = spec;
	config->source_state = state;
	config->header = g_strdup (header);

	g_object_ref (config->source_spec);
	g_object_ref (config->source_state);

	config->state = e_table_state_duplicate (state);

	config->domain = g_strdup (spec->domain);

	for (column = config->source_spec->columns; *column; column++){
		char *label = (*column)->title;

		if ((*column)->disabled)
			continue;

		config->column_names = g_slist_append (
			config->column_names, label);
	}

	setup_gui (config);

	gtk_window_set_transient_for (GTK_WINDOW (config->dialog_toplevel),
				      parent_window);

	config_sort_info_update   (config);
	config_group_info_update  (config);
	config_fields_info_update (config);

	return E_TABLE_CONFIG (config);
}
void SPECTRUM_INDICATOR__TYPE_STRAIGHT::setup(int _N)
{
	/********************
	********************/
	setup_gui();
	init_vbo();
	
	/********************
	********************/
	N = _N;
	
	// NUM_DISP_SPECTRUMS = int(N * 0.3);
	NUM_DISP_SPECTRUMS = int(N * 0.15);
	set_x_ofs();
	
	/********************
	********************/
	update_DynamicParam();
}
Ejemplo n.º 8
0
int
main (int argc, char *argv[])
{

  GstElement *pipeline = NULL;
  GError *error = NULL;
  GstElement *level;

  gst_init (&argc, &argv);
  gtk_init (&argc, &argv);

  pipeline = gst_parse_launchv ((const gchar **) &argv[1], &error);
  if (error) {
    g_print ("pipeline could not be constructed: %s\n", error->message);
    g_print ("Please give a complete pipeline  with a 'level' element.\n");
    g_print ("Example: sinesrc ! level ! %s\n", DEFAULT_AUDIOSINK);
    g_error_free (error);
    return 1;
  }

  level = gst_bin_get_by_name (GST_BIN (pipeline), "level0");
  if (level == NULL) {
    g_print ("Please give a pipeline with a 'level' element in it\n");
    return 1;
  }

  g_object_set (level, "signal", TRUE, NULL);
  g_signal_connect (level, "level", G_CALLBACK (level_callback), NULL);


  /* setup GUI */
  setup_gui ();

  /* connect level signal */

  /* go to main loop */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_idle_add (idler, pipeline);

  gtk_main ();

  return 0;
}
Ejemplo n.º 9
0
static app_t *
app_create (const app_params_t *params)
{
    app_t *self = (app_t*) calloc (1, sizeof (app_t));

    self->foo = params->foo;

    if (0 != load_ppm (self, params->filename)) goto fail;

    setup_gui (self);

    bot_gtk_gl_image_area_set_image_format (self->gl_area,
            self->img_width, self->img_height, GL_RGB);
    bot_gtk_gl_image_area_upload_image (self->gl_area, self->img, 
            self->img_stride);

    return self;
fail:
    app_destroy (self);
    return NULL;
}
Ejemplo n.º 10
0
QT_BEGIN_NAMESPACE
        
e2prom_util_gui::e2prom_util_gui(int width, int height, QWidget *parent)
: QDialog(parent)
{
        resize(width, height);
        setWindowTitle("E2prom Util");
        setup_gui();
        QApplication::restoreOverrideCursor();

        connect(selt_box->select_template_cmbox, SIGNAL(currentIndexChanged(int)), this, SLOT(switch_param_panel()));
        connect(console_pbtn, SIGNAL(clicked()), this, SLOT(show_console_output()));
        connect(generate_pbtn, SIGNAL(clicked()), this, SLOT(collect_params()));
        connect(this, SIGNAL(has_params(QStringList)), this, SLOT(do_generate_eeprom(QStringList)));
        connect(this, SIGNAL(param_panel_size_changed()), this, SLOT(adjust_console_tedit()));
        connect(console_pbtn, SIGNAL(clicked()), this, SLOT(adjust_console_tedit()));
        connect(&gen_eeprom, SIGNAL(readyReadStandardError()), this, SLOT(update_result_err()));
        connect(&gen_eeprom, SIGNAL(readyReadStandardOutput()), this, SLOT(update_result_out()));
        connect(&gen_eeprom, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(gen_exit(int, QProcess::ExitStatus)));
        connect(&gen_eeprom, SIGNAL(error(QProcess::ProcessError)), this, SLOT(gen_error(QProcess::ProcessError)));
}
Ejemplo n.º 11
0
int main() {
    int button_code;
    int pause_state = 0;
    int reset_state = 0;

    setup_gui();

    // Seed random num generator
    srand (time(NULL));

    box_fam = create_gen(gen_size);
    randomise_gen(box_fam);    

    ifit = -1;

    for (int i=0; i<ngen; i++) {
        // Score generation
        score_gen(box_fam);

        printf("gen %i\r", i);
        fflush(stdout);
        // Draw fittest of the fit
        jfit = fittest_cov(box_fam);
        if (ifit != jfit) {
            ifit = jfit;
            clear_window();
            draw_boarder();
            draw_cover(& box_fam[ifit]);
            draw_pause_button(pause_state);
            draw_reset_button(reset_state);
            flush_window();
            printf("gen %i, %f\n", i, nboxes*pow(box_fam[ifit].l,2));
            add_score(i, nboxes*pow(box_fam[ifit].l,2));
        } 
        if (window_redraw_required()) {
            clear_window();
            draw_boarder();
            draw_cover(& box_fam[ifit]);
            draw_pause_button(pause_state);
            draw_reset_button(reset_state);
            draw_scores();
            flush_window();
        }

        button_code = handle_button_presses();
        while (button_code != 0 || pause_state || reset_state) {
            if (pause_state || reset_state)
                button_code = blocking_handle_button_presses();

            switch (button_code) {
                case -1:
                    // Redraw Required
                    clear_window();
                    draw_boarder();
                    draw_cover(& box_fam[ifit]);
                    draw_pause_button(pause_state);
                    draw_reset_button(reset_state);
                    draw_scores();
                    flush_window();
                    break;
                case 1:
                    // Play/Pause Button
                    if (pause_state) {
                        printf("\rPlay!         \n");
                        pause_state = 0;
                    } else {
                        printf("\rPause!        \n");
                        pause_state = 1;
                    }

                    draw_pause_button(pause_state);
                    flush_window();
                    break;
                case 2:
                    // Reset/Start Button  
                    if (reset_state) {
                        printf("\rStart!             \n");
                        reset_state = 0;
                    } else {
                        printf("\rReset!             \n");
                        print_best();
                        i = 0;
                        randomise_gen(box_fam);
                        score_gen(box_fam);            
                        reset_state = 1;
                        reset_scores();
                        flush_window();
                    }
                    clear_window();
                    draw_boarder();
                    draw_cover(& box_fam[ifit]);

                    draw_pause_button(pause_state);
                    draw_reset_button(reset_state);
                    flush_window();
                    break;
                default:
                    printf("\rButton Error %i\n         ", button_code);
                    exit(button_code);
            }
            button_code = handle_button_presses();
        }

        // Evolve Generation
        new_gen(box_fam); 
    }
    // Clear last gen n line
    printf("                  \r");
    fflush(stdout);

    close_gui();
    print_best();

    printf("Press enter to close\n");
    while( getchar() != '\n' );
    return 0;
}
Ejemplo n.º 12
0
static void race_select_init(void)
{
    point2d_t dummy_pos = {0, 0};
	coord_t button_coord;
	list_elem_t tmp;
    int i;
    
    scoreboard_open=True;
    
    winsys_set_display_func( main_loop );
    winsys_set_idle_func( main_loop );
    winsys_set_reshape_func( reshape );
    winsys_set_mouse_func( GameMenu_mouse_func );
    winsys_set_motion_func( GameMenu_motion_func );
    winsys_set_passive_motion_func( GameMenu_motion_func );
	winsys_set_joystick_func( NULL );
	winsys_set_joystick_button_func( NULL );
    
	winsys_reset_js_bindings();
	winsys_add_js_axis_bindings();
	winsys_add_js_button_binding(SDL_CONTROLLER_BUTTON_A, SDLK_RETURN);
	winsys_add_js_button_binding(SDL_CONTROLLER_BUTTON_B, SDLK_ESCAPE);
    
	winsys_add_js_button_binding(SDL_CONTROLLER_BUTTON_DPAD_LEFT, SDLK_LEFT);
	winsys_add_js_button_binding(SDL_CONTROLLER_BUTTON_DPAD_RIGHT, SDLK_RIGHT);

	GameMenu_init();
	setup_gui();

    plyr = get_player_data( local_player() );
    
    /* Setup the race list */
    if ( g_game.practicing ) {
        g_game.current_event = "__Practice_Event__";
        g_game.current_cup = "__Practice_Cup__";
#ifdef SPEED_MODE
        if(g_game.is_speed_only_mode)
            race_list = get_speed_courses_list();
        else
            race_list = get_score_courses_list();
#else
        race_list = get_score_courses_list();
#endif
        cup_data = NULL;
        last_completed_race = NULL;
        event_data = NULL;
    }
    
    /* Unless we're coming back from a race, initialize the race data to 
     defaults.
     */
    if ( g_game.prev_mode != GAME_OVER ) {
        /* Make sure we don't play previously loaded course */
        cup_complete = False;
        
        /* Initialize the race data */
		if (cur_elem==NULL)
		{
			cur_elem = get_list_head( race_list );
		}
		else
		{
			bool_t needs_changing=False;
			tmp=get_list_head(race_list);
			while (tmp!=cur_elem && tmp!=NULL)
			{
				tmp=get_next_list_elem(race_list, tmp);
			}
			if (!tmp)
			{
				cur_elem = get_list_head( race_list );
			}
		}
        
        if ( g_game.practicing ) {
            g_game.race.course = NULL;
            g_game.race.name = NULL;
            g_game.race.description = NULL;
            
            for (i=0; i<DIFFICULTY_NUM_LEVELS; i++) {
                g_game.race.herring_req[i] = 0;
                g_game.race.time_req[i] = 0;
                g_game.race.score_req[i] = 0;
            }
            
            g_game.race.mirrored = False;
            g_game.race.conditions = RACE_CONDITIONS_SUNNY;
            g_game.race.windy = False;
            g_game.race.snowing = False;
        } else {
            /* Not practicing */
            
            race_data_t *data;
            data = (race_data_t*) get_list_elem_data( cur_elem );
            g_game.race = *data;
            
            if ( is_cup_complete( event_data, 
                                 get_event_cup_by_name( 
                                                       event_data, 
                                                       g_game.current_cup ) ) )
            {
                cup_complete = True;
                last_completed_race = get_list_tail( race_list );
            } else {
                cup_complete = False;
                last_completed_race = NULL;
            }
        }
    } else {
        /* Back from a race */
        if ( !g_game.race_aborted ) {
            update_race_results();
        }
	}
    
    /* 
     * Create text area 
     */
    desc_ta = textarea_create( make_point2d(
		0.1*getparam_x_resolution(), 0.2*getparam_y_resolution()),
		0.4*getparam_x_resolution(), 0.23*getparam_y_resolution(), "race_description", "" );
    
    textarea_set_visible( desc_ta, True );
    
    update_race_data();
    
	button_coord.x_coord_type=button_coord.y_coord_type=NORMALIZED_COORD;
	button_coord.x=0.50;
	button_coord.y=0.85;
	button_coord.x_just=CENTER_JUST;
	button_coord.y_just=CENTER_JUST;
    
	gui_add_widget(course_title_label=create_label(""), &button_coord);
    
	button_coord.x=0.1;
	button_coord.x_just=LEFT_JUST;
	gui_add_widget(prev_course_btn=create_button(LEFT_ARROW, prev_cb), &button_coord);
    
	button_coord.x=0.9;
	button_coord.x_just=RIGHT_JUST;
	gui_add_widget(next_course_btn=create_button(RIGHT_ARROW, next_cb), &button_coord);
    
	course_title_label->font_binding="race_selection_title";
	prev_course_btn->font_binding="race_selection_title";
	next_course_btn->font_binding="race_selection_title";
    
	button_coord.x=0.30;
	button_coord.y=0.09;
	button_coord.x_just=CENTER_JUST;
	gui_add_widget(back_button=create_button(get_back_text(), back_cb), &button_coord);
    
	button_coord.x=0.70;
	gui_add_widget(play_button=create_button(get_race_text(), play_cb), &button_coord);
    
	init_scoreboard_labels();
	init_scoreboard();

    play_music( "start_screen" );
}
Ejemplo n.º 13
0
/*!
  \brief main() is the typical main function in a C program, it performs
  all core initialization, loading of all main parameters, initializing handlers
  and entering gtk_main to process events until program close
  \param argc is the count of command line arguments
  \param argv is the array of command line args
  \returns TRUE
  */
gint main(gint argc, gchar ** argv)
{
	Serial_Params *serial_params = NULL;
	GAsyncQueue *queue = NULL;
	GCond *cond = NULL;
	GMutex *mutex = NULL;
	gint id = 0;
	setlocale(LC_ALL,"");
#ifdef __WIN32__
	bindtextdomain(PACKAGE, "C:\\Program Files\\MegaTunix\\dist\\locale");
#else
	bindtextdomain(PACKAGE, LOCALEDIR);
#endif
	textdomain (PACKAGE);

#ifdef DEBUG
	printf("This is a debug release, Git hash: %s\n",MTX_GIT_HASH);
#endif
	if(!g_thread_supported())
		g_thread_init(NULL);
	gdk_threads_init();
	gtk_init(&argc, &argv);
	glade_init();

	gdk_gl_init_check(&argc, &argv);
	gl_ability = gtk_gl_init_check(&argc, &argv);

	global_data = g_new0(gconstpointer, 1);

	/* Condition variables */
	cond = g_cond_new();
	DATA_SET(global_data,"statuscounts_cond",cond);
	cond = g_cond_new();
	DATA_SET(global_data,"io_dispatch_cond",cond);
	cond = g_cond_new();
	DATA_SET(global_data,"gui_dispatch_cond",cond);
	cond = g_cond_new();
	DATA_SET(global_data,"pf_dispatch_cond",cond);
	cond = g_cond_new();
	DATA_SET(global_data,"rtv_thread_cond",cond);

	/* Mutexes */
	mutex = g_mutex_new();
	DATA_SET(global_data,"serio_mutex",mutex);
	mutex = g_mutex_new();
	DATA_SET(global_data,"rtt_mutex",mutex);
	mutex = g_mutex_new();
	DATA_SET(global_data,"rtv_mutex",mutex);
	mutex = g_mutex_new();
	DATA_SET(global_data,"dash_mutex",mutex);
	mutex = g_mutex_new();
	DATA_SET(global_data,"statuscounts_mutex",mutex);
	mutex = g_mutex_new();
	DATA_SET(global_data,"io_dispatch_mutex",mutex);
	mutex = g_mutex_new();
	DATA_SET(global_data,"gui_dispatch_mutex",mutex);
	mutex = g_mutex_new();
	DATA_SET(global_data,"pf_dispatch_mutex",mutex);
	mutex = g_mutex_new();
	DATA_SET(global_data,"rtv_thread_mutex",mutex);

	/* For testing if gettext works
	   printf(_("Hello World!\n"));
	 */

	/* Build table of strings to enum values */
	build_string_2_enum_table();
	serial_params = (Serial_Params *)g_malloc0(sizeof(Serial_Params));
	DATA_SET(global_data,"serial_params",serial_params);

	handle_args(argc,argv);	/* handle CLI arguments */

	/* This will exit mtx if the locking fails! */
	create_mtx_lock();
	open_debug();		/* Open debug log */
	/* Allocate memory  */
	init();			/* Initialize global vars */
	make_mtx_dirs();	/* Create config file dirs if missing */

	/* Create Message passing queues */
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"io_data_queue",queue,g_async_queue_unref);
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"slave_msg_queue",queue,g_async_queue_unref);
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"pf_dispatch_queue",queue,g_async_queue_unref);
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"gui_dispatch_queue",queue,g_async_queue_unref);
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"io_repair_queue",queue,g_async_queue_unref);

	read_config();
	setup_gui();		

	gtk_rc_parse_string("style \"override\"\n{\n\tGtkTreeView::horizontal-separator = 0\n\tGtkTreeView::vertical-separator = 0\n}\nwidget_class \"*\" style \"override\"");

	id = g_timeout_add_full(-50,16,(GSourceFunc)pf_dispatcher,NULL,NULL);
	DATA_SET(global_data,"pf_dispatcher_id",GINT_TO_POINTER(id));
	id = g_timeout_add_full(-35,35,(GSourceFunc)gui_dispatcher,NULL,NULL);
	DATA_SET(global_data,"gui_dispatcher_id",GINT_TO_POINTER(id));
	id = g_timeout_add(1000,(GSourceFunc)flush_binary_logs,NULL);
        DATA_SET(global_data,"binlog_flush_id",GINT_TO_POINTER(id));

	sleep_calib();
	/* Check for first_time flag, if so, run first tiem wizard, otherwise
	   load personality choice
	   */
	gdk_threads_add_timeout(500,(GSourceFunc)check_for_first_time,NULL);
	

	DATA_SET(global_data,"ready",GINT_TO_POINTER(TRUE));
	gdk_threads_enter();
	gtk_main();
	gdk_threads_leave();
	return (0) ;
}
Ejemplo n.º 14
0
/*!
  \brief main() is the typical main function in a C program, it performs
  all core initialization, loading of all main parameters, initializing handlers
  and entering gtk_main to process events until program close
  \param argc is the count of command line arguments
  \param argv is the array of command line args
  \returns TRUE
  */
gint main(gint argc, gchar ** argv)
{
	Serial_Params *serial_params = NULL;
	GAsyncQueue *queue = NULL;
	GTimer *timer = NULL;
	GCond *rtv_thread_cond = NULL;
	GMutex *dash_mutex = NULL;
	GMutex *rtt_mutex = NULL;
	GMutex *rtv_mutex = NULL;
	GMutex *rtv_thread_mutex = NULL;
	GMutex *serio_mutex = NULL;
	gint id = 0;
	setlocale(LC_ALL,"");
#ifdef __WIN32__
	bindtextdomain(PACKAGE, "C:\\Program Files\\MegaTunix\\dist\\locale");
#else
	bindtextdomain(PACKAGE, LOCALEDIR);
#endif
	textdomain (PACKAGE);

#ifdef DEBUG
	printf("This is a debug release, Git hash: %s\n",GIT_HASH);
#endif
	// Not needed?
//	gdk_threads_init();
	gtk_init(&argc, &argv);
	glade_init();

	/* Check if OpenGL is supported. */
	if (gdk_gl_query() == FALSE) {
		g_print("OpenGL not supported\n");
		return 0;
	}
	else
		gl_ability = TRUE;

//	gdk_gl_init_check(&argc, &argv);
//	gl_ability = gtk_gl_init_check(&argc, &argv);

	global_data = g_new0(gconstpointer, 1);

	/* Condition Variables */
	rtv_thread_cond = g_new0(GCond,1);
	g_cond_init(rtv_thread_cond);
	DATA_SET(global_data,"rtv_thread_cond",rtv_thread_cond);
	/* Mutexes */
	dash_mutex = g_new0(GMutex, 1);
	g_mutex_init(dash_mutex);
	DATA_SET(global_data,"dash_mutex",dash_mutex);
	rtt_mutex = g_new0(GMutex, 1);
	g_mutex_init(rtt_mutex);
	DATA_SET(global_data,"rtt_mutex",rtt_mutex);
	rtv_mutex = g_new0(GMutex, 1);
	g_mutex_init(rtv_mutex);
	DATA_SET(global_data,"rtv_mutex",rtv_mutex);
	rtv_thread_mutex = g_new0(GMutex, 1);
	g_mutex_init(rtv_thread_mutex);
	DATA_SET(global_data,"rtv_thread_mutex",rtv_thread_mutex);
	serio_mutex = g_new0(GMutex, 1);
	g_mutex_init(serio_mutex);
	DATA_SET(global_data,"serio_mutex",serio_mutex);

	/* For testing if gettext works
	   printf(_("Hello World!\n"));
	 */

	/* Build table of strings to enum values */
	build_string_2_enum_table();
	serial_params = (Serial_Params *)g_malloc0(sizeof(Serial_Params));
	DATA_SET(global_data,"serial_params",serial_params);

	handle_args(argc,argv);	/* handle CLI arguments */

	/* This will exit mtx if the locking fails! */
	/* Prevents multiple instances  but stops esoteric usess too 
	 * create_mtx_lock();
	 * */
	open_debug();		/* Open debug log */

	ENTER();
	/* Allocate memory  */
	init();			/* Initialize global vars */
	make_mtx_dirs();	/* Create config file dirs if missing */

	/* Create Message passing queues */
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"io_data_queue",queue,g_async_queue_unref);
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"slave_msg_queue",queue,g_async_queue_unref);
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"io_repair_queue",queue,g_async_queue_unref);

	read_config();
	setup_gui();		

	gtk_rc_parse_string("style \"override\"\n{\n\tGtkTreeView::horizontal-separator = 0\n\tGtkTreeView::vertical-separator = 0\n}\nwidget_class \"*\" style \"override\"");

	/* This doesn't do any GUI stuff so can run as is... */
	id = g_timeout_add(2000,(GSourceFunc)flush_binary_logs,NULL);
    DATA_SET(global_data,"binlog_flush_id",GINT_TO_POINTER(id));

	sleep_calib();
	/* Check for first_time flag, if so, run first time wizard, otherwise
	   load personality choice
	   */
	timer = g_timer_new();
	DATA_SET_FULL(global_data,"mtx_uptime_timer",timer,g_timer_destroy);
	g_idle_add((GSourceFunc)check_for_first_time,NULL);
	
	DATA_SET(global_data,"ready",GINT_TO_POINTER(TRUE));

	gdk_threads_enter();
	gtk_main();
	gdk_threads_leave();
	EXIT();
	return (0);
}
Ejemplo n.º 15
0
//--------------------------------------------------------------
void ofApp::setup(){
	/********************
	********************/
	ofSetVerticalSync(false);
	ofEnableSmoothing();
	
	// ofEnableDepthTest(); // 注意!!!! 2d imageで、αが効かなくなる.
	
	ofEnableAlphaBlending();
	ofEnableBlendMode(OF_BLENDMODE_ADD);
	// ofEnableBlendMode(OF_BLENDMODE_ALPHA);
	
	
	// image.loadImage( "light_gray.png" );
	image.loadImage( "light_Square.png" );
	
	setup_gui();
	
	/********************
	********************/
	init_vbo();
	
	/********************
	setGeometryInputType(), setGeometryOutputType()に指定可能なtypeは決まっている。
		http://openframeworks.cc/documentation/gl/ofShader/#show_setGeometryOutputType
		
	入力は、単に1入力プリミティブあたりに何個の頂点を送るか、だけと考えて良い。
		http://miffysora.wikidot.com/geometry-shader
		
	並べた順にshaderに渡される。
	
	outputは、「typeと順番」で描画内容が変わってくるので注意してoutputする。
	inputの時に、混乱なきよう、順序を考慮しておくのが良い。
		http://openframeworks.cc/documentation/gl/ofVbo/
	
	shader.setGeometryOutputCount()で設定できるCountは、それほど大きくない(1024とか、そんな所)。
	今回のケースでは、Lineを渡すと、始点から終点まで、textureを繰り返し描画(4点 x texture枚数)。
	n本のLineを描画するのに、Vboへ全ての点を設定して一気に描画したくなるが、すぐCountがmaxを超えてしまう。
	つまり、n本のLineは、都度 描画コマンドを発行すること。
	********************/
	//Enable detailed logging of openFrameworks messages in console
	ofSetLogLevel( OF_LOG_VERBOSE );

	//We must to specify geometry shader parameters before loading shader
	shader.setGeometryInputType( GL_LINES );
	shader.setGeometryOutputType( GL_TRIANGLE_STRIP );
	
	// Maximal possible number of output vertices
	// " * 1/2 - 1" しないと動作しなかった.(実験結果:don't know why...)
	printf("%d\n", shader.getGeometryMaxOutputCount());
	// shader.setGeometryOutputCount( 128 );
	shader.setGeometryOutputCount( shader.getGeometryMaxOutputCount() / 2 - 1 );

	//Load shader
	shader.load( "shaderVert.c", "shaderFrag.c", "shaderGeom.c" );


	/********************
	********************/
	sound.load( "surface.wav" );	
	sound.setLoop( true );
	sound.play();
	// sound.setVolume(0.0);

	//Set spectrum values to 0
	for (int i=0; i<N; i++) {
		spectrum[i] = 0.0f;
	}
}