Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make OpenGL dependency conditional #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions OpenAL.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ flag BuildExamples
description: Build various OpenAL examples.
default: False

flag UseOpenGL
description: Use OpenGL-provided Vertex and Vector types.
default: True

library
exposed-modules:
Sound.OpenAL
Expand Down Expand Up @@ -87,8 +91,7 @@ library
base >= 3 && < 5,
transformers >= 0.2 && < 0.6,
ObjectName >= 1.1 && < 1.2,
StateVar >= 1.1 && < 1.3,
OpenGL >= 2.12 && < 3.1
StateVar >= 1.1 && < 1.3
default-language: Haskell2010
ghc-options: -Wall
if impl(ghc > 8)
Expand All @@ -101,6 +104,14 @@ library
frameworks: OpenAL
else
extra-libraries: openal
if flag(UseOpenGL)
build-depends:
OpenGL >= 2.12 && < 3.1
cpp-options:
-DUSEOPENGL
else
build-depends:
Tensor >= 1 && < 2

executable TestDevice
if !flag(BuildExamples)
Expand Down
9 changes: 7 additions & 2 deletions src/Sound/OpenAL.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
--------------------------------------------------------------------------------
-- |
-- Module : Sound.OpenAL
Expand Down Expand Up @@ -39,15 +40,19 @@ module Sound.OpenAL (
-- * Convenience Re-exports
, module Data.ObjectName
, module Data.StateVar
, module Graphics.Rendering.OpenGL.GL.Tensor
, module Tensor
) where

import Sound.OpenAL.AL
import Sound.OpenAL.ALC

import Data.ObjectName
import Data.StateVar
import Graphics.Rendering.OpenGL.GL.Tensor ( Vector3(..), Vertex3(..) )
#ifdef USEOPENGL
import Graphics.Rendering.OpenGL.GL.Tensor as Tensor ( Vector3(..), Vertex3 (..) )
#else
import Data.Tensor as Tensor ( Vector3(..), Vertex3 (..) )
#endif

--------------------------------------------------------------------------------
-- $ABriefHistoryOfOpenAL
Expand Down
4 changes: 4 additions & 0 deletions src/Sound/OpenAL/AL/Listener.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ import Foreign.Marshal.Array ( allocaArray, withArray )
import Foreign.Marshal.Utils ( with )
import Foreign.Ptr ( Ptr )
import Foreign.Storable ( Storable )
#ifdef USEOPENGL
import Graphics.Rendering.OpenGL.GL.Tensor ( Vector3(..), Vertex3 (..) )
#else
import Data.Tensor ( Vector3(..), Vertex3 (..) )
#endif

import Sound.OpenAL.AL.BasicTypes
import Sound.OpenAL.AL.PeekPoke
Expand Down
6 changes: 5 additions & 1 deletion src/Sound/OpenAL/AL/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ import Foreign.Marshal.Array ( allocaArray, peekArray, withArrayLen )
import Foreign.Marshal.Utils ( with )
import Foreign.Ptr ( Ptr, castPtr )
import Foreign.Storable ( Storable(..) )
import Graphics.Rendering.OpenGL.GL.Tensor ( Vector3(..), Vertex3(..) )
#ifdef USEOPENGL
import Graphics.Rendering.OpenGL.GL.Tensor ( Vector3(..), Vertex3 (..) )
#else
import Data.Tensor ( Vector3(..), Vertex3 (..) )
#endif

import Sound.OpenAL.AL.ALboolean
import Sound.OpenAL.AL.BasicTypes
Expand Down