public CoordinateMarkerRenderer(GraphicsContext graphicsContext) { _vertexRenderer = graphicsContext.CreateVertexRenderer<TexturedColouredVertex4>(6); _noTexture = graphicsContext.GetTexture("noTexture.png"); PopululateBuffer(); }
public TextureAreaHolder GetByName(string name) { if (CacheByName.ContainsKey(name)) { return CacheByName[name]; } var cachedTexture = new TextureAreaHolder(CacheByName[BlankTexture].TextureArea); RegisterTexture(cachedTexture, name); if (UseThreadToLoadTextures) { lock(_tasks) { _tasks.Add(new Task{FileName = name, ToUpdate = cachedTexture}); Monitor.PulseAll(_tasks); } } else { UpdateTextureArea(cachedTexture, name); cachedTexture.Update(); } return cachedTexture; }
private List<TextureAreaHolder> UpdateTextureAreas(string textureFilename, List<TextureAtlasTextureDefinition> definitions) { var cachedTexture = GetByName(textureFilename); var cachedTextureArea = cachedTexture.TextureArea; foreach (var definition in definitions) { definition.NormalizeTextureCoordinates(cachedTextureArea.Width, cachedTextureArea.Height); CacheByName[definition.Name] = new TextureAreaHolder(cachedTextureArea.Clone(definition)); TextureAtlasTextureDefinition definition1 = definition; cachedTexture.OnChange += item => CacheByName[definition1.Name].TextureArea = item.TextureArea; } var textureAreas = new List<TextureAreaHolder>(definitions.Count); foreach (var definition in definitions) { var holder = new TextureAreaHolder(CreateTextureArea(cachedTextureArea, definition)); var definition1 = definition; cachedTexture.OnChange += item => UpdateAtlasSection(holder, item, definition1); } return textureAreas; }
private void UpdateTextureArea(TextureAreaHolder holder, string name) { holder.TextureArea = GetTextureArea(name); _requiresUpdate = true; }
private void UpdateAtlasSection(TextureAreaHolder target, TextureAreaHolder content, TextureAtlasTextureDefinition def) { target.TextureArea = CreateTextureArea(content.TextureArea, def); }
private void RegisterTexture(TextureAreaHolder cachedTexture, string name) { CacheById[NextTextureId] = cachedTexture; CacheByName[name] = cachedTexture; NextTextureId++; }
private void SetTexture(TextureAreaHolder textureArea) { _effect.SetTexture("tex0", textureArea); }