public LTexture LoadTexture(string name) { if (imageList == null) { throw new Exception("Xml data not loaded !"); } ImageData data = (ImageData)CollectionUtils.Get(imageList, name); if (data == null) { throw new Exception("No such image reference: '" + name + "'"); } if (this.values[data.index] != null) { return(this.values[data.index].texture); } LTexture img = null; if (data.mask != null) { img = TextureUtils.FilterColor(data.xref, data.mask, data.scaleType == 0 ? Loon.Core.Graphics.Opengl.LTexture.Format.DEFAULT : Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR); } else { img = LTextures.LoadTexture(data.xref, data.scaleType == 0 ? Loon.Core.Graphics.Opengl.LTexture.Format.DEFAULT : Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR); } if ((data.w != 0) && (data.h != 0)) { img = img.GetSubTexture(data.x, data.y, data.w, data.h); } if (data.scale != 0) { img = img.Scale(data.scale); } this.values[data.index] = new LTextureObject(img, 0, 0); return(img); }
public virtual void SetBackground(LTexture background) { if (background != null) { SetRepaintMode(SCREEN_BITMAP_REPAINT); LTexture screen = null; if (background.GetWidth() != GetWidth() || background.GetHeight() != GetHeight()) { screen = background.Scale(GetWidth(), GetHeight()); } else { screen = background; } LTexture tmp = currentScreen; currentScreen = screen; if (tmp != null) { tmp.Destroy(); tmp = null; } } else { SetRepaintMode(SCREEN_CANVAS_REPAINT); } }