GPipe-1.3.2: A functional graphics API for programmable GPUs

Safe HaskellSafe-Infered

Graphics.GPipe.Texture

Contents

Description

Textures are type safe in GPipe, e.g. when you sample a RGBFormat texture, you get an RGB value.

Textures are either created directly from memory, or by giving a framebuffer a concrete size (which it otherwise don't have). The latter is however not possible for 3D textures.

Depth textures are textures that contains depth component data (of type DepthFormat) but takes the type of LuminanceFormat or AlphaFormat textures, and are sampled as such.

Synopsis

Data types

data Texture3D f Source

A 3D texture. May only be created from main memory in GPipe. Texture3D f has the following associated types in its Texture instance:

TextureFormat (Texture3D f)
f
TextureSize (Texture3D f)
Vec3 Int
TextureVertexCoord (Texture3D f)
Vec3 (Vertex Float)
TextureFragmentCoord (Texture3D f)
Vec3 (Fragment Float)

Instances

data Texture2D f Source

A 2D texture. Texture2D f has the following associated types in its Texture instance:

TextureFormat (Texture2D f)
f
TextureSize (Texture2D f)
Vec2 Int
TextureVertexCoord (Texture2D f)
Vec2 (Vertex Float)
TextureFragmentCoord (Texture2D f)
Vec2 (Fragment Float)

data Texture1D f Source

A 1D texture. Assumes a frame buffer of height 1 when created from such. Texture1D f has the following associated types in its Texture instance:

TextureFormat (Texture1D f)
f
TextureSize (Texture1D f)
Int
TextureVertexCoord (Texture1D f)
Vertex Float
TextureFragmentCoord (Texture1D f)
Fragment Float

data TextureCube f Source

A cube texture. The sides of the cube are always specified in this order: Positive X, negative X, positive Y, negative Y, positive Z, negative Z. TextureCube f has the following associated types in its Texture instance:

TextureFormat (TextureCube f)
f
TextureSize (TextureCube f)
Vec2 Int (The size of each side)
TextureVertexCoord (TextureCube f)
Vec3 (Vertex Float)
TextureFragmentCoord (TextureCube f)
Vec3 (Fragment Float)

Instances

Operation

class Texture t whereSource

Associated Types

type TextureFormat t Source

The color format of the texture, affects the type of the samples from the texture.

type TextureSize t Source

The type that is used for the dimension of texture.

type TextureVertexCoord t Source

The sample coordinate in Vertexs.

type TextureFragmentCoord t Source

The sample coordinate in Fragments.

Methods

textureCPUFormatByteSize :: CPUFormat (TextureFormat t) -> TextureSize t -> [Int]Source

Calculates the byte size of all mipmaps for a specific format and size, which eases the useage of newTexture and newDepthTexture.

sample :: Sampler -> t -> TextureFragmentCoord t -> Color (TextureFormat t) (Fragment Float)Source

Samples the texture using mipmaps in a Fragment.

sampleBias :: Sampler -> t -> TextureFragmentCoord t -> Fragment Float -> Color (TextureFormat t) (Fragment Float)Source

Samples the texture using mipmaps in a Fragment, with a bias to add to the mipmap level.

sampleLod :: Sampler -> t -> TextureVertexCoord t -> Vertex Float -> Color (TextureFormat t) (Vertex Float)Source

Samples the texture using a specific mipmap in a Vertex.

Creation

newTextureSource

Arguments

:: (Texture t, GPUFormat (TextureFormat t)) 
=> CPUFormat (TextureFormat t)

The format of the data in the provided Ptr's.

-> TextureFormat t

The format of the resulting texture on the GPU.

-> TextureSize t

The dimension of the texture.

-> [Ptr a]

A list of Ptr's for each mipmap of the texture (you may provide as many as you want). For TextureCube, this list starts with all mipmaps of the first side, then the mipmaps of the second, and so on. In this case all sides must have the same number of mipmaps. All rows and depth levels are tightly packed, i.e. no padding between them and 1 byte alignment.

-> IO t 

Creates a texture from color data in main memory. It lives in the IO monad for the sake of the Ptr's, and could otherwise safely be wrapped in unsafePerformIO calls.

newDepthTextureSource

Arguments

:: (Texture t, DepthColorFormat (TextureFormat t)) 
=> CPUFormat (TextureFormat t)

The format of the data in the provided Ptr's.

-> DepthFormat

The depth format of the resulting texture on the GPU.

-> TextureSize t

The dimension of the texture.

-> [Ptr a]

A list of Ptr's for each mipmap of the texture (you may provide as many as you want). For TextureCube, this list starts with all mipmaps of the first side, then the mipmaps of the second, and so on. In this case all sides must have the same number of mipmaps. All rows and depth levels are tightly packed, i.e. no padding between them and 1 byte alignment.

-> IO t 

Creates a depth texture from data in main memory. The texture will have the type of a color format and is sampled as such, but contains depth component information internally. It lives in the IO monad for the sake of the Ptr's, and could otherwise safely be wrapped in unsafePerformIO calls.

class Texture t => FromFrameBufferColor t c whereSource

The textures that is instances of this class may be created from a FrameBuffers color buffer.

Methods

fromFrameBufferColor :: TextureFormat t -> TextureSize t -> FrameBuffer c d s -> tSource

Create a texture of a specific format from a FrameBuffer and a size.

class Texture t => FromFrameBufferDepth t whereSource

The textures that is instances of this class may be created from a FrameBuffers depth buffer. The texture will have the type of a color format and is sampled as such, but contains depth component information internally.

Methods

fromFrameBufferDepth :: DepthFormat -> TextureSize t -> FrameBuffer c DepthFormat s -> tSource

Create a texture of a specific depth format from a FrameBuffer and a size.

class ColorFormat a => DepthColorFormat a Source

The formats that is instances of this class may be used as depth textures, i.e. created with newDepthTexture, fromFrameBufferDepth and fromFrameBufferCubeDepth.

fromFrameBufferCubeColor :: ColorFormat c => c -> Vec2 Int -> FrameBuffer c d1 s1 -> FrameBuffer c d2 s2 -> FrameBuffer c d3 s3 -> FrameBuffer c d4 s4 -> FrameBuffer c d5 s5 -> FrameBuffer c d6 s6 -> TextureCube cSource

Create a TextureCube of a specific format and size from the the color buffers of six framebuffers.

fromFrameBufferCubeDepth :: DepthColorFormat d => DepthFormat -> Vec2 Int -> FrameBuffer c1 DepthFormat s1 -> FrameBuffer c2 DepthFormat s2 -> FrameBuffer c3 DepthFormat s3 -> FrameBuffer c4 DepthFormat s4 -> FrameBuffer c5 DepthFormat s5 -> FrameBuffer c6 DepthFormat s6 -> TextureCube dSource

Create a TextureCube of a specific depth format and size from the the depth buffers of six framebuffers. The texture will have the type of a color format and is sampled as such, but contains depth component information internally.

Samplers

data Sampler Source

A structure describing how a texture is sampled

Constructors

Sampler Filter EdgeMode 

Instances

data Filter Source

Filter mode used in sampler state

Constructors

Point 
Linear 

data EdgeMode Source

Edge mode used in sampler state

Constructors

Wrap 
Mirror 
Clamp