Ejemplo n.º 1
0
/*
Finally, the third function creates a toolbox window. In this simple mesh
viewer, this toolbox only contains a tab control with three edit boxes for
changing the scale of the displayed model.
*/
void createToolBox()
{
	// remove tool box if already there
	IGUIEnvironment* env = Device->getGUIEnvironment();
	IGUIElement* root = env->getRootGUIElement();
	IGUIElement* e = root->getElementFromId(GUI_ID_DIALOG_ROOT_WINDOW, true);
	if (e)
		e->remove();

	// create the toolbox window
	IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,45,800,480),
		false, L"Toolset", 0, GUI_ID_DIALOG_ROOT_WINDOW);

	// create tab control and tabs
	IGUITabControl* tab = env->addTabControl(
		core::rect<s32>(2,20,800-602,480-7), wnd, true, true);

	IGUITab* t1 = tab->addTab(L"Config");

	// add some edit boxes and a button to tab one
	env->addStaticText(L"Scale:",
			core::rect<s32>(10,20,60,45), false, false, t1);
	env->addStaticText(L"X:", core::rect<s32>(22,48,40,66), false, false, t1);
	env->addEditBox(L"1.0", core::rect<s32>(40,46,130,66), true, t1, GUI_ID_X_SCALE);
	env->addStaticText(L"Y:", core::rect<s32>(22,82,40,96), false, false, t1);
	env->addEditBox(L"1.0", core::rect<s32>(40,76,130,96), true, t1, GUI_ID_Y_SCALE);
	env->addStaticText(L"Z:", core::rect<s32>(22,108,40,126), false, false, t1);
	env->addEditBox(L"1.0", core::rect<s32>(40,106,130,126), true, t1, GUI_ID_Z_SCALE);

	env->addButton(core::rect<s32>(10,134,85,165), t1, GUI_ID_BUTTON_SET_SCALE, L"Set");

	// quick scale buttons
	env->addButton(core::rect<s32>(65,20,95,40), t1, GUI_ID_BUTTON_SCALE_MUL10, L"* 10");
	env->addButton(core::rect<s32>(100,20,130,40), t1, GUI_ID_BUTTON_SCALE_DIV10, L"* 0.1");

	updateScaleInfo(Model);

	// add transparency control
	env->addStaticText(L"GUI Transparency Control:",
			core::rect<s32>(10,200,150,225), true, false, t1);
	IGUIScrollBar* scrollbar = env->addScrollBar(true,
			core::rect<s32>(10,225,150,240), t1, GUI_ID_SKIN_TRANSPARENCY);
	scrollbar->setMax(255);
	scrollbar->setPos(255);

	// add framerate control
	env->addStaticText(L":", core::rect<s32>(10,240,150,265), true, false, t1);
	env->addStaticText(L"Framerate:",
			core::rect<s32>(12,240,75,265), false, false, t1);
	// current frame info
	env->addStaticText(L"", core::rect<s32>(75,240,200,265), false, false, t1,
			GUI_ID_ANIMATION_INFO);
	scrollbar = env->addScrollBar(true,
			core::rect<s32>(10,265,150,280), t1, GUI_ID_SKIN_ANIMATION_FPS);
	scrollbar->setMax(MAX_FRAMERATE);
	scrollbar->setMin(-MAX_FRAMERATE);
	scrollbar->setPos(DEFAULT_FRAMERATE);
	scrollbar->setSmallStep(1);
}
Ejemplo n.º 2
0
void StateNetwork::Init()
{
	//일단 GUI부터 그리고 그다음에 초기화 하면서 넘어간다!!
	IVideoDriver* pDriver = Irrdevice::GetInstance()->GetVideoDriver();
	IGUIEnvironment* env  = Irrdevice::GetInstance()->GetGUIEnvironment();
	IGUISkin	   * skin = env->getSkin();

	IGUIFont* font = env->getFont("media/fonthaettenschweiler.bmp");
	if(font)
		skin->setFont(font);

	skin->setFont(env->getBuiltInFont(),EGDF_TOOLTIP);

	env->addButton(rect<s32>(10,240,110,240 + 32), 0, GUI_ID_SERVER_BUTTON,
		L"SERVER", L"HELL SERVER");
	env->addButton(rect<s32>(10,280,110,280 + 32), 0, GUI_ID_CLIENT_BUTTON,
		L"CLIENT", L"HELL CLIENT");

	m_pConnectButton = env->addButton(rect<s32>(500,280,610,280 + 32), 0, GUI_ID_CONNECT_BUTTON,
		L"CONNECT", NULL);
	m_pConnectButton ->setVisible(false);
	m_pServerIpBox = env->addEditBox(L"192.168.0.3",rect<s32>(200,280,480,280 + 32),true,0,GUI_ID_TEXT_BOX);
	m_pServerIpBox->setVisible(false);

	m_bSelectState = false;

	//배경화면

	m_pBackGround = pDriver->getTexture("media/network.jpg");

	

}
Ejemplo n.º 3
0
	void GUIChat::Load() {
		IGUIEnvironment* env = mainGame->env;
		wChat = env->addWindow(rect<s32>(305, 615, 1020, 640), false, L"");
		wChat->getCloseButton()->setVisible(false);
		wChat->setDraggable(false);
		wChat->setDrawTitlebar(false);
		wChat->setVisible(false);
		ebChatInput = env->addEditBox(L"", rect<s32>(3, 2, 710, 22), true, wChat, EDITBOX_CHAT);
	}
