handa-opengl 0.1.12.1 → 0.1.13.0
raw patch · 3 files changed
+48/−37 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Foreign.C.Types.Instances: instance Data.Aeson.Types.FromJSON.FromJSON Foreign.C.Types.CDouble
- Foreign.C.Types.Instances: instance Data.Aeson.Types.FromJSON.FromJSON Foreign.C.Types.CFloat
- Graphics.Rendering.Handa.Projection: instance (GHC.Generics.Generic a, Data.Aeson.Types.FromJSON.FromJSON a) => Data.Aeson.Types.FromJSON.FromJSON (Graphics.Rendering.Handa.Projection.Screen a)
- Graphics.Rendering.Handa.Viewer: instance (Data.Aeson.Types.FromJSON.FromJSON a, GHC.Generics.Generic a) => Data.Aeson.Types.FromJSON.FromJSON (Graphics.Rendering.Handa.Viewer.ViewerParameters a)
- Graphics.Rendering.Handa.Viewer: instance (Data.Binary.Class.Binary a, GHC.Generics.Generic a) => Data.Binary.Class.Binary (Graphics.Rendering.Handa.Viewer.ViewerParameters a)
- Graphics.Rendering.OpenGL.GL.Tensor.Instances: instance (Data.Aeson.Types.FromJSON.FromJSON a, GHC.Generics.Generic a) => Data.Aeson.Types.FromJSON.FromJSON (Graphics.Rendering.OpenGL.GL.Tensor.Vector3 a)
- Graphics.Rendering.OpenGL.GL.Tensor.Instances: instance (Data.Aeson.Types.FromJSON.FromJSON a, GHC.Generics.Generic a) => Data.Aeson.Types.FromJSON.FromJSON (Graphics.Rendering.OpenGL.GL.Tensor.Vertex3 a)
- Graphics.UI.Handa.Setup: instance (GHC.Generics.Generic a, Data.Aeson.Types.FromJSON.FromJSON a) => Data.Aeson.Types.FromJSON.FromJSON (Graphics.UI.Handa.Setup.Setup a)
- Graphics.UI.Handa.Setup: instance Data.Aeson.Types.FromJSON.FromJSON Graphics.UI.Handa.Setup.Stereo
- Graphics.UI.Handa.Setup: instance Data.Aeson.Types.FromJSON.FromJSON Graphics.UI.Handa.Setup.Viewer
+ Foreign.C.Types.Instances: instance Data.Aeson.Types.Class.FromJSON Foreign.C.Types.CDouble
+ Foreign.C.Types.Instances: instance Data.Aeson.Types.Class.FromJSON Foreign.C.Types.CFloat
+ Foreign.C.Types.Instances: instance GHC.Generics.Constructor Foreign.C.Types.Instances.C1_0CDouble
+ Foreign.C.Types.Instances: instance GHC.Generics.Constructor Foreign.C.Types.Instances.C1_0CFloat
+ Foreign.C.Types.Instances: instance GHC.Generics.Datatype Foreign.C.Types.Instances.D1CDouble
+ Foreign.C.Types.Instances: instance GHC.Generics.Datatype Foreign.C.Types.Instances.D1CFloat
+ Graphics.Rendering.Handa.Projection: instance (GHC.Generics.Generic a, Data.Aeson.Types.Class.FromJSON a) => Data.Aeson.Types.Class.FromJSON (Graphics.Rendering.Handa.Projection.Screen a)
+ Graphics.Rendering.Handa.Projection: instance GHC.Generics.Constructor Graphics.Rendering.Handa.Projection.C1_0Screen
+ Graphics.Rendering.Handa.Projection: instance GHC.Generics.Datatype Graphics.Rendering.Handa.Projection.D1Screen
+ Graphics.Rendering.Handa.Projection: instance GHC.Generics.Selector Graphics.Rendering.Handa.Projection.S1_0_0Screen
+ Graphics.Rendering.Handa.Projection: instance GHC.Generics.Selector Graphics.Rendering.Handa.Projection.S1_0_1Screen
+ Graphics.Rendering.Handa.Projection: instance GHC.Generics.Selector Graphics.Rendering.Handa.Projection.S1_0_2Screen
+ Graphics.Rendering.Handa.Viewer: glassesViewer :: (Fractional a, Storable a) => ViewerParameters a
+ Graphics.Rendering.Handa.Viewer: instance (GHC.Generics.Generic a, Data.Aeson.Types.Class.FromJSON a) => Data.Aeson.Types.Class.FromJSON (Graphics.Rendering.Handa.Viewer.ViewerParameters a)
+ Graphics.Rendering.Handa.Viewer: instance (GHC.Generics.Generic a, Data.Binary.Class.Binary a) => Data.Binary.Class.Binary (Graphics.Rendering.Handa.Viewer.ViewerParameters a)
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Constructor Graphics.Rendering.Handa.Viewer.C1_0ViewerParameters
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Datatype Graphics.Rendering.Handa.Viewer.D1ViewerParameters
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Selector Graphics.Rendering.Handa.Viewer.S1_0_0ViewerParameters
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Selector Graphics.Rendering.Handa.Viewer.S1_0_1ViewerParameters
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Selector Graphics.Rendering.Handa.Viewer.S1_0_2ViewerParameters
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Selector Graphics.Rendering.Handa.Viewer.S1_0_3ViewerParameters
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Selector Graphics.Rendering.Handa.Viewer.S1_0_4ViewerParameters
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Selector Graphics.Rendering.Handa.Viewer.S1_0_5ViewerParameters
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Selector Graphics.Rendering.Handa.Viewer.S1_0_6ViewerParameters
+ Graphics.Rendering.Handa.Viewer: instance GHC.Generics.Selector Graphics.Rendering.Handa.Viewer.S1_0_7ViewerParameters
+ Graphics.Rendering.OpenGL.GL.Tensor.Instances: instance (Data.Aeson.Types.Class.FromJSON a, GHC.Generics.Generic a) => Data.Aeson.Types.Class.FromJSON (Graphics.Rendering.OpenGL.GL.Tensor.Vector3 a)
+ Graphics.Rendering.OpenGL.GL.Tensor.Instances: instance (Data.Aeson.Types.Class.FromJSON a, GHC.Generics.Generic a) => Data.Aeson.Types.Class.FromJSON (Graphics.Rendering.OpenGL.GL.Tensor.Vertex3 a)
+ Graphics.Rendering.OpenGL.GL.Tensor.Instances: instance GHC.Generics.Constructor Graphics.Rendering.OpenGL.GL.Tensor.Instances.C1_0Vector3
+ Graphics.Rendering.OpenGL.GL.Tensor.Instances: instance GHC.Generics.Constructor Graphics.Rendering.OpenGL.GL.Tensor.Instances.C1_0Vertex3
+ Graphics.Rendering.OpenGL.GL.Tensor.Instances: instance GHC.Generics.Datatype Graphics.Rendering.OpenGL.GL.Tensor.Instances.D1Vector3
+ Graphics.Rendering.OpenGL.GL.Tensor.Instances: instance GHC.Generics.Datatype Graphics.Rendering.OpenGL.GL.Tensor.Instances.D1Vertex3
+ Graphics.UI.Handa.Setup: Glasses :: Viewer
+ Graphics.UI.Handa.Setup: instance (GHC.Generics.Generic a, Data.Aeson.Types.Class.FromJSON a) => Data.Aeson.Types.Class.FromJSON (Graphics.UI.Handa.Setup.Setup a)
+ Graphics.UI.Handa.Setup: instance Data.Aeson.Types.Class.FromJSON Graphics.UI.Handa.Setup.Stereo
+ Graphics.UI.Handa.Setup: instance Data.Aeson.Types.Class.FromJSON Graphics.UI.Handa.Setup.Viewer
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_0Setup
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_0Stereo
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_0Viewer
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_1Stereo
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_1Viewer
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_2Stereo
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_2Viewer
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_3Stereo
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_3Viewer
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Constructor Graphics.UI.Handa.Setup.C1_4Viewer
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Datatype Graphics.UI.Handa.Setup.D1Setup
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Datatype Graphics.UI.Handa.Setup.D1Stereo
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Datatype Graphics.UI.Handa.Setup.D1Viewer
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Selector Graphics.UI.Handa.Setup.S1_0_0Setup
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Selector Graphics.UI.Handa.Setup.S1_0_1Setup
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Selector Graphics.UI.Handa.Setup.S1_0_2Setup
+ Graphics.UI.Handa.Setup: instance GHC.Generics.Selector Graphics.UI.Handa.Setup.S1_0_3Setup
- Graphics.Rendering.Handa.Projection: fetchProjection :: forall a. (MatrixComponent a, RealFloat a) => IO [[a]]
+ Graphics.Rendering.Handa.Projection: fetchProjection :: (MatrixComponent a, RealFloat a) => IO [[a]]
- Graphics.Rendering.Handa.Projection: projection :: forall a. (AdditiveGroup a, MatrixComponent a, RealFloat a) => OffAxisProjection -> Screen a -> Vertex3 a -> a -> a -> IO ()
+ Graphics.Rendering.Handa.Projection: projection :: (AdditiveGroup a, MatrixComponent a, RealFloat a) => OffAxisProjection -> Screen a -> Vertex3 a -> a -> a -> IO ()
Files
- handa-opengl.cabal +2/−2
- src/Graphics/Rendering/Handa/Viewer.hs +43/−34
- src/Graphics/UI/Handa/Setup.hs +3/−1
handa-opengl.cabal view
@@ -1,5 +1,5 @@ name: handa-opengl-version: 0.1.12.1+version: 0.1.13.0 synopsis: Utility functions for OpenGL and GLUT description: This is a collection of miscellaneous utility functions for OpenGL and GLUT. @@ -14,7 +14,7 @@ stability: Stable homepage: https://bitbucket.org/bwbush/handa-opengl bug-reports: https://bwbush.atlassian.net/projects/HOGL/issues/-package-url: https://bitbucket.org/bwbush/handa-opengl/downloads/handa-opengl-0.1.12.1.tar.gz+package-url: https://bitbucket.org/bwbush/handa-opengl/downloads/handa-opengl-0.1.13.0.tar.gz extra-source-files: ReadMe.md
src/Graphics/Rendering/Handa/Viewer.hs view
@@ -28,6 +28,7 @@ , laptopViewer , desktopViewer , projectorViewer+, glassesViewer -- * Callbacks and Rendering , reshape , loadViewer@@ -85,65 +86,73 @@ } instance (Fractional a, Storable a) => Default (ViewerParameters a) where- def =- ViewerParameters- {- screen =- Screen- {- lowerLeft = Vertex3 (-0.5) (-0.5) 0- , lowerRight = Vertex3 0.5 (-0.5) 0- , upperLeft = Vertex3 (-0.5) 0.5 0- }- , nearPlane = 0.1- , farPlane = 100- , eyePosition = Vertex3 0 0 1- , eyeSeparation = Vector3 0.02 0 0- , eyeUpward = Vector3 0 1 0- , sceneCenter = Vertex3 0 0 0- , sceneScale = Vector3 1 1 1- }+ def = laptopViewer -- | Construct viewer geometry from physical geometry. viewerGeometry :: (Fractional a, Storable a)- => a -- ^ The width of the screen or display.- -> a -- ^ The height of the screen or display.- -> a -- ^ The distance from the eyes to the screen or display.+ => a -- ^ The aspect ratio (width over height) of the screen or display.+ -> a -- ^ The throw ratio (distance over width) of the screen or display.+ -> a -- ^ The distance from the eyes to the screen or display, in inches. -> ViewerParameters a -- ^ The corresponding viewer parameters.-viewerGeometry width height throw =- def- {+viewerGeometry aspect throw distance =+ ViewerParameters+ { screen = Screen {- lowerLeft = Vertex3 (- 1 / 2) (- height / width / 2) 0- , lowerRight = Vertex3 ( 1 / 2) (- height / width / 2) 0- , upperLeft = Vertex3 (- 1 / 2) ( height / width / 2) 0+ lowerLeft = Vertex3 (- width / 2) (- height / 2) 0+ , lowerRight = Vertex3 ( width / 2) (- height / 2) 0+ , upperLeft = Vertex3 (- width / 2) ( height / 2) 0 }- , eyePosition = Vertex3 0 0 (throw / width)- , sceneScale = 0.5 *^ Vector3 1 (height / width) 1- }+ , nearPlane = 1 + , farPlane = 5 * distance+ , eyePosition = Vertex3 0 0 distance+ , eyeSeparation = Vector3 (typical * (1 - comfort)) 0 0+ , eyeUpward = Vector3 0 1 0+ , sceneCenter = Vertex3 0 0 1+ , sceneScale = size *^ Vector3 aspect 1 1+ }+ where+ width = distance / throw+ height = width / aspect+ margin = 0.10 -- 10% margin+ size = (1 - margin) / (1 / height + 1 / distance)+ -- See <https://www.nvidia.com/content/GTC-2010/pdfs/2010_GTC2010.pdf>:+ typical = 2.5 -- inches for typical maximum eye separation+ comfort = 0.50 -- 25% reduction in eye separation for comforat at mid-range focus -- | Viewer parameters for a typical smartphone screen. phoneViewer :: (Fractional a, Storable a) => ViewerParameters a-phoneViewer = viewerGeometry 5.27 2.80 12+phoneViewer = viewerGeometry (1280 / 768) 0.5 18 -- | Viewer parameters for a typical laptop screen. laptopViewer :: (Fractional a, Storable a) => ViewerParameters a-laptopViewer = viewerGeometry 13.625 7.875 24+laptopViewer = viewerGeometry (1920 / 1080) 1.8 24 -- | Viewer parameters for a typical desktop monitor. desktopViewer :: (Fractional a, Storable a) => ViewerParameters a-desktopViewer = viewerGeometry 20.75 11.625 32+desktopViewer = viewerGeometry (1920 / 1080) 1.6 32 -- | Viewer parameters for a typical projector. projectorViewer :: (Fractional a, Storable a) => ViewerParameters a-projectorViewer = viewerGeometry 1.6 1.0 (1.5 * 1.6)+projectorViewer = viewerGeometry 1.6 1.5 36+++-- | Viewer parameters for typical VR glasses.+glassesViewer :: (Fractional a, Storable a) => ViewerParameters a+glassesViewer = + viewerGeometry (realToFrac $ pixelWidth / pixelHeight) (distance / width) $ 0.2 * distance+ where+ distance = 4 * 39.37+ pixelWidth = 852+ pixelHeight = 480+ pixelDiagonal = sqrt (pixelWidth * pixelWidth + pixelHeight * pixelHeight)+ width = 100 * realToFrac (pixelWidth / pixelDiagonal :: Double) -- | The aspect ratio of the viewer.
src/Graphics/UI/Handa/Setup.hs view
@@ -37,7 +37,7 @@ import Foreign.Storable (Storable) import GHC.Generics (Generic) import Graphics.Rendering.DLP (DlpEncoding)-import Graphics.Rendering.Handa.Viewer (ViewerParameters(eyeSeparation), desktopViewer, laptopViewer, phoneViewer, projectorViewer, reshape)+import Graphics.Rendering.Handa.Viewer (ViewerParameters(eyeSeparation), desktopViewer, glassesViewer, laptopViewer, phoneViewer, projectorViewer, reshape) import Graphics.Rendering.OpenGL (BlendingFactor(..), Capability(Enabled), ComparisonFunction(Less), MatrixComponent, ($=), blend, blendFunc) import Graphics.UI.GLUT (DisplayMode(..), IdleCallback, createWindow, depthFunc, fullScreen, idleCallback, initialDisplayMode, initialize, postRedisplay, reshapeCallback) @@ -89,6 +89,7 @@ | Laptop -- ^ A typical laptop. | Desktop -- ^ A typical desktop display. | Projector -- ^ A typical projector.+ | Glasses -- ^ Typical VR glasses. deriving (Binary, Bounded, Data, Enum, Eq, FromJSON, Generic, Ord, Read, Show, Typeable) instance Default Viewer where@@ -124,6 +125,7 @@ Right Laptop -> laptopViewer Right Desktop -> desktopViewer Right Projector -> projectorViewer+ Right Glasses -> glassesViewer Left parameters -> parameters viewerParameters' = if switchEyes