2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-05 11:19:39 -04:00

Added raylib-example project

- Separate project to test raylib on its own.
-
This commit is contained in:
ChrisDill 2018-07-28 09:26:59 +01:00
parent 1f6735248b
commit 759a652501
9 changed files with 8595 additions and 11 deletions

@ -15,11 +15,13 @@ namespace Raylibcs
{
var options = driver.Options;
var module = options.AddModule("raylib");
module.IncludeDirs.Add("C:\\raylib\\raylib\\release\\include");
// module.IncludeDirs.Add("C:\\raylib\\raylib\\src");
// module.IncludeDirs.Add("C:\\raylib\\raylib\\release\\include");
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.Headers.Add("rlgl.h");
module.Headers.Add("raymath.h");
// module.Headers.Add("easings.h");
module.LibraryDirs.Add("C:\\raylib\\raylib\\projects\\VS2017\\x64\\Debug.DLL");
module.Libraries.Add("raylib.lib");
var parserOptions = driver.ParserOptions;
@ -28,7 +30,7 @@ namespace Raylibcs
}
void ILibrary.SetupPasses(Driver driver)
{
{
driver.Context.TranslationUnitPasses.RenameDeclsUpperCase(RenameTargets.Any);
// driver.AddTranslationUnitPass(new FunctionToInstanceMethodPass());
// driver.AddTranslationUnitPass(new HandleDefaultParamValuesPass());
@ -37,11 +39,12 @@ namespace Raylibcs
}
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_(.*)");
}

@ -7,7 +7,6 @@ namespace Raylibcs
{
class Program
{
// TODO: setup windows forms gui
static void Main(string[] args)
{
Console.WriteLine("Raylib-cs generator");
@ -15,7 +14,7 @@ namespace Raylibcs
while (true)
{
Console.WriteLine();
Console.WriteLine("1. Regenerate bindings in .exe folder");
Console.WriteLine("1. Genertate c# binding code");
Console.WriteLine("2. Run test example, requires raylib.dll in .exe folder");
Console.WriteLine("3. Exit");

@ -54,6 +54,27 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="CppSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.dll</HintPath>
@ -96,7 +117,10 @@
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<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">

@ -5,6 +5,8 @@ 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}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raylib-example", "..\Raylib-example\Raylib-example.csproj", "{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -19,14 +21,26 @@ Global
{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|Any CPU
{3B25D9D6-17A6-4A32-B9D1-C637002BD554}.Debug|x86.Build.0 = Debug|Any CPU
{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
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Debug|x64.Build.0 = Debug|x64
{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}.Debug|x86.ActiveCfg = Debug|x86
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

57
Raylib-example/Program.cs Normal file

@ -0,0 +1,57 @@
using raylib;
using static raylib.raylib;
namespace Raylibexample
{
class Program
{
static void Main(string[] args)
{
Test();
}
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;
}
}
}

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Raylib-example")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Raylib-example")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a2b3bbc8-3d48-46dd-b3cf-263f554e4474")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Raylib_example</RootNamespace>
<AssemblyName>Raylib-example</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<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" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Raylib.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="dlls\x64\raylib.dll" />
<Content Include="dlls\x86\raylib.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

8345
Raylib-example/Raylib.cs Normal file

File diff suppressed because it is too large Load Diff