Ejemplo n.º 4
0
void NBEditor::load()
{
	IGUIStaticText* sidebar = state->menu->sidebar;
	IGUIEnvironment* guienv = state->device->getGUIEnvironment();

	if (sidebar) {
		sidebar->setText(L"Node Box Tool");
		IGUIStaticText* t = guienv->addStaticText(L"No node selected",
				rect<s32>(20, 30, 140, 100),
				false, true, sidebar, ENB_GUI_MAIN_MSG);
		
		IGUIListBox* lb = guienv->addListBox(rect<s32>(20, 30, 230, 128),
				sidebar, ENB_GUI_MAIN_LISTBOX, true);

		if (lb) {
			lb->setVisible(false);
			IGUIButton* b1 = guienv->addButton(rect<s32>(0, 100, 50, 125),
					lb, GUI_PROJ_NEW_BOX, L"+", L"Add a node box");
			IGUIButton* b2 = guienv->addButton(rect<s32>(60, 100, 110,125),
					lb, GUI_PROJ_DELETE_BOX, L"-", L"Delete node box");
			b1->setNotClipped(true);
			b2->setNotClipped(true);
		}

		// Create nodebox properties
		t = guienv->addStaticText(L"Properties",
				rect<s32>(0, 170, 120, 190),
				false, true, sidebar, ENB_GUI_PROP);
		t->setVisible(false);

		// Add name properties box
		guienv->addStaticText(L"Name:", rect<s32>(10, 30, 50, 50), false,
				true, t)->setNotClipped(true);
		guienv->addEditBox(L"", rect<s32>(60, 30, 210, 50), true,
				t, ENB_GUI_PROP_NAME)->setNotClipped(true);

		// Add positioning
		addXYZ(t, guienv, vector2di(10, 60),  ENB_GUI_PROP_X1);
		addXYZ(t, guienv, vector2di(10, 160), ENB_GUI_PROP_X2); // 60

		// Add buttons
		guienv->addButton(rect<s32>(30, 250, 100, 280), t, ENB_GUI_PROP_UPDATE,
				L"Update", L"")->setNotClipped(true);
		guienv->addButton(rect<s32>(110, 250, 180, 280), t, ENB_GUI_PROP_REVERT,
				L"Revert", L"")->setNotClipped(true);
	}
	load_ui();
}
Ejemplo n.º 5
0
/*
OK, now for the more interesting part. First, create the Irrlicht device. As in
some examples before, we ask the user which driver he wants to use for this
example.
*/
int main()
{


	// create device and exit if creation failed
	IrrlichtDevice * device = createDevice(EDT_OPENGL,core::dimension2d<u32>(640, 480));

	if (device == 0)
		return 1; // could not create selected driver.

	/* The creation was successful, now we set the event receiver and
		store pointers to the driver and to the gui environment. */

	device->setWindowCaption(L"Irrlicht Engine - User Interface Demo");
	device->setResizable(true);

	video::IVideoDriver* driver = device->getVideoDriver();
	IGUIEnvironment* env = device->getGUIEnvironment();

	const io::path mediaPath = getExampleMediaPath();

	/*
	To make the font a little bit nicer, we load an external font
	and set it as the new default font in the skin.
	To keep the standard font for tool tip text, we set it to
	the built-in font.
	*/

	IGUISkin* skin = env->getSkin();
	IGUIFont* font = env->getFont(mediaPath + "fonthaettenschweiler.bmp");
	if (font)
		skin->setFont(font);

	skin->setFont(env->getBuiltInFont(), EGDF_TOOLTIP);

	/*
	We add three buttons. The first one closes the engine. The second
	creates a window and the third opens a file open dialog. The third
	parameter is the id of the button, with which we can easily identify
	the button in the event receiver.
	*/

	env->addButton(rect<s32>(10,240,110,240 + 32), 0, GUI_ID_QUIT_BUTTON,
			L"Quit", L"Exits Program");
	env->addButton(rect<s32>(10,280,110,280 + 32), 0, GUI_ID_NEW_WINDOW_BUTTON,
			L"New Window", L"Launches a new Window");
	env->addButton(rect<s32>(10,320,110,320 + 32), 0, GUI_ID_FILE_OPEN_BUTTON,
			L"File Open", L"Opens a file");

	/*
	Now, we add a static text and a scrollbar, which modifies the
	transparency of all gui elements. We set the maximum value of
	the scrollbar to 255, because that's the maximal value for
	a color value.
	Then we create an other static text and a list box.
	*/

	env->addStaticText(L"Transparent Control:", rect<s32>(150,20,350,40), true);
	IGUIScrollBar* scrollbar = env->addScrollBar(true,
			rect<s32>(150, 45, 350, 60), 0, GUI_ID_TRANSPARENCY_SCROLL_BAR);
	scrollbar->setMax(255);
	scrollbar->setPos(255);
	setSkinTransparency( scrollbar->getPos(), env->getSkin());

	// set scrollbar position to alpha value of an arbitrary element
	scrollbar->setPos(env->getSkin()->getColor(EGDC_WINDOW).getAlpha());

	env->addStaticText(L"Logging ListBox:", rect<s32>(10,110,350,130), true);
	IGUIListBox * listbox = env->addListBox(rect<s32>(10, 140, 350, 210));
	env->addEditBox(L"Editable Text", rect<s32>(350, 80, 550, 100));

	// Store the appropriate data in a context structure.
	SAppContext context;
	context.device = device;
	context.counter = 0;
	context.listbox = listbox;

	// Then create the event receiver, giving it that context structure.
	MyEventReceiver receiver(context);

	// And tell the device to use our custom event receiver.
	device->setEventReceiver(&receiver);


	/*
	And at last, we create a nice Irrlicht Engine logo in the top left corner.
	*/
	env->addImage(driver->getTexture(mediaPath + "irrlichtlogo2.png"),
			position2d<int>(10,10));


	/*
	That's all, we only have to draw everything.
	*/
  fluid_settings_t* settings;
//  int arg1 = 1;
  char buf[512];
//  int c, i;
  int interactive = 1;
  int midi_in = 1;
  fluid_player_t* player = NULL;
  fluid_midi_router_t* router = NULL;
  //fluid_sequencer_t* sequencer = NULL;
  fluid_midi_driver_t* mdriver = NULL;
  fluid_audio_driver_t* adriver = NULL;
  fluid_synth_t* synth = NULL;
#ifdef NETWORK_SUPPORT
  fluid_server_t* server = NULL;
  int with_server = 0;
#endif
  char* config_file = NULL;
  int audio_groups = 0;
  int audio_channels = 0;
  int dump = 0;
  int fast_render = 0;
  static const char optchars[] = "a:C:c:dE:f:F:G:g:hijK:L:lm:nO:o:p:R:r:sT:Vvz:";
#ifdef LASH_ENABLED
  int connect_lash = 1;
  int enabled_lash = 0;		/* set to TRUE if lash gets enabled */
  fluid_lash_args_t *lash_args;

  lash_args = fluid_lash_extract_args (&argc, &argv);
#endif



  settings = new_fluid_settings();


 /* The 'groups' setting is relevant for LADSPA operation and channel mapping
   * in rvoice_mixer.
   * If not given, set number groups to number of audio channels, because
   * they are the same (there is nothing between synth output and 'sound card')
   */
  if ((audio_groups == 0) && (audio_channels != 0)) {
      audio_groups = audio_channels;
  }
  if (audio_groups != 0)
  {
      fluid_settings_setint(settings, "synth.audio-groups", audio_groups);
  }

  if (fast_render) {
    midi_in = 0;
    interactive = 0;
#ifdef NETWORK_SUPPORT
    with_server = 0;
#endif
    fluid_settings_setstr(settings, "player.timing-source", "sample");
    fluid_settings_setint(settings, "synth.lock-memory", 0);
  }

  /* create the synthesizer */
  synth = new_fluid_synth(settings);
  if (synth == NULL) {
    fprintf(stderr, "Failed to create the synthesizer\n");
    exit(-1);
  }


  /* load the soundfonts (check that all non options are SoundFont or MIDI files) */
//  for (i = arg1; i < argc; i++) {
    if (fluid_is_soundfont(psoundfont))
    {
      if (fluid_synth_sfload(synth, psoundfont, 1) == -1)
	fprintf(stderr, "Failed to load the SoundFont %s\n", psoundfont);
    }
    else if (!fluid_is_midifile(psoundfont))
      fprintf (stderr, "Parameter '%s' not a SoundFont or MIDI file or error occurred identifying it.\n",
	       psoundfont);


  /* start the synthesis thread */
  if (!fast_render) {
		fluid_settings_setstr(settings, "audio.driver", "alsa");
    adriver = new_fluid_audio_driver(settings, synth);
    if (adriver == NULL) {
      fprintf(stderr, "Failed to create the audio driver\n");
//      goto cleanup;
    }
  }


  /* start the midi router and link it to the synth */
#if WITH_MIDI
  if (midi_in) {
    /* In dump mode, text output is generated for events going into and out of the router.
     * The example dump functions are put into the chain before and after the router..
     */
    //sequencer = new_fluid_sequencer2(0);

    router = new_fluid_midi_router(
      settings,
      dump ? fluid_midi_dump_postrouter : fluid_synth_handle_midi_event,
      (void*)synth);

    if (router == NULL) {
      fprintf(stderr, "Failed to create the MIDI input router; no MIDI input\n"
	      "will be available. You can access the synthesizer \n"
	      "through the console.\n");
    } else {
      mdriver = new_fluid_midi_driver(
	settings,
	dump ? fluid_midi_dump_prerouter : fluid_midi_router_handle_midi_event,
	(void*) router);
      if (mdriver == NULL) {
	fprintf(stderr, "Failed to create the MIDI thread; no MIDI input\n"
		"will be available. You can access the synthesizer \n"
		"through the console.\n");
      }
    }
  }
#endif


  /* play the midi fildes, if any */
//  for (i = arg1; i < argc; i++) {
    if  (fluid_is_midifile(psong)) {

      if (player == NULL) {
	player = new_fluid_player(synth);
	if (player == NULL) {
	  fprintf(stderr, "Failed to create the midifile player.\n"
		  "Continuing without a player.\n");
	//  break;
	}
      }

      fluid_player_add(player, psong);
    }
 // }

  if (player != NULL) {

    if (fluid_synth_get_sfont(synth, 0) == NULL) {
      /* Try to load the default soundfont if no soundfont specified */
      char *s;
      if (fluid_settings_dupstr(settings, "synth.default-soundfont", &s) != FLUID_OK)
        s = NULL;
      if ((s != NULL) && (s[0] != '\0'))
        fluid_synth_sfload(synth, s, 1);

      FLUID_FREE(s);
    }

    fluid_player_play(player);
  }

  cmd_handler = new_fluid_cmd_handler(synth, router);
  if (cmd_handler == NULL) {
    fprintf(stderr, "Failed to create the command handler\n");
 //   goto cleanup;
  }

  /* try to load the user or system configuration */
  if (config_file != NULL) {
    fluid_source(cmd_handler, config_file);
  } else if (fluid_get_userconf(buf, sizeof(buf)) != NULL) {
    fluid_source(cmd_handler, buf);
  } else if (fluid_get_sysconf(buf, sizeof(buf)) != NULL) {
    fluid_source(cmd_handler, buf);
  }

  /* run the server, if requested */
#ifdef NETWORK_SUPPORT
  if (with_server) {
    server = new_fluid_server(settings, synth, router);
    if (server == NULL) {
      fprintf(stderr, "Failed to create the server.\n"
	     "Continuing without it.\n");
    }
  }
#endif

#ifdef LASH_ENABLED
  if (enabled_lash)
    fluid_lash_create_thread (synth);
#endif




	while(device->run() && driver)
	if (device->isWindowActive())
	{
		driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(0,200,200,200));

		env->drawAll();

//fast_render;

// if (fast_render) {
//    char *filename;
//    if (player == NULL) {
//      fprintf(stderr, "No midi file specified!\n");
//   //   fluid_player_play(player);
////      goto cleanup;
//    }
//
//    fluid_settings_dupstr (settings, "audio.file.name", &filename);
//    printf ("Rendering audio to file '%s'..\n", filename);
//    if (filename) FLUID_FREE (filename);
//
//    fast_render_loop(settings, synth, player);
//  }

        /* Play a note */
  //      fluid_synth_noteon(synth, 0, 60, 100);

//        printf("Press \"Enter\" to stop: ");
//        fgetc(stdin);
//        printf("done\n");



		device->sleep(129);

		driver->endScene();
	}

        if (adriver) {
                delete_fluid_audio_driver(adriver);
        }
        if (synth) {
                delete_fluid_synth(synth);
        }
        if (settings) {
                delete_fluid_settings(settings);
        }

	device->drop();

	return 0;
}
Ejemplo n.º 6
0
/*
Ok, now for the more interesting part. First, create the Irrlicht device. As in
some examples before, we ask the user which driver he wants to use for this
example:
*/
int main()
{
	// ask user for driver
	video::E_DRIVER_TYPE driverType=driverChoiceConsole();
	if (driverType==video::EDT_COUNT)
		return 1;

	// create device and exit if creation failed

	IrrlichtDevice * device = createDevice(driverType, core::dimension2d<u32>(640, 480));

	if (device == 0)
		return 1; // could not create selected driver.

	/* The creation was successful, now we set the event receiver and
		store pointers to the driver and to the gui environment. */

	device->setWindowCaption(L"Irrlicht Engine - User Interface Demo");
	device->setResizable(true);

	video::IVideoDriver* driver = device->getVideoDriver();
	IGUIEnvironment* env = device->getGUIEnvironment();

	/*
	To make the font a little bit nicer, we load an external font
	and set it as the new default font in the skin.
	To keep the standard font for tool tip text, we set it to
	the built-in font.
	*/

	IGUISkin* skin = env->getSkin();
	IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
	if (font)
		skin->setFont(font);

	skin->setFont(env->getBuiltInFont(), EGDF_TOOLTIP);

	/*
	We add three buttons. The first one closes the engine. The second
	creates a window and the third opens a file open dialog. The third
	parameter is the id of the button, with which we can easily identify
	the button in the event receiver.
	*/

	env->addButton(rect<s32>(10,240,110,240 + 32), 0, GUI_ID_QUIT_BUTTON,
			L"Quit", L"Exits Program");
	env->addButton(rect<s32>(10,280,110,280 + 32), 0, GUI_ID_NEW_WINDOW_BUTTON,
			L"New Window", L"Launches a new Window");
	env->addButton(rect<s32>(10,320,110,320 + 32), 0, GUI_ID_FILE_OPEN_BUTTON,
			L"File Open", L"Opens a file");

	/*
	Now, we add a static text and a scrollbar, which modifies the
	transparency of all gui elements. We set the maximum value of
	the scrollbar to 255, because that's the maximal value for
	a color value.
	Then we create an other static text and a list box.
	*/

	env->addStaticText(L"Transparent Control:", rect<s32>(150,20,350,40), true);
	IGUIScrollBar* scrollbar = env->addScrollBar(true,
			rect<s32>(150, 45, 350, 60), 0, GUI_ID_TRANSPARENCY_SCROLL_BAR);
	scrollbar->setMax(255);
	scrollbar->setPos(255);
	setSkinTransparency( scrollbar->getPos(), env->getSkin());

	// set scrollbar position to alpha value of an arbitrary element
	scrollbar->setPos(env->getSkin()->getColor(EGDC_WINDOW).getAlpha());

	env->addStaticText(L"Logging ListBox:", rect<s32>(10,110,350,130), true);
	IGUIListBox * listbox = env->addListBox(rect<s32>(10, 140, 350, 210));
	env->addEditBox(L"Editable Text", rect<s32>(350, 80, 550, 100));

	// Store the appropriate data in a context structure.
	SAppContext context;
	context.device = device;
	context.counter = 0;
	context.listbox = listbox;

	// Then create the event receiver, giving it that context structure.
	MyEventReceiver receiver(context);

	// And tell the device to use our custom event receiver.
	device->setEventReceiver(&receiver);


	/*
	And at last, we create a nice Irrlicht Engine logo in the top left corner.
	*/
	env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"),
			position2d<int>(10,10));


	/*
	That's all, we only have to draw everything.
	*/

	while(device->run() && driver)
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, SColor(0,200,200,200));

		env->drawAll();

		driver->endScene();
	}

	device->drop();

	return 0;
}
Ejemplo n.º 7
0
int main()
{
    // ask user for driver
    video::E_DRIVER_TYPE driverType=driverChoiceConsole();
    if (driverType==video::EDT_COUNT)
        return 1;

    // create device and exit if creation failed

    Device = createDevice(driverType, core::dimension2d<u32>(640, 480));
    if(Device == NULL)
        return 1;

    IVideoDriver *Driver = Device->getVideoDriver();
    IGUIEnvironment* env = Device->getGUIEnvironment();
    ISceneManager *Scene = Device->getSceneManager();

    Scene->addCameraSceneNode(0, vector3df(0,10,-40), vector3df(0,0,0));

    MyEventReceiver receiver;
    Device->setEventReceiver(&receiver);

    // Load fonts
    fonts[0] = env->getFont(FONTPATH1, SIZE_FONT_NORMAL);
    fonts[1] = env->getFont(FONTPATH1, SIZE_FONT_BIG);
    fonts[2] = env->getFont(FONTPATH2, SIZE_FONT_NORMAL);
    fonts[3] = env->getFont(FONTPATH2, SIZE_FONT_BIG);
    fonts[4] = env->getFont(FONTPATH3, SIZE_FONT_NORMAL);
    fonts[5] = env->getFont(FONTPATH3, SIZE_FONT_BIG);

    for( int i = 0; i < 6; ++i ) {
        fonts[i]->setBatchLoadSize(1);
        fonts[i]->setMaxPageTextureSize( dimension2du(512, 512) );
    }

    font = fonts[0];
    font2 = fonts[1];

    skin = env->getSkin();
    skin->setFont(font);

    txtTrans = env->addStaticText(L"Transparency:", rect<s32>(50,20,250,40), true);
    IGUIScrollBar* scrollbar = env->addScrollBar(true, rect<s32>(50, 45, 250, 60), 0, 104);
    scrollbar->setMax(255);
    SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)0);
    scrollbar->setPos(col.getAlpha());

    txtLog = env->addStaticText(L"Logging ListBox:", rect<s32>(50,80,250,100), true);
    listbox = env->addListBox(rect<s32>(50, 110, 250, 180));

    btnQuit = env->addButton(rect<s32>(10,210,100,240), 0, 101, L"Quit");
    btnNew = env->addButton(rect<s32>(10,250,100,290), 0, 102, L"New Window");
    btnFile = env->addButton(rect<s32>(10,300,100,340), 0, 103, L"Open File");

    edtName = env->addEditBox(L"",rect<s32>(300,60,580,80));
    edtName->setMax(40);
    edtMemo = env->addEditBox(L"",rect<s32>(300,100,580,450));
    edtMemo->setMultiLine(true);
    edtMemo->setTextAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);

    lstLang = env->addListBox(rect<s32>(10, 400, 250, 470),0,120);
    lstLang->addItem(L"Arial");
    lstLang->addItem(L"Times Roman");
    lstLang->addItem(L"MS-Gothic(Japanese)");
    lstLang->setSelected(0);

    int lastFPS = -1;

    while(Device->run())
    {
        Driver->beginScene(true, true, SColor(0,64,64,128));

        Scene->drawAll();
        env->drawAll();

        if (!lang){
            font2->draw(L"Hello TrueType",rect<s32>(250,20,640,100),SColor(255,255,64,64),true);
        } else {
            //font2->draw(jtxtHello,rect<s32>(250,20,640,100),SColor(255,255,64,64),true);
            font2->draw(zhtwHello,rect<s32>(100,100,640,100),SColor(255,255,64,64),false);
        }

        Driver->endScene();

        int fps = Driver->getFPS();
        if (lastFPS != fps)
        {
            wchar_t tmp[1024];
            swprintf(tmp, L"Irrlicht TrueType Demo (fps:%d)", fps);
            Device->setWindowCaption(tmp);
            lastFPS = fps;
        }

    }

    Device->drop();
    return 0;
}
Ejemplo n.º 8
0
/*
OK, now for the more interesting part. First, create the Irrlicht device. As in
some examples before, we ask the user which driver he wants to use for this
example.
*/
int main()
{


	// create device and exit if creation failed
	IrrlichtDevice * device = createDevice(EDT_OPENGL,core::dimension2d<u32>(640, 480));

	if (device == 0)
		return 1; // could not create selected driver.

	/* The creation was successful, now we set the event receiver and
		store pointers to the driver and to the gui environment. */

	device->setWindowCaption(L"Irrlicht Engine - User Interface Demo");
	device->setResizable(true);

	video::IVideoDriver* driver = device->getVideoDriver();
	IGUIEnvironment* env = device->getGUIEnvironment();

	const io::path mediaPath = getExampleMediaPath();

	/*
	To make the font a little bit nicer, we load an external font
	and set it as the new default font in the skin.
	To keep the standard font for tool tip text, we set it to
	the built-in font.
	*/

	IGUISkin* skin = env->getSkin();
	IGUIFont* font = env->getFont(mediaPath + "fonthaettenschweiler.bmp");
	if (font)
		skin->setFont(font);

	skin->setFont(env->getBuiltInFont(), EGDF_TOOLTIP);

	/*
	We add three buttons. The first one closes the engine. The second
	creates a window and the third opens a file open dialog. The third
	parameter is the id of the button, with which we can easily identify
	the button in the event receiver.
	*/

	env->addButton(rect<s32>(10,240,110,240 + 32), 0, GUI_ID_QUIT_BUTTON,
			L"Quit", L"Exits Program");
	env->addButton(rect<s32>(10,280,110,280 + 32), 0, GUI_ID_NEW_WINDOW_BUTTON,
			L"New Window", L"Launches a new Window");
	env->addButton(rect<s32>(10,320,110,320 + 32), 0, GUI_ID_FILE_OPEN_BUTTON,
			L"File Open", L"Opens a file");

	/*
	Now, we add a static text and a scrollbar, which modifies the
	transparency of all gui elements. We set the maximum value of
	the scrollbar to 255, because that's the maximal value for
	a color value.
	Then we create an other static text and a list box.
	*/

	env->addStaticText(L"Transparent Control:", rect<s32>(150,20,350,40), true);
	IGUIScrollBar* scrollbar = env->addScrollBar(true,
			rect<s32>(150, 45, 350, 60), 0, GUI_ID_TRANSPARENCY_SCROLL_BAR);
	scrollbar->setMax(255);
	scrollbar->setPos(255);
	setSkinTransparency( scrollbar->getPos(), env->getSkin());

	// set scrollbar position to alpha value of an arbitrary element
	scrollbar->setPos(env->getSkin()->getColor(EGDC_WINDOW).getAlpha());

	env->addStaticText(L"Logging ListBox:", rect<s32>(10,110,350,130), true);
	IGUIListBox * listbox = env->addListBox(rect<s32>(10, 140, 350, 210));
	env->addEditBox(L"Editable Text", rect<s32>(350, 80, 550, 100));

	// Store the appropriate data in a context structure.
	SAppContext context;
	context.device = device;
	context.counter = 0;
	context.listbox = listbox;

	// Then create the event receiver, giving it that context structure.
	MyEventReceiver receiver(context);

	// And tell the device to use our custom event receiver.
	device->setEventReceiver(&receiver);


	/*
	And at last, we create a nice Irrlicht Engine logo in the top left corner.
	*/
	env->addImage(driver->getTexture(mediaPath + "irrlichtlogo2.png"),
			position2d<int>(10,10));


	/*
	That's all, we only have to draw everything.
	*/
	        fluid_settings_t* settings;
        fluid_synth_t* synth = NULL;
        fluid_audio_driver_t* adriver = NULL;
        int err = 0;
        struct fx_data_t fx_data;
//
//        if (argc != 3) {
//                fprintf(stderr, "Usage: fluidsynth_simple [soundfont] [gain]\n");
//                return 1;
//        }
//
        /* Create the settings object. This example uses the default
         * values for the settings. */
        settings = new_fluid_settings();
        if (settings == NULL) {
                fprintf(stderr, "Failed to create the settings\n");
                err = 2;
                goto cleanup;
        }

        /* Create the synthesizer */
        synth = new_fluid_synth(settings);
        if (synth == NULL) {
                fprintf(stderr, "Failed to create the synthesizer\n");
                err = 3;
                goto cleanup;
        }

        /* Load the soundfont */
//        if (fluid_synth_sfload(synth, "soundfonts/example.sf2", 1) == -1) {
        if (fluid_synth_sfload(synth, "soundfonts/VintageDreamsWaves-v2.sf2", 1) == -1) {
//        if (fluid_synth_sfload(synth, "soundfonts/VintageDreamsWaves-v2.sf3", 1) == -1) {
 //       if (fluid_synth_sfload(synth, "soundfonts/philharmonia_violin_short.gig", 1) == -1) { //was to check and see if it had gig support but no.

                fprintf(stderr, "Failed to load the SoundFont\n");
                err = 4;
                goto cleanup;
        }

        /* Fill in the data of the effects unit */
        fx_data.synth = synth;
        fx_data.gain = 10; //atof(argv[2]);

        /* Create the audio driver. As soon as the audio driver is
         * created, the synthesizer can be played. */
fluid_settings_setstr(settings, "audio.driver", "alsa");
        adriver = new_fluid_audio_driver2(settings, fx_function, (void*) &fx_data);
        if (adriver == NULL) {
                fprintf(stderr, "Failed to create the audio driver\n");
                err = 5;
                goto cleanup;
        }



	while(device->run() && driver)
	if (device->isWindowActive())
	{
		driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(0,200,200,200));

		env->drawAll();




        /* Play a note */
        fluid_synth_noteon(synth, 0, 60, 100);

//        printf("Press \"Enter\" to stop: ");
//        fgetc(stdin);
//        printf("done\n");





		driver->endScene();
	}
 cleanup:

        if (adriver) {
                delete_fluid_audio_driver(adriver);
        }
        if (synth) {
                delete_fluid_synth(synth);
        }
        if (settings) {
                delete_fluid_settings(settings);
        }

	device->drop();

	return 0;
}