public MyEventReceiver(IrrlichtDevice device, SceneNode room, SceneNode earth) { device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent); // store pointer to room so we can change its drawing mode this.driver = device.VideoDriver; this.room = room; this.earth = earth; GUIEnvironment env = device.GUIEnvironment; // set a nicer font GUIFont font = env.GetFont("../../media/fonthaettenschweiler.bmp"); if (font != null) { env.Skin.SetFont(font); } // add window and listbox GUIWindow window = env.AddWindow(new Recti(460, 375, 630, 470), false, "Use 'E' + 'R' to change"); this.listBox = env.AddListBox(new Recti(2, 22, 165, 88), window); this.listBox.AddItem("Diffuse"); this.listBox.AddItem("Bump mapping"); this.listBox.AddItem("Parallax mapping"); this.listBox.SelectedIndex = 1; // create problem text this.problemText = env.AddStaticText( "Your hardware or this renderer is not able to use the needed shaders for this material. Using fall back materials.", new Recti(150, 20, 470, 80)); this.problemText.OverrideColor = new Color(255, 255, 255, 100); // set start material (prefer parallax mapping if available) MaterialRenderer renderer = this.driver.GetMaterialRenderer(MaterialType.ParallaxMapSolid); if (renderer != null && renderer.Capability == 0) { this.listBox.SelectedIndex = 2; } // set the material which is selected in the listbox setMaterial(); }
static void Main(string[] args) { DriverType driverType; if (!AskUserForDriver(out driverType)) { return; } device = IrrlichtDevice.CreateDevice(driverType, new Dimension2Di(640, 480)); if (device == null) { return; } device.SetWindowCaption("Irrlicht Engine - User Interface Demo"); device.SetWindowResizable(true); VideoDriver driver = device.VideoDriver; GUIEnvironment env = device.GUIEnvironment; GUISkin skin = env.Skin; GUIFont font = env.GetFont("../../media/fonthaettenschweiler.bmp"); if (font != null) { skin.SetFont(font); } skin.SetFont(env.BuiltInFont, GUIDefaultFont.Tooltip); env.AddButton(new Recti(10, 240, 110, 240 + 32), null, GUI_ID_ButtonQuit, "Quit", "Exits Program"); env.AddButton(new Recti(10, 280, 110, 280 + 32), null, GUI_ID_ButtonWindowNew, "New Window", "Launches a new Window"); env.AddButton(new Recti(10, 320, 110, 320 + 32), null, GUI_ID_ButtonFileOpen, "File Open", "Opens a file"); env.AddStaticText("Transparent Control:", new Recti(150, 20, 350, 40), true); GUIScrollBar scrollbar = env.AddScrollBar(true, new Recti(150, 45, 350, 60), null, GUI_ID_ScrollbarTransparency); scrollbar.MaxValue = 255; scrollbar.Position = (int)env.Skin.GetColor(GUIDefaultColor.WindowBackground).Alpha; GUIStaticText trq = env.AddStaticText("Logging ListBox:", new Recti(50, 110, 250, 130), true); listbox = env.AddListBox(new Recti(50, 140, 250, 210)); env.AddEditBox("Editable Text", new Recti(350, 80, 550, 100)); device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent); env.AddImage(driver.GetTexture("../../media/irrlichtlogoalpha2.tga"), new Vector2Di(10, 10)); while (device.Run()) { if (device.WindowActive) { driver.BeginScene(true, true, new Color(200, 200, 200)); env.DrawAll(); driver.EndScene(); } } device.Drop(); }