public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { var content = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content; _spriteBatch = new SpriteBatch(message.Graphics.GraphicsDevice); if (_ellipse == null) { _ellipse = new Ellipse(content, message.Graphics) { Thickness = OrbitThickness, BlendState = BlendState.Additive }; _ellipse.LoadContent(); } if (_filledEllipse == null) { _filledEllipse = new FilledEllipse(content, message.Graphics) { Gradient = DeadZoneDiffuseWidth, Color = DeadZoneColor, BlendState = BlendState.Additive }; _filledEllipse.LoadContent(); } }
public void Run() { m_factory = new DisposeCollectorResourceFactory(m_gd.ResourceFactory); GraphicsDeviceCreated?.Invoke(m_gd, m_factory, m_gd.MainSwapchain); Stopwatch sw = Stopwatch.StartNew(); double previousElapsed = sw.Elapsed.TotalSeconds; while (m_window.Exists) { double newElapsed = sw.Elapsed.TotalSeconds; float deltaSeconds = (float)(newElapsed - previousElapsed); InputSnapshot inputSnapshot = m_window.PumpEvents(); InputTracker.UpdateFrameInput(inputSnapshot); if (m_window.Exists) { previousElapsed = newElapsed; if (m_windowResized) { m_windowResized = false; m_gd.ResizeMainWindow((uint)m_window.Width, (uint)m_window.Height); Resized?.Invoke(); } Rendering?.Invoke(deltaSeconds); } } m_gd.WaitForIdle(); m_factory.DisposeCollector.DisposeAll(); m_gd.Dispose(); GraphicsDeviceDestroyed?.Invoke(); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { var content = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content; if (_renderer == null) { _renderer = new SpriteBatchRenderer { GraphicsDeviceService = message.Graphics }; } _renderer.LoadContent(content); foreach (var component in Components) { foreach (var effect in component.Effects) { if (effect.Effect == null) { effect.Effect = content.Load <ParticleEffect>(effect.AssetName).DeepCopy(); effect.Effect.LoadContent(content); effect.Effect.Initialise(); } else { effect.Effect.LoadContent(content); } } } foreach (var effect in _effects) { effect.Value.LoadContent(content); } }
public override void ViewDidLoad() { base.ViewDidLoad(); SwapchainSource ss = SwapchainSource.CreateUIView(this.View.Handle); SwapchainDescription scd = new SwapchainDescription( ss, (uint)View.Frame.Width, (uint)View.Frame.Height, PixelFormat.R32_Float, false); if (_backend == GraphicsBackend.Metal) { _gd = GraphicsDevice.CreateMetal(_options); _sc = _gd.ResourceFactory.CreateSwapchain(ref scd); } else if (_backend == GraphicsBackend.OpenGLES) { _gd = GraphicsDevice.CreateOpenGLES(_options, scd); _sc = _gd.MainSwapchain; } else if (_backend == GraphicsBackend.Vulkan) { throw new NotImplementedException(); } GraphicsDeviceCreated?.Invoke(_gd, _gd.ResourceFactory, _sc); _viewLoaded = true; }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { var device = message.Graphics.GraphicsDevice; var content = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content; _spriteBatch = new SpriteBatch(device); _bloomExtractEffect = content.Load <Effect>("Shaders/BloomExtract"); _bloomCombineEffect = content.Load <Effect>("Shaders/BloomCombine"); _gaussianBlurEffect = content.Load <Effect>("Shaders/GaussianBlur"); // Create two rendertargets for the bloom processing. These are half the // size of the backbuffer, in order to minimize fillrate costs. Reducing // the resolution in this way doesn't hurt quality, because we are going // to be blurring the bloom images anyway. var pp = device.PresentationParameters; var width = pp.BackBufferWidth / 2; var height = pp.BackBufferHeight / 2; _renderTarget1 = new RenderTarget2D( device, width, height, false, pp.BackBufferFormat, DepthFormat.None); _renderTarget2 = new RenderTarget2D( device, width, height, false, pp.BackBufferFormat, DepthFormat.None); }
public void Run() { GraphicsDeviceOptions options = new GraphicsDeviceOptions( debug: false, swapchainDepthFormat: PixelFormat.R16_UNorm, syncToVerticalBlank: true, resourceBindingModel: ResourceBindingModel.Improved, preferDepthRangeZeroToOne: true, preferStandardClipSpaceYDirection: true); #if DEBUG options.Debug = true; #endif // construct a graphics device using the default backend. _gd = VeldridStartup.CreateGraphicsDevice(_window, options); // to determine what the default backend is you can run: //VeldridStartup.GetPlatformDefaultBackend() // to specify a specific backend use: //_gd = VeldridStartup.CreateGraphicsDevice(_window, options, GraphicsBackend.Metal); _factory = new DisposeCollectorResourceFactory(_gd.ResourceFactory); GraphicsDeviceCreated?.Invoke(_gd, _factory, _gd.MainSwapchain); Stopwatch sw = Stopwatch.StartNew(); double previousElapsed = sw.Elapsed.TotalSeconds; while (IsWindowOpen()) { double newElapsed = sw.Elapsed.TotalSeconds; float deltaSeconds = (float)(newElapsed - previousElapsed); InputSnapshot inputSnapshot = _window.PumpEvents(); InputTracker.UpdateFrameInput(inputSnapshot); if (_window.Exists) { previousElapsed = newElapsed; if (_windowResized) { _windowResized = false; _gd.ResizeMainWindow((uint)_window.Width, (uint)_window.Height); Resized?.Invoke(); } Rendering?.Invoke(deltaSeconds); } } Shutdown?.Invoke(); _gd.WaitForIdle(); _factory.DisposeCollector.DisposeAll(); _gd.Dispose(); GraphicsDeviceDestroyed?.Invoke(); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { if (_sun == null) { _sun = new Sun(((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content, message.Graphics); _sun.LoadContent(); } }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { _spriteBatch = new SpriteBatch(message.Graphics.GraphicsDevice); var content = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content; _font = content.Load <SpriteFont>("Fonts/ConsoleFont"); _arrow = content.Load <Texture2D>("Textures/arrow"); }
public void Run() { var options = new GraphicsDeviceOptions( false, PixelFormat.R16_UNorm, true, ResourceBindingModel.Improved, true, true); #if DEBUG options.Debug = true; #endif GraphicsDevice gd; if (_options.GraphicsBackend.HasValue) { gd = VeldridStartup.CreateGraphicsDevice(_window, options, _options.GraphicsBackend.Value); } else { gd = VeldridStartup.CreateGraphicsDevice(_window, options); } var factory = new DisposeCollectorResourceFactory(gd.ResourceFactory); _veldrid = new VeldridContext(gd, factory, gd.MainSwapchain); GraphicsDeviceCreated?.Invoke(_veldrid); var sw = Stopwatch.StartNew(); var previousElapsed = sw.Elapsed.TotalSeconds; while (_window.Exists) { var newElapsed = sw.Elapsed.TotalSeconds; var deltaSeconds = (float)(newElapsed - previousElapsed); var inputSnapshot = _window.PumpEvents(); if (_window.Exists) { previousElapsed = newElapsed; if (_windowResized) { _windowResized = false; gd.ResizeMainWindow((uint)_window.Width, (uint)_window.Height); Resized?.Invoke(); } Rendering?.Invoke(deltaSeconds); } } gd.WaitForIdle(); factory.DisposeCollector.DisposeAll(); gd.Dispose(); GraphicsDeviceDestroyed?.Invoke(); }
private void CreateDevice() { var options = new GraphicsDeviceOptions(true, PixelFormat.R32_Float, true, ResourceBindingModel.Improved); var logicalDpi = 96.0f * CompositionScaleX; var renderWidth = RenderSize.Width; var renderHeight = RenderSize.Height; _graphicsDevice = GraphicsDevice.CreateD3D11(options, this, renderWidth, renderHeight, logicalDpi); _resources = new DisposeCollectorResourceFactory(_graphicsDevice.ResourceFactory); GraphicsDeviceCreated?.Invoke(_graphicsDevice, _resources, _graphicsDevice.MainSwapchain); }
private Game() { Content.RootDirectory = "Content"; Window.Title = "Hero6"; var services = new MonoGameServiceLocator(Services); services.Add <IPlatformInfo, PlatformInfo>(); services.Add <IServiceLocator>(services); services.Add <IFileWrapper, FileWrapper>(); services.Add <IDirectoryWrapper, DirectoryWrapper>(); ui = services.Make <MonoGameUserInterfaces>(); services.Add <IUserInterfaces>(ui); gameSettings = new GameSettings(ui); services.Add <IGameSettings>(gameSettings); var userSettings = services.Make <UserSettings>(typeof(UserSettings)); services.Add <IUserSettings>(userSettings); services.Add <ILoggerCore, LoggerCore>(); logger = services.Make <Logger>(typeof(Logger)); services.Add <IMouseCore, MouseCore>(); services.Add <ILogger>(logger); services.Add <IControllerRepository, ControllerRepositoryProvider>(); services.Add(Content); campaigns = services.Make <MonoGameCampaigns>(); services.Add <ICampaigns>(campaigns); services.Add <IMouse, Mouse>(); var graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = userSettings.WindowWidth, PreferredBackBufferHeight = userSettings.WindowHeight, IsFullScreen = userSettings.IsFullScreen, GraphicsProfile = GraphicsProfile.Reach, #if ANDROID SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight #endif }; graphics.DeviceCreated += (s, a) => { spriteBatch = new SpriteBatch(GraphicsDevice); services.Add(graphics); services.Add(spriteBatch); logger.Info("Graphics Device Created."); logger.Info($"Graphics Adapter Width {GraphicsDevice.Adapter.CurrentDisplayMode.Width}"); logger.Info($"Graphics Adapter Height {GraphicsDevice.Adapter.CurrentDisplayMode.Height}"); logger.Info($"Graphics Adapter Aspect Ratio {GraphicsDevice.Adapter.CurrentDisplayMode.AspectRatio}"); GraphicsDeviceCreated?.Invoke(s, a); }; logger.Info("Hero6 Game Instance Created."); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { _spriteBatch = new SpriteBatch(message.Graphics.GraphicsDevice); var content = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content; _textures.Add(Fuselage.TypeId, content.Load <Texture2D>("Textures/Items/mountpoint_fuselage")); _textures.Add(Reactor.TypeId, content.Load <Texture2D>("Textures/Items/mountpoint_reactor")); _textures.Add(Sensor.TypeId, content.Load <Texture2D>("Textures/Items/mountpoint_sensor")); _textures.Add(Shield.TypeId, content.Load <Texture2D>("Textures/Items/mountpoint_shield")); _textures.Add(Thruster.TypeId, content.Load <Texture2D>("Textures/Items/mountpoint_thruster")); _textures.Add(Weapon.TypeId, content.Load <Texture2D>("Textures/Items/mountpoint_weapon")); _textures.Add(Wing.TypeId, content.Load <Texture2D>("Textures/Items/mountpoint_wing")); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { var pp = message.Graphics.GraphicsDevice.PresentationParameters; _scene = new RenderTarget2D( message.Graphics.GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, false, pp.BackBufferFormat, DepthFormat.None, pp.MultiSampleCount, RenderTargetUsage.PreserveContents); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { _spriteBatch = new SpriteBatch(message.Graphics.GraphicsDevice); var content = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content; foreach (var background in _backgrounds) { for (var i = 0; i < background.TextureNames.Length; i++) { background.Textures[i] = content.Load <Texture2D>(background.TextureNames[i]); } } }
public void Run() { GraphicsDeviceOptions options = new GraphicsDeviceOptions( debug: false, swapchainDepthFormat: PixelFormat.R16_UNorm, syncToVerticalBlank: true, resourceBindingModel: ResourceBindingModel.Improved, preferDepthRangeZeroToOne: true, preferStandardClipSpaceYDirection: true); #if DEBUG options.Debug = true; #endif GD = VeldridStartup.CreateGraphicsDevice(Window, options, GraphicsBackend.Direct3D11); Factory = new DisposeCollectorResourceFactory(GD.ResourceFactory); GraphicsDeviceCreated?.Invoke(GD, Factory, GD.MainSwapchain); Stopwatch sw = Stopwatch.StartNew(); double previousElapsed = sw.Elapsed.TotalSeconds; long ticks = 0; while (Window.Exists) { double newElapsed = sw.Elapsed.TotalSeconds; float deltaSeconds = (float)(newElapsed - previousElapsed); InputSnapshot inputSnapshot = Window.PumpEvents(); InputTracker.UpdateFrameInput(inputSnapshot); if (Window.Exists) { previousElapsed = newElapsed; if (WindowResized) { WindowResized = false; GD.ResizeMainWindow((uint)Window.Width, (uint)Window.Height); Resized?.Invoke(); } Rendering?.Invoke(deltaSeconds, ticks++); } } GD.WaitForIdle(); Factory.DisposeCollector.DisposeAll(); GD.Dispose(); GraphicsDeviceDestroyed?.Invoke(); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { _spriteBatch = new SpriteBatch(message.Graphics.GraphicsDevice); var content = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content; _radarDirection[(int)RadarDirection.Top] = content.Load <Texture2D>("Textures/Radar/top"); _radarDirection[(int)RadarDirection.Left] = content.Load <Texture2D>("Textures/Radar/left"); _radarDirection[(int)RadarDirection.Right] = content.Load <Texture2D>("Textures/Radar/right"); _radarDirection[(int)RadarDirection.Bottom] = content.Load <Texture2D>("Textures/Radar/bottom"); _radarDirection[(int)RadarDirection.TopLeft] = content.Load <Texture2D>("Textures/Radar/top_left"); _radarDirection[(int)RadarDirection.TopRight] = content.Load <Texture2D>("Textures/Radar/top_right"); _radarDirection[(int)RadarDirection.BottomLeft] = content.Load <Texture2D>("Textures/Radar/bottom_left"); _radarDirection[(int)RadarDirection.BottomRight] = content.Load <Texture2D>("Textures/Radar/bottom_right"); _radarDistance = content.Load <Texture2D>("Textures/Radar/distance"); _distanceFont = content.Load <SpriteFont>("Fonts/visitor"); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { var content = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content; if (_shader == null) { _shader = new Graphics.Shield(content, message.Graphics); _shader.LoadContent(); } foreach (var component in _shields) { if (!string.IsNullOrWhiteSpace(component.Factory.Structure)) { component.Structure = content.Load <Texture2D>(component.Factory.Structure); } } }
public void Run() { GraphicsDeviceOptions options = new GraphicsDeviceOptions( debug: false, swapchainDepthFormat: PixelFormat.R16_UNorm, syncToVerticalBlank: true, resourceBindingModel: ResourceBindingModel.Improved); #if DEBUG options.Debug = true; #endif _gd = VeldridStartup.CreateGraphicsDevice(_window, options); _factory = new DisposeCollectorResourceFactory(_gd.ResourceFactory); GraphicsDeviceCreated?.Invoke(_gd, _factory, _gd.MainSwapchain); Stopwatch sw = Stopwatch.StartNew(); double previousElapsed = sw.Elapsed.TotalSeconds; while (_window.Exists) { double newElapsed = sw.Elapsed.TotalSeconds; float deltaSeconds = (float)(newElapsed - previousElapsed); InputSnapshot inputSnapshot = _window.PumpEvents(); InputTracker.UpdateFrameInput(inputSnapshot); if (_window.Exists) { previousElapsed = newElapsed; if (_windowResized) { _windowResized = false; _gd.ResizeMainWindow((uint)_window.Width, (uint)_window.Height); Resized?.Invoke(); } Rendering?.Invoke(deltaSeconds); } } _gd.WaitForIdle(); _factory.DisposeCollector.DisposeAll(); _gd.Dispose(); GraphicsDeviceDestroyed?.Invoke(); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { var content = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content; if (_planet == null) { _planet = new Planet(content, message.Graphics); _planet.LoadContent(); } foreach (var component in Components) { var factory = component.Factory; if (factory == null) { continue; } LoadPlanetTextures(factory, component, content); } }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { _spriteBatch = new SpriteBatch(message.Graphics.GraphicsDevice); _font = ((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content.Load <SpriteFont>("Fonts/bauhaus"); }
private void OnViewCreatedDevice() { _disposeFactory = _view.GraphicsDevice.ResourceFactory; GraphicsDeviceCreated?.Invoke(_view.GraphicsDevice, _disposeFactory, _view.MainSwapchain); Resized?.Invoke(); }
public unsafe UserControl1() { try { InitializeComponent(); if (this.DesignMode) { return; } this.MouseWheel += UserControl1_MouseWheel; //释放组件 Disposed += OnDispose; //this.MouseMove += UserControl1_MouseMove ; GraphicsDeviceOptions options = new GraphicsDeviceOptions( debug: false, swapchainDepthFormat: PixelFormat.R16_UNorm, syncToVerticalBlank: true, resourceBindingModel: ResourceBindingModel.Improved); #if DEBUG options.Debug = true; #endif //获取当前窗体的Hwnd var hwnd = this.Handle; var p = hwnd.ToPointer(); //这里创建的sld windows消息捕获出现了问题, //获取运行进程的handle var instance = Process.GetCurrentProcess().Handle; _gd = VeldridStartup.CreateVulkanGraphicsDeviceForWin32(options, hwnd, instance, this.Width, this.Height); _factory = new DisposeCollectorResourceFactory(_gd.ResourceFactory); _scene = new PongGlobe.Scene.Scene(this.Width, this.Height); var globeRender = new RayCastedGlobe(_scene); var shareRender = new ShareRender(_scene); this.renders.Add(shareRender); this.renders.Add(globeRender); //创建完相关对象后注册事件 this.GraphicsDeviceCreated += OnGraphicsDeviceCreated; this.GraphicsDeviceDestroyed += OnDeviceDestroyed; this.Rendering += PreDraw; this.Rendering += Draw; GraphicsDeviceCreated?.Invoke(_gd, _factory, _gd.MainSwapchain); _window = new Sdl2Window(hwnd, false); //创建一个计时器 sw = Stopwatch.StartNew(); previousElapsed = sw.Elapsed.TotalSeconds; //this.ParentForm.Shown += ParentForm_Shown; //开始运行 //Run(); //创建一个线程执行run,使用多线程之后便需要考虑不同线程变量同步的问题了,例如isrunning变量的修改需要lock之后再修改,有时可以使用线程安全的集合来处理不同线程的变量交换, //c#封装了很多,这些都不是问题_coomadList并不是线程安全的,在主线程创建,在子线程使用,这样问题并不大,当时两个子线程同时使用commandLits便可能出现问题 //这里的渲染仍然是单线程的,每个不同的render都可以独开线程并提交渲染任务 _renderTask = Task.Factory.StartNew(() => { Run(); }); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public static void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { LoadContent(message.Graphics); }
private static void OnGraphicsDeviceCreated(object sender, EventArgs e) { GraphicsDeviceCreated?.Invoke(sender, e); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { _graphicsDevice = message.Graphics.GraphicsDevice; _primitiveBatch = new PrimitiveBatch(_graphicsDevice); }
public void OnGraphicsDeviceCreated(GraphicsDeviceCreated message) { LoadContent(((ContentSystem)Manager.GetSystem(ContentSystem.TypeId)).Content, message.Graphics); }