public static int LoadTexture2D( Surface surface, bool flip, TextureOptions options) { if (surface == null) { throw new ArgumentNullException("surface"); } if (options == null) { throw new ArgumentNullException("options"); } int textureID; using (Surface textureSurface = TransformSurface(surface, flip)) { Gl.glGenTextures(1, out textureID); Gl.glBindTexture(Gl.GL_TEXTURE_2D, textureID); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, (int)options.MinifyingFilter); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, (int)options.MagnificationFilter); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, (int)options.WrapS); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, (int)options.WrapT); if (options.MinifyingFilter == MinifyingOption.Linear || options.MinifyingFilter == MinifyingOption.Nearest) { Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, textureSurface.BytesPerPixel, textureSurface.Width, textureSurface.Height, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, textureSurface.Pixels); } else { Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, textureSurface.BytesPerPixel, textureSurface.Width, textureSurface.Height, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, textureSurface.Pixels); } } return(textureID); }
public Texture2D(Surface surface, bool flip, TextureOptions options) { if (surface == null) { throw new ArgumentNullException("surface"); } if (options == null) { throw new ArgumentNullException("options"); } this.surface = surface; this.flip = flip; this.options = options; this.refresh = -1; this.textureID = -1; }
public SpriteDrawable(Surface surface, Vector2D[] vertexes, Vector2D[] coordinates, bool flip, TextureOptions options) { this.vertexes = new ARBArrayBuffer<Vector2D>(vertexes, Vector2D.Size); this.coordinates = new ARBArrayBuffer<Vector2D>(coordinates, Vector2D.Size); this.texture = new Texture2D(surface, flip, options); this.color = new ScalarColor4(1, 1, 1, 1); }
public static int[] LoadTexture2DRange( Surface surface, bool flip, TextureOptions[] options) { if (surface == null) { throw new ArgumentNullException("surface"); } if (options == null) { throw new ArgumentNullException("options"); } for (int index = 0; index < options.Length; ++index) { if (options[index] == null) { throw new ArgumentNullException("options"); } } int[] textureIDs = new int[options.Length]; using (Surface textureSurface = TransformSurface(surface, flip)) { Gl.glGenTextures(options.Length, textureIDs); for (int index = 0; index < options.Length; ++index) { Gl.glBindTexture(Gl.GL_TEXTURE_2D, textureIDs[index]); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, (int)options[index].MinifyingFilter); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, (int)options[index].MagnificationFilter); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, (int)options[index].WrapS); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, (int)options[index].WrapT); if (options[index].MinifyingFilter == MinifyingOption.Linear || options[index].MinifyingFilter == MinifyingOption.Nearest) { Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, textureSurface.BytesPerPixel, textureSurface.Width, textureSurface.Height, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, textureSurface.Pixels); } else { Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, textureSurface.BytesPerPixel, textureSurface.Width, textureSurface.Height, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, textureSurface.Pixels); } } } return textureIDs; }
public SpriteDrawable(Surface surface, Vector2D[] vertexes, Vector2D[] coordinates, bool flip, TextureOptions options) { this.vertexes = new ARBArrayBuffer <Vector2D>(vertexes, Vector2D.Size); this.coordinates = new ARBArrayBuffer <Vector2D>(coordinates, Vector2D.Size); this.texture = new Texture2D(surface, flip, options); this.color = new ScalarColor4(1, 1, 1, 1); }