Skip to content

Commit

Permalink
Bump raylib version
Browse files Browse the repository at this point in the history
* Bump raylib version in the quickstart demo
* Bumped WebDemo to raylib v5
  • Loading branch information
notgiven688 authored Nov 19, 2023
1 parent f75e339 commit 5142776
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 58 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

Jitter Physics 2, the evolution of [Jitter Physics](https://github.com/notgiven688/jitterphysics), is an impulse-based dynamics engine with a semi-implicit Euler integrator. It is a fast, simple, and dependency-free engine written in C# with a clear and user-friendly API.

Run a small demo directly [in the browser](https://jitterphysics.com/AppBundle/index.html)!
Run a small demo directly [in the browser](https://jitterphysics.com/AppBundle/index.html)!

There is a tiny demo available for the [Godot engine](other/GodotDemo).

A [quick start for raylib](https://jitterphysics.com/docs/quickstart/hello-world) is also available.

The official **NuGet** package can be found [here](https://www.nuget.org/packages/Jitter2).

See below for a fully-featured demo.
Expand Down Expand Up @@ -59,7 +57,7 @@ Find the [documentation here](https://notgiven688.github.io/jitterphysics2).
## ToDo

- [x] Develop and distribute NuGet packages and releases.
- [ ] Stabilize the engine and demo.
- [x] Stabilize the engine and demo.
- [ ] Expand the documentation to cover more topics and functionalities.

## Contribute 👋
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/01_quickstart/00-project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ First, create a new directory named "BoxDrop" and navigate into it:
mkdir BoxDrop && cd BoxDrop
```

Next, create a new console application in this directory and add Raylib# and Jitter2:
Next, create a new console application in this directory and add Raylib-cs and Jitter2:

```sh
dotnet new console
dotnet add package Raylib-cs --version 4.5.0.4
dotnet add package Jitter2 --version 2.0.0-alpha
dotnet add package Raylib-cs --version 5.0.0
dotnet add package Jitter2 --version 2.0.1
```

You have completed the setup. If you now execute the following command:
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/01_quickstart/01-render-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ SetMaterialTexture(ref planeModel, 0, MaterialMapIndex.MATERIAL_MAP_DIFFUSE, ref
// Create a camera
Camera3D camera = new ()
{
position = new Vector3(-20.0f, 8.0f, 10.0f),
target = new Vector3(0.0f, 4.0f, 0.0f),
up = new Vector3(0.0f, 1.0f, 0.0f),
fovy = 45.0f,
projection = CameraProjection.CAMERA_PERSPECTIVE
Position = new Vector3(-20.0f, 8.0f, 10.0f),
Target = new Vector3(0.0f, 4.0f, 0.0f),
Up = new Vector3(0.0f, 1.0f, 0.0f),
FovY = 45.0f,
Projection = CameraProjection.CAMERA_PERSPECTIVE
};

// Set a target of 100 fps
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/01_quickstart/02-hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ for(int i = 0; i < NumberOfBoxes; i++)
// create a camera
Camera3D camera = new ()
{
position = new Vector3(-20.0f, 8.0f, 10.0f),
target = new Vector3(0.0f, 4.0f, 0.0f),
up = new Vector3(0.0f, 1.0f, 0.0f),
fovy = 45.0f,
projection = CameraProjection.CAMERA_PERSPECTIVE
Position = new Vector3(-20.0f, 8.0f, 10.0f),
Target = new Vector3(0.0f, 4.0f, 0.0f),
Up = new Vector3(0.0f, 1.0f, 0.0f),
FovY = 45.0f,
Projection = CameraProjection.CAMERA_PERSPECTIVE
};

// 100 fps target
Expand Down
2 changes: 1 addition & 1 deletion docs/static/AppBundle/dotnet.js

Large diffs are not rendered by default.

Binary file modified docs/static/AppBundle/dotnet.wasm
Binary file not shown.
Binary file modified docs/static/AppBundle/managed/Raylib-cs.dll
Binary file not shown.
Binary file modified docs/static/AppBundle/managed/System.Private.CoreLib.dll
Binary file not shown.
Binary file modified docs/static/AppBundle/managed/WebDemo.dll
Binary file not shown.
7 changes: 1 addition & 6 deletions docs/static/AppBundle/mono-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,10 @@
"behavior": "vfs",
"name": "supportFiles/2_texel_checker.png"
},
{
"virtualPath": "assets/texel_checker_small.png",
"behavior": "vfs",
"name": "supportFiles/3_texel_checker_small.png"
},
{
"virtualPath": "runtimeconfig.bin",
"behavior": "vfs",
"name": "supportFiles/4_runtimeconfig.bin"
"name": "supportFiles/3_runtimeconfig.bin"
},
{
"virtualPath": "/usr/share/zoneinfo/",
Expand Down
Binary file not shown.
1 change: 0 additions & 1 deletion docs/static/AppBundle/supportFiles/4_runtimeconfig.bin

This file was deleted.

35 changes: 18 additions & 17 deletions other/WebDemo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,25 @@ void InitWorld()
// Define the camera to look into our 3d world
Camera3D camera = new()
{
position = new Vector3(2.0f, 8.0f, -16.0f),
target = new Vector3(0.0f, 0.5f, 0.0f),
up = new Vector3(0.0f, 1.0f, 0.0f),
fovy = 45.0f,
projection = CameraProjection.CAMERA_PERSPECTIVE

Position = new Vector3(2.0f, 8.0f, -16.0f),
Target = new Vector3(0.0f, 0.5f, 0.0f),
Up = new Vector3(0.0f, 1.0f, 0.0f),
FovY = 45.0f,
Projection = CameraProjection.CAMERA_PERSPECTIVE
};

// Load models and texture
Model modelPlane = LoadModelFromMesh(GenMeshPlane(12, 12, 1, 1));
Model modelCube = LoadModelFromMesh(GenMeshCube(1.0f, 1.0f, 1.0f));
Model modelSphere = LoadModelFromMesh(GenMeshSphere(0.5f, 32, 32));

Texture2D texture = LoadTexture("assets/texel_checker.png");
Texture2D textureSmall = LoadTexture("assets/texel_checker_small.png");
var img = LoadImage("assets/texel_checker.png");

Texture2D texture = LoadTextureFromImage(img);
Texture2D textureQ = LoadTextureFromImage(ImageFromImage(img, new Rectangle(0, 0, 512, 512)));

// Assign texture to default model material
Raylib.SetMaterialTexture(ref modelCube, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref textureSmall);
Raylib.SetMaterialTexture(ref modelCube, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref textureQ);
Raylib.SetMaterialTexture(ref modelSphere, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref modelPlane, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);

Expand All @@ -95,8 +96,8 @@ void InitWorld()

unsafe
{
shader.locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
shader.locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
}

// Ambient light level
Expand All @@ -120,7 +121,7 @@ void InitWorld()

InitWorld();

SetCameraMode(camera, CameraMode.CAMERA_ORBITAL);
//SetCamera(camera, CameraMode.CAMERA_ORBITAL);

//--------------------------------------------------------------------------------------

Expand All @@ -130,7 +131,7 @@ void InitWorld()
// Update
//----------------------------------------------------------------------------------

UpdateCamera(ref camera);
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);

// if (IsKeyPressed(KeyboardKey.KEY_SPACE))
// {
Expand All @@ -148,8 +149,8 @@ void InitWorld()
// Update the light shader with the camera view position
Raylib.SetShaderValue(
shader,
shader.locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW],
camera.position,
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW],
camera.Position,
ShaderUniformDataType.SHADER_UNIFORM_VEC3
);
}
Expand All @@ -170,12 +171,12 @@ void InitWorld()

if (body.Shapes[0] is BoxShape)
{
modelCube.transform = GetRayLibTransformMatrix(body);
modelCube.Transform = GetRayLibTransformMatrix(body);
DrawModel(modelCube, Vector3.Zero, 1.0f, Color.WHITE);
}
else if (body.Shapes[0] is SphereShape)
{
modelSphere.transform = GetRayLibTransformMatrix(body);
modelSphere.Transform = GetRayLibTransformMatrix(body);
DrawModel(modelSphere, Vector3.Zero, 1.0f, Color.WHITE);
}
}
Expand Down
10 changes: 3 additions & 7 deletions other/WebDemo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

**Credits for raylib-cs in the browser and this README go to: https://github.com/disketteman/DotnetRaylibWasm**

## Local setup
## Setup

Make sure you have the latest version of .NET 7 for example from [here](https://dotnet.microsoft.com/en-us/download/dotnet/7.0), the prototype was built with:
```
dotnet --version
7.0.100
```
Make sure you have the latest version of .NET 7.

Install the official wasm tooling:

Expand All @@ -28,7 +24,7 @@ dotnet tool install --global dotnet-serve
`publish` the solution. Don't use `build`. Publishing may take a while.

```
dotnet publish -C Release
dotnet publish -c Release
```

To serve the files use this command:
Expand Down
16 changes: 8 additions & 8 deletions other/WebDemo/RLights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Shader shader
return light;
}

private static float[] colors = new float[4];

public static void UpdateLightValues(Shader shader, Light light)
{
// Send to shader light enabled state and type
Expand All @@ -77,13 +79,11 @@ public static void UpdateLightValues(Shader shader, Light light)
Raylib.SetShaderValue(shader, light.TargetLoc, light.Target, ShaderUniformDataType.SHADER_UNIFORM_VEC3);

// Send to shader light color values
float[] color = new[]
{
(float)light.Color.r / (float)255,
(float)light.Color.g / (float)255,
(float)light.Color.b / (float)255,
(float)light.Color.a / (float)255
};
Raylib.SetShaderValue(shader, light.ColorLoc, color, ShaderUniformDataType.SHADER_UNIFORM_VEC4);
colors[0] = (float)light.Color.R / 255.0f;
colors[1] = (float)light.Color.G / 255.0f;
colors[2] = (float)light.Color.B / 255.0f;
colors[3] = (float)light.Color.A / 255.0f;

Raylib.SetShaderValue(shader, light.ColorLoc, colors, ShaderUniformDataType.SHADER_UNIFORM_VEC4);
}
}
2 changes: 1 addition & 1 deletion other/WebDemo/WebDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<ItemGroup>
<PackageReference Include="Jitter2" Version="2.0.1" />
<PackageReference Include="Raylib-cs" Version="4.2.0" />
<PackageReference Include="Raylib-cs" Version="5.0.0" />
</ItemGroup>

</Project>
Binary file removed other/WebDemo/assets/texel_checker_small.png
Binary file not shown.
3 changes: 3 additions & 0 deletions other/WebDemo/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

dotnet publish -c Release && dotnet serve --mime .wasm=application/wasm --mime .js=text/javascript --mime .json=application/json --directory ./bin/Release/net7.0/browser-wasm/AppBundle
Binary file modified other/WebDemo/runtimes/raylib.a
Binary file not shown.

0 comments on commit 5142776

Please sign in to comment.