Skip to content

Commit

Permalink
Merge pull request #48 from archydragon/update-4.5
Browse files Browse the repository at this point in the history
Update to raylib 4.5
  • Loading branch information
bakpakin authored May 27, 2023
2 parents 36baa1d + 9d43c87 commit c60e5ae
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 158 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ Clone the repo with submodules, or use `git submodule update --init --recursive`
jpm build
```

This should compile `build\jaylib.so` on nix systems, which you can import in a janet repl. Jaylib does not build
on Windows with jpm because jpm expects MSVC, but Raylib requires gcc or clang
for C99 features that MSVC does not support. A long term goal is to be able to install jaylib on windows
with minimal dependencies on the external build system.
This should compile `build\jaylib.so` on nix systems or `build\jaylib.dll` on Windows, which you can import in
a janet repl.

```janet
(use ./build/jaylib)
Expand Down
2 changes: 1 addition & 1 deletion project.janet
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

:cflags [;default-cflags ;cflags]

:defines {"PLATFORM_DESKTOP" true "_POSIX_C_SOURCE" "200809L" "_DARWIN_C_SOURCE" (if (= o :macos) "1" nil)}
:defines {"PLATFORM_DESKTOP" true "_POSIX_C_SOURCE" "200809L" "_DARWIN_C_SOURCE" (if (= o :macos) "1" nil) "_GNU_SOURCE" true}

