Browse Source

Forgot to include deprecated modules. Update readme. Fix
validateRaylibBinding so it only is not included during *raylib*
unittests. Update generating documentation.

Steven Schveighoffer 3 years ago
parent
commit
bf04da9071
9 changed files with 90 additions and 56 deletions
  1. 46 24
      README.md
  2. 9 0
      dub.json
  3. 11 30
      generating.md
  4. 4 0
      source/easings.d
  5. 4 2
      source/raylib/binding.d
  6. 4 0
      source/raylib_types.d
  7. 4 0
      source/raymath.d
  8. 4 0
      source/raymathext.d
  9. 4 0
      source/rlgl.d

+ 46 - 24
README.md

@@ -3,13 +3,24 @@
 # raylib-d [![DUB](https://img.shields.io/dub/v/raylib-d?style=for-the-badge)](https://code.dlang.org/packages/raylib-d)
 # raylib-d [![DUB](https://img.shields.io/dub/v/raylib-d?style=for-the-badge)](https://code.dlang.org/packages/raylib-d)
 (static) D bindings for [raylib](https://www.raylib.com/), a simple and easy-to-use library to learn videogames programming.
 (static) D bindings for [raylib](https://www.raylib.com/), a simple and easy-to-use library to learn videogames programming.
 
 
-*Note: this is a resurrected copy of the original raylib-d. The original author, onroundit (Petro Romanovych) deleted his github acccount. Therefore, some links in this README are broken, and some of the history is lost for good. I will accept any PRs that fix broken links or replace original data, but the code history itself is intact.*
-
 # Installation
 # Installation
-`dub add raylib-d`
 
 
-## First, get a copy of Raylib
-You can get the library by compiling it from the [source](https://github.com/raysan5/raylib), download the [official precompiled binaries](https://github.com/raysan5/raylib/releases). The local copies of binaries are no longer available, as that history was lost.
+## Adding the dependency
+
+raylib-d is used via the [dub](https://code.dlang.org) build system.
+
+Use `dub add` to add raylib-d to the dependency list of an existing project:
+
+```sh
+> dub add raylib-d
+Adding dependency raylib-d ~>4.2.0
+>
+```
+
+Or you can add the dependency through the interactive prompts when creating your project with `dub init`
+
+## Get a copy of Raylib
+You can get the library by compiling it from the [source](https://github.com/raysan5/raylib), or download the [official precompiled binaries](https://github.com/raysan5/raylib/releases).
 
 
 *WARNING*: Make sure you get the correct copy of the raylib library based on the version of raylib-d! Getting the incorrect version will cause SILENT compatibility errors, including memory corruption. It is extremely important to match these together.
 *WARNING*: Make sure you get the correct copy of the raylib library based on the version of raylib-d! Getting the incorrect version will cause SILENT compatibility errors, including memory corruption. It is extremely important to match these together.
 
 
@@ -17,9 +28,23 @@ If you depend on raylib-d vX.Y.Z, then your raylib binary should be vX.Y.0. Note
 
 
 For example, if you depend on raylib-d version `v3.0.x`, then you should download raylib version `3.0.0`. If you depend on raylib-d version `3.7.x`, then you should download raylib version `3.7.0`.
 For example, if you depend on raylib-d version `v3.0.x`, then you should download raylib version `3.0.0`. If you depend on raylib-d version `3.7.x`, then you should download raylib version `3.7.0`.
 
 
-#### Linux/Mac:
+### Runtime validation of binding
+
+Starting with version 4.2.0, raylib-d includes a new module `raylib.binding`,
+which at the moment contains one function: `validateRaylibBinding`. @raysan5
+was kind enough to include a runtime-accessible version string for version
+4.2.0 of the library, so now we can validate the raylib binding mechanically
+without relying on proper environmental setup. So if you compile against one
+version, but link against another, you can call this function and it will exit
+the program with an error code if the binding is incorrect. This is better than
+creating memory corruption errors!
+
+If you link against an earlier verison of raylib, it should fail to link if
+this symbol doesn't exist.
 
 
-You must make raylib visible to the linkage binder. CD into the extracted raylib folder.
+### Linux/Mac:
+
+You must make raylib visible to the linker. `cd` into the extracted raylib folder (e.g. `raylib-4.2.0_macos`).
 
 
 Now we must make raylib visible to the compiler and linker system wide. Simply run the following.
 Now we must make raylib visible to the compiler and linker system wide. Simply run the following.
 ```
 ```
@@ -31,28 +56,23 @@ Linux users must also update the linker with this command:
 sudo ldconfig
 sudo ldconfig
 ```
 ```
 
 
-#### Windows:
+### Windows:
 On Windows you must drag and drop all the required library files into the root directory of your project. These are `raylib.dll`, `raylib.lib`, and `raylibdll.lib`.
 On Windows you must drag and drop all the required library files into the root directory of your project. These are `raylib.dll`, `raylib.lib`, and `raylibdll.lib`.
 
 
 ## In order to link against raylib, add it to your dub.json.
 ## In order to link against raylib, add it to your dub.json.
-#### Using version 4.0.0 as an example.
-### On Linux/Mac:
-```json
-"dependencies": { "raylib-d": "~>4.0.0" },
-"libs": [ "raylib" ],
-```
 
 
-### On Windows:
-Starting with `4.0.0`, raylib includes 2 windows linker files, `raylib.lib` for static linking (not recommended) and `raylibdll.lib` for dynamic linking. Even though the dll is called `raylib.dll`, use the `raylibdll` for the linker file to link dynamically.
-```json
-"dependencies": { "raylib-d": "~>4.0.0" },
-"libs": [ "raylibdll" ],
-```
 
 
+Starting with `4.0.0`, raylib on windows includes 2 windows linker files, `raylib.lib` for static linking (not recommended) and `raylibdll.lib` for dynamic linking. Even though the dll is called `raylib.dll`, use the `raylibdll` for the linker file to link dynamically.
+
+You can link against all oses correctly by using os-specific `libs` keys.
 
 
-(*Note: this is missing, but may be available from wayback machine*)
+Using version 4.2.0 as an example:
 
 
-For more information look into the [wiki](https://github.com/onroundit/raylib-d/wiki/Installation).
+```json
+"dependencies": { "raylib-d": "~>4.2.0" },
+"libs-posix": [ "raylib" ],
+"libs-windows": [ "raylibdll" ],
+```
 
 
 # Example
 # Example
 ```D
 ```D
@@ -60,6 +80,8 @@ import raylib;
 
 
 void main()
 void main()
 {
 {
+        // call this before using raylib
+        validateRaylibBinding();
 	InitWindow(800, 600, "Hello, Raylib-D!");
 	InitWindow(800, 600, "Hello, Raylib-D!");
 	while (!WindowShouldClose())
 	while (!WindowShouldClose())
 	{
 	{
@@ -72,9 +94,9 @@ void main()
 }
 }
 ```
 ```
 
 
-*Note: this is missing, but may be available from wayback machine*
+# Docs/Cheatsheet
 
 
-# [Docs / cheatsheet](https://github.com/onroundit/raylib-d/wiki/Docs-(cheatsheet))
+At the moment, we do not properly ddoc the binding. This may change in the near future. However, all documentation is valid from the raylib [online cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html), or you can view the binding source files directly.
 
 
 # License
 # License
 raylib-d is licensed under an unmodified zlib/libpng license. View [LICENSE](LICENSE).
 raylib-d is licensed under an unmodified zlib/libpng license. View [LICENSE](LICENSE).

+ 9 - 0
dub.json

@@ -5,6 +5,15 @@
 	"authors": [
 	"authors": [
 		"ONROUNDIT"
 		"ONROUNDIT"
 	],
 	],
+        "configurations" : [
+            {
+                "name": "library"
+            },
+            {
+                "name": "unittest",
+                "versions" : ["raylib_test"]
+            }
+        ],
 	"copyright": "Copyright (c) Ramon Santamaria (@raysan5), Petro Romanovych (@onroundit), Jan Hoenig (@m3m0ry), Steven Schveighoffer (@schveiguy)",
 	"copyright": "Copyright (c) Ramon Santamaria (@raysan5), Petro Romanovych (@onroundit), Jan Hoenig (@m3m0ry), Steven Schveighoffer (@schveiguy)",
         "excludedSourceFiles": ["source/rlgl.d", "source/raymath.d", "source/easings.d", "source/raygui.d", "source/raymathext.d", "source/raylib_types.d"],
         "excludedSourceFiles": ["source/rlgl.d", "source/raymath.d", "source/easings.d", "source/raygui.d", "source/raymathext.d", "source/raylib_types.d"],
 	"targetType": "sourceLibrary"
 	"targetType": "sourceLibrary"

+ 11 - 30
generating.md

@@ -7,7 +7,7 @@ Three modules should be regenerated: `raylib`, `raymath` and `rlgl`.
 Run the following command from the `raylib/src` directory. Note: path/to/raylib-d should be the path to the raylib-d repository that you have on your system.
 Run the following command from the `raylib/src` directory. Note: path/to/raylib-d should be the path to the raylib-d repository that you have on your system.
 
 
 ```
 ```
-dstep raylib.h raymath.h rlgl.h -o path/to/raylib-d/source --space-after-function-name=false --skip Vector2 \
+dstep raylib.h raymath.h rlgl.h -o path/to/raylib-d/source/raylib --space-after-function-name=false --skip Vector2 \
     --skip Vector3 --skip Vector4 --skip Quaternion --skip Matrix --skip Rectangle --skip RL_MALLOC --skip RL_CALLOC \
     --skip Vector3 --skip Vector4 --skip Quaternion --skip Matrix --skip Rectangle --skip RL_MALLOC --skip RL_CALLOC \
     --skip RL_REALLOC --skip RL_FREE
     --skip RL_REALLOC --skip RL_FREE
 ```
 ```
@@ -15,6 +15,8 @@ dstep raylib.h raymath.h rlgl.h -o path/to/raylib-d/source --space-after-functio
 Note: we're skipping a couple symbols because we define them manually in `raylib_types`. We also skip memory functions
 Note: we're skipping a couple symbols because we define them manually in `raylib_types`. We also skip memory functions
 because they only have effect when compiling Raylib in C.
 because they only have effect when compiling Raylib in C.
 
 
+Finally, the `raylib.h` file will export as `raylib.d`, but it should be moved to `raylib/package.d`.
+
 After you regenerate them, they won't be ready to use yet. We need to add module declarations and imports at the top
 After you regenerate them, they won't be ready to use yet. We need to add module declarations and imports at the top
 of each module:
 of each module:
 
 
@@ -23,22 +25,23 @@ module raylib;
 
 
 public
 public
 {
 {
-    import rlgl;
-    import easings;
-    import raymath;
-    import raymathext;
-    import raylib_types;
+    import raylib.rlgl;
+    import raylib.reasings;
+    import raylib.raymath;
+    import raylib.raymathext;
+    import raylib.raylib_types;
+    import raylib.binding;
 }
 }
 ```
 ```
 
 
 ```d
 ```d
-module raymath;
+module raylib.raymath;
 
 
 import raylib;
 import raylib;
 ```
 ```
 
 
 ```d
 ```d
-module rlgl;
+module raylib.rlgl;
 
 
 import raylib;
 import raylib;
 ```
 ```
@@ -46,28 +49,6 @@ import raylib;
 Additionally, each of those modules will have an automatically generated `extern (C):` line. We need to find it and
 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:`.
 edit it to `extern (C) @nogc nothrow:`.
 
 
-## For version 3.7.0 and possibly earlier versions
-
-dstep will also make a mistake in `raylib.d` and incorrectly define a few `alias`es as `enum`s. Those must be fixed.
-Look for a block of code similar to this:
-
-```d
-// Temporal hacks to avoid breaking old codebases using
-// deprecated raylib implementation or definitions
-enum FormatText = TextFormat;
-enum LoadText = LoadFileText;
-enum GetExtension = GetFileExtension;
-enum GetImageData = LoadImageColors;
-enum FILTER_POINT = TextureFilter.TEXTURE_FILTER_POINT;
-enum FILTER_BILINEAR = TextureFilter.TEXTURE_FILTER_BILINEAR;
-enum MAP_DIFFUSE = MATERIAL_MAP_DIFFUSE;
-enum PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 = PixelFormat.PIXELFORMAT_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
-```
-
-Change `enum` for each of the functions `FormatText`, `LoadText`, `GetExtension`, and `GetImageData` to `alias`. The others can remain `enum`s.
-
-These definitions are not present since 4.0.0
-
 This should be enough. Run `dub test` and see if it compiles.
 This should be enough. Run `dub test` and see if it compiles.
 
 
 [dstep]: https://github.com/jacob-carlborg/dstep
 [dstep]: https://github.com/jacob-carlborg/dstep

+ 4 - 0
source/easings.d

@@ -0,0 +1,4 @@
+deprecated("module easings is deprecated, import raylib.reasings instead")
+module easings;
+
+public import raylib.reasings;

+ 4 - 2
source/raylib/binding.d

@@ -15,9 +15,11 @@ private extern(C) extern __gshared const(char)* raylibVersion;
  *
  *
  * If the binding is not valid, then the program will exit with a -1 error code.
  * If the binding is not valid, then the program will exit with a -1 error code.
  *
  *
- * This is a template to avoid requiring linking libraylib for unittests.
+ * The function is not included when running raylib unittests, so there are no
+ * linker errors. (raylib-d unittests do not test the C binding)
  */
  */
-void validateRaylibBinding()() @nogc nothrow {
+version(raylib_test) {} else
+void validateRaylibBinding() @nogc nothrow {
     import core.stdc.stdio;
     import core.stdc.stdio;
     import core.stdc.stdlib;
     import core.stdc.stdlib;
     import core.stdc.string;
     import core.stdc.string;

+ 4 - 0
source/raylib_types.d

@@ -0,0 +1,4 @@
+deprecated("module raylib_types is deprecated, import raylib.raylib_types instead")
+module raylib_types;
+
+public import raylib.raylib_types;

+ 4 - 0
source/raymath.d

@@ -0,0 +1,4 @@
+deprecated("module raymath is deprecated, import raylib.raymath instead")
+module raymath;
+
+public import raylib.raymath;

+ 4 - 0
source/raymathext.d

@@ -0,0 +1,4 @@
+deprecated("module raymathext is deprecated, import raylib.raymathext instead")
+module raymathext;
+
+public import raylib.raymathext;

+ 4 - 0
source/rlgl.d

@@ -0,0 +1,4 @@
+deprecated("module rlgl is deprecated, import raylib.rlgl instead")
+module rlgl;
+
+public import raylib.rlgl;