fix shader issue

This commit is contained in:
mtgmonkey
2025-12-04 22:30:01 +01:00
parent c115a8a024
commit f0e26d0efe

View File

@@ -56,7 +56,7 @@ main = do
Model
objects
(Camera
(V3 0 0 5)
(V3 0 0 3)
(V3 0 0 0)
(V3 0 1 0)
)
@@ -117,7 +117,7 @@ vertShader =
"uniform mat4 u_projection;\n" ++
"void main()\n" ++
"{\n" ++
" gl_Position = u_projection * u_view * vec4(a_vPos, 0);\n" ++
" gl_Position = u_projection * u_view * vec4(a_vPos.xyz, 1.0);\n" ++
"}"
-- | fragment shader
@@ -228,8 +228,8 @@ loop window update view modelRef = do
Just frameEnd <- GLFW.getTime
let
dt = frameEnd - frameStart :: Double
target = 1 / 60 :: Double
when (dt < target) $ threadDelay $ floor $ (target - dt) * 1000
target = 1 / 30 :: Double
when (dt < target) $ threadDelay $ floor $ (target - dt) * 1000000
loop window update view modelRef
@@ -273,13 +273,13 @@ view window (model@(Model objects (Camera camPos camTarget camUp) program)) = do
-- apply transforms
let
viewMatrix = L.lookAt camPos camTarget camUp
projectionMatrix = L.perspective 1 (fromIntegral w / fromIntegral h) 0.1 100
projectionMatrix = L.perspective 1.4 (fromIntegral w / fromIntegral h) 0.1 100
viewGLMatrix <- GL.newMatrix GL.ColumnMajor $ toGLMatrix projectionMatrix :: IO (GL.GLmatrix GL.GLfloat)
viewGLMatrix <- GL.newMatrix GL.RowMajor $ toGLMatrix viewMatrix :: IO (GL.GLmatrix GL.GLfloat)
viewLocation <- GL.get $ GL.uniformLocation program "u_view"
GL.uniform viewLocation $= viewGLMatrix
projectionGLMatrix <- GL.newMatrix GL.ColumnMajor $ toGLMatrix projectionMatrix :: IO (GL.GLmatrix GL.GLfloat)
projectionGLMatrix <- GL.newMatrix GL.RowMajor $ toGLMatrix projectionMatrix :: IO (GL.GLmatrix GL.GLfloat)
projectionLocation <- GL.get $ GL.uniformLocation program "u_projection"
GL.uniform projectionLocation $= projectionGLMatrix