:source ["src/main.c"

Expand Down
2 changes: 1 addition & 1 deletion raylib
Submodule raylib updated 535 files
67 changes: 28 additions & 39 deletions src/3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ static Janet cfun_DrawCube(int32_t argc, Janet *argv) {
return janet_wrap_nil();
}

static Janet cfun_DrawCubeTexture(int32_t argc, Janet *argv) {
janet_fixarity(argc, 6);
Texture2D *texture = jaylib_gettexture2d(argv, 0);
Vector3 position = jaylib_getvec3(argv, 1);
float width = (float) janet_getnumber(argv, 2);
float height = (float) janet_getnumber(argv, 3);
float length = (float) janet_getnumber(argv, 4);
Color color = jaylib_getcolor(argv, 5);
DrawCubeTexture(*texture, position, width, height, length, color);
return janet_wrap_nil();
}

static Janet cfun_DrawGrid(int32_t argc, Janet *argv) {
janet_fixarity(argc, 2);
int slices = janet_getinteger(argv, 0);
Expand Down Expand Up @@ -357,6 +345,16 @@ static Janet cfun_LoadMaterialDefault(int32_t argc, Janet *argv) {
return janet_wrap_abstract(defaultMaterial);
}

static Janet cfun_IsMaterialReady(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Material material = *jaylib_getmaterial(argv, 0);
if (IsMaterialReady(material)) {
return janet_wrap_true();
} else {
return janet_wrap_false();
}
}

static Janet cfun_UnloadMaterial(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Material *material = jaylib_getmaterial(argv, 0);
Expand Down Expand Up @@ -390,6 +388,16 @@ static Janet cfun_LoadModel(int32_t argc, Janet *argv) {
return janet_wrap_abstract(model);
}

static Janet cfun_IsModelReady(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Model model = *jaylib_getmodel(argv, 0);
if (IsModelReady(model)) {
return janet_wrap_true();
} else {
return janet_wrap_false();
}
}

static Janet cfun_LoadModelFromMesh(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Mesh *mesh = jaylib_getmesh(argv, 0);
Expand Down Expand Up @@ -509,13 +517,6 @@ static Janet cfun_GenMeshTangents(int32_t argc, Janet *argv) {
return janet_wrap_nil();
}

static Janet cfun_GenMeshBinormals(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Mesh *mesh = jaylib_getmesh(argv, 0);
GenMeshBinormals(mesh);
return janet_wrap_nil();
}

static Janet cfun_DrawModel(int32_t argc, Janet *argv) {
janet_fixarity(argc, 4);
Model model = *jaylib_getmodel(argv, 0);
Expand Down Expand Up @@ -695,14 +696,6 @@ static Janet cfun_GetRayCollisionQuad(int32_t argc, Janet *argv) {
return jaylib_wrap_raycollision(result);
}

static Janet cfun_GetRayCollisionModel(int32_t argc, Janet *argv) {
janet_fixarity(argc, 2);
Ray ray = jaylib_getray(argv, 0);
Model *model = jaylib_getmodel(argv, 1);
RayCollision result = GetRayCollisionModel(ray, *model);
return jaylib_wrap_raycollision(result);
}

static JanetReg threed_cfuns[] = {
{"draw-line-3d", cfun_DrawLine3D,
"(draw-line-3d [start-x start-y start-z] [end-x end-y end-z] color)\n\n"
Expand Down Expand Up @@ -736,10 +729,6 @@ static JanetReg threed_cfuns[] = {
"(draw-cube-wires-v [center-x center-y center-z] [width height length] color)\n\n"
"Draw cube wires (Vector version)"
},
{"draw-cube-texture", cfun_DrawCubeTexture,
"(draw-cube-texture texture [center-x center-y center-z] width height length color)\n\n"
"Draw cube textured"
},
{"draw-grid", cfun_DrawGrid,
"(draw-grid slices spacing)\n\n"
"Draw a grid (centered at (0, 0, 0))"
Expand Down Expand Up @@ -796,6 +785,10 @@ static JanetReg threed_cfuns[] = {
"(load-material-default)\n\n"
"Load and return the default material"
},
{"material-ready?", cfun_IsMaterialReady,
"(material-ready? material)\n\n"
"Checks if a material is ready"
},
{"unload-material", cfun_UnloadMaterial,
"(unload-material material)\n\n"
"Unload material from GPU memory (VRAM)"
Expand Down Expand Up @@ -856,6 +849,10 @@ static JanetReg threed_cfuns[] = {
"(load-model filename)\n\n"
"Load model from files (meshes and materials)"
},
{"model-ready?", cfun_IsModelReady,
"(model-ready? model)\n\n"
"Checks if a model is ready"
},
{"load-model-from-mesh", cfun_LoadModelFromMesh,
"(load-model-from-mesh mesh)\n\n"
"Load model from generated mesh (default material)"
Expand Down Expand Up @@ -908,10 +905,6 @@ static JanetReg threed_cfuns[] = {
"(gen-mesh-tangents mesh)\n\n"
"Compute mesh tangents"
},
{"gen-mesh-binormals", cfun_GenMeshBinormals,
"(gen-mesh-binormals mesh)\n\n"
"Compute mesh binormals"
},
{"draw-model", cfun_DrawModel,
"(draw-model model position scale tint)\n\n"
"Draw a model (with texture if set)"
Expand Down Expand Up @@ -972,9 +965,5 @@ static JanetReg threed_cfuns[] = {
"(get-ray-collision-quad ray p1 p2 p3 p4)\n\n"
"Get collision info between ray and quad"
},
{"get-ray-collision-model", cfun_GetRayCollisionModel,
"(get-ray-collision-model ray model)\n\n"
"Get collision info between ray and model"
},
{NULL, NULL, NULL}
};
43 changes: 43 additions & 0 deletions src/audio.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "raylib.h"
static Janet cfun_InitAudioDevice(int32_t argc, Janet *argv) {
(void) argv;
janet_fixarity(argc, 0);
Expand Down Expand Up @@ -45,6 +46,16 @@ static Janet cfun_LoadWave(int32_t argc, Janet *argv) {
return janet_wrap_abstract(wave);
}

static Janet cfun_IsWaveReady(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Wave wave = *jaylib_getwave(argv, 0);
if (IsWaveReady(wave)) {
return janet_wrap_true();
} else {
return janet_wrap_false();
}
}

static Janet cfun_LoadSound(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
const char *fileName = janet_getcstring(argv, 0);
Expand All @@ -61,6 +72,16 @@ static Janet cfun_LoadSoundFromWave(int32_t argc, Janet *argv) {
return janet_wrap_abstract(sound);
}

static Janet cfun_IsSoundReady(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Sound sound = *jaylib_getsound(argv, 0);
if (IsSoundReady(sound)) {
return janet_wrap_true();
} else {
return janet_wrap_false();
}
}

static Janet cfun_UnloadWave(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Wave wave = *jaylib_getwave(argv, 0);
Expand Down Expand Up @@ -157,6 +178,16 @@ static Janet cfun_LoadMusicStream(int32_t argc, Janet *argv) {
return janet_wrap_abstract(music);
}

static Janet cfun_IsMusicReady(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Music music = *jaylib_getmusic(argv, 0);
if (IsMusicReady(music)) {
return janet_wrap_true();
} else {
return janet_wrap_false();
}
}

static Janet cfun_UnloadMusicStream(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
Music music = *jaylib_getmusic(argv, 0);
Expand Down Expand Up @@ -347,10 +378,18 @@ static JanetReg audio_cfuns[] = {
"(load-wave file-name)\n\n"
"Load wave data from file"
},
{"wave-ready?", cfun_IsWaveReady,
"(wave-ready? wave)\n\n"
"Checks if wave data is ready"
},
{"load-sound", cfun_LoadSound,
"(load-sound file-name)\n\n"
"Load sound from file"
},
{"sound-ready?", cfun_IsSoundReady,
"(sound-ready? wave)\n\n"
"Checks if sound is ready"
},
{"load-sound-from-wave", cfun_LoadSoundFromWave,
"(load-sound-from-wave wave)\n\n"
"Load sound from wave data"
Expand Down Expand Up @@ -407,6 +446,10 @@ static JanetReg audio_cfuns[] = {
"(load-music-stream file-name)\n\n"
"Load music stream from file"
},
{"music-ready?", cfun_IsMusicReady,
"(music-ready? wave)\n\n"
"Checks if a music stream is ready"
},
{"unload-music-stream", cfun_UnloadMusicStream,
"(unload-music-stream music)\n\n"
"Unload music stream"
Expand Down
Loading

0 comments on commit c60e5ae

Please sign in to comment.