示例#1
0
        public CoordinateMarkerRenderer(GraphicsContext graphicsContext)
        {
            _vertexRenderer = graphicsContext.CreateVertexRenderer<TexturedColouredVertex4>(6);
            _noTexture = graphicsContext.GetTexture("noTexture.png");

            PopululateBuffer();
        }
示例#2
0
        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;
        }
示例#3
0
        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;
        }
示例#4
0
 private void UpdateTextureArea(TextureAreaHolder holder, string name)
 {
     holder.TextureArea = GetTextureArea(name);
     _requiresUpdate = true;
 }
示例#5
0
 private void UpdateAtlasSection(TextureAreaHolder target, TextureAreaHolder content, TextureAtlasTextureDefinition def)
 {
     target.TextureArea = CreateTextureArea(content.TextureArea, def);
 }
示例#6
0
 private void RegisterTexture(TextureAreaHolder cachedTexture, string name)
 {
     CacheById[NextTextureId] = cachedTexture;
     CacheByName[name] = cachedTexture;
     NextTextureId++;
 }
示例#7
0
 private void SetTexture(TextureAreaHolder textureArea)
 {
     _effect.SetTexture("tex0", textureArea);
 }