public Initialize ( bool autoCreateWindow ) : Axiom.Graphics.RenderWindow | ||
autoCreateWindow | bool | /// If true, a rendering window will automatically be created. The window will be /// created based on the options currently set on the render system. /// |
return | Axiom.Graphics.RenderWindow |
static void Main(string[] args) { IConfigurationManager ConfigurationManager = ConfigurationManagerFactory.CreateDefault(); using (Root _root = new Root("game.log")) { ConfigurationManager.RestoreConfiguration(_root); if (ConfigurationManager.ShowConfigDialog(_root)) { ConfigurationManager.SaveConfiguration(_root); using (RenderWindow _renderWindow = _root.Initialize(true, "Illisian.Niva")) { var game = new Game(_root, _renderWindow); WindowEventMonitor.Instance.RegisterListener(_renderWindow, game); game.OnLoad(); game.CreateScene(); _root.FrameRenderingQueued += game.OnRenderFrame; _root.FrameStarted += game.UpdateInput; _root.FrameStarted += game.UpdateOverlay; _root.FrameEnded += game.OnRenderFrameEnd; _root.StartRendering(); game.OnUnload(); } } } }
private static void Main() { using (var r = new Root()) { r.RenderSystem = r.RenderSystems[0]; using (r.Initialize(true)) { var win = new DemoWindow(r); win.OnLoad(); r.FrameRenderingQueued += win.OnRenderFrame; r.StartRendering(); win.OnUnload(); } } }
private static void Main() { using (var r = new Root()) { if (r.RenderSystems.Count == 0) throw new Exception("No Rendersystem found"); Console.WriteLine("Select a Rendersystem"); for (var i = 0; i < r.RenderSystems.Count; i++) Console.WriteLine("{0}: {1}", i + 1, r.RenderSystems[i].Name); while (true) { int index; if (!int.TryParse(Console.ReadKey(true).KeyChar.ToString(), out index)) continue; if (index < 1) continue; index--; if (index >= r.RenderSystems.Count) continue; r.RenderSystem = r.RenderSystems[index]; break; } using (r.Initialize(true)) { var win = new DemoWindow(r, r.AutoWindow); win.OnLoad(); r.FrameRenderingQueued += win.OnRenderFrame; r.StartRendering(); win.OnUnload(); } } }
/// <summary> /// Overridden to switch to event based keyboard input. /// </summary> /// <returns></returns> protected bool Setup() { // get a reference to the engine singleton engine = new Root(null, null); engine.FixedFPS = fixedFPS; // If the user supplied the command-line arg, limit the // FPS. In any case, limit the frame rate to 100 fps, // since this prevents the render loop spinning when // rendering isn't happening if (maxFPS > 0) engine.MaxFramesPerSecond = maxFPS; else engine.MaxFramesPerSecond = 100; // add event handlers for frame events engine.FrameStarted += new FrameEvent(OnFrameStarted); engine.FrameEnded += new FrameEvent(OnFrameEnded); // Set up our game specific logic // gameWorld = new BetaWorld(this); worldManager = new WorldManager(); gameWorld.WorldManager = worldManager; //if (standalone) { // networkHelper = new LoopbackNetworkHelper(worldManager); //} else networkHelper = new NetworkHelper(worldManager); if (standalone) this.LoopbackWorldServerEntry = networkHelper.GetWorldEntry("standalone"); if (this.LoopbackWorldServerEntry != null) { string worldId = this.LoopbackWorldServerEntry.WorldName; // Bypass the login and connection to master server loginSettings.worldId = worldId; networkHelper.SetWorldEntry(worldId, this.LoopbackWorldServerEntry); networkHelper.MasterToken = this.LoopbackIdToken; networkHelper.OldToken = this.LoopbackOldToken; } else { // Show the login dialog. If we successfully return from this // we have initialized the helper's world entry map with the // resolveresponse data. if (!ShowLoginDialog(networkHelper)) return false; } // Update our media tree (base this on the world to which we connect) WorldServerEntry entry = networkHelper.GetWorldEntry(loginSettings.worldId); // If they specify an alternate location for the media patcher, // use that. if (this.WorldPatcherUrl != null) entry.PatcherUrl = this.WorldPatcherUrl; if (this.WorldUpdateUrl != null) entry.UpdateUrl = this.WorldUpdateUrl; if (this.PatchMedia && entry.PatcherUrl != null && entry.PatcherUrl != string.Empty && entry.UpdateUrl != null && entry.UpdateUrl != string.Empty) { // Fetch the appropriate media (full scan) if (!UpdateWorldAssets(entry.WorldRepository, entry.PatcherUrl, entry.UpdateUrl, fullScan)) return false; } // exit the client after patching media if flag is set if (this.ExitAfterMediaPatch) { return false; } // If we aren't overriding the repository, and we could have // updated, use the world directory. If we don't have an // update url for some reason, use the default repository. if (!useRepository && entry.UpdateUrl != null && entry.UpdateUrl != string.Empty) this.RepositoryPaths = entry.WorldRepositoryDirectories; // Tell the engine where to find media SetupResources(this.RepositoryPaths); // We need to load the Movie plugin here. PluginManager.Instance.LoadPlugins(".", "Multiverse.Movie.dll"); // Set up the scripting system log.Debug("Client.Startup: Loading UiScripting"); UiScripting.SetupInterpreter(); UiScripting.LoadCallingAssembly(); log.Debug("Client.Startup: Finished loading UiScripting"); log.Debug("Client.Startup: Loading Assemblies"); ArrayList assemblies = PluginManager.Instance.GetAssemblies(); foreach (Assembly assembly in assemblies) { UiScripting.LoadAssembly(assembly); } log.Debug("Client.Startup: Finished loading Assemblies"); // Run script that contains world-specific initializations // that must be performed before the display device is // created. But for upward compatibility, if we can't // find the file, don't throw an error. UiScripting.RunFile("ClientInit.py"); // Wait til now to set the networkHelper.UseTCP flag, // because the ClientInit.py may have overriden it. networkHelper.UseTCP = this.UseTCP; // Register our handlers. We must do this before we call // MessageDispatcher.Instance.HandleMessageQueue, so that we will // get the callbacks for the incoming messages. SetupMessageHandlers(); string initialLoadBitmap = ""; if (File.Exists(MultiverseLoadScreen)) initialLoadBitmap = MultiverseLoadScreen; // show the config dialog and collect options if (!Configurate()) { log.Warn("Failed to configure system"); // shutting right back down engine.Shutdown(); throw new ClientException("Failed to configure system"); // return false; } // setup the engine log.Debug("Client.Startup: Calling engine.Initialize()"); window = engine.Initialize(true, "Multiverse World Browser", initialLoadBitmap); log.Debug("Client.Startup: Finished engine.Initialize()"); try { System.Windows.Forms.Control control = window.GetCustomAttribute("HWND") as System.Windows.Forms.Control; System.Windows.Forms.Form f = control.FindForm(); if (allowResize) { if (!window.IsFullScreen) f.MaximizeBox = true; f.Resize += this.OnResize; f.ResizeEnd += this.OnResizeEnd; } f.Closing += new System.ComponentModel.CancelEventHandler(this.OnClosing); } catch (Exception) { log.Warn("Unable to register closing event handler"); } try { System.Windows.Forms.Control control = window.GetCustomAttribute("HWND") as System.Windows.Forms.Control; System.Windows.Forms.Form f = control.FindForm(); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetEntryAssembly(); Stream iconStream = assembly.GetManifestResourceStream("MultiverseClient.MultiverseIcon.ico"); control.FindForm().Icon = new System.Drawing.Icon(iconStream); } catch (Exception e) { LogUtil.ExceptionLog.Warn("Unable to load or apply MultiverseIcon. Using default instead"); LogUtil.ExceptionLog.InfoFormat("Exception Detail: {0}", e); } // Tell the MeterManager where it should write logs MeterManager.MeterEventsFile = MeterEventsFile; MeterManager.MeterLogFile = MeterLogFile; // This seems to need the window object to have been initialized TextureManager.Instance.DefaultNumMipMaps = 5; ChooseSceneManager(); // Set up my timers so that I can see how much time is spent in // the various render queues. scene.QueueStarted += new RenderQueueEvent(scene_OnQueueStarted); scene.QueueEnded += new RenderQueueEvent(scene_OnQueueEnded); // XXXMLM - force a reference to the assembly for script reflection log.Debug("Client.Startup: Calling Multiverse.Web.Browser.RegisterForScripting()"); Multiverse.Web.Browser.RegisterForScripting(); log.Debug("Client.Startup: Finished Multiverse.Web.Browser.RegisterForScripting()"); log.Debug("Client.Startup: Calling SetupGui()"); SetupGui(); // Tell Windows that the widget containing the DirectX // screen should now be visible. This may not be the // right place to do this. window.PictureBoxVisible = true; // Set the scene manager worldManager.SceneManager = scene; // Set up a default ambient light for the scene manager scene.AmbientLight = ColorEx.Black; // Sets up the various things attached to the world manager, // as well as registering the various message handlers. // This also initializes the networkHelper. worldManager.Init(rootWindow, this); // At this point, I can have a camera CreateCamera(); // #if !PERFHUD_BUILD inputHandler = new DefaultInputHandler(this); // inputHandler.InitViewpoint(worldManager.Player); // #endif CreateViewports(); // call the overridden CreateScene method CreateScene(); // Set up our game specific stuff (right now, just betaworld) gameWorld.Initialize(); gameWorld.SetupMessageHandlers(); needConnect = true; // retrieve and initialize the input system // input = PlatformManager.Instance.CreateInputReader(); // input.Initialize(window, true, true, false, false); // Initialize the client API and load world specific scripts ClientAPI.InitAPI(gameWorld); Monitor.Enter(scene); log.InfoFormat("Client setup complete at {0}", DateTime.Now); // At this point, you can create timer events. return true; }