diff --git a/default.nix b/default.nix index fb78969..2ffd0ac 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,7 @@ }: mkDerivation { pname = "h-raylib"; - version = "5.5.2.0"; + version = "5.5.3.0"; src = ./.; isLibrary = true; isExecutable = buildExamples; diff --git a/examples/first-person-camera/src/Main.hs b/examples/first-person-camera/src/Main.hs index 9932c83..ad78fc9 100644 --- a/examples/first-person-camera/src/Main.hs +++ b/examples/first-person-camera/src/Main.hs @@ -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 diff --git a/flake.lock b/flake.lock index 734973a..7023cc0 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1729265718, - "narHash": "sha256-4HQI+6LsO3kpWTYuVGIzhJs1cetFcwT7quWCk/6rqeo=", + "lastModified": 1729980323, + "narHash": "sha256-eWPRZAlhf446bKSmzw6x7RWEE4IuZgAp8NW3eXZwRAY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ccc0c2126893dd20963580b6478d1a10a4512185", + "rev": "86e78d3d2084ff87688da662cf78c2af085d8e73", "type": "github" }, "original": { diff --git a/h-raylib.cabal b/h-raylib.cabal index 8ac4034..505b7b4 100644 --- a/h-raylib.cabal +++ b/h-raylib.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: h-raylib -version: 5.5.2.0 +version: 5.5.3.0 synopsis: Raylib bindings for Haskell category: graphics description: @@ -322,7 +322,6 @@ library if flag(platform-web) cpp-options: -DWEB_FFI - c-sources: lib/web.c else cc-options: diff --git a/lib/rl_internal.c b/lib/rl_internal.c index 023366a..dd365ae 100644 --- a/lib/rl_internal.c +++ b/lib/rl_internal.c @@ -103,4 +103,4 @@ RLBIND int rlGetPixelDataSize(int width, int height, int format) } return dataSize; -} \ No newline at end of file +} diff --git a/lib/web.c b/lib/web.c deleted file mode 100644 index e022581..0000000 --- a/lib/web.c +++ /dev/null @@ -1,19 +0,0 @@ -/** - * See web.h - */ - -#include "web.h" - -// See https://gitlab.haskell.org/ghc/ghc-wasm-meta#custom-imports -void _jslog(void *buf, uint32_t len) __attribute__((__import_module__("env"), __import_name__("log"))); -void jslog(void *buf, uint32_t len) { _jslog(buf, len); } - -void _jsfree(void *ptr) __attribute__((__import_module__("env"), __import_name__("free"))); -void jsfree(void *ptr) { _jsfree(ptr); } - -void *_callRaylibFunction(char *name, uint32_t nameLen, void **params, uint32_t *sizeParams, uint8_t *typeParams, uint32_t numParams, uint32_t returnSizeBytes, uint8_t returnType) __attribute__((__import_module__("env"), __import_name__("callRaylibFunction"))); -void *callRaylibFunction( - char *name, uint32_t nameLen, void **params, uint32_t *sizeParams, uint8_t *typeParams, uint32_t numParams, uint32_t returnSizeBytes, uint8_t returnType) -{ - return _callRaylibFunction(name, nameLen, params, sizeParams, typeParams, numParams, returnSizeBytes, returnType); -}