Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed metavar's dsl

  • Loading branch information...
commit 20f955b7a2e8285e64d6ae00b0eef8697ffddc8d 1 parent 5e82fee
Nik Nyby authored
Showing with 0 additions and 89 deletions.
  1. +0 −89 MetaGL.hs
View
89 MetaGL.hs
@@ -1,89 +0,0 @@
-{-# OPTIONS -fglasgow-exts #-}
-
-{- metavar's dsl. do it this way until i know what can be removed
- -}
-
-module MetaGL (
- GLC(..),
- rotate,
- scale,
- translate,
- identity,
- triangles,
- quads,
- serial,
- parallel,
- vertex,
- color,
- render,
-) where
-
-import qualified Graphics.UI.GLUT as GL
---import qualified Graphics.Rendering.OpenGL as OGL
-
-class GLCommand a where
- render :: a -> IO ()
-
-data GLC = forall a. GLCommand a => GLC a
-instance GLCommand GLC where
- render (GLC a) = render a
-
-rotate :: GL.GLdouble -> GL.GLdouble -> GL.GLdouble -> GL.GLdouble -> GLC
-rotate a v1 v2 v3 = GLC $ ActionRotate a (GL.Vector3 v1 v2 v3)
-scale :: GL.GLdouble -> GL.GLdouble -> GL.GLdouble -> GLC
-scale x y z = GLC $ ActionScale x y z
-translate :: GL.GLdouble -> GL.GLdouble -> GL.GLdouble -> GLC
-translate x y z = GLC $ ActionTranslate (GL.Vector3 x y z)
-identity :: GLC
-identity = GLC $ (ActionIdentity :: MatrixActions GL.GLdouble)
-
-data GL.MatrixComponent a => MatrixActions a =
- ActionRotate a (GL.Vector3 a)
- | ActionScale a a a
- | ActionTranslate (GL.Vector3 a)
- | ActionIdentity
-
-instance GL.MatrixComponent a => GLCommand (MatrixActions a) where
- render = matrixActions
-matrixActions (ActionRotate angle vec) = GL.rotate angle vec
-matrixActions (ActionScale x y z) = GL.scale x y z
-matrixActions (ActionTranslate vec) = GL.translate vec
-matrixActions (ActionIdentity) = GL.loadIdentity
-
-data GL.VertexComponent a => VertexActions a = ActionVertex (GL.Vertex2 a)
-instance GL.VertexComponent a => GLCommand (VertexActions a) where
- render = vertexActions
-vertexActions (ActionVertex vec) = GL.vertex vec
-vertex :: GL.GLdouble -> GL.GLdouble -> GLC
-vertex x y = GLC $ ActionVertex (GL.Vertex2 x y)
-
-data GL.ColorComponent a => ColorActions a = ActionColor (GL.Color3 a)
-instance GL.ColorComponent a => GLCommand (ColorActions a) where
- render = colorActions
-colorActions (ActionColor c) = GL.color c
-color :: GL.GLdouble -> GL.GLdouble -> GL.GLdouble -> GLC
-color r g b = GLC $ ActionColor (GL.Color3 r g b)
-
-triangles, quads, serial, parallel :: [GLC] -> GLC
-triangles commands = GLC $ RenderTriangles commands
-quads commands = GLC $ RenderQuads commands
-serial commands = GLC $ RenderSerial commands
-parallel commands = GLC $ RenderParallel commands
-
-data RenderActions =
- RenderTriangles [GLC]
- | RenderQuads [GLC]
- | RenderSerial [GLC]
- | RenderParallel [GLC]
--- | RenderRenderMode [GLC]
--- | RenderSelectMode [GLC]
-instance GLCommand RenderActions where
- render = renderActions
-
-renderActions :: RenderActions -> IO ()
-renderActions (RenderTriangles commands) = GL.renderPrimitive GL.Triangles $ mapM_ render commands
-renderActions (RenderQuads commands) = GL.renderPrimitive GL.Quads $ mapM_ render commands
-renderActions (RenderSerial commands) = mapM_ render commands
-renderActions (RenderParallel commands) = mapM_ (GL.preservingMatrix . render) commands
---renderActions (RenderRenderMode commands) = GL.renderMode $ mapM_ render commands
---renderActions (RenderSelectMode commands) =
Please sign in to comment.
Something went wrong with that request. Please try again.