public OpenGLSceneProcessor(IServiceProvider serviceProvider, IRenderWindow renderWindow, SceneGraph sceneGraph) { _serviceProvider = serviceProvider; _cancellationTokenManager = _serviceProvider.GetRequiredService <CancellationTokenSource>(); _logger = _serviceProvider.GetRequiredService <ILogger <RenderWindow> >(); _shaderCompiler = _serviceProvider.GetRequiredService <IShaderCompiler>(); _textureLoader = _serviceProvider.GetRequiredService <ITextureLoader>(); _renderWindow = renderWindow; // This cannot be passed via the service provider otherwise there will be a cycle in the DI graph _sceneGraph = sceneGraph; _renderList = new LinkedList <IRenderCommand>(); _renderInfo = new RenderInfo(); _requestPicking = null; GL.LoadBindings(new GLFWBindingsContext()); // Get human readable log messages during debugging if (Debugger.IsAttached) { GL.Enable(EnableCap.DebugOutput); _debugProc = DebugMessageCallback; _gcHandle = GCHandle.Alloc(_debugProc); GL.DebugMessageCallback(_debugProc, IntPtr.Zero); } GL.Enable(EnableCap.DepthTest); // Save default frame buffer id for later blitting GL.GetInteger(GetPName.FramebufferBinding, out _defaultFrameBufferId); GL.BindFramebuffer(FramebufferTarget.Framebuffer, _defaultFrameBufferId); InitFrameBuffer(640, 360); }
public TextureShader(IDataProvider dataProvider, IEventAggregator eventAggregator, ITextureLoader textureLoader) : base(eventAggregator) { _shaderProgramFactory = new ShaderProgramFactory(new ShaderFactory("Texture")); _figureResult = dataProvider.GetVertexPoints("Textures"); _textureLoader = textureLoader; }
public TextureFactory(ITextureLoader loader, int capacity = 1024) { if (loader == null) throw new ArgumentNullException(nameof(loader)); this.loader = loader; this.textures = new Entry[capacity]; }
public BufferManager(SceneGraph sceneGraph, ILogger <BufferManager> logger, IShaderCompiler shaderCompiler, ITextureLoader textureLoader) { _sceneGraph = sceneGraph; _logger = logger; _shaderCompiler = shaderCompiler; _textureLoader = textureLoader; _objectToGeometryBuffers = new Dictionary <ObjectIdentityBase, HashSet <ObjectIdentityBase> >(); }
protected AbstractTexture(ITextureLoader loader, string characterRace, int width, int height) { this.textureLoader = loader; this.CharacterRace = characterRace; this.height = height; this.width = width; loadCallback = (textures, paths) => LoadingTexture(textures, paths); }
/// <summary> /// Texture from buffer /// </summary> /// <param name="index"></param> public TextureItem(int index, ITextureLoader textureLoader) { m_textureIndex = index; m_textureLoader = textureLoader; if (m_textureLoader == null) { throw new Exception("ITextureLoader is null."); } }
public TextureFactory(ITextureLoader loader, int capacity = 1024) { if (loader == null) { throw new ArgumentNullException(nameof(loader)); } this.loader = loader; this.textures = new Entry[capacity]; }
public static AbstractTexture Create(TextureType type, ITextureLoader loader, string characterRace) { switch (type) { case TextureType.Skin: return(new Textures.Skin(loader, 0, 0, 1024, 1024, characterRace)); case TextureType.Eyebrow: return(new Textures.Eyebrow(loader, 384, 0, 640, 384, characterRace)); case TextureType.Scar: return(new Textures.Scar(loader, 384, 0, 640, 384, characterRace)); case TextureType.Beard: return(new Textures.Beard(loader, 384, 0, 640, 384, characterRace)); case TextureType.FaceFeature: return(new Textures.FaceFeature(loader, 384, 0, 640, 384, characterRace)); case TextureType.Hair: return(new Textures.Hair(loader, 384, 0, 640, 384, characterRace)); case TextureType.Eye: return(new Textures.Eye(loader, 960, 0, 64, 64, characterRace)); case TextureType.Head: return(new Textures.Head(loader, 384, 0, 640, 384, characterRace)); case TextureType.Pants: return(new Textures.Pants(loader, 0, 0, 512, 576, characterRace)); case TextureType.Torso: return(new Textures.Torso(loader, 0, 512, 1024, 512, characterRace)); case TextureType.Shoe: return(new Textures.Shoes(loader, 0, 0, 384, 448, characterRace)); case TextureType.Glove: return(new Textures.Gloves(loader, 512, 384, 512, 448, characterRace)); case TextureType.RobeLong: return(new Textures.RobeLong(loader, 0, 0, 512, 576, characterRace)); case TextureType.RobeShort: return(new Textures.RobeShort(loader, 0, 0, 512, 576, characterRace)); case TextureType.Belt: return(new Textures.Belt(loader, 0, 512, 512, 256, characterRace)); case TextureType.Cloak: return(new Textures.Cloak(loader, 0, 0, 512, 512, characterRace)); } return(null); }
protected AbstractTexture(ITextureLoader loader, int x, int y, int width, int height, string characterRace, int order, TextureType type = TextureType.Skin) : this(loader, characterRace, width, height) { this.x = x; this.y = y; this.MergeOrder = order; this.Type = type; textures = textureLoader.ParseTextures(this); LoadTexture(); }
public static void RegisterLoader(ITextureLoader newLoader) { if (newLoader != null) { if (isExistExternalLoader) { externalLoader.Deinit(); } externalLoader = newLoader; initialized = false; } }
public MainLoop(IPclWorkarounds pclWorkarounds, IClientStatistics statistics, IClientSettings settings, IContext context, IRavcGameWindow gameWindow, IMainThreadBorderStage mainThreadBorderStage, IFinalFrameProvider finalFrameProvider, IClientStatisticsRenderer statisticsRenderer, ITextureLoader textureLoader) { this.settings = settings; this.context = context; this.statistics = statistics; this.gameWindow = gameWindow; this.mainThreadBorderStage = mainThreadBorderStage; this.finalFrameProvider = finalFrameProvider; this.statisticsRenderer = statisticsRenderer; finalRenderer = new FinalRenderer(pclWorkarounds, settings, context); cursorRenderer = new CursorRenderer(settings, context, textureLoader); stopwatch = new Stopwatch(); }
/// <summary> /// Initializes a new instance of the <see cref="Atlas" /> class. /// </summary> /// <param name="path">The path.</param> /// <param name="textureLoader">The texture loader.</param> /// <exception cref="System.Exception">Error reading atlas file: + path</exception> public Atlas(string path, ITextureLoader textureLoader) { Stream stream = WaveServices.Storage.OpenContentFile(path); using (StreamReader reader = new StreamReader(stream)) { try { this.Load(reader, Path.GetDirectoryName(path), textureLoader); } catch (Exception ex) { throw new Exception("Error reading atlas file: " + path, ex); } } }
public LightningShader(IDataProvider dataProvider, IEventAggregator eventAggregator, ITextureLoader textureLoader) : base(eventAggregator) { _shaderProgramFactory = new ShaderProgramFactory(new ShaderFactory("Lightning")); _lampShaderProgramFactory = new ShaderProgramFactory(new ShaderFactory("LightningLamp")); _worldMapProgramFactory = new ShaderProgramFactory(new ShaderFactory("WorldMap")); _figureResult = dataProvider.GetVertexPoints("Lightning"); _worldMapResult = dataProvider.GetVertexPoints("WorldMap"); _textureLoader = textureLoader; eventAggregator.OnKeyDown += OnOnKeyDown; Timer timer = new Timer(); timer.Tick += TimerOnTick; timer.Interval = 10; timer.Enabled = true; }
public static bool Register(ImageFormat format, ITextureLoader loader) { try { var verified = loader.Verify(); if (verified) { Loaders[format] = loader; return(true); } } catch (Exception e) { XuaLogger.AutoTranslator.Warn(e, "An image loader could not be registered."); } return(false); }
/// <summary> /// Builds a buffer based on the given triangles for the given scene graph /// </summary> /// <param name="sceneGraph">The scene graph for the entire world model.</param> /// <param name="triangleAssertionsToRender">The triangles for which a buffer needs to be constructed.</param> public TriangleBuffer(SceneGraph sceneGraph, BufferManager bufferManager, IEnumerable <Core.Scene.Triangle> triangleAssertionsToRender, ILogger logger, IShaderCompiler shaderCompiler, ITextureLoader textureLoader) : base() { _logger = logger; _shaderCompiler = shaderCompiler; _textureLoader = textureLoader; _sceneGraph = sceneGraph; _bufferManager = bufferManager; _triangleAssertionsToRender = triangleAssertionsToRender.ToArray(); _vertexBuffer = new Lazy <float[]>(() => new float[_triangleAssertionsToRender.Length * VerticesPerTriangle * ComponentsPerVertex]); _vertexIndexBuffer = new Lazy <uint[]>(() => new uint[_triangleAssertionsToRender.Length * VerticesPerTriangle]); _textureObjectIdToShaderIndex = new EqualityComparerMapper <ulong>(EqualityComparer <ulong> .Default); BuildBuffer(); }
public CursorRenderer(IClientSettings settings, IContext context, ITextureLoader textureLoader) { var header = settings.IsEs ? EsHeader : DesktopHeader; var vertexShader = context.Create.VertexShader(header + VertexShaderText); var fragmentShader = context.Create.FragmentShader(header + FragmentShaderText); program = context.Create.Program(new ShaderProgramDescription { VertexShaders = new[] { vertexShader }, FragmentShaders = new[] { fragmentShader }, VertexAttributeNames = new[] { "in_position", "in_tex_coord" }, SamplerNames = new[] { "DiffTexture" } }); var vertexBuffer = context.Create.Buffer(BufferTarget.ArrayBuffer, 4 * Vertex.Size, BufferUsageHint.StaticDraw, new[] { new Vertex(-1f, 1f, 0f, 0f), new Vertex(1f, 1f, 1f, 0f), new Vertex(1f, -1f, 1f, 1f), new Vertex(-1f, -1f, 0f, 1f) }); var indexBuffer = context.Create.Buffer(BufferTarget.ElementArrayBuffer, 6 * sizeof(ushort), BufferUsageHint.StaticDraw, new ushort[] { 0, 1, 2, 0, 2, 3 }); vertexArray = context.Create.VertexArray(); vertexArray.SetVertexAttributeF(0, vertexBuffer, VertexAttributeDimension.Two, VertexAttribPointerType.Float, false, Vertex.Size, 0); vertexArray.SetVertexAttributeF(1, vertexBuffer, VertexAttributeDimension.Two, VertexAttribPointerType.Float, false, Vertex.Size, 2 * sizeof(float)); vertexArray.SetElementArrayBuffer(indexBuffer); texture = textureLoader.LoadTexture(context, "Cursor.png"); sampler = context.Create.Sampler(); sampler.SetMagFilter(TextureMagFilter.Nearest); }
/// <summary> /// Initializes a new instance of the <see cref="Atlas" /> class. /// </summary> /// <param name="reader">The reader.</param> /// <param name="dir">The dir.</param> /// <param name="textureLoader">The texture loader.</param> public Atlas(TextReader reader, string dir, ITextureLoader textureLoader) { this.Load(reader, dir, textureLoader); }
public TextureResourceManager(ITextureLoader textureLoader, IConfiguration configuration, ILogger logger) { _textureLoader = textureLoader; _configuration = configuration; _logger = logger; }
public Skin(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 0, TextureType.Skin) { }
public DXTextureFactory(ITextureLoader loader, int capacity = 1024) : base(loader, capacity) { }
public Pants(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 21, TextureType.Pants) { }
public Eye(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 7, TextureType.Eye) { }
public Torso(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 22, TextureType.Torso) { }
public DXTextureFactory(DXGraphicsHost host, ITextureLoader loader, int capacity = 1024) : base(loader, capacity) { this.graphicsHost = host; }
public Shoes(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 23, TextureType.Shoe) { }
public MeshTexture(ITextureLoader loader, string characterRace, string[][] texturePaths) : base(loader, characterRace, 512, 512, texturePaths) { folderPath = null; }
public FaceFeature(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 3, TextureType.FaceFeature) { }
public void RegisterTextureLoader(ITextureLoader loader) { Loaders.Add(loader); }
public RobeShort(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 27, TextureType.RobeShort) { }
public Cloak(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 24, TextureType.Cloak) { }
protected AbstractTexture(ITextureLoader loader, string characterRace, int width, int height, string path) : this(loader, characterRace, width, height) { textures = loader.ParseTextures(this, path); LoadTexture(); }
/// <summary> /// Loads the specified reader. /// </summary> /// <param name="reader">The reader.</param> /// <param name="imagesDir">The images dir.</param> /// <param name="textureLoader">The texture loader.</param> /// <exception cref="System.ArgumentNullException">textureLoader cannot be null.</exception> private void Load(TextReader reader, string imagesDir, ITextureLoader textureLoader) { if (textureLoader == null) { throw new ArgumentNullException("textureLoader cannot be null."); } this.textureLoader = textureLoader; string[] tuple = new string[4]; AtlasPage page = null; while (true) { string line = reader.ReadLine(); if (line == null) { break; } if (line.Trim().Length == 0) { page = null; } else if (page == null) { page = new AtlasPage(); page.Name = line; page.Format = (Format)Enum.Parse(typeof(Format), this.ReadValue(reader), false); this.ReadTuple(reader, tuple); page.MinFilter = (TextureFilter)Enum.Parse(typeof(TextureFilter), tuple[0], true); page.MagFilter = (TextureFilter)Enum.Parse(typeof(TextureFilter), tuple[1], true); string direction = this.ReadValue(reader); page.UWrap = TextureWrap.ClampToEdge; page.VWrap = TextureWrap.ClampToEdge; if (direction == "x") { page.UWrap = TextureWrap.Repeat; } else if (direction == "y") { page.VWrap = TextureWrap.Repeat; } else if (direction == "xy") { page.UWrap = page.VWrap = TextureWrap.Repeat; } textureLoader.Load(page, Path.Combine(imagesDir, line)); this.Pages.Add(page); } else { AtlasRegion region = new AtlasRegion(); region.Name = line; region.Page = page; region.Rotate = bool.Parse(this.ReadValue(reader)); this.ReadTuple(reader, tuple); int x = int.Parse(tuple[0]); int y = int.Parse(tuple[1]); this.ReadTuple(reader, tuple); int width = int.Parse(tuple[0]); int height = int.Parse(tuple[1]); region.U = x / (float)page.Width; region.V = y / (float)page.Height; if (region.Rotate) { region.U2 = (x + height) / (float)page.Width; region.V2 = (y + width) / (float)page.Height; } else { region.U2 = (x + width) / (float)page.Width; region.V2 = (y + height) / (float)page.Height; } region.X = x; region.Y = y; region.Width = Math.Abs(width); region.Height = Math.Abs(height); if (this.ReadTuple(reader, tuple) == 4) { // split is optional region.Splits = new int[] { int.Parse(tuple[0]), int.Parse(tuple[1]), int.Parse(tuple[2]), int.Parse(tuple[3]) }; if (this.ReadTuple(reader, tuple) == 4) { // pad is optional, but only present with splits region.Pads = new int[] { int.Parse(tuple[0]), int.Parse(tuple[1]), int.Parse(tuple[2]), int.Parse(tuple[3]) }; this.ReadTuple(reader, tuple); } } region.OriginalWidth = int.Parse(tuple[0]); region.OriginalHeight = int.Parse(tuple[1]); this.ReadTuple(reader, tuple); region.OffsetX = int.Parse(tuple[0]); region.OffsetY = int.Parse(tuple[1]); region.Index = int.Parse(this.ReadValue(reader)); this.regions.Add(region); } } }
public Head(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 20, TextureType.Head) { }
public Belt(ITextureLoader loader, int x, int y, int width, int height, string characterRace) : base(loader, x, y, width, height, characterRace, 28, TextureType.Belt) { }
public TextureProvider(TextureSearcher textureSearcher, ITextureLoader <TBitmap> loader, SceneContext sceneContext) { _textureSearcher = textureSearcher; _loader = loader; _sceneContext = sceneContext; }
/// <param name="textureLoader"></param> /// <param name="addressFormat">"Should have parrameter 0 - width, parameter 1 - height"</param> public RandomTextureLoader([NotNull] ITextureLoader textureLoader, [NotNull] string addressFormat) { this.textureLoader = textureLoader ?? throw new ArgumentNullException(nameof(textureLoader)); this.addressFormat = addressFormat ?? throw new ArgumentNullException(nameof(addressFormat)); }
protected AbstractTexture(ITextureLoader loader, string characterRace, int width, int height, string[][] texturePaths) : this(loader, characterRace, width, height) { textures = texturePaths; LoadTexture(); }