Michelangelo 0.1.0.1 → 0.1.0.2
raw patch · 11 files changed
+115/−75 lines, 11 files
Files
- Michelangelo.cabal +4/−3
- README.md +1/−0
- src/Graphics/Michelangelo/Camera.hs +1/−0
- src/Graphics/Michelangelo/Entity.hs +1/−6
- src/Graphics/Michelangelo/Mesh.hs +1/−21
- src/Graphics/Michelangelo/Scene.hs +1/−9
- src/Graphics/Michelangelo/Shaders.hs +1/−36
- src/Graphics/Michelangelo/Shapes.hs +1/−0
- src/Graphics/Michelangelo/Transformations.hs +1/−0
- src/Graphics/Michelangelo/Types.hs +101/−0
- src/Graphics/Michelangelo/Utils.hs +2/−0
Michelangelo.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 0.1.0.1 +version: 0.1.0.2 -- A short (one-line) description of the package. synopsis: OpenGL for dummies @@ -52,8 +52,9 @@ library -- Modules exported by the library. - exposed-modules: Graphics.Michelangelo.Utils, Graphics.Michelangelo.Transformations, Graphics.Michelangelo.Shapes, Graphics.Michelangelo.Shaders, - Graphics.Michelangelo.Scene, Graphics.Michelangelo.Mesh, Graphics.Michelangelo.Entity, Graphics.Michelangelo.Camera + exposed-modules: Graphics.Michelangelo.Types, Graphics.Michelangelo.Utils, Graphics.Michelangelo.Transformations, Graphics.Michelangelo.Shapes, + Graphics.Michelangelo.Shaders, Graphics.Michelangelo.Scene, Graphics.Michelangelo.Mesh, Graphics.Michelangelo.Entity, + Graphics.Michelangelo.Camera -- Modules included in this library but not exported. -- other-modules:
README.md view
@@ -6,5 +6,6 @@ ------------ Jonatan H Sundqvist + TODO ----
src/Graphics/Michelangelo/Camera.hs view
@@ -25,6 +25,7 @@ -------------------------------------------------------------------------------------------------------------------------------------------- -- We'll need these -------------------------------------------------------------------------------------------------------------------------------------------- +import Graphics.Michelangelo.Types
src/Graphics/Michelangelo/Entity.hs view
@@ -27,12 +27,7 @@ -------------------------------------------------------------------------------------------------------------------------------------------- import Control.Lens -- - - --------------------------------------------------------------------------------------------------------------------------------------------- --- Types --------------------------------------------------------------------------------------------------------------------------------------------- -data Entity = Entity {} +import Graphics.Michelangelo.Types
src/Graphics/Michelangelo/Mesh.hs view
@@ -45,28 +45,8 @@ import Graphics.WaveFront.Load as WFL -- import Graphics.WaveFront.Parsers as WF -- +import Graphics.Michelangelo.Types import Graphics.Michelangelo.Shaders as Shade -- - - - --------------------------------------------------------------------------------------------------------------------------------------------- --- Types --------------------------------------------------------------------------------------------------------------------------------------------- --- | --- TODO: Include shader program, attributes, uniforms, etc. (?) --- TODO: Store render function (?) --- TODO: Restructure (?) --- TODO: Metadata (?) -data Mesh = Mesh { texture :: Maybe GL.TextureObject, -- TODO: Allow more than one texture (?) - primitive :: GL.PrimitiveMode, -- - attributes :: Map.Map String Attribute, -- - uniforms :: Map.Map String (GL.UniformLocation, UniformValue), -- - shader :: GL.Program, -- - prepare :: Maybe (Mesh -> IO ()), -- Optional rendering setup function - centre :: V3 Float, -- - bounds :: WF.BoundingBox Float, -- - size :: Int -- - } --deriving (Show)
src/Graphics/Michelangelo/Scene.hs view
@@ -25,18 +25,10 @@ -------------------------------------------------------------------------------------------------------------------------------------------- -- We'll need these -------------------------------------------------------------------------------------------------------------------------------------------- - --------------------------------------------------------------------------------------------------------------------------------------------- +import Graphics.Michelangelo.Types import Graphics.Michelangelo.Camera import Graphics.Michelangelo.Entity import Graphics.Michelangelo.Mesh - - - --------------------------------------------------------------------------------------------------------------------------------------------- --- Types --------------------------------------------------------------------------------------------------------------------------------------------- --- data Scene = Scene { _camera :: Camera, _entities :: [Entity], }
src/Graphics/Michelangelo/Shaders.hs view
@@ -63,42 +63,7 @@ import Text.Printf - - --------------------------------------------------------------------------------------------------------------------------------------------- --- Types --------------------------------------------------------------------------------------------------------------------------------------------- --- | -data ShaderProgram = ShaderProgram { _program :: GL.Program, - _attributes :: Map.Map String (GL.AttribLocation, GL.VariableType), - _uniforms :: Map.Map String (GL.UniformLocation, GL.VariableType)} - - --- | --- type Uniform = (GL.UniformLocation, UniformValue) -- -type Attribute = (GL.AttribLocation, GL.BufferObject, Int) -- TODO: Are there any non-buffer attribute types, separate type (?) - - --- | --- TODO: Make polymorphic (?) --- TODO: Refactor --- TODO: Implement uniformv --- TODO: Find out how to read uniform value --- instance GL.UniformComponent a => GL.Uniform (M44 a) where -instance GL.Uniform (M44 Float) where - uniform (GL.UniformLocation loc) = GL.makeStateVar (error "Not implemented") (\u -> Marshal.with (transpose u) (\ptr -> GLRaw.glUniformMatrix4fv loc 1 0 (castPtr (ptr :: Ptr (M44 Float))))) - -- uniformv loc count = uniform3v location count . (castPtr :: Ptr (Vertex3 b) -> Ptr b) - - -instance GL.Uniform (Float) where - uniform (GL.UniformLocation loc) = GL.makeStateVar (error "Not implemented") (\f -> Marshal.with f (\ptr -> GLRaw.glUniform1fv loc 1 (castPtr (ptr :: Ptr (Float))))) - -- uniformv loc count = uniform3v location count . (castPtr :: Ptr (Vertex3 b) -> Ptr b) - - --- | -instance GL.Uniform (Int) where - uniform (GL.UniformLocation loc) = GL.makeStateVar (error "Not implemented") (\i -> Marshal.with i (\ptr -> GLRaw.glUniform1iv loc 1 (castPtr (ptr :: Ptr (Int))))) - -- uniformv loc count = uniform3v location count . (castPtr :: Ptr (Vertex3 b) -> Ptr b) +import Graphics.Michelangelo.Types
src/Graphics/Michelangelo/Shapes.hs view
@@ -25,6 +25,7 @@ -------------------------------------------------------------------------------------------------------------------------------------------- -- We'll need these -------------------------------------------------------------------------------------------------------------------------------------------- +import Graphics.Michelangelo.Types
src/Graphics/Michelangelo/Transformations.hs view
@@ -38,6 +38,7 @@ -------------------------------------------------------------------------------------------------------------------------------------------- -- Types -------------------------------------------------------------------------------------------------------------------------------------------- +import Graphics.Michelangelo.Types
+ src/Graphics/Michelangelo/Types.hs view
@@ -0,0 +1,101 @@+-- | +-- Module : Graphics.Michelangelo.Types.hs +-- Description : +-- Copyright : (c) Jonatan H Sundqvist, 2015 +-- License : MIT +-- Maintainer : Jonatan H Sundqvist +-- Stability : experimental|stable +-- Portability : POSIX (not sure) +-- + +-- Created October 30 2015 + +-- TODO | - +-- - + +-- SPEC | - +-- - + + + +-------------------------------------------------------------------------------------------------------------------------------------------- +-- GHC Pragmas +-------------------------------------------------------------------------------------------------------------------------------------------- + + + + +-------------------------------------------------------------------------------------------------------------------------------------------- +-- API +-------------------------------------------------------------------------------------------------------------------------------------------- +module Graphics.Michelangelo.Types.hs where + + + +-------------------------------------------------------------------------------------------------------------------------------------------- +-- We'll need these +-------------------------------------------------------------------------------------------------------------------------------------------- + + + + +-------------------------------------------------------------------------------------------------------------------------------------------- +-- Types +-------------------------------------------------------------------------------------------------------------------------------------------- + +-- | +data Entity = Entity {} + + +-- | +-- TODO: Include shader program, attributes, uniforms, etc. (?) +-- TODO: Store render function (?) +-- TODO: Restructure (?) +-- TODO: Metadata (?) +data Mesh = Mesh { texture :: Maybe GL.TextureObject, -- TODO: Allow more than one texture (?) + primitive :: GL.PrimitiveMode, -- + attributes :: Map.Map String Attribute, -- + uniforms :: Map.Map String (GL.UniformLocation, UniformValue), -- + shader :: GL.Program, -- + prepare :: Maybe (Mesh -> IO ()), -- Optional rendering setup function + centre :: V3 Float, -- + bounds :: WF.BoundingBox Float, -- + size :: Int -- + } --deriving (Show) + + +-- | +-- data Scene = Scene { _camera :: Camera, _entities :: [Entity], } + + +-- | +data ShaderProgram = ShaderProgram { _program :: GL.Program, + _attributes :: Map.Map String (GL.AttribLocation, GL.VariableType), + _uniforms :: Map.Map String (GL.UniformLocation, GL.VariableType)} + + +-- | +-- type Uniform = (GL.UniformLocation, UniformValue) -- +type Attribute = (GL.AttribLocation, GL.BufferObject, Int) -- TODO: Are there any non-buffer attribute types, separate type (?) + + +-- | +-- TODO: Make polymorphic (?) +-- TODO: Refactor +-- TODO: Implement uniformv +-- TODO: Find out how to read uniform value +-- instance GL.UniformComponent a => GL.Uniform (M44 a) where +instance GL.Uniform (M44 Float) where + uniform (GL.UniformLocation loc) = GL.makeStateVar (error "Not implemented") (\u -> Marshal.with (transpose u) (\ptr -> GLRaw.glUniformMatrix4fv loc 1 0 (castPtr (ptr :: Ptr (M44 Float))))) + -- uniformv loc count = uniform3v location count . (castPtr :: Ptr (Vertex3 b) -> Ptr b) + + +instance GL.Uniform (Float) where + uniform (GL.UniformLocation loc) = GL.makeStateVar (error "Not implemented") (\f -> Marshal.with f (\ptr -> GLRaw.glUniform1fv loc 1 (castPtr (ptr :: Ptr (Float))))) + -- uniformv loc count = uniform3v location count . (castPtr :: Ptr (Vertex3 b) -> Ptr b) + + +-- | +instance GL.Uniform (Int) where + uniform (GL.UniformLocation loc) = GL.makeStateVar (error "Not implemented") (\i -> Marshal.with i (\ptr -> GLRaw.glUniform1iv loc 1 (castPtr (ptr :: Ptr (Int))))) + -- uniformv loc count = uniform3v location count . (castPtr :: Ptr (Vertex3 b) -> Ptr b)
src/Graphics/Michelangelo/Utils.hs view
@@ -36,6 +36,8 @@ -- import Graphics.GLUtil.JuicyTextures import qualified Data.ByteString as BS +import Graphics.Michelangelo.Types + --------------------------------------------------------------------------------------------------------------------------------------------