Skip to content

Commit

Permalink
chore: update submodules, increment version
Browse files Browse the repository at this point in the history
  • Loading branch information
Anut-py committed Jul 12, 2024
1 parent b27b8d9 commit f7433fb
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 16 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}:
mkDerivation {
pname = "h-raylib";
version = "5.1.3.0";
version = "5.5.0.0";
src = ./.;
isLibrary = true;
isExecutable = buildExamples;
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
forAllSystems' = nixpkgs.lib.genAttrs;
forAllSystems = forAllSystems' supportedSystems;

raylibRev = "dcf2f6a8e97911c90efce5722bd7f0c7cdc8601e";
raylibHash = "sha256-GNID5U475isYwB9j7CqygoiqU0scbILeHcgEEDwHaUM=";
rayguiRev = "4b3d94f5df6a5a2aa86286350f7e20c0ca35f516";
rayguiHash = "sha256-+UVvUOp+6PpnoWy81ZCqD8BR6sxZJhtQNYQfbv6SOy0=";
raylibRev = "8d5374a443509036063a350d1649408e009425e7";
raylibHash = "sha256-kYuqEUkyw8dngy5yBneNn+Br0xQr6NagP/s2CPM+q44=";
rayguiRev = "3fb9d77a67243497e10ae0448374a52a2a65e26f";
rayguiHash = "sha256-aWfXimbGU7RYqqOd44GmH3jPN8gcN4D/ygB71jIEr2c=";

pkgsForSystem =
system:
Expand Down
4 changes: 2 additions & 2 deletions h-raylib.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: h-raylib
version: 5.1.3.0
version: 5.5.0.0
synopsis: Raylib bindings for Haskell
category: graphics
description:
Expand Down Expand Up @@ -322,7 +322,7 @@ library
c-sources: lib/web.c

else
cc-options: -DPLATFORM_DESKTOP -Wno-int-to-void-pointer-cast
cc-options: -DPLATFORM_DESKTOP_GLFW -Wno-int-to-void-pointer-cast
c-sources:
lib/rgui_bindings.c
lib/rl_bindings.c
Expand Down
34 changes: 33 additions & 1 deletion lib/rl_bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,13 @@ RLBIND Image *ImageFromImage_(Image *a, Rectangle *b)
return ptr;
}

RLBIND Image *ImageFromChannel_(Image *a, int b)
{
Image *ptr = (Image *)malloc(sizeof(Image));
*ptr = ImageFromChannel(*a, b);
return ptr;
}

RLBIND Image *ImageText_(char *a, int b, Color *c)
{
Image *ptr = (Image *)malloc(sizeof(Image));
Expand Down Expand Up @@ -924,6 +931,31 @@ RLBIND void ImageDrawRectangleLines_(Image *a, Rectangle *b, int c, Color *d)
ImageDrawRectangleLines(a, *b, c, *d);
}

RLBIND void ImageDrawTriangle_(Image *a, Vector2 *b, Vector2 *c, Vector2 *d, Color *e)
{
ImageDrawTriangle(a, *b, *c, *d, *e);
}

RLBIND void ImageDrawTriangleEx_(Image *a, Vector2 *b, Vector2 *c, Vector2 *d, Color *e, Color *f, Color *g)
{
ImageDrawTriangleEx(a, *b, *c, *d, *e, *f, *g);
}

RLBIND void ImageDrawTriangleLines_(Image *a, Vector2 *b, Vector2 *c, Vector2 *d, Color *e)
{
ImageDrawTriangleLines(a, *b, *c, *d, *e);
}

RLBIND void ImageDrawTriangleFan_(Image *a, Vector2 *b, int c, Color *d)
{
ImageDrawTriangleFan(a, b, c, *d);
}

RLBIND void ImageDrawTriangleStrip_(Image *a, Vector2 *b, int c, Color *d)
{
ImageDrawTriangleStrip(a, b, c, *d);
}

RLBIND void ImageDraw_(Image *a, Image *b, Rectangle *c, Rectangle *d, Color *e)
{
ImageDraw(a, *b, *c, *d, *e);
Expand Down Expand Up @@ -2730,7 +2762,7 @@ RLBIND void ImageBlurGaussian_(Image *a, int b)
ImageBlurGaussian(a, b);
}

