{-# OPTIONS_HADDOCK hide #-}
module Graphics.Rendering.OpenGL.GL.Texturing.Filter (
TextureFilter(..),
MinificationFilter, marshalMinificationFilter, unmarshalMinificationFilter,
MagnificationFilter, marshalMagnificationFilter, unmarshalMagnificationFilter
) where
import Graphics.GL
data TextureFilter =
Nearest
| Linear'
deriving ( TextureFilter -> TextureFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextureFilter -> TextureFilter -> Bool
$c/= :: TextureFilter -> TextureFilter -> Bool
== :: TextureFilter -> TextureFilter -> Bool
$c== :: TextureFilter -> TextureFilter -> Bool
Eq, Eq TextureFilter
TextureFilter -> TextureFilter -> Bool
TextureFilter -> TextureFilter -> Ordering
TextureFilter -> TextureFilter -> TextureFilter
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TextureFilter -> TextureFilter -> TextureFilter
$cmin :: TextureFilter -> TextureFilter -> TextureFilter
max :: TextureFilter -> TextureFilter -> TextureFilter
$cmax :: TextureFilter -> TextureFilter -> TextureFilter
>= :: TextureFilter -> TextureFilter -> Bool
$c>= :: TextureFilter -> TextureFilter -> Bool
> :: TextureFilter -> TextureFilter -> Bool
$c> :: TextureFilter -> TextureFilter -> Bool
<= :: TextureFilter -> TextureFilter -> Bool
$c<= :: TextureFilter -> TextureFilter -> Bool
< :: TextureFilter -> TextureFilter -> Bool
$c< :: TextureFilter -> TextureFilter -> Bool
compare :: TextureFilter -> TextureFilter -> Ordering
$ccompare :: TextureFilter -> TextureFilter -> Ordering
Ord, Int -> TextureFilter -> ShowS
[TextureFilter] -> ShowS
TextureFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextureFilter] -> ShowS
$cshowList :: [TextureFilter] -> ShowS
show :: TextureFilter -> String
$cshow :: TextureFilter -> String
showsPrec :: Int -> TextureFilter -> ShowS
$cshowsPrec :: Int -> TextureFilter -> ShowS
Show )
type MinificationFilter = (TextureFilter, Maybe TextureFilter)
type MagnificationFilter = TextureFilter
magToMin :: MagnificationFilter -> MinificationFilter
magToMin :: TextureFilter -> MinificationFilter
magToMin TextureFilter
magFilter = (TextureFilter
magFilter, forall a. Maybe a
Nothing)
minToMag :: MinificationFilter -> MagnificationFilter
minToMag :: MinificationFilter -> TextureFilter
minToMag (TextureFilter
magFilter, Maybe TextureFilter
Nothing) = TextureFilter
magFilter
minToMag MinificationFilter
minFilter = forall a. HasCallStack => String -> a
error (String
"minToMag: illegal value " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show MinificationFilter
minFilter)
marshalMinificationFilter :: MinificationFilter -> GLint
marshalMinificationFilter :: MinificationFilter -> GLint
marshalMinificationFilter MinificationFilter
x = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ case MinificationFilter
x of
(TextureFilter
Nearest, Maybe TextureFilter
Nothing ) -> GLenum
GL_NEAREST
(TextureFilter
Linear', Maybe TextureFilter
Nothing ) -> GLenum
GL_LINEAR
(TextureFilter
Nearest, Just TextureFilter
Nearest) -> GLenum
GL_NEAREST_MIPMAP_NEAREST
(TextureFilter
Linear', Just TextureFilter
Nearest) -> GLenum
GL_LINEAR_MIPMAP_NEAREST
(TextureFilter
Nearest, Just TextureFilter
Linear') -> GLenum
GL_NEAREST_MIPMAP_LINEAR
(TextureFilter
Linear', Just TextureFilter
Linear') -> GLenum
GL_LINEAR_MIPMAP_LINEAR
marshalMagnificationFilter :: MagnificationFilter -> GLint
marshalMagnificationFilter :: TextureFilter -> GLint
marshalMagnificationFilter = MinificationFilter -> GLint
marshalMinificationFilter forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextureFilter -> MinificationFilter
magToMin
unmarshalMinificationFilter :: GLint -> MinificationFilter
unmarshalMinificationFilter :: GLint -> MinificationFilter
unmarshalMinificationFilter GLint
x
| GLenum
y forall a. Eq a => a -> a -> Bool
== GLenum
GL_NEAREST = (TextureFilter
Nearest, forall a. Maybe a
Nothing)
| GLenum
y forall a. Eq a => a -> a -> Bool
== GLenum
GL_LINEAR = (TextureFilter
Linear', forall a. Maybe a
Nothing)
| GLenum
y forall a. Eq a => a -> a -> Bool
== GLenum
GL_NEAREST_MIPMAP_NEAREST = (TextureFilter
Nearest, forall a. a -> Maybe a
Just TextureFilter
Nearest)
| GLenum
y forall a. Eq a => a -> a -> Bool
== GLenum
GL_LINEAR_MIPMAP_NEAREST = (TextureFilter
Linear', forall a. a -> Maybe a
Just TextureFilter
Nearest)
| GLenum
y forall a. Eq a => a -> a -> Bool
== GLenum
GL_NEAREST_MIPMAP_LINEAR = (TextureFilter
Nearest, forall a. a -> Maybe a
Just TextureFilter
Linear')
| GLenum
y forall a. Eq a => a -> a -> Bool
== GLenum
GL_LINEAR_MIPMAP_LINEAR = (TextureFilter
Linear', forall a. a -> Maybe a
Just TextureFilter
Linear')
| Bool
otherwise = forall a. HasCallStack => String -> a
error (String
"unmarshalMinificationFilter: illegal value " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show GLint
x)
where y :: GLenum
y = forall a b. (Integral a, Num b) => a -> b
fromIntegral GLint
x
unmarshalMagnificationFilter :: GLint -> MagnificationFilter
unmarshalMagnificationFilter :: GLint -> TextureFilter
unmarshalMagnificationFilter = MinificationFilter -> TextureFilter
minToMag forall b c a. (b -> c) -> (a -> b) -> a -> c
. GLint -> MinificationFilter
unmarshalMinificationFilter