/*
Most of the hard work is done. We only need to create the Irrlicht Engine
device and all the buttons, menus and toolbars. We start up the engine as
usual, using createDevice(). To make our application catch events, we set our
eventreceiver as parameter. As you can see, there is also a call to
IrrlichtDevice::setResizeable(). This makes the render window resizeable, which
is quite useful for a mesh viewer.
*/
int main(int argc, char* argv[])
{
	// ask user for driver
	video::E_DRIVER_TYPE driverType=driverChoiceConsole();
	if (driverType==video::EDT_COUNT)
		return 1;

	// create device and exit if creation failed
	MyEventReceiver receiver;
	Device = createDevice(driverType, core::dimension2d<u32>(800, 600),
		16, false, false, false, &receiver);

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

	Device->setResizable(true);

	Device->setWindowCaption(L"Irrlicht Engine - Loading...");

	video::IVideoDriver* driver = Device->getVideoDriver();
	IGUIEnvironment* env = Device->getGUIEnvironment();
	scene::ISceneManager* smgr = Device->getSceneManager();
	smgr->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true);

	driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

	smgr->addLightSceneNode(0, core::vector3df(200,200,200),
		video::SColorf(1.0f,1.0f,1.0f),2000);
	smgr->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
	// add our media directory as "search path"
	Device->getFileSystem()->addFileArchive("../../media/");

	/*
	The next step is to read the configuration file. It is stored in the xml
	format and looks a little bit like this:

	@verbatim
	<?xml version="1.0"?>
	<config>
		<startUpModel file="some filename" />
		<messageText caption="Irrlicht Engine Mesh Viewer">
			Hello!
		</messageText>
	</config>
	@endverbatim

	We need the data stored in there to be written into the global variables
	StartUpModelFile, MessageText and Caption. This is now done using the
	Irrlicht Engine integrated XML parser:
	*/

	// read configuration from xml file

	io::IXMLReader* xml = Device->getFileSystem()->createXMLReader( L"config.xml");

	while(xml && xml->read())
	{
		switch(xml->getNodeType())
		{
		case io::EXN_TEXT:
			// in this xml file, the only text which occurs is the
			// messageText
			MessageText = xml->getNodeData();
			break;
		case io::EXN_ELEMENT:
			{
				if (core::stringw("startUpModel") == xml->getNodeName())
					StartUpModelFile = xml->getAttributeValue(L"file");
				else
				if (core::stringw("messageText") == xml->getNodeName())
					Caption = xml->getAttributeValue(L"caption");
			}
			break;
		default:
			break;
		}
	}

	if (xml)
		xml->drop(); // don't forget to delete the xml reader

	if (argc > 1)
		StartUpModelFile = argv[1];

	/*
	That wasn't difficult. Now we'll set a nicer font and create the Menu.
	It is possible to create submenus for every menu item. The call
	menu->addItem(L"File", -1, true, true); for example adds a new menu
	Item with the name "File" and the id -1. The following parameter says
	that the menu item should be enabled, and the last one says, that there
	should be a submenu. The submenu can now be accessed with
	menu->getSubMenu(0), because the "File" entry is the menu item with
	index 0.
	*/

	// set a nicer font

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

	// create menu
	gui::IGUIContextMenu* menu = env->addMenu();
	menu->addItem(L"File", -1, true, true);
	menu->addItem(L"View", -1, true, true);
	menu->addItem(L"Camera", -1, true, true);
	menu->addItem(L"Help", -1, true, true);

	gui::IGUIContextMenu* submenu;
	submenu = menu->getSubMenu(0);
	submenu->addItem(L"Open Model File & Texture...", GUI_ID_OPEN_MODEL);
	submenu->addItem(L"Set Model Archive...", GUI_ID_SET_MODEL_ARCHIVE);
	submenu->addItem(L"Load as Octree", GUI_ID_LOAD_AS_OCTREE);
	submenu->addSeparator();
	submenu->addItem(L"Quit", GUI_ID_QUIT);

	submenu = menu->getSubMenu(1);
	submenu->addItem(L"sky box visible", GUI_ID_SKY_BOX_VISIBLE, true, false, true);
	submenu->addItem(L"toggle model debug information", GUI_ID_TOGGLE_DEBUG_INFO, true, true);
	submenu->addItem(L"model material", -1, true, true );

	submenu = submenu->getSubMenu(1);
	submenu->addItem(L"Off", GUI_ID_DEBUG_OFF);
	submenu->addItem(L"Bounding Box", GUI_ID_DEBUG_BOUNDING_BOX);
	submenu->addItem(L"Normals", GUI_ID_DEBUG_NORMALS);
	submenu->addItem(L"Skeleton", GUI_ID_DEBUG_SKELETON);
	submenu->addItem(L"Wire overlay", GUI_ID_DEBUG_WIRE_OVERLAY);
	submenu->addItem(L"Half-Transparent", GUI_ID_DEBUG_HALF_TRANSPARENT);
	submenu->addItem(L"Buffers bounding boxes", GUI_ID_DEBUG_BUFFERS_BOUNDING_BOXES);
	submenu->addItem(L"All", GUI_ID_DEBUG_ALL);

	submenu = menu->getSubMenu(1)->getSubMenu(2);
	submenu->addItem(L"Solid", GUI_ID_MODEL_MATERIAL_SOLID);
	submenu->addItem(L"Transparent", GUI_ID_MODEL_MATERIAL_TRANSPARENT);
	submenu->addItem(L"Reflection", GUI_ID_MODEL_MATERIAL_REFLECTION);

	submenu = menu->getSubMenu(2);
	submenu->addItem(L"Maya Style", GUI_ID_CAMERA_MAYA);
	submenu->addItem(L"First Person", GUI_ID_CAMERA_FIRST_PERSON);

	submenu = menu->getSubMenu(3);
	submenu->addItem(L"About", GUI_ID_ABOUT);

	/*
	Below the menu we want a toolbar, onto which we can place colored
	buttons and important looking stuff like a senseless combobox.
	*/

	// create toolbar

	gui::IGUIToolBar* bar = env->addToolBar();

	video::ITexture* image = driver->getTexture("open.png");
	bar->addButton(GUI_ID_BUTTON_OPEN_MODEL, 0, L"Open a model",image, 0, false, true);

	image = driver->getTexture("tools.png");
	bar->addButton(GUI_ID_BUTTON_SHOW_TOOLBOX, 0, L"Open Toolset",image, 0, false, true);

	image = driver->getTexture("zip.png");
	bar->addButton(GUI_ID_BUTTON_SELECT_ARCHIVE, 0, L"Set Model Archive",image, 0, false, true);

	image = driver->getTexture("help.png");
	bar->addButton(GUI_ID_BUTTON_SHOW_ABOUT, 0, L"Open Help", image, 0, false, true);

	// create a combobox for texture filters

	gui::IGUIComboBox* box = env->addComboBox(core::rect<s32>(250,4,350,23), bar, GUI_ID_TEXTUREFILTER);
	box->addItem(L"No filtering");
	box->addItem(L"Bilinear");
	box->addItem(L"Trilinear");
	box->addItem(L"Anisotropic");
	box->addItem(L"Isotropic");

	/*
	To make the editor look a little bit better, we disable transparent gui
	elements, and add an Irrlicht Engine logo. In addition, a text showing
	the current frames per second value is created and the window caption is
	changed.
	*/

	// disable alpha

	for (s32 i=0; i<gui::EGDC_COUNT ; ++i)
	{
		video::SColor col = env->getSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i);
		col.setAlpha(255);
		env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col);
	}

	// add a tabcontrol

	createToolBox();

	// create fps text

	IGUIStaticText* fpstext = env->addStaticText(L"",
			core::rect<s32>(400,4,570,23), true, false, bar);

	IGUIStaticText* postext = env->addStaticText(L"",
			core::rect<s32>(10,50,470,80),false, false, 0, GUI_ID_POSITION_TEXT);
	postext->setVisible(false);

	// set window caption

	Caption += " - [";
	Caption += driver->getName();
	Caption += "]";
	Device->setWindowCaption(Caption.c_str());

	/*
	That's nearly the whole application. We simply show the about message
	box at start up, and load the first model. To make everything look
	better, a skybox is created and a user controled camera, to make the
	application a little bit more interactive. Finally, everything is drawn
	in a standard drawing loop.
	*/

	// show about message box and load default model
	if (argc==1)
		showAboutText();
	loadModel(StartUpModelFile.c_str());

	// add skybox

	SkyBox = smgr->addSkyBoxSceneNode(
		driver->getTexture("irrlicht2_up.jpg"),
		driver->getTexture("irrlicht2_dn.jpg"),
		driver->getTexture("irrlicht2_lf.jpg"),
		driver->getTexture("irrlicht2_rt.jpg"),
		driver->getTexture("irrlicht2_ft.jpg"),
		driver->getTexture("irrlicht2_bk.jpg"));

	// add a camera scene node
	Camera[0] = smgr->addCameraSceneNodeMaya();
	Camera[0]->setFarValue(20000.f);
	// Maya cameras reposition themselves relative to their target, so target the location
	// where the mesh scene node is placed.
	Camera[0]->setTarget(core::vector3df(0,30,0));

	Camera[1] = smgr->addCameraSceneNodeFPS();
	Camera[1]->setFarValue(20000.f);
	Camera[1]->setPosition(core::vector3df(0,0,-70));
	Camera[1]->setTarget(core::vector3df(0,30,0));

	setActiveCamera(Camera[0]);

	// load the irrlicht engine logo
	IGUIImage *img =
		env->addImage(driver->getTexture("irrlichtlogo2.png"),
			core::position2d<s32>(10, driver->getScreenSize().Height - 128));

	// lock the logo's edges to the bottom left corner of the screen
	img->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT,
			EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT);

	// remember state so we notice when the window does lose the focus
	bool hasFocus = Device->isWindowFocused();

	// draw everything

	while(Device->run() && driver)
	{
		// Catch focus changes (workaround until Irrlicht has events for this)
		bool focused = Device->isWindowFocused();
		if ( hasFocus && !focused )
			onKillFocus();
		hasFocus = focused;

		if (Device->isWindowActive())
		{
			driver->beginScene(true, true, video::SColor(150,50,50,50));

			smgr->drawAll();
			env->drawAll();

			driver->endScene();

			// update information about current frame-rate
			core::stringw str(L"FPS: ");
			str.append(core::stringw(driver->getFPS()));
			str += L" Tris: ";
			str.append(core::stringw(driver->getPrimitiveCountDrawn()));
			fpstext->setText(str.c_str());

			// update information about the active camera
			scene::ICameraSceneNode* cam = Device->getSceneManager()->getActiveCamera();
			str = L"Pos: ";
			str.append(core::stringw(cam->getPosition().X));
			str += L" ";
			str.append(core::stringw(cam->getPosition().Y));
			str += L" ";
			str.append(core::stringw(cam->getPosition().Z));
			str += L" Tgt: ";
			str.append(core::stringw(cam->getTarget().X));
			str += L" ";
			str.append(core::stringw(cam->getTarget().Y));
			str += L" ";
			str.append(core::stringw(cam->getTarget().Z));
			postext->setText(str.c_str());

			// update the tool dialog
			updateToolBox();
		}
		else
			Device->yield();
	}

	Device->drop();
	return 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");

	

}
Beispiel #3
0
void IrrWrapper :: Init()
{
	receiver = new MyEventReceiver();

	// Setup irrlicht devices:
	SIrrlichtCreationParameters parameters;
	parameters.AntiAlias = 0; // 1
	parameters.DriverType = EDT_OPENGL;
	parameters.WindowSize = dimension2d<u32>(SCREEN_SIZE_X, SCREEN_SIZE_Y);
	parameters.Bits = 16; //32
	parameters.Fullscreen = false;
	parameters.Stencilbuffer = false;
	parameters.Vsync = false;
	parameters.EventReceiver = receiver;

	device = createDeviceEx(parameters);

    driver = 			device->getVideoDriver();
    sceneMgr = 			device->getSceneManager();
    gui = 				device->getGUIEnvironment();
	collisionMgr =		sceneMgr->getSceneCollisionManager();

	IGUISkin* skin = gui->getSkin();
	font = gui->getFont("tex/font.bmp");
	skin->setFont(font);

	// Setup camera:
	camera = IrrWrapper::sceneMgr->addCameraSceneNode(0, vector3df(0,0,0), vector3df(0,0,0), 0);
	camera->setNearValue(0.01f);
}
/** Set the global font of Irrlicht engine
  *
  * This font will be use for every text that is no override.
  *
  * \param fontName The fontname type
  * \param size The font size
  *
  */
