Testing the idea of generating the bindings
- Added cppsharp to see if it will work with raylib.
This commit is contained in:
parent
172e0ecbb7
commit
d20a719c92
8 changed files with 9828 additions and 104 deletions
46
Raylib-cs/Generator.cs
Normal file
46
Raylib-cs/Generator.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
using CppSharp;
|
||||||
|
using CppSharp.AST;
|
||||||
|
using CppSharp.Generators;
|
||||||
|
|
||||||
|
namespace Raylibcs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generates the bindings for raylib
|
||||||
|
/// ConsoleDriver.Run(new SampleLibrary());
|
||||||
|
/// </summary>
|
||||||
|
public class SampleLibrary : ILibrary
|
||||||
|
{
|
||||||
|
public void Preprocess(Driver driver, ASTContext ctx)
|
||||||
|
{
|
||||||
|
|
||||||
|
// ctx.SetNameOfEnumWithMatchingItem("KEY_", "Keys");
|
||||||
|
|
||||||
|
// throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Postprocess(Driver driver, ASTContext ctx)
|
||||||
|
{
|
||||||
|
//throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ILibrary.Setup(Driver driver)
|
||||||
|
{
|
||||||
|
var options = driver.Options;
|
||||||
|
options.GeneratorKind = GeneratorKind.CSharp;
|
||||||
|
options.Verbose = true;
|
||||||
|
|
||||||
|
var module = options.AddModule("raylib");
|
||||||
|
module.IncludeDirs.Add("C:\\raylib\\raylib\\src");
|
||||||
|
module.Headers.Add("raylib.h");
|
||||||
|
module.Headers.Add("raymath.h");
|
||||||
|
module.LibraryDirs.Add("C:\\raylib\\raylib\\release\\libs\\win32\\msvc");
|
||||||
|
module.Libraries.Add("raylib.lib");
|
||||||
|
module.Defines.Add("KEY_SPACE");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ILibrary.SetupPasses(Driver driver)
|
||||||
|
{
|
||||||
|
// throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
using System;
|
using CppSharp;
|
||||||
using static Raylibcs.Raylibcs;
|
using raylib;
|
||||||
|
using static raylib.raymath;
|
||||||
|
using static raylib.raylib;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Raylibcs
|
namespace Raylibcs
|
||||||
{
|
{
|
||||||
|
|
@ -7,36 +10,44 @@ namespace Raylibcs
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
InitWindow(800, 450, "Raylibcs 0.1");
|
// ConsoleDriver.Run(new SampleLibrary());
|
||||||
|
Test();
|
||||||
|
// Console.Read();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Test()
|
||||||
|
{
|
||||||
|
InitWindow(800, 450, "Raylib-cs [2.0]");
|
||||||
|
InitAudioDevice();
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
SetExitKey(256);
|
SetExitKey(256);
|
||||||
|
|
||||||
var sound = LoadSound("alive.wav");
|
var sound = LoadSound("Data/alive.wav");
|
||||||
PlaySound(ref sound);
|
// PlaySound(sound);
|
||||||
|
|
||||||
var t = LoadTexture("crimbocore.png");
|
var t = LoadTexture("Data/test.png");
|
||||||
//var f = LoadSpriteFont("Vera.ttf");
|
|
||||||
|
|
||||||
var w = new Color(255, 255, 255, 255);
|
int a = 0;
|
||||||
var c = new Color(124, 124, 124, 255);
|
var f = LoadFontEx("Data/Vera.ttf", 96, 0, ref a);
|
||||||
var g = new Color(230, 230, 230, 255);
|
|
||||||
|
var c = new Color();
|
||||||
|
c.R = 255;
|
||||||
|
c.G = 255;
|
||||||
|
c.B = 255;
|
||||||
|
c.A = 255;
|
||||||
|
|
||||||
while (!WindowShouldClose())
|
while (!WindowShouldClose())
|
||||||
{
|
{
|
||||||
if (IsKeyPressed(257))
|
|
||||||
{
|
|
||||||
TakeScreenshot("test.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(c);
|
ClearBackground(c);
|
||||||
|
DrawTexture(t, 0, 0, c);
|
||||||
DrawTexture(t, 0, 0, w);
|
// DrawTextEx(f, "testing", new Vector2 { X = 100, Y = 100 }, 20, 10, c);
|
||||||
DrawFPS(0, 0);
|
// DrawFPS(0, 0);
|
||||||
//DrawTextEx(f, "Congrats! You created your first window!", new Vector2(190, 200), 20, 0, w);
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnloadTexture(t);
|
||||||
|
CloseAudioDevice();
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
|
@ -31,7 +33,49 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="CppSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="CppSharp.AST, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.AST.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="CppSharp.Generator, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Generator.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="CppSharp.Parser, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Parser.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="CppSharp.Parser.CLI, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
||||||
|
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Parser.CLI.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="CppSharp.Parser.CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Parser.CSharp.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="CppSharp.Runtime, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Runtime.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
|
@ -42,22 +86,24 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="examples\textures\textures_rectangle.cs" />
|
<Compile Include="Generator.cs" />
|
||||||
<Compile Include="examples\text\text_ttf_loading.cs" />
|
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="raylib-cs.cs" />
|
<Compile Include="raylib-manual.cs" />
|
||||||
|
<Compile Include="raylib.cs" />
|
||||||
|
<Compile Include="Std.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup />
|
||||||
<Folder Include="examples\audio\" />
|
|
||||||
<Folder Include="examples\core\" />
|
|
||||||
<Folder Include="examples\models\" />
|
|
||||||
<Folder Include="examples\physac\" />
|
|
||||||
<Folder Include="examples\shaders\" />
|
|
||||||
<Folder Include="examples\shapes\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<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">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
|
</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>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -8,13 +8,19 @@ EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|x64 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{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|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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{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|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
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
||||||
12
Raylib-cs/Std.cs
Normal file
12
Raylib-cs/Std.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// <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")]
|
||||||
|
|
||||||
5
Raylib-cs/packages.config
Normal file
5
Raylib-cs/packages.config
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Baseclass.Contrib.Nuget.Output" version="2.4.3" targetFramework="net461" />
|
||||||
|
<package id="CppSharp" version="0.8.20" targetFramework="net461" developmentDependency="true" />
|
||||||
|
</packages>
|
||||||
1580
Raylib-cs/raylib-manual.cs
Normal file
1580
Raylib-cs/raylib-manual.cs
Normal file
File diff suppressed because it is too large
Load diff
9401
Raylib-cs/raylib.cs
Normal file
9401
Raylib-cs/raylib.cs
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue