-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
40 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,46 @@ | ||
{-# LANGUAGE PatternSynonyms #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Main where | ||
|
||
import Raylib.Core (clearBackground, disableCursor) | ||
import Raylib.Core (initWindowUnmanaged, setTargetFPS, windowShouldClose, closeWindow, clearBackground, disableCursor) | ||
import Raylib.Core.Camera (updateCamera) | ||
import Raylib.Core.Models (drawCircle3D, drawCubeWiresV, drawLine3D) | ||
import Raylib.Core.Text (drawFPS) | ||
import Raylib.Types (Camera3D (Camera3D), CameraMode (CameraModeFirstPerson), CameraProjection (CameraPerspective), pattern Vector3) | ||
import Raylib.Util (drawing, mode3D, whileWindowOpen_, withWindow) | ||
import Raylib.Util (drawing, mode3D, raylibApplication) | ||
import Raylib.Util.Colors (black, white) | ||
|
||
main :: IO () | ||
main = do | ||
withWindow | ||
600 | ||
450 | ||
"raylib [core] example - first person camera" | ||
60 | ||
( \_ -> do | ||
disableCursor | ||
|
||
let camera = Camera3D (Vector3 0 0 0) (Vector3 2 0 1) (Vector3 0 1 0) 70 CameraPerspective | ||
|
||
whileWindowOpen_ | ||
( \c -> | ||
drawing | ||
( do | ||
clearBackground black | ||
drawFPS 10 20 | ||
|
||
mode3D | ||
c | ||
( do | ||
drawCircle3D (Vector3 2 0 1) 2 (Vector3 0 0 0) 0 white | ||
drawLine3D (Vector3 3 (-1) 1) (Vector3 1 1 1) white | ||
drawLine3D (Vector3 4 2 2) (Vector3 1 (-1) 1) white | ||
drawCubeWiresV (Vector3 (-2) 0 0) (Vector3 1 1 1) white | ||
) | ||
) | ||
>> updateCamera c CameraModeFirstPerson | ||
) | ||
startup :: IO Camera3D | ||
startup = do | ||
initWindowUnmanaged 600 450 "raylib [core] example - first person camera" | ||
setTargetFPS 60 | ||
disableCursor | ||
|
||
return $ Camera3D (Vector3 0 0 0) (Vector3 2 0 1) (Vector3 0 1 0) 70 CameraPerspective | ||
|
||
mainLoop :: Camera3D -> IO Camera3D | ||
mainLoop camera = | ||
drawing | ||
( do | ||
clearBackground black | ||
drawFPS 10 20 | ||
|
||
mode3D | ||
camera | ||
( do | ||
drawCircle3D (Vector3 2 0 1) 2 (Vector3 0 0 0) 0 white | ||
drawLine3D (Vector3 3 (-1) 1) (Vector3 1 1 1) white | ||
drawLine3D (Vector3 4 2 2) (Vector3 1 (-1) 1) white | ||
drawCubeWiresV (Vector3 (-2) 0 0) (Vector3 1 1 1) white | ||
) | ||
) | ||
>> updateCamera camera CameraModeFirstPerson | ||
|
||
shouldClose :: Camera3D -> IO Bool | ||
shouldClose _ = windowShouldClose | ||
|
||
teardown :: Camera3D -> IO () | ||
teardown _ = closeWindow Nothing | ||
|
||
raylibApplication 'startup 'mainLoop 'shouldClose 'teardown |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,4 +103,4 @@ RLBIND int rlGetPixelDataSize(int width, int height, int format) | |
} | ||
|
||
return dataSize; | ||
} | ||
} |