public void addRenderSystem(RenderSystem newRend) { Root_addRenderSystem(ogreRoot, newRend.OgreRenderSystem); }
public void setRenderSystem(RenderSystem system) { Root_setRenderSystem(ogreRoot, system.OgreRenderSystem); }
public void initialize(PluginManager pluginManager, IServiceCollection serviceCollection) { //Load config new OgreConfig(pluginManager.ConfigFile); chosenRenderSystem = OgreConfig.RenderSystemType; //Setup ogre root root = new Root("", "", ""); renderSystemPlugin = OgreInterface_LoadRenderSystem(ref chosenRenderSystem); ogreUpdate = new OgreUpdate(root); instance = this; WindowInfo defaultWindowInfo; pluginManager.setRendererPlugin(this, out defaultWindowInfo); try { //Initialize Ogre rs = root._getRenderSystemWrapper(OgreInterface_GetRenderSystem(ref chosenRenderSystem)); root.setRenderSystem(rs); root.initialize(false); //Create the default window. Dictionary <String, String> miscParams = new Dictionary <string, string>(); String fsaa = OgreConfig.FSAA; if (fsaa.Contains("Quality")) { miscParams.Add("FSAAHint", "Quality"); } int spaceIndex = fsaa.IndexOf(' '); if (spaceIndex != -1) { fsaa = fsaa.Substring(0, spaceIndex); } miscParams.Add("FSAA", fsaa); miscParams.Add("vsync", OgreConfig.VSync.ToString()); miscParams.Add("monitorIndex", defaultWindowInfo.MonitorIndex.ToString()); miscParams.Add("useNVPerfHUD", OgreConfig.UseNvPerfHUD.ToString()); miscParams.Add("contentScalingFactor", defaultWindowInfo.ContentScalingFactor.ToString()); if (defaultWindowInfo.AutoCreateWindow) { RenderWindow renderWindow = root.createRenderWindow(defaultWindowInfo.AutoWindowTitle, (uint)defaultWindowInfo.Width, (uint)defaultWindowInfo.Height, defaultWindowInfo.Fullscreen, miscParams); OgreOSWindow ogreWindow = new OgreOSWindow(renderWindow); primaryWindow = new AutomaticWindow(ogreWindow); } else { miscParams.Add("externalWindowHandle", defaultWindowInfo.EmbedWindow.WindowHandle.ToString()); RenderWindow renderWindow = root.createRenderWindow(defaultWindowInfo.AutoWindowTitle, (uint)defaultWindowInfo.Width, (uint)defaultWindowInfo.Height, defaultWindowInfo.Fullscreen, miscParams); primaryWindow = new EmbeddedWindow(defaultWindowInfo.EmbedWindow, renderWindow); } if (InitialClearColor.HasValue) { rs.clearFrameBuffer(FrameBufferType.FBT_COLOUR, InitialClearColor.Value); primaryWindow.OgreRenderTarget.update(true); } defaultWindowInfo._fireWindowCreated(new WindowInfoEventArgs(primaryWindow)); //Setup compressed textures SelectedTextureFormat = OgreInterface_SetupVaryingCompressedTextures(CompressedTextureSupport); //Setup commands pluginManager.addCreateSimElementManagerCommand(new AddSimElementManagerCommand("Create Ogre Scene Manager", OgreSceneManagerDefinition.Create)); pluginManager.addCreateSimElementCommand(new AddSimElementCommand("Create Ogre Scene Node", SceneNodeDefinition.Create)); //Setup shader cache if (MicrocodeCachePath != null) { GpuProgramManager.Instance.SaveMicrocodesToCache = true; if (File.Exists(MicrocodeCachePath)) { if (AllowMicrocodeCacheLoad) { using (Stream stream = File.OpenRead(MicrocodeCachePath)) { GpuProgramManager.Instance.loadMicrocodeCache(stream); Log.Info("Using microcode cache {0}", MicrocodeCachePath); } } else { deleteMicrocodeCache(); } } } //Setup Resources pluginManager.addSubsystemResources("Ogre", OgreResourceManager.Instance); //Setup the device lost listener. deviceLostListener = new DeviceLostListener(); rs.addListener(deviceLostListener); serviceCollection.TryAddSingleton <Root>(this.root); //This is externally owned serviceCollection.TryAddSingleton <RendererWindow>(this.PrimaryWindow); //This is externally owned serviceCollection.TryAddSingleton <RenderTarget>(this.OgrePrimaryWindow.OgreRenderTarget); //This is externally owned serviceCollection.TryAddSingleton <SceneViewLightManager>(s => s.GetRequiredService <PluginManager>().RendererPlugin.createSceneViewLightManager()); serviceCollection.TryAddSingleton <FrameClearManager>(s => new FrameClearManager(s.GetRequiredService <RenderTarget>(), Color.FromRGB(0x333333))); } catch (Exception e) { throw new InvalidPluginException(String.Format("Exception initializing renderer. Message: {0}", e.Message), e); } }