/// <summary> /// Constructs a DisplayWindow from a resource. /// </summary> /// <param name="resources"></param> /// <param name="name"></param> public DisplayWindow(Resources.AgateResourceCollection resources, string name) { Resources.AgateResource res = resources[name]; Resources.DisplayWindowResource disp = res as Resources.DisplayWindowResource; if (disp == null) { throw new Resources.AgateResourceException("Resource " + name + " was found, but was of type " + name.GetType().ToString() + ", not DisplayWindowResource."); } if (disp.FullScreen) { CreateWindowParams par = CreateWindowParams.FullScreen( disp.Title, disp.Size.Width, disp.Size.Height, disp.Bpp); impl = Display.Impl.CreateDisplayWindow(par); } else { CreateWindowParams par = CreateWindowParams.Windowed( disp.Title, disp.Size.Width, disp.Size.Height, disp.AllowResize, null); impl = Display.Impl.CreateDisplayWindow(par); } Display.RenderTarget = this; Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); }
/// <summary> /// Creates a surface object from a resource. /// </summary> /// <param name="resources"></param> /// <param name="name"></param> public Surface(Resources.AgateResourceCollection resources, string name) { if (Display.Impl == null) { throw new AgateException("AgateLib's display system has not been initialized."); } Resources.AgateResource res = resources[name]; Resources.SurfaceResource surf = res as Resources.SurfaceResource; impl = resources.LoadSurfaceImpl(surf.Filename); Display.DisposeDisplay += new Display.DisposeDisplayHandler(Dispose); Display.PackAllSurfacesEvent += new EventHandler(Display_PackAllSurfacesEvent); }