コード例 #1
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");

	

}
コード例 #2
0
ファイル: main.cpp プロジェクト: tecan/IrrlichtDemos
/*
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;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Legun/irrlicht
/*
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;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: pecc0/jw-earth
/*
 That's it. The Scene node is done. Now we simply have to start
 the engine, create the scene node and a camera, and look at the result.
 */
int main()
{
	// ask user for driver
	video::E_DRIVER_TYPE driverType = video::EDT_OPENGL; //FIXME: hardcoded driverChoiceConsole();
	if (driverType == video::EDT_COUNT)
		return 1;

	// create device

	MyEventReceiver receiver;

	g_Device = createDevice(driverType, core::dimension2d<u32>(640, 480), 16,
			false, false, false, &receiver);

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

	// create engine and camera

	g_Device->setWindowCaption(L"Custom Scene Node - Irrlicht Engine Demo");

	video::IVideoDriver* driver = g_Device->getVideoDriver();
	scene::ISceneManager* smgr = g_Device->getSceneManager();

	IGUIEnvironment* env = g_Device->getGUIEnvironment();

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

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

	env->addStaticText(L"Movement speed:", rect<s32> (GUI_X, GUI_Y, GUI_X + 95,
			GUI_Y + 20), true);
	IGUIScrollBar* scrollbar = env->addScrollBar(true, rect<s32> (GUI_X + 100,
			GUI_Y, GUI_X + 100 + 200, GUI_Y + 20), 0, GUI_ID_SPEED_SCROLL);

	//scrollbar->drop();

	//max speed -> 1000 * 1000 / 100000 = 10 km/frame
	//min speed -> 10 * 10 / 100000 = 1m / frame
	scrollbar->setMax(1000);
	scrollbar->setMin(10);

	scrollbar->setPos(255);

	// add a camera scene node
	scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
	//scene::ICameraSceneNode* camera = addCameraSceneNodeFPS(smgr);

	g_CameraAnimator = JWSceneNodeAnimatorCameraFPS::injectOnFPSCamera(camera);
	g_CameraAnimator->setMoveSpeed(scrollbar->getPos() / 5000.0);
	g_CameraAnimator->setAnimationEventsReceiver(&receiver);

	env->addStaticText(L"Level:", rect<s32> (GUI_X, GUI_Y + 22, GUI_X + 95,
			GUI_Y + 22 + 20), true);
	scrollbar = env->addScrollBar(true, rect<s32> (GUI_X + 100, GUI_Y + 22,
			GUI_X + 100 + 200, GUI_Y + 22 + 20), 0, GUI_ID_LEVEL);

#define START_LEVEL 14
	scrollbar->setMax(14);
	scrollbar->setMin(0);
	scrollbar->setPos(START_LEVEL);
	g_LevelScroll = scrollbar;
	env->addStaticText(L"Wireframe:", rect<s32> (GUI_X, GUI_Y + 22 + 22, GUI_X
			+ 95, GUI_Y + 22 + 22 + 20), true);
	env->addCheckBox(false, rect<s32> (GUI_X + 100, GUI_Y + 22 + 22, GUI_X
			+ 100 + 200, GUI_Y + 22 + 22 + 20), 0, GUI_ID_WIREFRAME);

	env->addStaticText(L"Update mesh:", rect<s32> (GUI_X, GUI_Y + 22 + 22 + 22,
			GUI_X + 95, GUI_Y + 22 + 22 + 22 + 20), true);
	env->addCheckBox(true, rect<s32> (GUI_X + 100, GUI_Y + 22 + 22 + 22, GUI_X
			+ 100 + 200, GUI_Y + 22 + 22 + 22 + 20), 0, GUI_ID_MESH_UPDATE);

	SKeyMap keyMap[] =
	{
	{ EKA_MOVE_FORWARD, KEY_KEY_W },
	{ EKA_MOVE_BACKWARD, KEY_KEY_S },
	{ EKA_STRAFE_LEFT, KEY_KEY_A },
	{ EKA_STRAFE_RIGHT, KEY_KEY_D },
	{ EKA_JUMP_UP, KEY_SPACE },
	{ EKA_CROUCH, KEY_LSHIFT } };
	g_CameraAnimator->setKeyMap(keyMap, 6);
	core::vector3df earthCenter(0, 0, 0);
	camera->setFarValue(500000.f); //500 000 km
	//camera->setUpVector(core::vector3df(0,0,1));
	camera->setPosition(core::vector3df(100, 100, -EARTH_RADIUS - 200.));
	camera->setTarget(earthCenter);
	//camera->setFarValue(20000.f);
	//camera->setPosition(core::vector3df(0,0,-200));
	// Maya cameras reposition themselves relative to their target, so target the location
	// where the mesh scene node is placed.
	//camera->setTarget(core::vector3df(0, 0, 0));
	//smgr->addCameraSceneNode(0, core::vector3df(0,-40,0), core::vector3df(0,0,0));
	/*
	 Create our scene node. I don't check the result of calling new, as it
	 should throw an exception rather than returning 0 on failure. Because
	 the new node will create itself with a reference count of 1, and then
	 will have another reference added by its parent scene node when it is
	 added to the scene, I need to drop my reference to it. Best practice is
	 to drop it only *after* I have finished using it, regardless of what
	 the reference count of the object is after creation.
	 */
	g_EarthVisualization = new SphereVisualization(smgr->getRootSceneNode(),
			smgr, driver, 666, START_LEVEL, earthCenter, EARTH_RADIUS);
	g_EarthVisualization->setMaterialType(video::EMT_SOLID);
	//g_textre = driver->getTexture("media/earth.bmp");
	//g_EarthVisualization->getMaterial().setTexture(0, g_textre);
	g_EarthVisualization->setViewerPoint(camera->getPosition());

	/*
	 To animate something in this boring scene consisting only of one
	 tetraeder, and to show that you now can use your scene node like any
	 other scene node in the engine, we add an animator to the scene node,
	 which rotates the node a little bit.
	 irr::scene::ISceneManager::createRotationAnimator() could return 0, so
	 should be checked.
	 */
	scene::ISceneNodeAnimator *anim = 0;
	//smgr->createRotationAnimator(core::vector3df(0.8f, 0, 0.8f));
	if (anim)
	{
		g_EarthVisualization->addAnimator(anim);
		/*
		 I'm done referring to anim, so must
		 irr::IReferenceCounted::drop() this reference now because it
		 was produced by a createFoo() function. As I shouldn't refer to
		 it again, ensure that I can't by setting to 0.
		 */
		anim->drop();
		anim = 0;
	}
	/*
	 I'm done with my CSampleSceneNode object, and so must drop my reference.
	 This won't delete the object, yet, because it is still attached to the
	 scene graph, which prevents the deletion until the graph is deleted or the
	 custom scene node is removed from it.
	 */
	g_EarthVisualization->drop();
	//myNode = 0; // As I shouldn't refer to it again, ensure that I can't
	scene::ISceneNode *bill = smgr->addBillboardSceneNode(0, core::dimension2d<
			f32>(600, 600), earthCenter, 113);
	//600x600 km billboard
	bill->setMaterialFlag(video::EMF_LIGHTING, false);
	bill->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
	bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
	bill->setMaterialTexture(0, driver->getTexture("media/particlered.bmp"));
	//bill->drop();
	/*
	 Now draw everything and finish.
	 */
	u32 frames = 0;
	while (g_Device->run())
	{
		driver->beginScene(true, true, video::SColor(0, 100, 100, 100));
		smgr->drawAll();
		env->drawAll();
		driver->endScene();
		if (++frames == 100)
		{
			core::vector3df vpoint = g_EarthVisualization->getViewerPoint();
			vpoint.normalize();
			core::vector2d<f32> txCoord = g_EarthVisualization->getSphericalCoordinates(vpoint);

			core::stringw str = L"FPS: ";
			str += (s32) (driver->getFPS());
			str += L" TCoord:(";
			str += txCoord.X;
			str += L", ";
			str += txCoord.Y;
			str += L") Tile: ";
			str.printBinary(g_EarthVisualization->getUTriangleUnderUs(), 32,
					L'0', L'1');
			g_Device->setWindowCaption(str.c_str());
			frames = 0;
		}
	}

	g_Device->drop();

	return 0;
}
コード例 #5
0
ファイル: simple.cpp プロジェクト: tecan/IrrlichtDemos
/*
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;
}