Fix resize crash
This commit is contained in:
@@ -6,7 +6,7 @@ import Picture
|
||||
|
||||
winScale :: Configuration -> Picture -> Picture
|
||||
{-# INLINE winScale #-}
|
||||
winScale cfig = scale (2 / _windowX cfig) (2 / _windowY cfig)
|
||||
winScale cfig = scale (1 / _windowX cfig) (1 / _windowY cfig)
|
||||
|
||||
doWindowScale :: Configuration -> Point2 -> Point2
|
||||
doWindowScale cfig (V2 x y) = V2 (x * 2 / _windowX cfig) (y * 2 / _windowY cfig)
|
||||
doWindowScale cfig (V2 x y) = V2 (x / _windowX cfig) (y / _windowY cfig)
|
||||
|
||||
+2
-4
@@ -55,9 +55,7 @@ handleWindowMoveEvent mev =
|
||||
handleResizeEvent :: WindowSizeChangedEventData -> Universe -> Universe
|
||||
handleResizeEvent sev u =
|
||||
u
|
||||
& uvConfig . windowX .~ fromIntegral x
|
||||
& uvConfig . windowY .~ fromIntegral y
|
||||
-- & uvIOEffects %~ sideEffectUpdatePreload
|
||||
& uvIOEffects %~ (updatePreload >=>)
|
||||
& uvIOEffects %~ ( (updatePreload . updateconfig) >=>)
|
||||
where
|
||||
updateconfig = (uvConfig . windowX .~ fromIntegral x) . (uvConfig . windowY .~ fromIntegral y)
|
||||
V2 x y = windowSizeChangedEventSize sev
|
||||
|
||||
+20
-8
@@ -103,10 +103,26 @@ doDrawing' win pdata u = do
|
||||
, (_shapeEBO pdata, nIndices)
|
||||
, (_silhouetteEBO pdata, nSilIndices)
|
||||
]
|
||||
-- draw the overlay
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboOverlay ._1 . unFBO)
|
||||
withArray [0, 0, 0, 0] $ \ptr ->
|
||||
glClearNamedFramebufferfv
|
||||
(pdata ^. fboOverlay . _1 . unFBO)
|
||||
GL_COLOR
|
||||
0
|
||||
ptr
|
||||
glDepthFunc GL_ALWAYS
|
||||
glDepthMask GL_FALSE
|
||||
glEnable GL_BLEND
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
setViewport _graphics_overlay_resolution cfig
|
||||
glBindBufferBase GL_UNIFORM_BUFFER 0 (pdata ^. orthonormalMatUBO)
|
||||
renderLayer FixedCoordLayer shadV layerCounts
|
||||
-- set the coordinate uniform ready for drawing elements using world coordinates
|
||||
glBindBufferBase GL_UNIFORM_BUFFER 0 (pdata ^. matUBO)
|
||||
withArray (perspectiveMatrixb rot camzoom trans wins viewFroms) $ \ptr ->
|
||||
glNamedBufferSubData (pdata ^. matUBO) 0 64 ptr
|
||||
renderLayer DebugLayer shadV layerCounts
|
||||
setViewport _graphics_world_resolution cfig
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase ._1 . unFBO)
|
||||
glDepthMask GL_TRUE
|
||||
@@ -335,7 +351,7 @@ doDrawing' win pdata u = do
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
--set viewport for radial distortion
|
||||
--setViewportSize (round winx) (round winy)
|
||||
setViewport _graphics_overlay_resolution cfig
|
||||
setViewport (const FullRes) cfig
|
||||
glDepthFunc GL_ALWAYS
|
||||
glBlendFunc GL_ONE GL_ZERO
|
||||
-- perform any radial distortion
|
||||
@@ -357,14 +373,10 @@ doDrawing' win pdata u = do
|
||||
toList = (pdata ^. fboBase . _2 . _1) : concat (repeat [snd $ _fbo2 pdata, snd $ _fbo3 pdata])
|
||||
bindings = zipWith (>>) (map bindFBO fboList) (map (glBindTextureUnit 1 . _unTO) toList)
|
||||
zipWithM_ (>>) bindings $ map bindDrawDist rds
|
||||
glDepthFunc GL_ALWAYS
|
||||
glDepthMask GL_FALSE
|
||||
glEnable GL_BLEND
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
renderLayer DebugLayer shadV layerCounts
|
||||
-- draw overlay
|
||||
glBindBufferBase GL_UNIFORM_BUFFER 0 (pdata ^. orthonormalMatUBO)
|
||||
renderLayer FixedCoordLayer shadV layerCounts
|
||||
--draw overlay onto base buffer
|
||||
glBindTextureUnit 0 (pdata ^. fboOverlay . _2 . unTO)
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
SDL.glSwapWindow win
|
||||
|
||||
getDistortions :: Configuration -> World -> [Distortion]
|
||||
|
||||
@@ -13,6 +13,8 @@ import Dodge.Data.Universe
|
||||
testStringInit :: Universe -> [String]
|
||||
testStringInit u = [show $ length $ lightsToRender (u ^. uvConfig) (u ^. uvWorld . cWorld . camPos)
|
||||
(u ^. uvWorld . cWorld . lWorld)
|
||||
, show $ u ^. uvConfig . windowX
|
||||
, show $ u ^. uvConfig . windowY
|
||||
, show $ u ^. uvWorld . input . scrollTestInt
|
||||
]
|
||||
--[show $ u ^? uvWorld . hud . hudElement . diSections . sssExtra . sssSelPos . _Just]
|
||||
|
||||
Reference in New Issue
Block a user