Safe Haskell | None |
---|---|
Language | Haskell2010 |
Textures.
- newTexture :: MonadIO m => TextureSpecification -> m Texture
- data Texture
- data TextureSpecification = TextureSpecification {}
- textureSpecification :: TextureSpecification
- data Topology
- = Tex1D { }
- | Tex2D { }
- | Tex3D { }
- | Tex1DArray {
- width1DArray :: !Int
- layers1D :: !Int
- | Tex2DArray {
- width2DArray :: !Int
- height2DArray :: !Int
- layers2D :: !Int
- | Tex2DMultisample {
- width2DMS :: !Int
- height2DMS :: !Int
- samples2DMS :: !Int
- fixedSampleLocations2DMS :: !Bool
- | Tex2DMultisampleArray {
- width2DMSArray :: !Int
- height2DMSArray :: !Int
- layers2DMS :: !Int
- samples2DMSArray :: !Int
- fixedSampleLocations2DMSArray :: !Bool
- | TexCube { }
- | TexBuffer { }
- uploadToTexture :: MonadIO m => Uploading -> Texture -> m ()
- data Uploading = Uploading {
- fromBuffer :: !Buffer
- bufferOffset :: !Int
- toMipmapLevel :: !Int
- specificationType :: !SpecificationType
- uploadFormat :: !UploadFormat
- xOffset :: !Int
- yOffset :: !Int
- zOffset :: !Int
- uWidth :: !Int
- uHeight :: !Int
- uDepth :: !Int
- cubeSide :: CubeSide
- numColumns :: !Int
- numRows :: !Int
- pixelAlignment :: !Int
- uploading1D :: Buffer -> Int -> SpecificationType -> UploadFormat -> Uploading
- uploading2D :: Buffer -> Int -> Int -> SpecificationType -> UploadFormat -> Uploading
- uploading3D :: Buffer -> Int -> Int -> Int -> SpecificationType -> UploadFormat -> Uploading
- data UploadFormat
- = UR
- | URG
- | URGB
- | URGBA
- | UBGR
- | UBGRA
- | UDEPTH_COMPONENT
- | USTENCIL_INDEX
- data CubeSide
- type TextureUnit = Int
- generateMipmaps :: (MonadIO m, MonadMask m) => Texture -> m ()
- setWrapping :: (MonadIO m, MonadMask m) => Wrapping -> Texture -> m ()
- getWrapping :: (MonadIO m, MonadMask m) => Texture -> m Wrapping
- setMinFilter :: (MonadIO m, MonadMask m) => MinFilter -> Texture -> m ()
- setMagFilter :: (MonadIO m, MonadMask m) => MagFilter -> Texture -> m ()
- getMinFilter :: MonadIO m => Texture -> m MinFilter
- getMagFilter :: MonadIO m => Texture -> m MagFilter
- setAnisotropy :: (MonadIO m, MonadMask m) => Float -> Texture -> m ()
- getAnisotropy :: (MonadIO m, MonadMask m) => Texture -> m Float
- setCompareMode :: (MonadIO m, MonadMask m) => CompareMode -> Texture -> m ()
- getCompareMode :: (MonadIO m, MonadMask m) => Texture -> m CompareMode
- data MinFilter
- data MagFilter
- data Wrapping
- data CompareMode
- viewSpecification :: Texture -> TextureSpecification
- viewWidth :: Texture -> Int
- viewHeight :: Texture -> Int
- viewDepth :: Texture -> Int
- viewMipmapLevels :: Texture -> Int
- viewSize2D :: Texture -> V2 Int
- viewSize3D :: Texture -> V3 Int
- maxMipmapLevels :: Int -> Int
Creating textures
newTexture :: MonadIO m => TextureSpecification -> m Texture Source
Creates a new texture.
Initially the contents of the texture are undefined.
Texture dimensions must be positive.
data TextureSpecification Source
Specification on what the texture should be like.
Use textureSpecification
and set at least topology
and imageFormat
.
Future minor versions remain compatible if you use textureSpecification
instead of the constructor directly.
TextureSpecification | |
|
Specifies a topology of a texture.
Tex1D | |
Tex2D | |
Tex3D | |
Tex1DArray | |
| |
Tex2DArray | |
| |
Tex2DMultisample | Multisampling is available if OpenGL version >= 3.2 or
|
| |
Tex2DMultisampleArray | |
| |
TexCube | |
TexBuffer | Buffer textures, see https://www.opengl.org/wiki/Buffer_Texture Available if OpenGL version >= 3.1 or
|
Uploading to textures
uploadToTexture :: MonadIO m => Uploading -> Texture -> m () Source
Uploads an image to a texture.
Used to specify how to move the data from a Buffer
to a Texture
in
uploadToTexture
.
This is common for all texture topologies. However, some fields are ignored depending on the topology.
For example, if you upload into a 1D texture, then all fields that deal with
higher dimensions (yOffset
, zOffset
, uHeight
etc.) are ignored.
It is recommended that you use one of the smart constructors as they implement the common use cases so you don't have to fill all these fields by yourself.
Uploading | |
|
:: Buffer | |
-> Int | How many pixels to upload. |
-> SpecificationType | |
-> UploadFormat | |
-> Uploading |
Constructs a common 1D uploading.
:: Buffer | |
-> Int | Width of the image to upload. |
-> Int | Height of the image to upload. |
-> SpecificationType | |
-> UploadFormat | |
-> Uploading |
Constructs a common 2D uploading.
This can also be used for uploading into 1D texture arrays.
:: Buffer | |
-> Int | Width of the image to upload. |
-> Int | Height of the image to upload. |
-> Int | Number of images to upload. |
-> SpecificationType | |
-> UploadFormat | |
-> Uploading |
Constructs a common 3D uploading.
This can also be used for uploading into 2D texture arrays.
data UploadFormat Source
Specifies the format in which buffer data is for the purposes of uploading said data to a texture.
UR | Just red. |
URG | Red and green. |
URGB | You know the drill. |
URGBA | |
UBGR | |
UBGRA | |
UDEPTH_COMPONENT | Depth values. |
USTENCIL_INDEX | Stencil values. |
Values of this type refer to sides of a cube.
Texture units
type TextureUnit = Int Source
The type of a texture unit.
The minimum valid value is 0 and maximum is implementation dependant but in OpenGL at least 48 units will work at the same time in shaders.
Mipmapping
generateMipmaps :: (MonadIO m, MonadMask m) => Texture -> m () Source
Generate all mipmaps for a texture. If mipmap levels were specified, that is.
Texture parameters
getMinFilter :: MonadIO m => Texture -> m MinFilter Source
getMagFilter :: MonadIO m => Texture -> m MagFilter Source
setCompareMode :: (MonadIO m, MonadMask m) => CompareMode -> Texture -> m () Source
getCompareMode :: (MonadIO m, MonadMask m) => Texture -> m CompareMode Source
data CompareMode Source
Texture comparison modes.
See glTexParameteri
documentation in OpenGL.
Views
viewHeight :: Texture -> Int Source
Returns the height of a texture.
This is 1 for one-dimensional textures.
viewDepth :: Texture -> Int Source
Returns the depth of a 3D texture or number of layers in array textures.
This is 1 for any other type of texture.
viewMipmapLevels :: Texture -> Int Source
viewSize2D :: Texture -> V2 Int Source
Returns the size of a texture, as a V2
. Width and height.
viewSize2D tex = V2 (viewWidth tex) (viewHeight tex)
viewSize3D :: Texture -> V3 Int Source
Returns the size of a texture, as a V3
. Width, height and depth.
viewSize3D tex = V3 (viewWidth tex) (viewHeight tex) (viewDepth tex)
Utilities
maxMipmapLevels :: Int -> Int Source
Returns the maximal number of mipmap levels when given a side length.