2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-03 11:09:40 -04:00

Moved tests into their own folder.

This commit is contained in:
ChrisDill 2019-03-08 11:32:25 +00:00
parent a01efa4a09
commit f43c79ee55
16 changed files with 51 additions and 106 deletions

View File

@ -1,2 +0,0 @@
mingw32-make
pause

View File

@ -2,66 +2,54 @@
# Raylib-cs
C# bindings for raylib 2.0, a simple and easy-to-use library to learn videogames programming (www.raylib.com)
C# bindings for raylib, a simple and easy-to-use library to learn videogames programming (www.raylib.com)
## Installation
# Installation
So far, I have only tested on Windows. Tips on making things work smoothly on all platforms is appreciated.
1. Add the [nuget package](https://www.nuget.org/packages/Raylib-cs/)
2. Start coding!
```csharp
using Raylib;
using static Raylib.Raylib;
using rl = Raylib.Raylib;
static class Program
{
public static void Main()
{
InitWindow(640, 480, "Hello World");
rl.InitWindow(640, 480, "Hello World");
while (!WindowShouldClose())
while (!rl.WindowShouldClose())
{
BeginDraw();
rl.BeginDraw();
ClearBackground(Color.WHITE);
DrawText("Hello, world!", 12, 12, 20, Color.BLACK);
rl.ClearBackground(Color.WHITE);
rl.DrawText("Hello, world!", 12, 12, 20, Color.BLACK);
EndDrawing();
rl.EndDrawing();
}
CloseWindow();
rl.CloseWindow();
}
}
```
# Tech notes
The bindings are close to the original with a few changes and extensions.
- Enums are passed in as type instead of int to avoid explicit casting to a int every time.
- Added constructors for some of the types.
- Enums are passed as `int` to prevent the need for explicit casts.
- Color defines stored inside `Color`.
- Uses `string.Format` in place of `TextFormat`.
## Custom build
1. Add [raygui](https://github.com/raysan5/raygui)
2. Add a file with the following
```c
#include "raylib.h"
#include "easings.h"
# Extras
- Structs have constructors.
- Operator overloading for math types.
#define PHYSAC_NO_THREADS
#define PHYSAC_IMPLEMENTATION
#include "physac.h"
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
```
## Contributing
# Contributing
If you have any ideas, feel free to open an issue and tell me what you think.
If you'd like to contribute, please fork the repository and make changes as
you'd like. Pull requests are warmly welcome.
If you want to [request features](https://github.com/raysan5/raylib/pulls) or [report bugs](https://github.com/raysan5/raylib/issues) related to the library (in contrast to this binding), please refer to the [author's project repo](https://github.com/raysan5/raylib).
## License
# License
raylib-cs (and raylib) is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.

View File

@ -1,7 +0,0 @@
{
"profiles": {
"Test.NetCore": {
"commandName": "Project"
}
}
}

View File

@ -4,7 +4,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
<ApplicationIcon>raylib-cs.ico</ApplicationIcon>
<Platforms>x64</Platforms>
<StartupObject>Test.NetCore.Program</StartupObject>
<StartupObject>physics_demo</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@ -23,23 +23,12 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>false</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Remove="raylib-cs\**" />
<EmbeddedResource Remove="raylib-cs\**" />
<None Remove="raylib-cs\**" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Bindings\Easings.cs" Link="Easings.cs" />
<Compile Include="..\Bindings\Physac.cs" Link="Physac.cs" />
<Compile Include="..\Bindings\Raygui.cs" Link="Raygui.cs" />
<Compile Include="..\Bindings\Raylib.cs" Link="Raylib.cs" />
<Compile Include="..\Bindings\Raymath.cs" Link="Raymath.cs" />
</ItemGroup>
<Import Project="..\Examples\Examples.projitems" Label="Shared" />
<Import Project="..\Examples\Examples.projitems" Label="Shared" />
<Import Project="..\..\Examples\Examples.projitems" Label="Shared" />
<Import Project="..\..\Examples\Examples.projitems" Label="Shared" />
<Import Project="..\..\Bindings\Raylib.projitems" Label="Shared" />
<Target Name="TestTarget" AfterTargets="Build">
<Copy Condition=" '$(Platform)' == 'x86' " SourceFiles="..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'AnyCPU' " SourceFiles="..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'x64' " SourceFiles="..\Bindings\native\x64\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'x86' " SourceFiles="..\..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'AnyCPU' " SourceFiles="..\..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'x64' " SourceFiles="..\..\Bindings\native\x64\raylib.dll" DestinationFolder="$(TargetDir)" />
</Target>
</Project>

View File

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View File

@ -20,21 +20,15 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>false</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Bindings\Easings.cs" Link="Easings.cs" />
<Compile Include="..\Bindings\Physac.cs" Link="Physac.cs" />
<Compile Include="..\Bindings\Raygui.cs" Link="Raygui.cs" />
<Compile Include="..\Bindings\Raylib.cs" Link="Raylib.cs" />
<Compile Include="..\Bindings\Raymath.cs" Link="Raymath.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27217-01" />
</ItemGroup>
<Import Project="..\Examples\Examples.projitems" Label="Shared" />
<Import Project="..\Examples\Examples.projitems" Label="Shared" />
<Import Project="..\..\Examples\Examples.projitems" Label="Shared" />
<Import Project="..\..\Examples\Examples.projitems" Label="Shared" />
<Import Project="..\..\Bindings\Raylib.projitems" Label="Shared" />
<Target Name="TestTarget" AfterTargets="Build">
<Copy Condition=" '$(Platform)' == 'x86' " SourceFiles="..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'AnyCPU' " SourceFiles="..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'x64' " SourceFiles="..\Bindings\native\x64\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'x86' " SourceFiles="..\..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'AnyCPU' " SourceFiles="..\..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'x64' " SourceFiles="..\..\Bindings\native\x64\raylib.dll" DestinationFolder="$(TargetDir)" />
</Target>
</Project>

View File

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View File

@ -3,7 +3,8 @@ using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Raylib;
using static Raylib.Raylib;
using rl = Raylib.Raylib;
using Color = Raylib.Color;
namespace Test.NetFX
{
@ -55,11 +56,11 @@ namespace Test.NetFX
private void Test()
{
SetConfigFlags(ConfigFlag.FLAG_WINDOW_UNDECORATED);
InitWindow(800, 480, "Rayforms test");
SetTargetFPS(60);
rl.SetConfigFlags(ConfigFlag.FLAG_WINDOW_UNDECORATED);
rl.InitWindow(800, 480, "Rayforms test");
rl.SetTargetFPS(60);
IntPtr winHandle = GetWindowHandle();
IntPtr winHandle = rl.GetWindowHandle();
Invoke(new Action(() =>
{
SetWindowPos(winHandle, Handle, 0, 0, 0, 0, 0x0401 /*NOSIZE | SHOWWINDOW */);
@ -68,8 +69,7 @@ namespace Test.NetFX
windowAttached = true;
}));
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
while (!rl.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
@ -78,20 +78,17 @@ namespace Test.NetFX
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
rl.BeginDrawing();
rl.ClearBackground(Color.RAYWHITE);
ClearBackground(RAYWHITE);
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, Color.MAROON);
rl.DrawText(rl.GetFrameTime().ToString(), 100, 10, 15, Color.MAROON);
rl.DrawFPS(10, 10);
DrawText("Congrats! You created your first window!", 190, 200, 20, MAROON);
DrawText(GetFrameTime().ToString(), 100, 10, 15, MAROON);
DrawFPS(10, 10);
EndDrawing();
rl.EndDrawing();
//----------------------------------------------------------------------------------
}
CloseWindow();
rl.CloseWindow();
}
public static void Run()

View File

@ -97,21 +97,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Bindings\Easings.cs">
<Link>Easings.cs</Link>
</Compile>
<Compile Include="..\Bindings\Physac.cs">
<Link>Physac.cs</Link>
</Compile>
<Compile Include="..\Bindings\Raygui.cs">
<Link>Raygui.cs</Link>
</Compile>
<Compile Include="..\Bindings\Raylib.cs">
<Link>Raylib.cs</Link>
</Compile>
<Compile Include="..\Bindings\Raymath.cs">
<Link>Raymath.cs</Link>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RayForm.cs">
@ -130,11 +115,12 @@
<Content Include="raylib-cs.ico" />
</ItemGroup>
<ItemGroup />
<Import Project="..\Examples\Examples.projitems" Label="Shared" />
<Import Project="..\..\Examples\Examples.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<Copy Condition=" '$(Platform)' == 'x86' " SourceFiles="..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'AnyCPU' " SourceFiles="..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'x64' " SourceFiles="..\Bindings\native\x64\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'x86' " SourceFiles="..\..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'AnyCPU' " SourceFiles="..\..\Bindings\native\x86\raylib.dll" DestinationFolder="$(TargetDir)" />
<Copy Condition=" '$(Platform)' == 'x64' " SourceFiles="..\..\Bindings\native\x64\raylib.dll" DestinationFolder="$(TargetDir)" />
</Target>
<Import Project="..\..\Bindings\Raylib.projitems" Label="Shared" />
</Project>

View File

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 139 KiB