I'm working on a Haskell raytracer. I have the following Camera-type:
data Cameras = Ortographic | Pinhole {
d :: Float,
zoom :: Float,
eye, lookAt, up :: Vector,
cu, cv, cw :: Vector
} deriving (Show)
And the following Camera-typeclass:
class Camera a where
renderPixel :: a -> (Float, Float) -> [Object] -> Float -> Vector
rayDirection :: a -> Vector -> Vector
Now, when I try to make the type an instance of the typeclass, like this:
instance Camera Cameras where
--Ortographic
renderPixel (Ortographic) (x, y) scene numSamples = ...
--Pinhole
rayDirection (Pinhole d _ _ _ _ cu cv cw) (Vector2 u v) =
normalize ((cu<*>u) <+> (cv<*>v) <-> (cw<*>d))
renderPixel (Pinhole d _ _ _ _ cu cv cw) (x, y) scene numSamples = ...
I get an error saying "Conflicting definitions for `renderPixel'", pointing to the lines where the renderPixel-function starts for each of the cameras. What am I doing wrong?