2020-10-12 04:08:33 +00:00
|
|
|
module Types.Texture where
|
|
|
|
|
|
|
|
import SDL (($=), get)
|
|
|
|
|
|
|
|
import qualified Graphics.Rendering.OpenGL as GL
|
|
|
|
|
|
|
|
-- internal imports
|
|
|
|
|
2020-10-17 14:18:42 +00:00
|
|
|
import Classes.Graphics.Bindable
|
2020-10-12 04:08:33 +00:00
|
|
|
|
|
|
|
data Texture = Texture
|
|
|
|
{ textureId :: GL.TextureObject
|
|
|
|
, textureSlot :: GL.TextureUnit
|
|
|
|
}
|
|
|
|
deriving (Eq, Show)
|
|
|
|
|
|
|
|
instance Bindable Texture where
|
|
|
|
|
|
|
|
bind t = do
|
|
|
|
GL.activeTexture $= textureSlot t
|
|
|
|
GL.textureBinding GL.Texture2D $= Just (textureId t)
|
|
|
|
|
|
|
|
unbind t = GL.textureBinding GL.Texture2D $= Nothing
|