RLBIND void ImageKernelConvolution_(Image *a, float *b, int c)
RLBIND void ImageKernelConvolution_(Image *a, const float *b, int c)
{
ImageKernelConvolution(a, b, c);
}
Expand Down
14 changes: 13 additions & 1 deletion lib/rl_bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ Image *ImageCopy_(Image *a);

Image *ImageFromImage_(Image *a, Rectangle *b);

Image *ImageFromChannel_(Image *a, int b);

Image *ImageText_(char *a, int b, Color *c);

Image *ImageTextEx_(Font *a, char *b, float c, float d, Color *e);
Expand Down Expand Up @@ -334,6 +336,16 @@ void ImageDrawRectangleRec_(Image *a, Rectangle *b, Color *c);

void ImageDrawRectangleLines_(Image *a, Rectangle *b, int c, Color *d);

void ImageDrawTriangle_(Image *a, Vector2 *b, Vector2 *c, Vector2 *d, Color *e);

void ImageDrawTriangleEx_(Image *a, Vector2 *b, Vector2 *c, Vector2 *d, Color *e, Color *f, Color *g);

void ImageDrawTriangleLines_(Image *a, Vector2 *b, Vector2 *c, Vector2 *d, Color *e);

void ImageDrawTriangleFan_(Image *a, Vector2 *b, int c, Color *d);

void ImageDrawTriangleStrip_(Image *a, Vector2 *b, int c, Color *d);

void ImageDraw_(Image *a, Image *b, Rectangle *c, Rectangle *d, Color *e);

void ImageDrawText_(Image *a, char *b, int c, int d, int e, Color *f);
Expand Down Expand Up @@ -1004,7 +1016,7 @@ void ImageAlphaPremultiply_(Image *a);

void ImageBlurGaussian_(Image *a, int b);

void ImageKernelConvolution_(Image *a, float *b, int c);
void ImageKernelConvolution_(Image *a, const float *b, int c);

void ImageResize_(Image *a, int b, int c);

Expand Down
2 changes: 1 addition & 1 deletion raygui
Submodule raygui updated 2 files
+2 −2 README.md
+12 −12 src/raygui.h
2 changes: 1 addition & 1 deletion raylib
Submodule raylib updated 56 files
+1 −0 .gitignore
+1 −1 README.md
+3 −1 cmake/LibraryConfigurations.cmake
+41 −33 examples/Makefile
+1 −1 examples/audio/audio_mixed_processor.c
+2 −2 examples/core/core_2d_camera_platformer.c
+1 −1 examples/core/core_input_mouse_wheel.c
+8 −8 examples/core/core_random_sequence.c
+4 −4 examples/core/core_smooth_pixelperfect.c
+1 −1 examples/core/core_storage_values.c
+27 −0 examples/examples.rc
+7 −5 examples/models/models_billboard.c
+1 −1 examples/models/models_draw_cube_texture.c
+9 −10 examples/models/models_loading_gltf.c
+2 −3 examples/models/models_skybox.c
+ examples/raylib.ico
+3 −3 examples/shaders/shaders_deferred_render.c
+2 −2 examples/shapes/shapes_lines_bezier.c
+1 −1 examples/shapes/shapes_splines_drawing.c
+106 −0 examples/textures/textures_image_channel.c
+ examples/textures/textures_image_channel.png
+183 −6 parser/output/raylib_api.json
+87 −6 parser/output/raylib_api.lua
+340 −280 parser/output/raylib_api.txt
+53 −7 parser/output/raylib_api.xml
+2 −2 parser/raylib_parser.c
+1 −1 projects/CMake/CMakeLists.txt
+3 −0 projects/VS2022/examples/models_loading_gltf.vcxproj
+8 −8 projects/VS2022/examples/shapes_splines_drawing.vcxproj
+5 −2 src/CMakeLists.txt
+68 −62 src/Makefile
+34 −37 src/build.zig
+4,200 −4,145 src/external/RGFW.h
+4 −0 src/external/rl_gputex.h
+6 −2 src/minshell.html
+9 −9 src/platforms/rcore_android.c
+12 −18 src/platforms/rcore_desktop_glfw.c
+321 −510 src/platforms/rcore_desktop_rgfw.c
+48 −48 src/platforms/rcore_desktop_sdl.c
+10 −11 src/platforms/rcore_drm.c
+4 −2 src/platforms/rcore_web.c
+3 −3 src/raudio.c
+5 −5 src/raylib.dll.rc
+ src/raylib.dll.rc.data
+13 −6 src/raylib.h
+6 −6 src/raylib.rc
+ src/raylib.rc.data
+67 −12 src/raymath.h
+2 −2 src/rcamera.h
+11 −5 src/rcore.c
+9 −7 src/rlgl.h
+252 −155 src/rmodels.c
+19 −19 src/rshapes.c
+5 −11 src/rtext.c
+458 −85 src/rtextures.c
+5 −0 src/shell.html
40 changes: 38 additions & 2 deletions src/Raylib/Core/Textures.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module Raylib.Core.Textures
genImageCellular,
genImageText,
imageFromImage,
imageFromChannel,
imageText,
imageTextEx,
imageFormat,
Expand Down Expand Up @@ -69,6 +70,11 @@ module Raylib.Core.Textures
imageDrawRectangleV,
imageDrawRectangleRec,
imageDrawRectangleLines,
imageDrawTriangle,
imageDrawTriangleEx,
imageDrawTriangleLines,
imageDrawTriangleFan,
imageDrawTriangleStrip,
imageDraw,
imageDrawText,
imageDrawTextEx,
Expand Down Expand Up @@ -132,6 +138,7 @@ module Raylib.Core.Textures
c'genImageText,
c'imageCopy,
c'imageFromImage,
c'imageFromChannel,
c'imageText,
c'imageTextEx,
c'imageFormat,
Expand Down Expand Up @@ -176,6 +183,11 @@ module Raylib.Core.Textures
c'imageDrawRectangleV,
c'imageDrawRectangleRec,
c'imageDrawRectangleLines,
c'imageDrawTriangle,
c'imageDrawTriangleEx,
c'imageDrawTriangleLines,
c'imageDrawTriangleFan,
c'imageDrawTriangleStrip,
c'imageDraw,
c'imageDrawText,
c'imageDrawTextEx,
Expand Down Expand Up @@ -284,6 +296,7 @@ $( genNative
("c'genImageText", "GenImageText_", "rl_bindings.h", [t|CInt -> CInt -> CString -> IO (Ptr Image)|], False),
("c'imageCopy", "ImageCopy_", "rl_bindings.h", [t|Ptr Image -> IO (Ptr Image)|], False),
("c'imageFromImage", "ImageFromImage_", "rl_bindings.h", [t|Ptr Image -> Ptr Rectangle -> IO (Ptr Image)|], False),
("c'imageFromChannel", "ImageFromChannel_", "rl_bindings.h", [t|Ptr Image -> CInt -> IO (Ptr Image)|], False),
("c'imageText", "ImageText_", "rl_bindings.h", [t|CString -> CInt -> Ptr Color -> IO (Ptr Image)|], False),
("c'imageTextEx", "ImageTextEx_", "rl_bindings.h", [t|Ptr Font -> CString -> CFloat -> CFloat -> Ptr Color -> IO (Ptr Image)|], False),
("c'imageFormat", "ImageFormat_", "rl_bindings.h", [t|Ptr Image -> CInt -> IO ()|], False),
Expand Down Expand Up @@ -328,6 +341,11 @@ $( genNative
("c'imageDrawRectangleV", "ImageDrawRectangleV_", "rl_bindings.h", [t|Ptr Image -> Ptr Vector2 -> Ptr Vector2 -> Ptr Color -> IO ()|], False),
("c'imageDrawRectangleRec", "ImageDrawRectangleRec_", "rl_bindings.h", [t|Ptr Image -> Ptr Rectangle -> Ptr Color -> IO ()|], False),
("c'imageDrawRectangleLines", "ImageDrawRectangleLines_", "rl_bindings.h", [t|Ptr Image -> Ptr Rectangle -> CInt -> Ptr Color -> IO ()|], False),
("c'imageDrawTriangle", "ImageDrawTriangle_", "rl_bindings.h", [t|Ptr Image -> Ptr Vector2 -> Ptr Vector2 -> Ptr Vector2 -> Ptr Color -> IO ()|], False),
("c'imageDrawTriangleEx", "ImageDrawTriangleEx_", "rl_bindings.h", [t|Ptr Image -> Ptr Vector2 -> Ptr Vector2 -> Ptr Vector2 -> Ptr Color -> Ptr Color -> Ptr Color -> IO ()|], False),
("c'imageDrawTriangleLines", "ImageDrawTriangleLines_", "rl_bindings.h", [t|Ptr Image -> Ptr Vector2 -> Ptr Vector2 -> Ptr Vector2 -> Ptr Color -> IO ()|], False),
("c'imageDrawTriangleFan", "ImageDrawTriangleFan_", "rl_bindings.h", [t|Ptr Image -> Ptr Vector2 -> CInt -> Ptr Color -> IO ()|], False),
("c'imageDrawTriangleStrip", "ImageDrawTriangleStrip_", "rl_bindings.h", [t|Ptr Image -> Ptr Vector2 -> CInt -> Ptr Color -> IO ()|], False),
("c'imageDraw", "ImageDraw_", "rl_bindings.h", [t|Ptr Image -> Ptr Image -> Ptr Rectangle -> Ptr Rectangle -> Ptr Color -> IO ()|], False),
("c'imageDrawText", "ImageDrawText_", "rl_bindings.h", [t|Ptr Image -> CString -> CInt -> CInt -> CInt -> Ptr Color -> IO ()|], False),
("c'imageDrawTextEx", "ImageDrawTextEx_", "rl_bindings.h", [t|Ptr Image -> Ptr Font -> CString -> Ptr Vector2 -> CFloat -> CFloat -> Ptr Color -> IO ()|], False),
Expand Down Expand Up @@ -486,13 +504,16 @@ genImageText width height text =
imageFromImage :: Image -> Rectangle -> IO Image
imageFromImage image rect = withFreeable image (withFreeable rect . c'imageFromImage) >>= pop

imageFromChannel :: Image -> Int -> IO Image
imageFromChannel image channel = withFreeable image (\i -> c'imageFromChannel i (fromIntegral channel)) >>= pop

imageText :: String -> Int -> Color -> IO Image
imageText text fontSize color =
withCString text (\t -> withFreeable color $ c'imageText t (fromIntegral fontSize)) >>= pop
withCString text (\t -> withFreeable color (c'imageText t (fromIntegral fontSize))) >>= pop

imageTextEx :: Font -> String -> Float -> Float -> Color -> IO Image
imageTextEx font text fontSize spacing tint =
withFreeable font (\f -> withCString text (\t -> withFreeable tint $ c'imageTextEx f t (realToFrac fontSize) (realToFrac spacing))) >>= pop
withFreeable font (\f -> withCString text (\t -> withFreeable tint (c'imageTextEx f t (realToFrac fontSize) (realToFrac spacing)))) >>= pop

imageFormat :: Image -> PixelFormat -> IO Image
imageFormat image newFormat =
Expand Down Expand Up @@ -637,6 +658,21 @@ imageDrawRectangleRec image rectangle color = withFreeable image (\i -> withFree
imageDrawRectangleLines :: Image -> Rectangle -> Int -> Color -> IO Image
imageDrawRectangleLines image rectangle thickness color = withFreeable image (\i -> withFreeable rectangle (\r -> withFreeable color (c'imageDrawRectangleLines i r (fromIntegral thickness))) >> peek i)

imageDrawTriangle :: Image -> Vector2 -> Vector2 -> Vector2 -> Color -> IO Image
imageDrawTriangle image v1 v2 v3 color = withFreeable image (\i -> withFreeable v1 (\p1 -> withFreeable v2 (\p2 -> withFreeable v3 (\p3 -> withFreeable color (\c -> c'imageDrawTriangle i p1 p2 p3 c)))) >> peek i)

imageDrawTriangleEx :: Image -> Vector2 -> Vector2 -> Vector2 -> Color -> Color -> Color -> IO Image
imageDrawTriangleEx image v1 v2 v3 c1 c2 c3 = withFreeable image (\i -> withFreeable v1 (\p1 -> withFreeable v2 (\p2 -> withFreeable v3 (\p3 -> withFreeable c1 (\q1 -> withFreeable c2 (\q2 -> withFreeable c3 (\q3 -> c'imageDrawTriangleEx i p1 p2 p3 q1 q2 q3)))))) >> peek i)

imageDrawTriangleLines :: Image -> Vector2 -> Vector2 -> Vector2 -> Color -> IO Image
imageDrawTriangleLines image v1 v2 v3 color = withFreeable image (\i -> withFreeable v1 (\p1 -> withFreeable v2 (\p2 -> withFreeable v3 (\p3 -> withFreeable color (\c -> c'imageDrawTriangleLines i p1 p2 p3 c)))) >> peek i)

imageDrawTriangleFan :: Image -> [Vector2] -> Color -> IO Image
imageDrawTriangleFan image points color = withFreeable image (\i -> withFreeableArrayLen points (\l p -> withFreeable color (c'imageDrawTriangleFan i p (fromIntegral l))) >> peek i)

imageDrawTriangleStrip :: Image -> [Vector2] -> Color -> IO Image
imageDrawTriangleStrip image points color = withFreeable image (\i -> withFreeableArrayLen points (\l p -> withFreeable color (c'imageDrawTriangleStrip i p (fromIntegral l))) >> peek i)

imageDraw :: Image -> Image -> Rectangle -> Rectangle -> Color -> IO Image
imageDraw image source srcRec dstRec tint = withFreeable image (\i -> withFreeable source (\s -> withFreeable srcRec (\sr -> withFreeable dstRec (withFreeable tint . c'imageDraw i s sr))) >> peek i)

Expand Down
30 changes: 30 additions & 0 deletions src/Raylib/Util/Math.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module Raylib.Util.Math
matrixPerspective,
matrixOrtho,
matrixLookAt,
matrixDecompose,

-- * Quaternion math
quaternionIdentity,
Expand Down Expand Up @@ -934,6 +935,35 @@ matrixLookAt eye target up = Matrix xx xy xz (-vx |.| eye) yx yy yz (-vy |.| eye
vx@(Vector3 xx xy xz) = vectorNormalize $ vector3CrossProduct up vz
vy@(Vector3 yx yy yz) = vector3CrossProduct vz vx

-- | Decompose a transformation matrix into its rotational, translational and scaling components
matrixDecompose :: Matrix -> (Vector3, Quaternion, Vector3)
matrixDecompose (Matrix m0 m4 m8 m12 m1 m5 m9 m13 m2 m6 m10 m14 m3 m7 m11 m15) =
(translation, rotation, scale)
where
a = m0
b = m4
c = m8
d = m1
e = m5
f = m9
g = m2
h = m6
i = m10
translation = Vector3 m12 m13 m14
a' = e*i - f*h
b' = f*g - d*i
c' = d*h - e*g
det = a*a' + b*b' + c*c'
abc = Vector3 a b c
def = Vector3 d e f
ghi = Vector3 g h i
scalex = magnitude abc
scaley = magnitude def
scalez = magnitude ghi
s = Vector3 scalex scaley scalez
scale@(Vector3 sx sy sz) = if det < 0 then additiveInverse s else s
rotation = if floatEquals det 0 then quaternionIdentity else quaternionFromMatrix (Matrix (m0 / sx) m4 m8 m12 m1 (m5 / sy) m9 m13 m2 m6 (m10 / sz) m14 m3 m7 m11 m15)

------------------------------------------------
-- Quaternion math -----------------------------
------------------------------------------------
Expand Down

0 comments on commit f7433fb

Please sign in to comment.