public LightingManager(IGameContext gameContext, IGameProperties gameProperties, IMeshManager meshManager, IMaterialManager materialManager, ITextureManager textureManager, IRenderManager renderManager, CameraManager cameraManager, LightStore lightStore, ILightManager lightManager, TimeManager timeManager) { this.gameContext = gameContext; this.gameProperties = gameProperties; this.meshManager = meshManager; this.textureManager = textureManager; this.renderManager = renderManager; this.cameraManager = cameraManager; this.lightStore = lightStore; this.lightManager = lightManager; this.timeManager = timeManager; skySphereMesh = meshManager.CreateMesh(ObjParser.LoadObj("meshes/skysphere.obj").MeshData); skyMaterial = materialManager.CreateMaterial("data/skybox.json"); noiseTexture = textureManager.LoadTexture("textures/noise_512.png"); skyMaterial.SetTexture("cloudsTex", noiseTexture); }
public IEnumerable <IRenderable> UpdatePerFrameResources(IRendererContext context, IEnumerable <IRenderable> renderables) { var c = (VeldridRendererContext)context; var gd = c.GraphicsDevice; if (!(renderables.FirstOrDefault() is SkyboxRenderable skybox)) { yield break; } ITextureManager textureManager = Resolve <ITextureManager>(); IDeviceObjectManager objectManager = Resolve <IDeviceObjectManager>(); textureManager?.PrepareTexture(skybox.Texture, context); TextureView textureView = (TextureView)textureManager?.GetTexture(skybox.Texture); var resourceSet = objectManager.Get <ResourceSet>((skybox, textureView)); if (resourceSet == null) { resourceSet = gd.ResourceFactory.CreateResourceSet(new ResourceSetDescription( _resourceLayout, gd.PointSampler, textureView, _uniformBuffer)); resourceSet.Name = $"RS_Sky:{skybox.Texture.Name}"; PerfTracker.IncrementFrameCounter("Create ResourceSet"); objectManager.Set((skybox, textureView), resourceSet); } yield return(skybox); }
public MainMenuState(Game game) : base(game) { game.Services.AddService(typeof(IMainMenuState), this); textureManager = (ITextureManager)game.Services.GetService(typeof(ITextureManager)); }
private SFMLGraphics2D() { m_PostOffice = null; m_RenderWindow = null; m_SpriteManager = null; m_GraphicsSettings = null; m_ModuleID = Constant.enumModuleID.GRAPHICS; m_MsgTypeArray = new Constant.enumMessage[] { Constant.enumMessage.INITIALISE, Constant.enumMessage.UPDATE, Constant.enumMessage.DRAW, Constant.enumMessage.CLOSING, Constant.enumMessage.LOAD_TEXTURES, Constant.enumMessage.UPDATE_GRAPHICS_SETTINGS, Constant.enumMessage.SWITCH_SPRITES_DRAW_STATUS, Constant.enumMessage.GET_GRAPHICS_SETTINGS, Constant.enumMessage.SEND_GAMEOBJECT, Constant.enumMessage.SEND_SPRITE_COMPONENTS, Constant.enumMessage.SEND_POSITION_COMPONENTS, Constant.enumMessage.SEND_TEXTURE_IDS, Constant.enumMessage.SEND_COMPONENTS, Constant.enumMessage.SEND_GAMEOBJECT, Constant.enumMessage.SEND_KEYBOARD_EVENT_HANDLER, Constant.enumMessage.SEND_MOUSE_BUTTON_EVENT_HANDLER, Constant.enumMessage.SEND_MOUSE_MOVE_EVENT_HANDLER, Constant.enumMessage.SEND_MOUSE_WHEEL_EVENT_HANDLER, Constant.enumMessage.SEND_GAMEOBJECTCOMPONENTS }; }
public SpashScene(EngineContext context, ITextureManager textureManage, IBus bus, IWorker worker, IConnectionFactory connectionFactory) : base(context, textureManage, bus) { _enableCache = false; _worker = worker; _connectionFactory = connectionFactory; }
public LoginScene(ITextBoxContainer textBoxContainer, EngineContext context, ITextureManager textureManager, IFontFactory fontFactory, IBus bus, IGoogleAnalytic analytic) : base(context, textureManager, bus) { _textBoxContainer = textBoxContainer; _fontFactory = fontFactory; _analytic = analytic; }
// Token: 0x060000CD RID: 205 RVA: 0x00008520 File Offset: 0x00006720 private void LoadTextures() { ITextureManager textureManager = this.context.Renderer.TextureManager; textureManager.LoadFromDota("health_ally", "panorama\\images\\hud\\reborn\\topbar_health_psd.vtex_c", 256, 12, false, -60, null); textureManager.LoadFromDota("health_ally_visible", "panorama\\images\\hud\\reborn\\topbar_health_psd.vtex_c", 256, 12, false, 0, null); textureManager.LoadFromDota("health_ally_bg", "panorama\\images\\hud\\reborn\\topbar_health_psd.vtex_c", 256, 12, false, -170, null); textureManager.LoadFromDota("health_enemy", "panorama\\images\\hud\\reborn\\topbar_health_dire_psd.vtex_c", 256, 12, false, 0, null); textureManager.LoadFromDota("health_enemy_invis", "panorama\\images\\hud\\reborn\\topbar_health_dire_psd.vtex_c", 256, 12, false, -60, null); textureManager.LoadFromDota("health_enemy_bg", "panorama\\images\\hud\\reborn\\topbar_health_dire_psd.vtex_c", 256, 12, false, -170, null); textureManager.LoadFromDota("mana", "panorama\\images\\hud\\reborn\\topbar_mana_psd.vtex_c", 256, 12, false, 0, null); textureManager.LoadFromDota("mana_invis", "panorama\\images\\hud\\reborn\\topbar_mana_psd.vtex_c", 256, 12, false, -60, null); textureManager.LoadFromDota("mana_bg", "panorama\\images\\hud\\reborn\\topbar_mana_psd.vtex_c", 256, 12, false, -170, null); textureManager.LoadFromDota("ult_rdy", "panorama\\images\\hud\\reborn\\ult_ready_psd.vtex_c", 0, 0, false, 0, null); textureManager.LoadFromDota("ult_cd", "panorama\\images\\hud\\reborn\\ult_cooldown_psd.vtex_c", 0, 0, false, 0, null); textureManager.LoadFromDota("ult_mp", "panorama\\images\\hud\\reborn\\ult_no_mana_psd.vtex_c", 0, 0, false, 0, null); textureManager.LoadFromDota("buyback", "panorama\\images\\hud\\reborn\\buyback_header_psd.vtex_c", 0, 0, false, -60, null); textureManager.LoadFromDota("top_ult_cd_bg", "panorama\\images\\masks\\softedge_circle_sharp_png.vtex_c", 0, 0, false, 0, new Vector4?(new Vector4(0f, 0f, 0f, 0.5f))); textureManager.LoadFromDota("outline", "panorama\\images\\hud\\reborn\\buff_outline_psd.vtex_c", 0, 0, false, 0, null); textureManager.LoadOutlineFromDota("outline_green_pct", "panorama\\images\\hud\\reborn\\buff_outline_psd.vtex_c", 0, new Vector4?(new Vector4(0f, 1f, 0f, 1f))); textureManager.LoadOutlineFromDota("outline_blue_pct", "panorama\\images\\hud\\reborn\\buff_outline_psd.vtex_c", 40, new Vector4?(new Vector4(0f, 0.4f, 0.9f, 1f))); foreach (AbilityId abilityId in this.drawItems) { textureManager.LoadFromDota(abilityId, true); } }
private SFMLGraphics2D() { m_PostOffice = null; m_RenderWindow = null; m_SpriteManager = null; m_GraphicsSettings = null; m_ModuleID = Constant.enumModuleID.GRAPHICS; m_MsgTypeArray = new Constant.enumMessage[] { Constant.enumMessage.INITIALISE, Constant.enumMessage.UPDATE, Constant.enumMessage.DRAW, Constant.enumMessage.CLOSING, Constant.enumMessage.LOAD_TEXTURES, Constant.enumMessage.UPDATE_GRAPHICS_SETTINGS, Constant.enumMessage.SWITCH_SPRITES_DRAW_STATUS, Constant.enumMessage.GET_GRAPHICS_SETTINGS, Constant.enumMessage.SEND_GAMEOBJECT, Constant.enumMessage.SEND_SPRITE_COMPONENTS, Constant.enumMessage.SEND_POSITION_COMPONENTS, Constant.enumMessage.SEND_TEXTURE_IDS, Constant.enumMessage.SEND_COMPONENTS, Constant.enumMessage.SEND_GAMEOBJECT, Constant.enumMessage.SEND_KEYBOARD_EVENT_HANDLER, Constant.enumMessage.SEND_MOUSE_BUTTON_EVENT_HANDLER, Constant.enumMessage.SEND_MOUSE_MOVE_EVENT_HANDLER, Constant.enumMessage.SEND_MOUSE_WHEEL_EVENT_HANDLER, Constant.enumMessage.SEND_GAMEOBJECTCOMPONENTS }; }
public void Render(IRendererContext context, RenderPasses renderPass, IRenderable renderable) { var c = (VeldridRendererContext)context; var cl = c.CommandList; var sc = c.SceneContext; ITextureManager textureManager = Resolve <ITextureManager>(); IDeviceObjectManager dom = Resolve <IDeviceObjectManager>(); EngineFlags engineFlags = Resolve <IEngineSettings>().Flags; // float depth = gd.IsDepthRangeZeroToOne ? 0 : 1; var sprite = (MultiSprite)renderable; var shaderKey = new SpriteShaderKey(sprite, engineFlags); sprite.PipelineId = shaderKey.GetHashCode(); //if (!shaderKey.UseArrayTexture) // return; cl.PushDebugGroup(sprite.Name); if (sc.PaletteView == null) { return; } TextureView textureView = (TextureView)textureManager?.GetTexture(sprite.Key.Texture); var resourceSet = dom.Get <ResourceSet>((sprite, textureView)); var instanceBuffer = dom.Get <DeviceBuffer>((sprite, sprite)); var uniformInfo = new SpriteUniformInfo { Flags = sprite.Key.Flags, TextureWidth = textureView?.Target.Width ?? 1, TextureHeight = textureView?.Target.Height ?? 1 }; if (sprite.Key.ScissorRegion.HasValue) { IWindowManager wm = Resolve <IWindowManager>(); var screenCoordinates = wm.UiToPixel(sprite.Key.ScissorRegion.Value); cl.SetScissorRect(0, (uint)screenCoordinates.X, (uint)screenCoordinates.Y, (uint)screenCoordinates.Width, (uint)screenCoordinates.Height); } cl.UpdateBuffer(_uniformBuffer, 0, uniformInfo); cl.SetPipeline(_pipelines[shaderKey]); cl.SetGraphicsResourceSet(0, resourceSet); cl.SetGraphicsResourceSet(1, sc.CommonResourceSet); cl.SetVertexBuffer(0, _vertexBuffer); cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16); cl.SetVertexBuffer(1, instanceBuffer); //cl.SetViewport(0, new Viewport(0, 0, sc.MainSceneColorTexture.Width, sc.MainSceneColorTexture.Height, depth, depth)); cl.DrawIndexed((uint)Indices.Length, (uint)sprite.ActiveInstances, 0, 0, 0); //cl.SetViewport(0, new Viewport(0, 0, sc.MainSceneColorTexture.Width, sc.MainSceneColorTexture.Height, 0, 1)); if (sprite.Key.ScissorRegion.HasValue) { cl.SetFullScissorRect(0); } cl.PopDebugGroup(); }
public LobbyScene(EngineContext context, ITextBoxContainer textboxContainer, ITextureManager textureManage, IBus bus, IWorker worker, IConnectionFactory connectionFactory) : base(context, textureManage, bus) { _enableCache = false; _worker = worker; _connectionFactory = connectionFactory; _textBoxContainer = textboxContainer; }
public static ITextureManager Instance() { if (m_Instance == null) { m_Instance = new SpriteManager(); } return m_Instance; }
public static ITextureManager Instance() { if (m_Instance == null) { m_Instance = new SpriteManager(); } return(m_Instance); }
// Token: 0x060001B7 RID: 439 RVA: 0x00014E48 File Offset: 0x00013048 private void LoadResources() { ITextureManager textureManager = base.Renderer.TextureManager; textureManager.LoadFromDota(base.MenuStyle.TextureArrowKey, "panorama\\images\\control_icons\\double_arrow_right_png.vtex_c", 0, 0, false, 0, null); textureManager.LoadFromDota(base.MenuStyle.TextureLeftArrowKey, "panorama\\images\\control_icons\\arrow_dropdown_png.vtex_c", 0, 0, false, 0, null); textureManager.LoadFromDota(base.MenuStyle.TextureIconKey, "panorama\\images\\hud\\reborn\\tournament_pip_on_psd.vtex_c", 0, 0, false, 0, null); }
public void Activate() { this.textureManager = this.context.Renderer.TextureManager; this.LoadTextures(); EntityManager9.UnitAdded += this.OnUnitAdded; EntityManager9.AbilityAdded += this.OnAbilityAdded; }
// Token: 0x060003BF RID: 959 RVA: 0x0001D618 File Offset: 0x0001B818 private void LoadTextures() { ITextureManager textureManager = this.context.Renderer.TextureManager; textureManager.LoadFromDota("notification_bg", "panorama\\images\\hud\\reborn\\bg_deathsummary_psd.vtex_c", 300, 200, false, 10, null); textureManager.LoadFromDota("gold", "panorama\\images\\hud\\reborn\\gold_large_png.vtex_c", 0, 0, false, 0, null); textureManager.LoadFromDota("ping", "panorama\\images\\hud\\reborn\\ping_icon_default_psd.vtex_c", 0, 0, false, 0, null); textureManager.LoadFromResource("rune_regen", "rune_regen.png"); textureManager.LoadFromResource("rune_bounty", "rune_bounty.png"); }
// Token: 0x060000A1 RID: 161 RVA: 0x000072CC File Offset: 0x000054CC private void LoadTextures() { ITextureManager textureManager = this.context.Renderer.TextureManager; textureManager.LoadFromDota("tusk_launch_snowball", "panorama\\images\\spellicons\\tusk_snowball_png.vtex_c", 0, 0, false, 0, null); textureManager.LoadFromDota("ability_cd_bg", "panorama\\images\\masks\\softedge_horizontal_png.vtex_c", 0, 0, false, 0, new Vector4?(new Vector4(0f, 0f, 0f, 0.6f))); textureManager.LoadFromDota("ability_0lvl_bg", "panorama\\images\\masks\\softedge_horizontal_png.vtex_c", 0, 0, false, 0, new Vector4?(new Vector4(0.3f, 0.3f, 0.3f, 0.4f))); textureManager.LoadFromDota("ability_lvl_bg", "panorama\\images\\masks\\softedge_horizontal_png.vtex_c", 0, 0, false, 0, new Vector4?(new Vector4(0f, 0f, 0f, 0.9f))); textureManager.LoadFromDota("ability_mana_bg", "panorama\\images\\masks\\softedge_horizontal_png.vtex_c", 0, 0, false, 0, new Vector4?(new Vector4(0f, 0f, 0.9f, 0.8f))); }
public GraphicsSystem(IGraphicsSettings graphicsSettings, ContentManager contentManager, SpriteFont spriteFont, SpriteFont debugSpriteFont, ITextureManager textureManager, OrthographicCamera camera2D, GraphicsDevice graphicsDevice) { GraphicsSettings = graphicsSettings; _contentManager = contentManager ?? throw new ArgumentNullException(nameof(contentManager)); SpriteFont = spriteFont; DebugSpriteFont = debugSpriteFont; TextureManager = textureManager; Camera2D = camera2D; GraphicsDevice = graphicsDevice; }
public GameState(Game game) : base(game) { tag = this; childComponents = new List <GameComponent>(); content = Game.Content; manager = (IStateManager)Game.Services.GetService(typeof(IStateManager)); textures = (ITextureManager)Game.Services.GetService(typeof(ITextureManager)); }
private string AddTexture(string path, string ID = "") { if (m_SpriteManager == null) { m_SpriteManager = SpriteManager.Instance(); } string generatedID = m_SpriteManager.loadTexture(path, ID); PrintError(("Texture Added with ID: " + generatedID + "\n Path:" + path), m_ErrorStatus.DEBUG); return(generatedID); }
public void Render(IRendererContext context, RenderPasses renderPass, IRenderable renderable) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (renderable == null) { throw new ArgumentNullException(nameof(renderable)); } var c = (VeldridRendererContext)context; var cl = c.CommandList; var gd = c.GraphicsDevice; var sc = c.SceneContext; ITextureManager textureManager = Resolve <ITextureManager>(); if (!(renderable is TileMapWindow window)) { return; } var tilemap = window.TileMap; cl.PushDebugGroup($"Tiles3D:{tilemap.Name}:{tilemap.RenderOrder}"); TextureView floors = (TextureView)textureManager.GetTexture(tilemap.Floors); TextureView walls = (TextureView)textureManager.GetTexture(tilemap.Walls); var miscUniformData = new MiscUniformData { TileSize = tilemap.TileSize, Unused1 = 0 }; cl.UpdateBuffer(_miscUniformBuffer, 0, miscUniformData); var resourceSet = gd.ResourceFactory.CreateResourceSet(new ResourceSetDescription(_layout, _miscUniformBuffer, gd.PointSampler, _textureSampler, floors, walls)); resourceSet.Name = $"RS_TileMap:{tilemap.Name}"; _resourceSets.Add(resourceSet); cl.SetPipeline(_pipeline); cl.SetGraphicsResourceSet(0, resourceSet); cl.SetGraphicsResourceSet(1, sc.CommonResourceSet); cl.SetVertexBuffer(0, _vb); cl.SetVertexBuffer(1, _instanceBuffers[window.InstanceBufferId]); cl.SetIndexBuffer(_ib, IndexFormat.UInt16); cl.DrawIndexed((uint)Indices.Length, (uint)window.Length, 0, 0, 0); cl.PopDebugGroup(); }
public void Render(IRendererContext context, RenderPasses renderPass, IRenderable renderable) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (renderable == null) { throw new ArgumentNullException(nameof(renderable)); } var c = (VeldridRendererContext)context; var cl = c.CommandList; var sc = c.SceneContext; ITextureManager textureManager = Resolve <ITextureManager>(); IDeviceObjectManager dom = Resolve <IDeviceObjectManager>(); var config = Resolve <CoreConfig>().Visual.Skybox; if (!(Resolve <ICamera>() is PerspectiveCamera camera)) { return; } var skybox = (SkyboxRenderable)renderable; cl.PushDebugGroup(skybox.Name); var uniformInfo = new SkyboxUniformInfo { uYaw = camera.Yaw, uPitch = camera.Pitch, uVisibleProportion = config.VisibleProportion }; cl.UpdateBuffer(_uniformBuffer, 0, uniformInfo); if (sc.PaletteView == null) { return; } TextureView textureView = (TextureView)textureManager?.GetTexture(skybox.Texture); var resourceSet = dom.GetDeviceObject <ResourceSet>((skybox, textureView, null)); cl.SetPipeline(_pipeline); cl.SetGraphicsResourceSet(0, resourceSet); cl.SetGraphicsResourceSet(1, sc.CommonResourceSet); cl.SetVertexBuffer(0, _vertexBuffer); cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16); cl.DrawIndexed((uint)Indices.Length, 1, 0, 0, 0); cl.PopDebugGroup(); }
public Config(AdvancedMiniMap plugin) { Factory = MenuFactory.Create("Advanced MiniMap"); Factory.Target.SetFontColor(Color.YellowGreen); Main = plugin; DebugMessages = Factory.Item <bool>("Enable Debug"); Render = Main.Context.Value.Renderer; TextureManager = Main.Context.Value.Renderer.TextureManager; MiniMapTowerScript = new MiniMapTowerScript(this, "Tower on MiniMap"); }
public IEnumerable <IRenderable> UpdatePerFrameResources(GraphicsDevice gd, CommandList cl, SceneContext sc, IEnumerable <IRenderable> renderables) { ITextureManager textureManager = Resolve <ITextureManager>(); ISpriteResolver spriteResolver = Resolve <ISpriteResolver>(); foreach (var buffer in _instanceBuffers) { buffer.Dispose(); } _instanceBuffers.Clear(); foreach (var resourceSet in _resourceSets) { resourceSet.Dispose(); } _resourceSets.Clear(); void SetupMultiSpriteResources(MultiSprite multiSprite) { textureManager?.PrepareTexture(multiSprite.Key.Texture, gd); multiSprite.BufferId = _instanceBuffers.Count; // multiSprite.RotateSprites(sc.Camera.Position); var buffer = gd.ResourceFactory.CreateBuffer(new BufferDescription((uint)multiSprite.Instances.Length * SpriteInstanceData.StructSize, BufferUsage.VertexBuffer)); buffer.Name = $"B_SpriteInst{_instanceBuffers.Count}"; cl.UpdateBuffer(buffer, 0, multiSprite.Instances); _instanceBuffers.Add(buffer); } var resolved = renderables.OfType <Sprite>().Select(spriteResolver.Resolve); var grouped = resolved.GroupBy(x => x.Item1, x => x.Item2); foreach (var group in grouped) { var multiSprite = group.Key.Flags.HasFlag(SpriteFlags.NoTransform) ? new UiMultiSprite(group.Key, _instanceBuffers.Count, group) : new MultiSprite(group.Key, _instanceBuffers.Count, group); SetupMultiSpriteResources(multiSprite); yield return(multiSprite); } foreach (var multiSprite in renderables.OfType <MultiSprite>()) { if (multiSprite.Instances.Length == 0) { continue; } SetupMultiSpriteResources(multiSprite); yield return(multiSprite); } }
public IEnumerable <IRenderable> UpdatePerFrameResources(GraphicsDevice gd, CommandList cl, SceneContext sc, IEnumerable <IRenderable> renderables) { ITextureManager textureManager = Resolve <ITextureManager>(); IDeviceObjectManager dom = Resolve <IDeviceObjectManager>(); foreach (var sprite in renderables.OfType <MultiSprite>()) { if (sprite.ActiveInstances == 0) { continue; } uint bufferSize = (uint)sprite.Instances.Length * SpriteInstanceData.StructSize; var buffer = dom.Prepare((sprite, sprite), () => { var newBuffer = gd.ResourceFactory.CreateBuffer(new BufferDescription(bufferSize, BufferUsage.VertexBuffer)); newBuffer.Name = $"B_SpriteInst:{sprite.Name}"; PerfTracker.IncrementFrameCounter("Create InstanceBuffer"); return(newBuffer); }, existing => existing.SizeInBytes != bufferSize); if (sprite.InstancesDirty) { cl.UpdateBuffer(buffer, 0, sprite.Instances); PerfTracker.IncrementFrameCounter("Update InstanceBuffers"); } textureManager?.PrepareTexture(sprite.Key.Texture, gd); TextureView textureView = textureManager?.GetTexture(sprite.Key.Texture); dom.Prepare((sprite, textureView), () => { var resourceSet = gd.ResourceFactory.CreateResourceSet(new ResourceSetDescription( _perSpriteResourceLayout, gd.PointSampler, textureView, _uniformBuffer)); resourceSet.Name = $"RS_Sprite:{sprite.Key.Texture.Name}"; PerfTracker.IncrementFrameCounter("Create ResourceSet"); return(resourceSet); }, _ => false ); sprite.InstancesDirty = false; yield return(sprite); } Resolve <ISpriteManager>().Cleanup(); }
public IEnumerable <IRenderable> UpdatePerFrameResources(IRendererContext context, IEnumerable <IRenderable> renderables) { var c = (VeldridRendererContext)context; var cl = c.CommandList; var gd = c.GraphicsDevice; ITextureManager textureManager = Resolve <ITextureManager>(); foreach (var buffer in _instanceBuffers) { buffer.Dispose(); } _instanceBuffers.Clear(); foreach (var resourceSet in _resourceSets) { resourceSet.Dispose(); } _resourceSets.Clear(); void UpdateTilemapWindow(TileMapWindow window) { var tilemap = window.TileMap; window.InstanceBufferId = _instanceBuffers.Count; var buffer = gd.ResourceFactory.CreateBuffer(new BufferDescription((uint)window.Length * TileMap.Tile.StructSize, BufferUsage.VertexBuffer)); buffer.Name = $"B_Tile3DInst{_instanceBuffers.Count}"; cl.UpdateBuffer(buffer, 0, ref tilemap.Tiles[window.Offset], TileMap.Tile.StructSize * (uint)window.Length); _instanceBuffers.Add(buffer); textureManager.PrepareTexture(tilemap.Floors, context); textureManager.PrepareTexture(tilemap.Walls, context); } foreach (var renderable in renderables) { if (renderable is TileMap tilemap) { var dummyWindow = new TileMapWindow(tilemap, 0, tilemap.Tiles.Length); UpdateTilemapWindow(dummyWindow); yield return(dummyWindow); } else if (renderable is TileMapWindow window) { UpdateTilemapWindow(window); yield return(window); } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { _logger.Debug("Game.LoadContent()"); LoadFonts(); LoadTextures(); _textureManager = new TextureManager(_textureRegions); _graphicsSystem = new GraphicsSystem(_graphicsSettings, Content, _spriteFont, _debugSpriteFont, _textureManager, _camera, GraphicsDevice); _sceneManager = new SceneManager(this); Components.Add(_sceneManager); _sceneManager.Load(new LoadingScene(this, _sceneManager, _graphicsSystem, _gameSettings, _logger, _gameKeys)); }
public void Render(GraphicsDevice gd, CommandList cl, SceneContext sc, RenderPasses renderPass, IRenderable renderable) { ITextureManager textureManager = Resolve <ITextureManager>(); var window = renderable as TileMapWindow; if (window == null) { return; } var tilemap = window.TileMap; cl.PushDebugGroup($"Tiles3D:{tilemap.Name}:{tilemap.RenderOrder}"); TextureView floors = textureManager.GetTexture(tilemap.Floors); TextureView walls = textureManager.GetTexture(tilemap.Walls); var miscUniformData = new MiscUniformData { Position = tilemap.Position, TileSize = tilemap.TileSize, Unused1 = 0, Unused2 = 0 }; cl.UpdateBuffer(_miscUniformBuffer, 0, miscUniformData); var resourceSet = gd.ResourceFactory.CreateResourceSet(new ResourceSetDescription(_layout, sc.ProjectionMatrixBuffer, sc.ModelViewMatrixBuffer, _miscUniformBuffer, gd.PointSampler, sc.PaletteView, _textureSampler, floors, walls)); _resourceSets.Add(resourceSet); cl.SetPipeline(_pipeline); cl.SetGraphicsResourceSet(0, resourceSet); cl.SetGraphicsResourceSet(1, sc.CommonResourceSet); cl.SetVertexBuffer(0, _vb); cl.SetVertexBuffer(1, _instanceBuffers[window.InstanceBufferId]); cl.SetIndexBuffer(_ib, IndexFormat.UInt16); cl.DrawIndexed((uint)Indices.Length, (uint)window.Length, 0, 0, 0); cl.PopDebugGroup(); }
public IEnumerable <IRenderable> UpdatePerFrameResources(GraphicsDevice gd, CommandList cl, SceneContext sc, IEnumerable <IRenderable> renderables) { ITextureManager textureManager = Resolve <ITextureManager>(); foreach (var buffer in _instanceBuffers) { buffer.Dispose(); } _instanceBuffers.Clear(); foreach (var resourceSet in _resourceSets) { resourceSet.Dispose(); } _resourceSets.Clear(); void UpdateTilemapWindow(TileMapWindow window) { var tilemap = window.TileMap; window.InstanceBufferId = _instanceBuffers.Count; var buffer = gd.ResourceFactory.CreateBuffer(new BufferDescription((uint)window.Length * TileMap.Tile.StructSize, BufferUsage.VertexBuffer)); buffer.Name = $"B_Tile3DInst{_instanceBuffers.Count}"; cl.UpdateBuffer(buffer, 0, ref tilemap.Tiles[window.Offset], TileMap.Tile.StructSize * (uint)window.Length); _instanceBuffers.Add(buffer); textureManager.PrepareTexture(tilemap.Floors, gd); textureManager.PrepareTexture(tilemap.Walls, gd); } foreach (var tilemap in renderables.OfType <TileMap>()) { var window = new TileMapWindow(tilemap, 0, tilemap.Tiles.Length); UpdateTilemapWindow(window); yield return(window); } foreach (var window in renderables.OfType <TileMapWindow>()) { UpdateTilemapWindow(window); yield return(window); } }
public void Render(GraphicsDevice gd, CommandList cl, SceneContext sc, RenderPasses renderPass, IRenderable renderable) { ITextureManager textureManager = Resolve <ITextureManager>(); // float depth = gd.IsDepthRangeZeroToOne ? 0 : 1; var sprite = (MultiSprite)renderable; var shaderKey = new SpriteShaderKey( sprite.Key.Texture.ArrayLayers > 1, !sprite.Flags.HasFlag(SpriteFlags.NoDepthTest)); //if (!shaderKey.UseArrayTexture) // return; cl.PushDebugGroup($"Sprite:{sprite.Key.Texture.Name}:{sprite.Key.RenderOrder}"); TextureView textureView = textureManager?.GetTexture(sprite.Key.Texture); if (sc.PaletteView == null) { return; } var resourceSet = gd.ResourceFactory.CreateResourceSet(new ResourceSetDescription( _perSpriteResourceLayout, sc.ProjectionMatrixBuffer, sc.ModelViewMatrixBuffer, gd.PointSampler, textureView, sc.PaletteView )); resourceSet.Name = $"RS_Sprite:{sprite.Key.Texture.Name}"; _resourceSets.Add(resourceSet); cl.SetPipeline(_pipelines[shaderKey]); cl.SetGraphicsResourceSet(0, resourceSet); cl.SetGraphicsResourceSet(1, sc.CommonResourceSet); cl.SetVertexBuffer(0, _vertexBuffer); cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16); cl.SetVertexBuffer(1, _instanceBuffers[sprite.BufferId]); //cl.SetViewport(0, new Viewport(0, 0, sc.MainSceneColorTexture.Width, sc.MainSceneColorTexture.Height, depth, depth)); cl.DrawIndexed((uint)Indices.Length, (uint)sprite.Instances.Length, 0, 0, 0); //cl.SetViewport(0, new Viewport(0, 0, sc.MainSceneColorTexture.Width, sc.MainSceneColorTexture.Height, 0, 1)); cl.PopDebugGroup(); }
public void Render(GraphicsDevice gd, CommandList cl, SceneContext sc, RenderPasses renderPass, IRenderable renderable) { ITextureManager textureManager = Resolve <ITextureManager>(); IDeviceObjectManager dom = Resolve <IDeviceObjectManager>(); // float depth = gd.IsDepthRangeZeroToOne ? 0 : 1; var sprite = (MultiSprite)renderable; var shaderKey = new SpriteShaderKey(sprite); sprite.PipelineId = shaderKey.GetHashCode(); //if (!shaderKey.UseArrayTexture) // return; cl.PushDebugGroup($"Sprite:{sprite.Key.Texture.Name}:{sprite.Key.RenderOrder}"); var uniformInfo = new SpriteUniformInfo { Flags = sprite.Key.Flags }; cl.UpdateBuffer(_uniformBuffer, 0, uniformInfo); if (sc.PaletteView == null) { return; } TextureView textureView = textureManager?.GetTexture(sprite.Key.Texture); var resourceSet = dom.Get <ResourceSet>((sprite, textureView)); var instanceBuffer = dom.Get <DeviceBuffer>((sprite, sprite)); cl.SetPipeline(_pipelines[shaderKey]); cl.SetGraphicsResourceSet(0, resourceSet); cl.SetGraphicsResourceSet(1, sc.CommonResourceSet); cl.SetVertexBuffer(0, _vertexBuffer); cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16); cl.SetVertexBuffer(1, instanceBuffer); //cl.SetViewport(0, new Viewport(0, 0, sc.MainSceneColorTexture.Width, sc.MainSceneColorTexture.Height, depth, depth)); cl.DrawIndexed((uint)Indices.Length, (uint)sprite.ActiveInstances, 0, 0, 0); //cl.SetViewport(0, new Viewport(0, 0, sc.MainSceneColorTexture.Width, sc.MainSceneColorTexture.Height, 0, 1)); cl.PopDebugGroup(); }
public void Load(ISceneProvider draw, IEventProvider events, INetworkProvider network, ISoundProvider sound, IModuleProvider modules, IMovementProvider movement, ICollisionProvider collision, IVoiceChatProvider voicechat, IWorldManager world, ITextureManager texture, ISoundManager soundmanager) { this.drawprovider = draw; this.eventprovider = events; this.networkprovider = network; this.soundprovider = sound; this.moduleprovider = modules; this.movementprovider = movement; this.collisionprovider = collision; this.voicechatprovider = voicechat; this.texturemanager = texture; this.worldmanager = world; this.soundmanager = soundmanager; this.LoadContexts (drawprovider, eventprovider, networkprovider, soundprovider, moduleprovider, movementprovider, collisionprovider, voicechatprovider, texturemanager, worldmanager, soundmanager); }
public void LoadEngineContext(IEngineContext context) { this.maproot = context.Configuration[EngineConfigurationName.MapRoot]; this.texturemanager = context.TextureManager; this.isloaded = true; }
private string AddTexture(string path, string ID = "") { if (m_SpriteManager == null) { m_SpriteManager = SpriteManager.Instance(); } string generatedID = m_SpriteManager.loadTexture(path, ID); PrintError(("Texture Added with ID: " + generatedID + "\n Path:" + path), m_ErrorStatus.DEBUG); return generatedID; }
public void LoadContent(ITextureManager textureManager) { Texture = textureManager[Content.ProgressBar]; Origin = Texture.Center(Scale); ZIndex = ZIndexManager.getZIndex(ZIndexManager.drawnItemOrders.healthBar); }
public static TextureWrap?GetIconTexture(this ITextureManager manager, int iconId) { return(manager.GetIconTexture((uint)iconId)); }
public IEnumerable <IRenderable> UpdatePerFrameResources(IRendererContext context, IEnumerable <IRenderable> renderables) { var c = (VeldridRendererContext)context; var cl = c.CommandList; var gd = c.GraphicsDevice; var sc = c.SceneContext; ITextureManager textureManager = Resolve <ITextureManager>(); IDeviceObjectManager objectManager = Resolve <IDeviceObjectManager>(); EngineFlags engineFlags = Resolve <IEngineSettings>().Flags; foreach (var renderable in renderables) { var sprite = (MultiSprite)renderable; if (sprite.ActiveInstances == 0) { continue; } var shaderKey = new SpriteShaderKey(sprite, engineFlags); if (!_pipelines.ContainsKey(shaderKey)) { _pipelines.Add(shaderKey, BuildPipeline(gd, sc, shaderKey)); } uint bufferSize = (uint)sprite.Instances.Length * SpriteInstanceData.StructSize; var buffer = objectManager.Get <DeviceBuffer>((sprite, sprite)); if (buffer?.SizeInBytes != bufferSize) { buffer = gd.ResourceFactory.CreateBuffer(new BufferDescription(bufferSize, BufferUsage.VertexBuffer)); buffer.Name = $"B_SpriteInst:{sprite.Name}"; PerfTracker.IncrementFrameCounter("Create InstanceBuffer"); objectManager.Set((sprite, sprite), buffer); } if (sprite.InstancesDirty) { cl.UpdateBuffer(buffer, 0, sprite.Instances); PerfTracker.IncrementFrameCounter("Update InstanceBuffers"); } textureManager?.PrepareTexture(sprite.Key.Texture, context); TextureView textureView = (TextureView)textureManager?.GetTexture(sprite.Key.Texture); var resourceSet = objectManager.Get <ResourceSet>((sprite, textureView)); if (resourceSet == null) { resourceSet = gd.ResourceFactory.CreateResourceSet(new ResourceSetDescription( _perSpriteResourceLayout, gd.PointSampler, textureView, _uniformBuffer)); resourceSet.Name = $"RS_Sprite:{sprite.Key.Texture.Name}"; PerfTracker.IncrementFrameCounter("Create ResourceSet"); objectManager.Set((sprite, textureView), resourceSet); } sprite.InstancesDirty = false; yield return(sprite); } Resolve <ISpriteManager>().Cleanup(); }