void RainbruRPG::Core::IrrFontManager::setGlobalFont(tIrrFont fontName, unsigned int size ) {

    IGUISkin* skin =GameEngine::getSingleton().getIrrlichtGui()->getSkin();

    IGUIFont* font = loadFont(fontName, size);
    if (font)
        skin->setFont(font);

};
Beispiel #5
0
int main()
{
	IrrlichtDevice *device =createDevice(video::EDT_OPENGL, core::dimension2d<s32>(800, 600));
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment *env = device->getGUIEnvironment();

	/*
		first we create the factory which can make new GUI elements
		and register it with the gui environment.
	*/

	IGUIElementFactory* factory = new CGUIEditFactory(env);
	env->registerGUIElementFactory(factory);
	// remember to drop since we created with a create call
	factory->drop();

	IGUISkin *skin = env->createSkin(EGST_WINDOWS_METALLIC);
	env->setSkin(skin);

	device->getFileSystem()->addFolderFileArchive ( "../../media/" );
	IGUIFont *font = env->getFont("lucida.xml");
	if (font)
		skin->setFont(font);
	skin->drop();

	// change transparency of skin
	for (s32 i=0; i<gui::EGDC_COUNT ; ++i)
	{
		video::SColor col = env->getSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i);
		col.setAlpha(250);
		env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col);
	}

	/*
		now we add the GUI Editor Workspace
	*/

	env->addGUIElement("GUIEditor");
	
	while(device->run()) 
	{
		device->sleep(10);

		if (device->isWindowActive())
		{
			driver->beginScene(true, true, video::SColor(0,200,200,200));
			smgr->drawAll();
			env->drawAll();
			driver->endScene();
		}
	}

	device->drop();
	
	return 0;
}
Beispiel #6
0
game::game(void)
{
	//create the device
	//and get desktop width and height
	RECT desktop;
	const HWND hDesktop = GetDesktopWindow();
	GetWindowRect(hDesktop, &desktop);
	//assign the width and height
	horizontal = desktop.right;
	vertical = desktop.bottom;

	device = createDevice(video::EDT_OPENGL, dimension2d<u32>(horizontal, vertical), 16, false, false, false, 0);

	device->setWindowCaption(L"PSI TEAM 3");
	device->setResizable(false);

	// initialize driver, scenemanager and gui environment
	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();
	playerCamera = new PlayerCamera(device);

	IGUISkin* skin = guienv->getSkin();
	IGUIFont* font = guienv->getFont("../media/fonts/candara14.bmp");
	skin->setFont(font);

	// initialize networkUtilities (all networking stuff is handled in in this class)
	networkUtilities = new NonRealtimeNetworkingUtilities();

	// initialize gameStateDTO
	gameState = new GameStateDTO(16);

	// initialize players
	localPlayer = new Player(device);
	opposingPlayer = new Player(device);

	fields = new std::vector<vector3df>();

	smgr->addCameraSceneNode(0, vector3df(0,8,-8), vector3df(0,0,0));


}
Beispiel #7
0
// ----------------------------------------------------------------------------
void Editor::initAfterDataDirKnown()
{
    m_rcs = RoadCrossSectionWndw::get();

    // fonts
    IGUISkin* skin = m_gui_env->getSkin();
    m_font = m_gui_env->getFont(m_data_loc + L"editor/font/font.xml");
    skin->setFont(m_font);

    // removing gui transparency
    for (s32 i = 0; i < EGDC_COUNT; ++i)
    {
        video::SColor col = skin->getColor((EGUI_DEFAULT_COLOR)i);
        col.setAlpha(255);
        skin->setColor((EGUI_DEFAULT_COLOR)i, col);
    }

    // free camera
    ICameraSceneNode* cam;
    cam = m_scene_manager->addCameraSceneNodeMaya();
    cam->setID(1);
    cam->setFarValue(20000.f);
    cam->setTarget(vector3df(0, 0, 0));
    cam->setInputReceiverEnabled(false);

    // viewport init
    ICameraSceneNode* norm_cam;
    norm_cam = m_scene_manager->addCameraSceneNode(0, vector3df(25, 50, 30),
        vector3df(5, 10, 6));
    norm_cam->setID(2);
    m_viewport = Viewport::get(norm_cam, &m_mouse, &m_keys);
    m_viewport->setFreeCamera(cam);
    m_indicator = m_viewport->getIndicator();
    m_scene_manager->setActiveCamera(norm_cam);

    m_msg_wndw = MsgWndw::get();

    m_toolbar = ToolBar::getToolBar();
    m_new_dialog_wndw = NewDialogWndw::get();
    m_new_dialog_wndw->hide();
    m_welcome_screen = WelcomeScreen::get();
} // initAfterDataDirKnown
Beispiel #8
0
/* ----------------------------------------------------------------------------
set the font used by the GUI
*/
void DLL_EXPORT IrrGUISetFont( IGUIFont* font )
{
	IGUISkin* skin = guienv->getSkin();
	if (font)
		skin->setFont(font);
}
Beispiel #9
0
int mainloop()
#endif
{	
	/*
		Settings
	*/
	SIrrlichtCreationParameters param;

	param.LoggingLevel = ELL_DEBUG;

	// Video settings
	param.Bits = 24;
	param.ZBufferBits = 16;
	param.AntiAlias  = 0;
	param.Vsync = false;
	param.Fullscreen = false;
	param.Stencilbuffer = false;
	param.EventReceiver = &eventReceiver;
	#ifdef _IRR_ANDROID_PLATFORM_
	param.DriverType = EDT_OGLES2;
	param.WindowSize = dimension2d<u32>(0,0);	// using 0,0 it will automatically set it to the maximal size
	param.PrivateData = app;
	#else
	param.DriverType = video::EDT_OPENGL;
	param.WindowSize = dimension2d<u32>(640,480);
	#endif

	// Create video device
	device = createDeviceEx(param);
	if (!device)
		return -1;

	// Gets the video driver
	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();
	logger = device->getLogger();
	fs = device->getFileSystem();

	logger->log("Irrlicht device is created");

	/*

		Android specifics
	
	*/
	#ifdef _IRR_ANDROID_PLATFORM_
	// Create native android window
	ANativeWindow* nativeWindow = static_cast<ANativeWindow*>(driver->getExposedVideoData().OGLESAndroid.Window);

	/* Get display metrics. We are accessing the Java functions of the JVM directly in this case as there is no NDK function for that yet.
	   Checkout android_tools.cpp if you want to know how that is done. */
	irr::android::SDisplayMetrics displayMetrics;
	memset(&displayMetrics, 0, sizeof displayMetrics);
	irr::android::getDisplayMetrics(app, displayMetrics);

	// The Android assets file-system does not know which sub-directories it has (blame google).
	// So we have to add all sub-directories in assets manually. Otherwise we could still open the files, 
	// but existFile checks will fail (which are for example needed by getFont).
	for ( u32 i=0; i < fs->getFileArchiveCount(); ++i )
	{
		IFileArchive* archive = fs->getFileArchive(i);
		if ( archive->getType() == EFAT_ANDROID_ASSET )
		{
			archive->addDirectoryToFileList("./");
			break;
		}
	}
	#endif 
	// Exiting android specifics

    IGUISkin* skin = guienv->getSkin();
    IGUIFont* font = guienv->getFont("assets/fonts/fontlucida.png");
    if (font)
        skin->setFont(font);
    skin->setFont(guienv->getBuiltInFont(), EGDF_TOOLTIP);

	// Create scene
	currentScene = new MainMenuScene();
	// Create and start timer
	timer = new Timer();

	wchar_t windowcaption[75];
	const f32 MOVEMENT_SPEED = 5.f;
	//ITimer* timer = device->getTimer();
	//timer->getTime();
	logger->log("Entering game loop");
	while(device->run())
	{
		if (device->isWindowActive()){
			// Start frame
			driver->beginScene(true, true, SColor(0,100,100,130));
			// Check for held down keys and such
			currentScene->inputLoop();
			// For frame dependent game logic
			currentScene->logicsLoop();
			// Draw 3d
			smgr->drawAll();
			// Draw gui
			guienv->drawAll();

			// End frame
			driver->endScene();

			swprintf(windowcaption, 75, L"Johans Irrlicht Demo - FPS: %i", timer->getFPS() );
			device->setWindowCaption(windowcaption);
		}
		device->yield();
		timer->update();
	}
	device->drop();

	return 0;
}
Beispiel #10
0
void GUIAdd(){
	IGUISkin* skin = env->getSkin();
    IGUIFont* font = env->getFont("fontcourier.bmp");
    if (font)
        skin->setFont(font);

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

	box = env->addComboBox(core::rect<s32>(10,400,130,420), 0, GUI_ID_COMBO1);
	box->addItem(L"BASLANGIC0");
    box->addItem(L"Z23");
    box->addItem(L"Z20"); 
    box->addItem(L"Z12");
    box->addItem(L"Z10");
    box->addItem(L"Z05");
    box->addItem(L"Z04");
    box->addItem(L"Z02");
    box->addItem(L"ROBOTIK");
    box->addItem(L"Z06");
    box->addItem(L"Z11");
    box->addItem(L"GENEL_LAB");
    box->addItem(L"KANTIN");

    box->addItem(L"BASLANGIC1");
    box->addItem(L"N123");
    box->addItem(L"N121"); 
    box->addItem(L"N119");
    box->addItem(L"N109");
    box->addItem(L"N104");
    box->addItem(L"N103");
    box->addItem(L"N102");
    box->addItem(L"N101");
    box->addItem(L"N108");
    box->addItem(L"N118");
    box->addItem(L"N120");
    box->addItem(L"N122");
    box->addItem(L"N24");

    box->addItem(L"BASLANGIC2");
    box->addItem(L"N254"); 
    box->addItem(L"N255");
    box->addItem(L"N248");
    box->addItem(L"N208");
    box->addItem(L"N243");
    box->addItem(L"N244");
    box->addItem(L"N239");
    box->addItem(L"N240");
    box->addItem(L"N235");
    box->addItem(L"N234");
    box->addItem(L"N230");
    box->addItem(L"N226");
    box->addItem(L"N221");
    box->addItem(L"N220"); 
    box->addItem(L"N216");
    box->addItem(L"N215");
    box->addItem(L"N212");
    box->addItem(L"N207");
    box->addItem(L"N206");
    box->addItem(L"N205");
    box->addItem(L"N204");
    box->addItem(L"N203");
    box->addItem(L"N202");
    box->addItem(L"N201");
    box->addItem(L"N214");
    box->addItem(L"N213"); 
    box->addItem(L"N219");
    box->addItem(L"N218");
    box->addItem(L"N225");
    box->addItem(L"N229");
    box->addItem(L"N233");
    box->addItem(L"N232");
    box->addItem(L"N237");
    box->addItem(L"N238");
    box->addItem(L"N241");
    box->addItem(L"N242");
    box->addItem(L"N251");
    box->addItem(L"N252");
    box->addItem(L"N253"); 
 

    env->addButton(rect<s32>(140,400,290,420), 0, GUI_ID_BASLANGICAYARLA,
			L"BASLANGIC AYARLA");

    box2 = env->addComboBox(core::rect<s32>(10,430,130,450), 0, GUI_ID_COMBO2);
    box2->addItem(L"BASLANGIC0");
    box2->addItem(L"Z23");
    box2->addItem(L"Z20"); 
    box2->addItem(L"Z12");
    box2->addItem(L"Z10");
    box2->addItem(L"Z05");
    box2->addItem(L"Z04");
    box2->addItem(L"Z02");
    box2->addItem(L"ROBOTIK");
    box2->addItem(L"Z06");
    box2->addItem(L"Z11");
    box2->addItem(L"GENEL_LAB");
    box2->addItem(L"KANTIN");

    box2->addItem(L"BASLANGIC1");
    box2->addItem(L"N123");
    box2->addItem(L"N121"); 
    box2->addItem(L"N119");
    box2->addItem(L"N109");
    box2->addItem(L"N104");
    box2->addItem(L"N103");
    box2->addItem(L"N102");
    box2->addItem(L"N101");
    box2->addItem(L"N108");
    box2->addItem(L"N118");
    box2->addItem(L"N120");
    box2->addItem(L"N122");
    box2->addItem(L"N24");

    box2->addItem(L"BASLANGIC2");
    box2->addItem(L"N254"); 
    box2->addItem(L"N255");
    box2->addItem(L"N248");
    box2->addItem(L"N208");
    box2->addItem(L"N243");
    box2->addItem(L"N244");
    box2->addItem(L"N239");
    box2->addItem(L"N240");
    box2->addItem(L"N235");
    box2->addItem(L"N234");
    box2->addItem(L"N230");
    box2->addItem(L"N226");
    box2->addItem(L"N221");
    box2->addItem(L"N220"); 
    box2->addItem(L"N216");
    box2->addItem(L"N215");
    box2->addItem(L"N212");
    box2->addItem(L"N207");
    box2->addItem(L"N206");
    box2->addItem(L"N205");
    box2->addItem(L"N204");
    box2->addItem(L"N203");
    box2->addItem(L"N202");
    box2->addItem(L"N201");
    box2->addItem(L"N214");
    box2->addItem(L"N213"); 
    box2->addItem(L"N219");
    box2->addItem(L"N218");
    box2->addItem(L"N225");
    box2->addItem(L"N229");
    box2->addItem(L"N233");
    box2->addItem(L"N232");
    box2->addItem(L"N237");
    box2->addItem(L"N238");
    box2->addItem(L"N241");
    box2->addItem(L"N242");
    box2->addItem(L"N251");
    box2->addItem(L"N252");
    box2->addItem(L"N253"); 


	env->addButton(core::rect<s32>(140,430,290,450), 0, GUI_ID_GIT, L"GIT");

    env->addButton(core::rect<s32>(300,430,420,450), 0, GUI_ID_QUIT_BUTTON, L"CIKIS");

    env->addButton(core::rect<s32>(10,460,130,480), 0, GUI_ID_GIT, L"DEVAM");

    myTextBox = env->addStaticText(L"", rect<s32>(300,400,500,420), true);


    env->addButton(core::rect<s32>(140,460,290,480), 0, GUI_ID_ACIL, L"DUR");
}
Beispiel #11
0
/*
 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;
}
Beispiel #12
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;
}
Beispiel #13
0
int main()
{
	// ask user for driver
	video::E_DRIVER_TYPE driverType=driverChoiceConsole(false);
	if (driverType==video::EDT_COUNT)
		return 1;

	IrrlichtDevice *device = createDevice(driverType, core::dimension2du(800, 600));
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment *env = device->getGUIEnvironment();

	device->setResizable(true);

	/*
		first we create the factory which can make new GUI elements
		and register it with the gui environment.
	*/

	IGUIElementFactory* factory = new CGUIEditFactory(env);
	env->registerGUIElementFactory(factory);
	// remember to drop since we created with a create call
	factory->drop();

	IGUISkin *skin = env->createSkin(EGST_WINDOWS_METALLIC);
	env->setSkin(skin);

	IGUIFont *font = env->getFont("../../media/lucida.xml");
	if (font)
		skin->setFont(font);
	skin->drop();

	// change transparency of skin
	for (s32 i=0; i<gui::EGDC_COUNT ; ++i)
	{
		video::SColor col = env->getSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i);
		col.setAlpha(250);
		env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col);
	}

	/*
		now we add the GUI Editor Workspace
	*/

	env->addGUIElement("GUIEditor");

	while(device->run())
	{
		if (!device->isWindowMinimized())
		{
			const core::dimension2d<u32>& screenSize = driver->getScreenSize();
			wchar_t caption[512];
			swprintf(caption, 512, L"screen (%4u/%4u)", screenSize.Width, screenSize.Height);
			device->setWindowCaption(caption);
			driver->beginScene(true, true, video::SColor(0,200,200,200));
			smgr->drawAll();
			env->drawAll();
			driver->endScene();
		}

		// be nice to CPU
		device->sleep(10);
		if (!device->isWindowActive())
			device->sleep(90);
	}

	device->closeDevice();
	device->drop();

	return 0;
}
/** \return Returns a pointer to the created skin.
   If you no longer need the image, you should call IGUISkin::drop().
   See IUnknown::drop() for more information. */
