{-# OPTIONS_HADDOCK hide #-}
--------------------------------------------------------------------------------
-- |
-- Module      :  Graphics.Rendering.OpenGL.GL.Shaders.Shader
-- Copyright   :  (c) Sven Panne 2019
-- License     :  BSD3
-- 
-- Maintainer  :  Sven Panne <svenpanne@gmail.com>
-- Stability   :  stable
-- Portability :  portable
--
-- This is a purely internal module for handling shader objects.
--
--------------------------------------------------------------------------------

module Graphics.Rendering.OpenGL.GL.Shaders.Shader (
   Shader(..)
) where

import Control.Monad.IO.Class
import Data.ObjectName
import Graphics.Rendering.OpenGL.GL.DebugOutput
import Graphics.Rendering.OpenGL.GL.GLboolean
import Graphics.Rendering.OpenGL.GL.QueryUtils
import Graphics.GL

--------------------------------------------------------------------------------

newtype Shader = Shader { Shader -> GLuint
shaderID :: GLuint }
   deriving ( Shader -> Shader -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Shader -> Shader -> Bool
$c/= :: Shader -> Shader -> Bool
== :: Shader -> Shader -> Bool
$c== :: Shader -> Shader -> Bool
Eq, Eq Shader
Shader -> Shader -> Bool
Shader -> Shader -> Ordering
Shader -> Shader -> Shader
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 :: Shader -> Shader -> Shader
$cmin :: Shader -> Shader -> Shader
max :: Shader -> Shader -> Shader
$cmax :: Shader -> Shader -> Shader
>= :: Shader -> Shader -> Bool
$c>= :: Shader -> Shader -> Bool
> :: Shader -> Shader -> Bool
$c> :: Shader -> Shader -> Bool
<= :: Shader -> Shader -> Bool
$c<= :: Shader -> Shader -> Bool
< :: Shader -> Shader -> Bool
$c< :: Shader -> Shader -> Bool
compare :: Shader -> Shader -> Ordering
$ccompare :: Shader -> Shader -> Ordering
Ord, Int -> Shader -> ShowS
[Shader] -> ShowS
Shader -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Shader] -> ShowS
$cshowList :: [Shader] -> ShowS
show :: Shader -> String
$cshow :: Shader -> String
showsPrec :: Int -> Shader -> ShowS
$cshowsPrec :: Int -> Shader -> ShowS
Show )

instance ObjectName Shader where
   isObjectName :: forall (m :: * -> *). MonadIO m => Shader -> m Bool
isObjectName = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. (Eq a, Num a) => a -> Bool
unmarshalGLboolean forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). MonadIO m => GLuint -> m GLboolean
glIsShader forall b c a. (b -> c) -> (a -> b) -> a -> c
. Shader -> GLuint
shaderID
   deleteObjectName :: forall (m :: * -> *). MonadIO m => Shader -> m ()
deleteObjectName = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). MonadIO m => GLuint -> m ()
glDeleteShader forall b c a. (b -> c) -> (a -> b) -> a -> c
. Shader -> GLuint
shaderID

instance CanBeLabeled Shader where
   objectLabel :: Shader -> StateVar (Maybe String)
objectLabel = GLuint -> GLuint -> StateVar (Maybe String)
objectNameLabel GLuint
GL_SHADER forall b c a. (b -> c) -> (a -> b) -> a -> c
. Shader -> GLuint
shaderID