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

Separated example from generator

- Renamed Raylib-example to ExampleApplication.
- Example removed from Raylib-cs. It now only contains the generator. Use the current bindings in ExampleApplication/Raylib-cs.
This commit is contained in:
ChrisDill 2018-07-31 13:33:19 +01:00
parent 33f6dd7bcd
commit a796df379b
13 changed files with 760 additions and 17402 deletions

View File

@ -75,26 +75,24 @@
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Raylib.cs" />
<Compile Include="Raylib-cs\Raylib.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="dlls\x64\raylib.dll" />
<Content Include="dlls\x86\raylib.dll" />
<Content Include="Raylib-cs\x64\raylib.dll" />
<Content Include="Raylib-cs\x86\raylib.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -1,20 +1,18 @@
using raylib;
using static raylib.raylib;
using Raylib;
using static Raylib.rl;
namespace Raylibexample
namespace ExampleApplication
{
class Program
{
static void Main(string[] args)
{
Test();
// LoadApp();
Run();
}
public static int Test()
public static int Run()
{
var RAYWHITE = new Color { R = 255, G = 255, B = 255, A = 255 };
var MAROON = new Color { R = 0, G = 0, B = 0, A = 255 };
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
@ -39,7 +37,7 @@ namespace Raylibexample
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, MAROON);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
DrawFPS(0, 0);
EndDrawing();

View File

@ -1,12 +1,13 @@
using CppSharp;
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Passes;
using System;
using System.IO;
namespace Raylibcs
{
/// <summary>
/// Generates the bindings for raylib
/// Generates the bindings for raylib(WIP)
/// ConsoleDriver.Run(new SampleLibrary());
/// </summary>
public class SampleLibrary : ILibrary
@ -14,38 +15,50 @@ namespace Raylibcs
void ILibrary.Setup(Driver driver)
{
var options = driver.Options;
options.GeneratorKind = GeneratorKind.CSharp;
options.OutputDir = Path.Combine(Environment.CurrentDirectory, "Raylib-cs");
options.Verbose = true;
// options.UseHeaderDirectories = true;
var module = options.AddModule("raylib");
// module.IncludeDirs.Add("C:\\raylib\\raylib\\release\\include");
module.IncludeDirs.Add("C:\\raylib\\raylib\\src");
module.Headers.Add("raylib.h");
module.Headers.Add("rlgl.h");
module.Headers.Add("raymath.h");
// module.Headers.Add("easings.h");
// module.Headers.Add("rlgl.h");
// module.Headers.Add("raymath.h");
module.LibraryDirs.Add("C:\\raylib\\raylib\\projects\\VS2017\\x64\\Debug.DLL");
module.Libraries.Add("raylib.lib");
var parserOptions = driver.ParserOptions;
options.GeneratorKind = GeneratorKind.CSharp;
options.Verbose = true;
// module.OutputNamespace = "Raylib";
// module.internalNamespace = "rl";
}
void ILibrary.SetupPasses(Driver driver)
{
driver.Context.TranslationUnitPasses.RenameDeclsUpperCase(RenameTargets.Any);
{
// driver.Context.TranslationUnitPasses.RenameDeclsUpperCase(RenameTargets.Any);
// driver.AddTranslationUnitPass(new FunctionToInstanceMethodPass());
// driver.AddTranslationUnitPass(new HandleDefaultParamValuesPass());
// driver.AddTranslationUnitPass(new CheckOperatorsOverloadsPass());
// driver.Context.TranslationUnitPasses.RemovePrefix("KEY_");
/*driver.Context.TranslationUnitPasses.RemovePrefix("FLAG_");
driver.Context.TranslationUnitPasses.RemovePrefix("KEY_");
driver.Context.TranslationUnitPasses.RemovePrefix("MOUSE_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_PS3_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_PS3_AXIS_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_XBOX_AXIS_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_ANDORID_");*/
}
public void Preprocess(Driver driver, ASTContext ctx)
{
{
ctx.SetNameOfEnumWithMatchingItem("KEY_UNKOWN", "Key");
ctx.GenerateEnumFromMacros("Flag", "FLAG_(.*)");
ctx.GenerateEnumFromMacros("Key", "KEY_(.*)");
ctx.GenerateEnumFromMacros("Mouse", "MOUSE_(.*)");
ctx.GenerateEnumFromMacros("Colors", "RAYWHITE");
// ctx.GenerateEnumFromMacros("Gamepad", "GAMEPAD_(.*)");
ctx.GenerateEnumFromMacros("Gamepad", "GAMEPAD_(.*)");
ctx.GenerateEnumFromMacros("GamepadPS3", "GAMEPAD_PS3_(.*)");
ctx.GenerateEnumFromMacros("GamepadPS3Axis", "GAMEPAD_PS3_AXIS_(.*)");
ctx.GenerateEnumFromMacros("GamepadXbox", "GAMEPAD_XBOX_(.*)");
ctx.GenerateEnumFromMacros("GamepadXboxAxis", "GAMEPAD_XBOX_AXIS_(.*)");
ctx.GenerateEnumFromMacros("GamepadAndroid", "GAMEPAD_ANDROID_(.*)");
// TODO: MaxTouchPoints, MaxShaderLocations, MaxMateiralMaps
}
public void Postprocess(Driver driver, ASTContext ctx)

View File

@ -1,7 +1,5 @@
using System;
using CppSharp;
using raylib;
using static raylib.raylib;
namespace Raylibcs
{
@ -9,73 +7,10 @@ namespace Raylibcs
{
static void Main(string[] args)
{
Console.WriteLine("Raylib-cs generator");
while (true)
{
Console.WriteLine();
Console.WriteLine("1. Genertate c# binding code");
Console.WriteLine("2. Run test example, requires raylib.dll in .exe folder");
Console.WriteLine("3. Exit");
var choice = Console.ReadLine();
if (choice == "1")
{
ConsoleDriver.Run(new SampleLibrary());
}
else if (choice == "2")
{
Test();
}
else if (choice == "3")
{
break;
}
}
}
public static int Test()
{
var RAYWHITE = new Color { R = 255, G = 255, B = 255, A = 255 };
var MAROON = new Color { R = 0, G = 0, B = 0, A = 255 };
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "Raylib-cs [core] example - basic window");
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, MAROON);
DrawFPS(0, 0);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//-----------------------------
return 0;
Console.WriteLine("Raylib-cs binding generator");
ConsoleDriver.Run(new SampleLibrary());
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
}
}

View File

@ -98,29 +98,19 @@
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Runtime.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Generator.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="raylib.cs" />
<Compile Include="Std.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="dlls\x64\raylib.dll" />
<Content Include="dlls\x86\raylib.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Baseclass.Contrib.Nuget.Output.2.4.3\build\Baseclass.Contrib.Nuget.Output.targets" Condition="Exists('packages\Baseclass.Contrib.Nuget.Output.2.4.3\build\Baseclass.Contrib.Nuget.Output.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
@ -129,4 +119,8 @@
</PropertyGroup>
<Error Condition="!Exists('packages\Baseclass.Contrib.Nuget.Output.2.4.3\build\Baseclass.Contrib.Nuget.Output.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Baseclass.Contrib.Nuget.Output.2.4.3\build\Baseclass.Contrib.Nuget.Output.targets'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2035
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-cs", "Raylib-cs.csproj", "{3B25D9D6-17A6-4A32-B9D1-C637002BD554}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleApplication", "..\ExampleApplication\ExampleApplication.csproj", "{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-example", "..\Raylib-example\Raylib-example.csproj", "{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-cs", "Raylib-cs.csproj", "{3B25D9D6-17A6-4A32-B9D1-C637002BD554}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,18 +17,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|x64.ActiveCfg = Debug|x64
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|x64.Build.0 = Debug|x64
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|x86.ActiveCfg = Debug|x86
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|x86.Build.0 = Debug|x86
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|Any CPU.Build.0 = Release|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|x64.ActiveCfg = Release|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|x64.Build.0 = Release|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|x86.ActiveCfg = Release|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|x86.Build.0 = Release|Any CPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Debug|x64.ActiveCfg = Debug|x64
@ -37,10 +25,22 @@ Global
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Debug|x86.Build.0 = Debug|x86
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|Any CPU.Build.0 = Release|Any CPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|x64.ActiveCfg = Release|Any CPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|x64.Build.0 = Release|Any CPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|x86.ActiveCfg = Release|Any CPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|x86.Build.0 = Release|Any CPU
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|x64.ActiveCfg = Release|x64
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|x64.Build.0 = Release|x64
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|x86.ActiveCfg = Release|x86
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Release|x86.Build.0 = Release|x86
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|x64.ActiveCfg = Debug|x64
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|x64.Build.0 = Debug|x64
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|x86.ActiveCfg = Debug|x86
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|x86.Build.0 = Debug|x86
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|Any CPU.Build.0 = Release|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|x64.ActiveCfg = Release|x64
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|x64.Build.0 = Release|x64
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|x86.ActiveCfg = Release|x86
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,12 +0,0 @@
// ----------------------------------------------------------------------------
// <auto-generated>
// This is autogenerated code by CppSharp.
// Do not edit this file or all your changes will be lost after re-generation.
// </auto-generated>
// ----------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("raylibtest")]

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff