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

module Graphics.Rendering.OpenGL.GL.MatrixComponent where

import Foreign.Ptr
import Foreign.Storable
import Graphics.Rendering.OpenGL.GL.QueryUtils
import Graphics.Rendering.OpenGL.GL.Tensor
import Graphics.GL

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

class Storable c => MatrixComponent c where
   getMatrix :: GetPNameMatrix p => p -> Ptr c -> IO ()
   loadMatrix :: Ptr c -> IO ()
   loadTransposeMatrix :: Ptr c -> IO ()
   multMatrix_ :: Ptr c -> IO ()
   multTransposeMatrix :: Ptr c -> IO ()
   getUniformv :: GLuint -> GLint -> Ptr c -> IO ()
   uniformMatrix4v :: GLint -> GLsizei -> GLboolean -> Ptr c -> IO ()
   rotate :: c -> Vector3 c -> IO ()
   translate :: Vector3 c -> IO ()
   scale :: c -> c -> c -> IO ()

instance MatrixComponent GLfloat where
   getMatrix :: forall p. GetPNameMatrix p => p -> Ptr GLfloat -> IO ()
getMatrix = p -> Ptr GLfloat -> IO ()
forall p. GetPNameMatrix p => p -> Ptr GLfloat -> IO ()
getMatrixf
   loadMatrix :: Ptr GLfloat -> IO ()
loadMatrix = Ptr GLfloat -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLfloat -> m ()
glLoadMatrixf
   loadTransposeMatrix :: Ptr GLfloat -> IO ()
loadTransposeMatrix = Ptr GLfloat -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLfloat -> m ()
glLoadTransposeMatrixf
   multMatrix_ :: Ptr GLfloat -> IO ()
multMatrix_ = Ptr GLfloat -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLfloat -> m ()
glMultMatrixf
   multTransposeMatrix :: Ptr GLfloat -> IO ()
multTransposeMatrix = Ptr GLfloat -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLfloat -> m ()
glMultTransposeMatrixf
   getUniformv :: GLuint -> GLint -> Ptr GLfloat -> IO ()
getUniformv = GLuint -> GLint -> Ptr GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLuint -> GLint -> Ptr GLfloat -> m ()
glGetUniformfv
   uniformMatrix4v :: GLint -> GLint -> GLboolean -> Ptr GLfloat -> IO ()
uniformMatrix4v = GLint -> GLint -> GLboolean -> Ptr GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLint -> GLint -> GLboolean -> Ptr GLfloat -> m ()
glUniformMatrix4fv
   rotate :: GLfloat -> Vector3 GLfloat -> IO ()
rotate GLfloat
a (Vector3 GLfloat
x GLfloat
y GLfloat
z) = GLfloat -> GLfloat -> GLfloat -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLfloat -> GLfloat -> GLfloat -> GLfloat -> m ()
glRotatef GLfloat
a GLfloat
x GLfloat
y GLfloat
z
   translate :: Vector3 GLfloat -> IO ()
translate (Vector3 GLfloat
x GLfloat
y GLfloat
z) = GLfloat -> GLfloat -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLfloat -> GLfloat -> GLfloat -> m ()
glTranslatef GLfloat
x GLfloat
y GLfloat
z
   scale :: GLfloat -> GLfloat -> GLfloat -> IO ()
scale = GLfloat -> GLfloat -> GLfloat -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLfloat -> GLfloat -> GLfloat -> m ()
glScalef

instance MatrixComponent GLdouble where
   getMatrix :: forall p. GetPNameMatrix p => p -> Ptr GLdouble -> IO ()
getMatrix = p -> Ptr GLdouble -> IO ()
forall p. GetPNameMatrix p => p -> Ptr GLdouble -> IO ()
getMatrixd
   loadMatrix :: Ptr GLdouble -> IO ()
loadMatrix = Ptr GLdouble -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLdouble -> m ()
glLoadMatrixd
   loadTransposeMatrix :: Ptr GLdouble -> IO ()
loadTransposeMatrix = Ptr GLdouble -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLdouble -> m ()
glLoadTransposeMatrixd
   multMatrix_ :: Ptr GLdouble -> IO ()
multMatrix_ = Ptr GLdouble -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLdouble -> m ()
glMultMatrixd
   multTransposeMatrix :: Ptr GLdouble -> IO ()
multTransposeMatrix = Ptr GLdouble -> IO ()
forall (m :: * -> *). MonadIO m => Ptr GLdouble -> m ()
glMultTransposeMatrixd
   getUniformv :: GLuint -> GLint -> Ptr GLdouble -> IO ()
getUniformv = GLuint -> GLint -> Ptr GLdouble -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLuint -> GLint -> Ptr GLdouble -> m ()
glGetUniformdv
   uniformMatrix4v :: GLint -> GLint -> GLboolean -> Ptr GLdouble -> IO ()
uniformMatrix4v = GLint -> GLint -> GLboolean -> Ptr GLdouble -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLint -> GLint -> GLboolean -> Ptr GLdouble -> m ()
glUniformMatrix4dv
   rotate :: GLdouble -> Vector3 GLdouble -> IO ()
rotate GLdouble
a (Vector3 GLdouble
x GLdouble
y GLdouble
z) = GLdouble -> GLdouble -> GLdouble -> GLdouble -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLdouble -> GLdouble -> GLdouble -> GLdouble -> m ()
glRotated GLdouble
a GLdouble
x GLdouble
y GLdouble
z
   translate :: Vector3 GLdouble -> IO ()
translate (Vector3 GLdouble
x GLdouble
y GLdouble
z) = GLdouble -> GLdouble -> GLdouble -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLdouble -> GLdouble -> GLdouble -> m ()
glTranslated GLdouble
x GLdouble
y GLdouble
z
   scale :: GLdouble -> GLdouble -> GLdouble -> IO ()
scale = GLdouble -> GLdouble -> GLdouble -> IO ()
forall (m :: * -> *).
MonadIO m =>
GLdouble -> GLdouble -> GLdouble -> m ()
glScaled