From 61f800cdd9639959b8cc438caa30d0b85e8a7631 Mon Sep 17 00:00:00 2001 From: nek0 Date: Wed, 17 May 2023 05:52:41 +0200 Subject: [PATCH] flip y axis --- src/CommandBuffer.hs | 5 +++-- src/Draw.hs | 2 +- src/Mesh.hs | 8 +++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/CommandBuffer.hs b/src/CommandBuffer.hs index e628f6e..90f607b 100644 --- a/src/CommandBuffer.hs +++ b/src/CommandBuffer.hs @@ -298,11 +298,12 @@ prepareRecording prepareRecording (V2 width height) commandBuffer graphicsPipeline = do Vk.cmdBindPipeline commandBuffer Vk.PIPELINE_BIND_POINT_GRAPHICS graphicsPipeline + -- Passing negative height and nonzero y origin to the viewport flips the models back in order let viewport = Vk.zero { Vk.x = 0 - , Vk.y = 0 + , Vk.y = fromIntegral height , Vk.width = fromIntegral width - , Vk.height = fromIntegral height + , Vk.height = - fromIntegral height , Vk.minDepth = 0 , Vk.maxDepth = 1 } diff --git a/src/Draw.hs b/src/Draw.hs index 17fbaff..a9e7118 100644 --- a/src/Draw.hs +++ b/src/Draw.hs @@ -57,7 +57,7 @@ drawFrame engineData frameNumber = do let (V2 width height) = engineWindowDimensions engineData camPosition = V3 (-10 * sin (fromIntegral frameNumber / 90)) - (-2) + 2 (-10 * cos (fromIntegral frameNumber / 90)) camCenter = V3 0 0 0 camUp = V3 0 1 0 diff --git a/src/Mesh.hs b/src/Mesh.hs index 6aba82a..6fb8d82 100644 --- a/src/Mesh.hs +++ b/src/Mesh.hs @@ -16,8 +16,6 @@ import qualified Data.Map.Strict as M import Data.Maybe (fromMaybe) import qualified Data.Vector as V -import Debug.Trace - import Foreign import Linear (V2(..), V3(..), V4(..)) @@ -40,9 +38,9 @@ loadMeshes -> m () loadMeshes allocator uploadContext queue device = do let triangle = V.fromList - [ Vertex (V3 0.5 0.5 0) (V3 0 0 0) (V4 0 1 0 1) (V2 0 0) - , Vertex (V3 (-0.5) 0.5 0) (V3 0 0 0) (V4 0 1 0 1) (V2 0 0) - , Vertex (V3 0 (-0.5) 0) (V3 0 0 0) (V4 0 1 0 1) (V2 0 0) + [ Vertex (V3 0.5 0 0) (V3 0 0 0) (V4 0 1 0 1) (V2 0 0) + , Vertex (V3 (-0.5) 0 0) (V3 0 0 0) (V4 0 1 0 1) (V2 0 0) + , Vertex (V3 0 1 0) (V3 0 0 0) (V4 0 1 0 1) (V2 0 0) ] triMesh <- uploadMesh triangle allocator uploadContext queue device