private void RetrieveItemAssetsFromRepository ( ItemId itemId, string itemType, string thumbnailUrl, string styleName, IEnumerable <Asset> assets ) { GameFacade.Instance.RetrieveProxy <ClientAssetRepository>().LoadAssetFromPath <ImageAsset> ( thumbnailUrl, delegate(ImageAsset imageAsset) { Texture2D fullImage = imageAsset.Texture2D; Texture2D thumbnail = TextureUtility.ResizeTexture(fullImage, THUMBNAIL_SIZE, THUMBNAIL_SIZE); TexturePixelSource fullImageSource = new TexturePixelSource(fullImage); LayeredTexture textureBuilder = new LayeredTexture(fullImageSource.Width, fullImageSource.Height, true); PixelSource fixinIcon = new TexturePixelSource(mNeedsFixinIconTexture); // normal and normalFixin textureBuilder.AddLayer("Main", fullImageSource); textureBuilder.FlattenLayers(); Texture2D normal = TextureUtility.CopyTexture(textureBuilder.Texture2D); textureBuilder.AddLayer("FixinIcon", fixinIcon); textureBuilder.MoveLayerRelative("FixinIcon", 10, fullImageSource.Height - 18 - THUMBNAIL_SIZE); textureBuilder.FlattenLayers(); Texture2D normalFixin = TextureUtility.CopyTexture(textureBuilder.Texture2D); normal.Apply(); normalFixin.Apply(); Pair <Texture2D> fullImagePair = new Pair <Texture2D>(fullImage, normalFixin); ClothingItem clothingItem = new ClothingItem(itemId, itemType, fullImagePair, thumbnail, styleName, assets); mItemIdsToClothingItems.Add(itemId, clothingItem); IList <ClothingItem> clothingItemsInType; if (mItemTypeToClothingItem.TryGetValue(itemType, out clothingItemsInType)) { clothingItemsInType.Add(clothingItem); } else { mItemTypeToClothingItem.Add(itemType, new List <ClothingItem>()); mItemTypeToClothingItem[itemType].Add(clothingItem); } textureBuilder.Dispose(); } ); }
/// <summary> /// Attaches a single layer of the given texture level to an attachment point. /// </summary> /// <remarks> /// Note that for cube maps and cube map arrays the <paramref name="layer"/> parameter actually indexes the layer-faces.<br/> /// Thus for cube maps the layer parameter equals the face to be bound.<br/> /// For cube map arrays the layer parameter can be calculated as 6 * arrayLayer + face, which is done automatically when using /// the corresponding overload <see cref="Attach(FramebufferTarget, FramebufferAttachment, TextureCubemapArray, int, int, int)"/>. /// </remarks> /// <param name="target">The framebuffer target to bind to.</param> /// <param name="attachment">The attachment point to attach to.</param> /// <param name="texture">The texture to attach.</param> /// <param name="layer">The layer of the texture to attach.</param> /// <param name="level">The level of the texture to attach.</param> public void Attach(FramebufferTarget target, FramebufferAttachment attachment, LayeredTexture texture, int layer, int level = 0) { texture.AssertLevel(level); AssertActive(target); GL.FramebufferTextureLayer(target, attachment, texture.Handle, level, layer); CheckState(target); }
/// <summary> /// Binds a single layer of the given texture level to an image unit.<br/> /// Note that for cube maps and cube map arrays the <paramref name="layer"/> parameter actually indexes the layer-faces.<br/> /// Thus for cube maps the layer parameter equals the face to be bound.<br/> /// For cube map arrays the layer parameter can be calculated as 6 * arrayLayer + face, which is done automatically when using /// the corresponding overload <see cref="Bind(int,TextureCubemapArray,int,int,int,OpenTK.Graphics.OpenGL.TextureAccess)"/>. /// </summary> /// <param name="imageUnit">The image unit to use.</param> /// <param name="texture">The texture to bind.</param> /// <param name="level">The mipmap level to bind.</param> /// <param name="layer">The layer of the texture to bind.</param> /// <param name="access">Specifies the type of access allowed on the image.</param> public void Bind(int imageUnit, LayeredTexture texture, int level, int layer, TextureAccess access) { Bind(imageUnit, texture, level, false, layer, access); }