more canvas size

This commit is contained in:
nek0 2017-03-23 04:32:43 +01:00
parent 0d48565c85
commit 4c7918d9df
3 changed files with 22 additions and 13 deletions

View file

@ -108,6 +108,7 @@ draw = do
} }
process (nodeGraph M.! "sink") process (nodeGraph M.! "sink")
present (GeglRectangle 0 0 800 600) foreground True present (GeglRectangle 0 0 800 600) foreground True
render Nothing Nothing
update :: Double -> Affection UserData () update :: Double -> Affection UserData ()
update dt = do update dt = do

View file

@ -100,6 +100,7 @@ draw = do
(G.GeglRectangle 0 0 800 600) (G.GeglRectangle 0 0 800 600)
foreground foreground
True True
render Nothing Nothing
update :: Double -> Affection UserData () update :: Double -> Affection UserData ()
update dt = do update dt = do

View file

@ -78,19 +78,24 @@ withAffection AffectionConfig{..} = do
renderer renderer
SDL.ABGR8888 SDL.ABGR8888
SDL.TextureAccessStreaming SDL.TextureAccessStreaming
(SDL.windowInitialSize windowConfig) (case canvasSize of
Just (cw, ch) -> (SDL.V2
(CInt $ fromIntegral cw)
(CInt $ fromIntegral ch)
)
Nothing ->
SDL.windowInitialSize windowConfig
)
-- make draw surface -- make draw surface
surface <- SDL.createRGBSurface -- pixelFormat <- liftIO $ peek . Raw.surfaceFormat =<< peek ptr
(SDL.windowInitialSize windowConfig) let SDL.V2 (CInt rw) (CInt rh) = windowInitialSize windowConfig
SDL.ABGR8888 (w, h) = case canvasSize of
let (SDL.Surface ptr _) = surface Just (cw, ch) -> (cw, ch)
pixelFormat <- liftIO $ peek . Raw.surfaceFormat =<< peek ptr Nothing -> (fromIntegral rw, fromIntegral rh)
SDL.V2 (CInt rw) (CInt rh) <- liftIO $ SDL.surfaceDimensions surface -- stride = fromIntegral (Raw.pixelFormatBytesPerPixel pixelFormat) * w
let (w, h) = (fromIntegral rw, fromIntegral rh) bablFormat = B.PixelFormat B.RGBA B.CFu8
stride = fromIntegral (Raw.pixelFormatBytesPerPixel pixelFormat) * w
pixels <- SDL.surfacePixels surface
let bablFormat = B.PixelFormat B.RGBA B.CFu8
cpp = B.babl_components_per_pixel bablFormat cpp = B.babl_components_per_pixel bablFormat
!stride = cpp * w
format <- B.babl_format bablFormat format <- B.babl_format bablFormat
initContainer <- (\x -> AffectionData initContainer <- (\x -> AffectionData
{ quitEvent = False { quitEvent = False
@ -100,8 +105,10 @@ withAffection AffectionConfig{..} = do
-- , drawSurface = surface -- , drawSurface = surface
, drawTexture = texture , drawTexture = texture
, drawFormat = format , drawFormat = format
, drawPixels = pixels -- , drawPixels = pixels
, drawDimensions = (w, h) , drawDimensions = case canvasSize of
Just (cw, ch) -> (cw, ch)
Nothing -> (w, h)
, drawStride = stride , drawStride = stride
, drawCPP = cpp , drawCPP = cpp
, drawStack = [] , drawStack = []