public static int loadFromFile(string url, int filter_far, int filter_near) { try { Texture tex = new Texture(); tex.bitmap = Texture.loadBMP(url); if (tex.bitmap == null) { return -1; } GL.GenTextures(1, out tex.ID); tex.Bind(); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, filter_far); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, filter_near); GL.GetTexParameter(TextureTarget.Texture2D, GetTextureParameter.TextureMagFilter, out tex.filterFar); GL.GetTexParameter(TextureTarget.Texture2D, GetTextureParameter.TextureMinFilter, out tex.filterNear); Rectangle rect = new Rectangle(0, 0, tex.bitmap.Width, tex.bitmap.Height); System.Drawing.Imaging.BitmapData bitmapdata = tex.bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, tex.bitmap.Width, tex.bitmap.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, bitmapdata.Scan0); tex.bitmap.Dispose(); return tex.ID; } catch(ArgumentException) { Debug.Trace("Class Texture: Error creating Bitmap: " + url); return -1; } }
public void init(Vector3 pos, Vector3 vel, float lifespan, float size, float angle, int color, string texName) { this.position = pos; this.velocity = vel; if (lifespan <= 0.0f) { Console.WriteLine("Class Particle: No Lifespan < 0 is permitted"); return; } this.life = lifespan; this.size = size; this.angle = angle; this.color = color; if(texName != null) { this.texture = new Texture(); Texture.loadFromFile(texName); } }