public spriteTexture(WebGLRenderingContext webgl, string url = null, textureformat format = textureformat.RGBA, bool mipmap = false, bool linear = true) { this.webgl = webgl; this.format = format; this.mat = new spriteMat();//ness this.mat.tex0 = this; this.mat.transparent = true; this.mat.shader = "spritedefault"; if (url == null)//不给定url 则 texture 不加载 { return; } this.texture = webgl.CreateTexture(); this.img = new Bridge.Html5.HTMLImageElement();// Image();// HTMLImageElement(); //ness this.img.Src = url; this.img.OnLoad = (e) => { if (this.disposeit) { this.img = null; return; } this._loadimg(mipmap, linear); }; }
public void reg(string url, string urladd, textureformat format, bool mipmap, bool linear) { //重复注册处理 if (this.mapInfo.ContainsKey(url)) //var item = this.mapInfo[url]; //if (item != Script.Undefined) { throw new Exception("you can't reg the same name"); //ness } var item = new texutreMgrItem(); //ness this.mapInfo[url] = item; item.url = url; item.urladd = urladd; item.format = format; item.mipmap = mipmap; item.linear = linear; }
static public spriteTexture fromRaw(WebGLRenderingContext webgl, HTMLImageElement img, textureformat format = textureformat.RGBA, bool mipmap = false, bool linear = true) { var st = new spriteTexture(webgl, null, format, mipmap, linear); st.texture = webgl.CreateTexture(); st.img = img; st._loadimg(mipmap, linear); return(st); }