IGUISkin* CGUIEnvironment::createSkin(EGUI_SKIN_TYPE type)
{
	IGUISkin* skin = new CGUISkin(type, Driver);
	skin->setFont(getBuiltInFont());
	return skin;
}
Beispiel #15
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;
}
Beispiel #16
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;
}
Beispiel #17
0
//第一次初始化执行
void main_init_on_login(IrrlichtDevice* device)
{
    guienv = device->getGUIEnvironment();
    guiroot = guienv->addStaticText(L"",
                                    core::rect<s32>(0, 0, 10000, 10000));
    
    the_device = device;
    the_smgr = device->getSceneManager();
    the_driver = device->getVideoDriver();
    
	porting::signal_handler_init();
	porting::initializePaths();
    
	// Create user data directory
	fs::CreateDir(porting::path_user);

    // Initialize default settings
	set_default_settings(g_settings);
	
	// Initialize sockets
	sockets_init();
	atexit(sockets_cleanup);
    
    std::vector<std::string> filenames;
    filenames.push_back(porting::path_user +
                        DIR_DELIM + "settings.conf");
#if RUN_IN_PLACE
    // Try also from a lower level (to aid having the same configuration
    // for many RUN_IN_PLACE installs)
    filenames.push_back(porting::path_user +
                        DIR_DELIM + ".." + DIR_DELIM + ".." + DIR_DELIM + "settings.conf");
#endif
    
    for(u32 i=0; i<filenames.size(); i++)
    {
        bool r = g_settings->readConfigFile(filenames[i].c_str());
        if(r)
        {
            g_settings_configpath = filenames[i];
            break;
        }
    }
    
    // If no path found, use the first one (menu creates the file)
    if(g_settings_configpath == "")
        g_settings_configpath = filenames[0];
    
    // Initialize random seed
	srand(time(0));
	mysrand(time(0));
    
    my_event_receiver.init();
    g_timegetter = new IrrlichtTimeGetter(device);
	
	// Create game callback for menus
	g_gamecallback = new MainGameCallback(device);
    
    bool random_input = false;//g_settings->getBool("random_input");
    
//	if(random_input)
//		input = new RandomInputHandler();
//	else
    {
        touchscreengui = new TouchScreenGUI(device);
        input = touchscreengui;
    }

    
	scene::ISceneManager* smgr = device->getSceneManager();
    //这里保存下原有的skin。从游戏内返回的时候需要重新加载
    IGUISkin* skin = guienv->getSkin();
    //设定一下一些控件的大小
    skin->setSize(EGDS_SCROLLBAR_SIZE, device->getVideoDriver()->getScreenSize().Width * 0.06);
    skin->setSize(EGDS_CHECK_BOX_WIDTH, device->getVideoDriver()->getScreenSize().Width * 0.03);
    skin->setSize(EGDS_BUTTON_WIDTH, device->getVideoDriver()->getScreenSize().Width * 0.1);
    skin->setSize(EGDS_BUTTON_HEIGHT, device->getVideoDriver()->getScreenSize().Width * 0.03);
    skin->setSize(EGDS_WINDOW_BUTTON_WIDTH, device->getVideoDriver()->getScreenSize().Width * 0.05);
    font = skin->getFont();
	if(font)
		skin->setFont(font);
	else
		errorstream<<"WARNING: Font file was not found."
        " Using default font."<<std::endl;
	// If font was not found, this will get us one
    //	font = skin->getFont();
	assert(font);
    
	//skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,0,0,0));
	skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,255,255,255));
	//skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(0,0,0,0));
	//skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(0,0,0,0));
    //	skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255,0,0,0));
    skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255,52,55,64));
	skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255,0,0,0));
    
    //	skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255,70,100,50));
    skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255,  161 , 164 , 179));
	skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255,255,255,255));
    
#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
	// Irrlicht 1.8 input colours
	skin->setColor(gui::EGDC_EDITABLE, video::SColor(255,128,128,128));
	skin->setColor(gui::EGDC_FOCUSED_EDITABLE, video::SColor(255,96,134,49));
#endif

    
    if (!g_menucloudsmgr)
		g_menucloudsmgr = smgr->createNewSceneManager();
	if (!g_menuclouds)
		g_menuclouds = new Clouds(g_menucloudsmgr->getRootSceneNode(),
                                  g_menucloudsmgr, -1, rand(), 100);
	g_menuclouds->update(v2f(0, 0), video::SColor(255,200,200,255));
	scene::ICameraSceneNode* camera;
	camera = g_menucloudsmgr->addCameraSceneNode(0,
                                                 v3f(0,0,0), v3f(0, 60, 100));
	camera->setFarValue(10000);
    
    
    guienv->clear();
    guiroot = guienv->addStaticText(L"",
                                   core::rect<s32>(0, 0, 10000, 10000));
}