main :: IO ()
main = do
    getArgsAndInitialize
    initialDisplayMode $= [DoubleBuffered, RGBAMode, WithDepthBuffer]
    initialWindowSize $= Size windowWidth windowHeight
    initialWindowPosition $= Position 100 100
    createWindow "Tutorial 26"

    -- frontFace $= CW
    -- cullFace $= Just Back
    depthFunc $= Just Lequal

    gScale <- newIORef 0.0
    cameraRef <- newIORef newCamera
    bampMapRef <- newIORef True

    lightingEffect <- initLightingTechnique
    enableLightingTechnique lightingEffect
    setLightingTextureUnit lightingEffect 0
    setLightingNormalMapTextureUnit lightingEffect 2
    setDirectionalLight lightingEffect dirLight

    pointerPosition $= mousePos

    boxMesh <- loadMesh "assets/box.obj"
    Just texture <- textureLoad "assets/bricks.jpg" Texture2D
    Just normalMap <- textureLoad "assets/normal_map.jpg" Texture2D
    Just trivialNormalMap <- textureLoad "assets/normal_up.jpg" Texture2D

    initializeGlutCallbacks boxMesh lightingEffect gScale cameraRef bampMapRef
        texture normalMap trivialNormalMap
    clearColor $= Color4 0 0 0 0

    mainLoop
  where
    newCamera = initCamera (Just
        (Vector3 0.5 1.025 0.25, Vector3 0 (-0.5) 1, Vector3 0 1 0)
        ) windowWidth windowHeight
    mousePos = Position (windowWidth `div` 2) (windowHeight `div` 2)
main :: IO ()
main = do
    getArgsAndInitialize
    initialDisplayMode $= [DoubleBuffered, RGBAMode, WithDepthBuffer]
    initialWindowSize $= Size windowWidth windowHeight
    initialWindowPosition $= Position 100 100
    createWindow "Tutorial 26"

    -- frontFace $= CW
    -- cullFace $= Just Back
    depthFunc $= Just Lequal

    gScale <- newIORef 0.0
    cameraRef <- newIORef newCamera
    bampMapRef <- newIORef True

    lightingEffect <- initLightingTechnique
    enableLightingTechnique lightingEffect
    setLightingTextureUnit lightingEffect 0
    setLightingNormalMapTextureUnit lightingEffect 2
    setDirectionalLight lightingEffect dirLight

    pointerPosition $= mousePos

    boxMesh <- loadMesh "assets/box.obj"
    Just texture <- textureLoad "assets/bricks.jpg" Texture2D
    Just normalMap <- textureLoad "assets/normal_map.jpg" Texture2D
    Just trivialNormalMap <- textureLoad "assets/normal_up.jpg" Texture2D

    initializeGlutCallbacks boxMesh lightingEffect gScale cameraRef bampMapRef
        texture normalMap trivialNormalMap
    clearColor $= Color4 0 0 0 0

    mainLoop
  where
    newCamera = initCamera (Just
        (Vector3 0.5 1.025 0.25, Vector3 0 (-0.5) 1, Vector3 0 1 0)
        ) windowWidth windowHeight
    mousePos = Position (windowWidth `div` 2) (windowHeight `div` 2)
main = do
    getArgsAndInitialize
    initialDisplayMode $= [DoubleBuffered, RGBAMode, WithDepthBuffer]
    initialWindowSize $= Size windowWidth windowHeight
    initialWindowPosition $= Position 100 100
    createWindow "Tutorial 26"

    -- frontFace $= CW
    -- cullFace $= Just Back
    depthFunc $= Just Lequal

    gScale <- newIORef 0.0
    cameraRef <- newIORef newCamera
    bampMapRef <- newIORef True

    lightingEffect <- initLightingTechnique
    enableLightingTechnique lightingEffect
    setLightingTextureUnit lightingEffect 0
    setLightingNormalMapTextureUnit lightingEffect 2
    setDirectionalLight lightingEffect dirLight

    pointerPosition $= mousePos

    boxMesh <- loadMesh "assets/box.obj"
    Just texture <- textureLoad "assets/bricks.jpg" Texture2D
    Just normalMap <- textureLoad "assets/normal_map.jpg" Texture2D
    Just trivialNormalMap <- textureLoad "assets/normal_up.jpg" Texture2D

    initializeGlutCallbacks boxMesh lightingEffect gScale cameraRef bampMapRef
        texture normalMap trivialNormalMap
    clearColor $= Color4 0 0 0 0

    mainLoop
  where
    newCamera = initCamera (Just
        (Vector3 0.5 1.025 0.25, Vector3 0 (-0.5) 1, Vector3 0 1 0)
        ) windowWidth windowHeight
    mousePos = Position (windowWidth `div` 2) (windowHeight `div` 2)