Module OgamlGraphics.Texture.Texture2D

Represents a simple 2D texture

This module provides an abstraction of OpenGL 2D textures that can be used for 2D rendering (with sprites) or 3D rendering when passed to a GLSL program.

type t
Type of a 2D texture
val create : (module RenderTarget.T with type t = 'a) -> 'a -> ?mipmaps:[ `AllEmpty | `Empty of int | `AllGenerated | `Generated of int | `None] -> [< `File of string | `Image of Image.t | `Empty of OgamlMath.Vector2i.t] -> t
Creates a texture from a source (a file or an image), or an empty texture. Generates all mipmaps by default.
Raises Texture_error if the requested size exceeds the maximal texture size allowed by the context.

See : OgamlGraphics.RenderTarget.T
See : OgamlMath.Vector2i
See : OgamlGraphics.Context
val size : t -> OgamlMath.Vector2i.t
Returns the size of a texture
See : OgamlMath.Vector2i
val minify : t -> MinifyFilter.t -> unit
Sets the minifying filter of a texture. Defaults as LinearMipmapLinear.
val magnify : t -> MagnifyFilter.t -> unit
Sets the magnifying filter of a texture. Defaults as Linear
val wrap : t -> WrapFunction.t -> unit
Sets the wrapping function of a texture. Defaults as ClampEdge.
val mipmap_levels : t -> int
Returns the number of mipmap levels of a texture
val mipmap : t -> int -> Texture2DMipmap.t
Returns a mipmap level of a texture. Raises Invalid_argument if the requested level is out of bounds
val bind : t -> int -> unit
System only function, binds a texture to a texture unit for drawing
val to_color_attachment : t -> Attachment.ColorAttachment.t
Texture2D implements the interface ColorAttachable and can be attached to an FBO. Binds the mipmap level 0.