Skip to content

Commit

Permalink
Update to raylib 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
schveiguy committed Nov 21, 2023
1 parent c532925 commit a8f9ab2
Show file tree
Hide file tree
Showing 6 changed files with 351 additions and 186 deletions.
6 changes: 6 additions & 0 deletions generating.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ module raylib.rlgl;
import raylib;
```

```d
module raylib.rcamera;
import raylib;
```

Additionally, each of those modules will have an automatically generated `extern (C):` line. We need to find it and
edit it to `extern (C) @nogc nothrow:`.

Expand Down
Binary file modified install/lib.tgz
Binary file not shown.
191 changes: 132 additions & 59 deletions source/raylib/package.d

Large diffs are not rendered by default.

67 changes: 37 additions & 30 deletions source/raylib/raymath.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@ import raylib;
*
* raymath v1.5 - Math functions to work with Vector2, Vector3, Matrix and Quaternions
*
* CONFIGURATION:
*
* #define RAYMATH_IMPLEMENTATION
* Generates the implementation of the library into the included file.
* If not defined, the library is in header only mode and can be included in other headers
* or source files without problems. But only ONE file should hold the implementation.
*
* #define RAYMATH_STATIC_INLINE
* Define static inline functions code, so #include header suffices for use.
* This may use up lots of memory.
*
* CONVENTIONS:
*
* - Matrix structure is defined as row-major (memory layout) but parameters naming AND all
* math operations performed by the library consider the structure as it was column-major
* It is like transposed versions of the matrices are used for all the maths
* It benefits some functions making them cache-friendly and also avoids matrix
* transpositions sometimes required by OpenGL
* Example: In memory order, row0 is [m0 m4 m8 m12] but in semantic math row0 is [m0 m1 m2 m3]
* - Functions are always self-contained, no function use another raymath function inside,
* required code is directly re-implemented inside
* - Functions input parameters are always received by value (2 unavoidable exceptions)
* - Functions use always a "result" variable for return
* - Functions are always defined inline
* - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)
* - No compound literals used to make sure libray is compatible with C++
*
* CONFIGURATION:
* #define RAYMATH_IMPLEMENTATION
* Generates the implementation of the library into the included file.
* If not defined, the library is in header only mode and can be included in other headers
* or source files without problems. But only ONE file should hold the implementation.
*
* #define RAYMATH_STATIC_INLINE
* Define static inline functions code, so #include header suffices for use.
* This may use up lots of memory.
*
*
* LICENSE: zlib/libpng
Expand Down Expand Up @@ -191,14 +196,7 @@ float Vector2Angle(Vector2 v1, Vector2 v2);
// NOTE: Parameters need to be normalized
// Current implementation should be aligned with glm::angle

// Dot product

// Clamp

// Alternative implementation, more costly
//float v1Length = sqrtf((start.x*start.x) + (start.y*start.y));
//float v2Length = sqrtf((end.x*end.x) + (end.y*end.y));
//float result = -acosf((start.x*end.x + start.y*end.y)/(v1Length*v2Length));
// TODO(10/9/2023): Currently angles move clockwise, determine if this is wanted behavior
float Vector2LineAngle(Vector2 start, Vector2 end);

// Scale vector (multiply by value)
Expand Down Expand Up @@ -309,6 +307,12 @@ Vector3 Vector3Divide(Vector3 v1, Vector3 v2);
// Normalize provided vector
Vector3 Vector3Normalize(Vector3 v);

//Calculate the projection of the vector v1 on to v2
Vector3 Vector3Project(Vector3 v1, Vector3 v2);

//Calculate the rejection of the vector v1 on to v2
Vector3 Vector3Reject(Vector3 v1, Vector3 v2);

// Orthonormalize provided vectors
// Makes vectors normalized and orthogonal to each other
// Gram-Schmidt function implementation
Expand Down Expand Up @@ -339,7 +343,7 @@ Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q);

// Vector3CrossProduct(w, wv)

// Vector3Scale(wv, 2 * a)
// Vector3Scale(wv, 2*a)

// Vector3Scale(wwv, 2)
Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle);
Expand Down Expand Up @@ -408,12 +412,11 @@ Vector3 Vector3ClampValue(Vector3 v, float min, float max);
// Check whether two given vectors are almost equal
int Vector3Equals(Vector3 p, Vector3 q);

// Compute the direction of a refracted ray where v specifies the
// normalized direction of the incoming ray, n specifies the
// normalized normal vector of the interface of two optical media,
// and r specifies the ratio of the refractive index of the medium
// from where the ray comes to the refractive index of the medium
// on the other side of the surface
// Compute the direction of a refracted ray
// v: normalized direction of the incoming ray
// n: normalized normal vector of the interface of two optical media
// r: ratio of the refractive index of the medium from where the ray comes
// to the refractive index of the medium on the other side of the surface
Vector3 Vector3Refract(Vector3 v, Vector3 n, float r);

//----------------------------------------------------------------------------------
Expand Down Expand Up @@ -502,16 +505,20 @@ Matrix MatrixFrustum(
// NOTE: Fovy angle must be provided in radians

// MatrixFrustum(-right, right, -top, top, near, far);
Matrix MatrixPerspective(double fovy, double aspect, double near, double far);
Matrix MatrixPerspective(
double fovY,
double aspect,
double nearPlane,
double farPlane);

// Get orthographic projection matrix
Matrix MatrixOrtho(
double left,
double right,
double bottom,
double top,
double near,
double far);
double nearPlane,
double farPlane);

// Get camera look-at matrix (view matrix)

Expand Down
54 changes: 36 additions & 18 deletions source/raylib/rcamera.d
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
module raylib.rcamera;

import raylib;
/*******************************************************************************************
*
* rcamera - Basic camera system with support for multiple camera modes
*
* CONFIGURATION:
* #define RCAMERA_IMPLEMENTATION
* Generates the implementation of the library into the included file.
* If not defined, the library is in header only mode and can be included in other headers
* or source files without problems. But only ONE file should hold the implementation.
*
* #define CAMERA_IMPLEMENTATION
* Generates the implementation of the library into the included file.
* If not defined, the library is in header only mode and can be included in other headers
* or source files without problems. But only ONE file should hold the implementation.
*
* #define CAMERA_STANDALONE
* If defined, the library can be used as standalone as a camera system but some
* functions must be redefined to manage inputs accordingly.
* #define RCAMERA_STANDALONE
* If defined, the library can be used as standalone as a camera system but some
* functions must be redefined to manage inputs accordingly.
*
* CONTRIBUTORS:
* Ramon Santamaria: Supervision, review, update and maintenance
Expand Down Expand Up @@ -39,23 +41,27 @@
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
module raylib.rcamera;

import raylib;

extern (C) @nogc nothrow:

//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
// Function specifiers definition // Functions defined as 'extern' by default (implicit specifiers)
// Function specifiers definition

// Function specifiers in case library is build/used as a shared library (Windows)
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll

// We are building the library as a Win32 shared library (.dll)

// We are using the library as a Win32 shared library (.dll) // Functions defined as 'extern' by default (implicit specifiers)

enum CAMERA_CULL_DISTANCE_NEAR = RL_CULL_DISTANCE_NEAR;
enum CAMERA_CULL_DISTANCE_FAR = RL_CULL_DISTANCE_FAR;

//----------------------------------------------------------------------------------
// Types and Structures Definition
// NOTE: Below types are required for CAMERA_STANDALONE usage
// NOTE: Below types are required for standalone usage
//----------------------------------------------------------------------------------

// Vector2, 2 components
Expand All @@ -69,6 +75,13 @@ enum CAMERA_CULL_DISTANCE_FAR = RL_CULL_DISTANCE_FAR;
// Vector y component
// Vector z component

// Matrix, 4x4 components, column major, OpenGL style, right-handed

// Matrix first row (4 components)
// Matrix second row (4 components)
// Matrix third row (4 components)
// Matrix fourth row (4 components)

// Camera type, defines a camera position/orientation in 3d space

// Camera position
Expand Down Expand Up @@ -121,7 +134,7 @@ void CameraRoll(Camera* camera, float angle);
Matrix GetCameraViewMatrix(Camera* camera);
Matrix GetCameraProjectionMatrix(Camera* camera, float aspect);

// CAMERA_H
// RCAMERA_H

/***********************************************************************************
*
Expand Down Expand Up @@ -289,12 +302,17 @@ Matrix GetCameraProjectionMatrix(Camera* camera, float aspect);

// Camera movement

//if (IsKeyDown(KEY_SPACE)) CameraMoveUp(camera, CAMERA_MOVE_SPEED);
//if (IsKeyDown(KEY_LEFT_CONTROL)) CameraMoveUp(camera, -CAMERA_MOVE_SPEED);
// Camera pan (for CAMERA_FREE)

// Mouse support

// Keyboard support

// Gamepad controller support

// Zoom target distance

// !CAMERA_STANDALONE
// !RCAMERA_STANDALONE

// Update camera movement, movement/rotation values should be provided by user

Expand All @@ -313,4 +331,4 @@ Matrix GetCameraProjectionMatrix(Camera* camera, float aspect);

// Zoom target distance

// CAMERA_IMPLEMENTATION
// RCAMERA_IMPLEMENTATION
Loading

0 comments on commit a8f9ab2

Please sign in to comment.