diff --git a/src/Dodge/Config/Data.hs b/src/Dodge/Config/Data.hs index 251b1ee6b..3bb2a6440 100644 --- a/src/Dodge/Config/Data.hs +++ b/src/Dodge/Config/Data.hs @@ -11,6 +11,7 @@ data Configuration = Configuration , _volume_music :: Float , _graphics_wall_textured :: Bool , _graphics_cloud_shadows :: Bool + , _graphics_object_shadows :: Bool , _graphics_resolution_factor :: ResFactor , _windowX :: Float , _windowY :: Float @@ -58,6 +59,7 @@ defaultConfig = Configuration , _volume_music = 1 , _graphics_wall_textured = True , _graphics_cloud_shadows = True + , _graphics_object_shadows = True , _graphics_resolution_factor = FullRes , _windowX = 800 , _windowY = 600 diff --git a/src/Dodge/Menu.hs b/src/Dodge/Menu.hs index 0f94a6777..585b781b3 100644 --- a/src/Dodge/Menu.hs +++ b/src/Dodge/Menu.hs @@ -134,7 +134,8 @@ graphicsMenuOptions :: [MenuOption] graphicsMenuOptions = [ makeEnumOption ScancodeS graphics_resolution_factor "RESOLUTION" updateFramebufferSize , makeBoolOption ScancodeW graphics_wall_textured "WALL TEXTURES" - , makeBoolOption ScancodeD graphics_cloud_shadows "CLOUD SHADOWS" + , makeBoolOption ScancodeO graphics_object_shadows "OBJECT SHADOWS" + , makeBoolOption ScancodeC graphics_cloud_shadows "CLOUD SHADOWS" ] gameOverMenu :: ScreenLayer diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index 732de49d0..7fc1db420 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -131,7 +131,9 @@ doDrawing pdata u = do drawShader (_textureArrayShader pdata) nFls --draw lightmap into its own buffer bindFramebuffer Framebuffer $= fst (_fboLighting pdata) - createLightMap pdata lightPoints nWalls nSilIndices nIndices (snd $ snd $ _fboBase pdata) + createLightMap pdata lightPoints nWalls nSilIndices nIndices + (_graphics_object_shadows $ _config u) + (snd $ snd $ _fboBase pdata) colorMask $= Color4 Enabled Enabled Enabled Enabled clearColor $= Color4 0 0 0 0 --apply lightmap to base buffer @@ -185,7 +187,9 @@ doDrawing pdata u = do depthMask $= Disabled blend $= Enabled bindFramebuffer Framebuffer $= fst (_fboLighting pdata) - createLightMap pdata lightPoints nWalls nSilIndices nIndices (snd $ snd $ _fboCloud pdata) + createLightMap pdata lightPoints nWalls nSilIndices nIndices + (_graphics_object_shadows $ _config u) + (snd $ snd $ _fboCloud pdata) colorMask $= Color4 Enabled Enabled Enabled Enabled clearColor $= Color4 0 0 0 0 --apply lightmap to cloud buffer diff --git a/src/Render.hs b/src/Render.hs index 764dc4994..e90a7e0a4 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -32,9 +32,10 @@ createLightMap -> Int -- ^ number of walls -> Int -- ^ number of silhoutte lines to draw -> Int -- ^ number of "caps" to attempt to draw + -> Bool -- ^ whether to draw object shadows or not -> TextureObject -- ^ the texture object giving positions -> IO () -createLightMap pdata lightPoints nWalls nSils nCaps toPos = do +createLightMap pdata lightPoints nWalls nSils nCaps drawObjShads toPos = do let llsShad = _lightingLineShadowShader pdata let lcShad = _lightingCapShader pdata let lwShad = _lightingWallShadShader pdata @@ -69,28 +70,29 @@ createLightMap pdata lightPoints nWalls nSils nCaps toPos = do (marshalEPrimitiveMode $ _shadPrim lwShad) 0 (fromIntegral nWalls) - --drawShader lwShad nWalls - --draw silhouette shadows - currentProgram $= Just (_shadProg llsShad) - uniform (head $ _shadUnis $ _lightingLineShadowShader pdata) - $= Vector3 x y z - bindVertexArrayObject $= Just (_vao $ _shadVAO llsShad) - glDrawElements - (marshalEPrimitiveMode $ _shadPrim llsShad) - (fromIntegral nSils) - GL_UNSIGNED_SHORT - nullPtr - cullFace $= Just Back - --draw caps on the near plane as required - currentProgram $= Just (_shadProg lcShad) - uniform (head $ _shadUnis lcShad) - $= Vector3 x y z - bindVertexArrayObject $= Just (_vao $ _shadVAO lcShad) - glDrawElements - (marshalEPrimitiveMode $ _shadPrim lcShad) - (fromIntegral nCaps) - GL_UNSIGNED_SHORT - nullPtr + if drawObjShads then do + --draw silhouette shadows + currentProgram $= Just (_shadProg llsShad) + uniform (head $ _shadUnis $ _lightingLineShadowShader pdata) + $= Vector3 x y z + bindVertexArrayObject $= Just (_vao $ _shadVAO llsShad) + glDrawElements + (marshalEPrimitiveMode $ _shadPrim llsShad) + (fromIntegral nSils) + GL_UNSIGNED_SHORT + nullPtr + cullFace $= Just Back + --draw caps on the near plane as required + currentProgram $= Just (_shadProg lcShad) + uniform (head $ _shadUnis lcShad) + $= Vector3 x y z + bindVertexArrayObject $= Just (_vao $ _shadVAO lcShad) + glDrawElements + (marshalEPrimitiveMode $ _shadPrim lcShad) + (fromIntegral nCaps) + GL_UNSIGNED_SHORT + nullPtr + else return () --draw lightmap itself depthFunc $= Just Always -- bind world position texture